Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b311983

Browse files
committed
拆分ExampleMapper接口。
1 parent 18e7a61 commit b311983

7 files changed

+212
-18
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*
2+
* The MIT License (MIT)
3+
*
4+
* Copyright (c) 2014 [email protected]
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy
7+
* of this software and associated documentation files (the "Software"), to deal
8+
* in the Software without restriction, including without limitation the rights
9+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
* copies of the Software, and to permit persons to whom the Software is
11+
* furnished to do so, subject to the following conditions:
12+
*
13+
* The above copyright notice and this permission notice shall be included in
14+
* all copies or substantial portions of the Software.
15+
*
16+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22+
* THE SOFTWARE.
23+
*/
24+
25+
package com.github.abel533.mapper;
26+
27+
import com.github.abel533.mapper.example.*;
28+
29+
/**
30+
* 通用Mapper接口,Example查询
31+
*
32+
* @param <T> 不能为空
33+
* @author liuzh
34+
*/
35+
public interface ExampleMapper<T> extends
36+
SelectByExampleMapper<T>,
37+
SelectCountByExampleMapper<T>,
38+
DeleteByExampleMapper<T>,
39+
UpdateByExampleMapper<T>,
40+
UpdateByExampleSelectiveMapper<T> {
41+
42+
}

src/main/java/com/github/abel533/mapper/Mapper.java

-2
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@
2424

2525
package com.github.abel533.mapper;
2626

27-
import com.github.abel533.mapper.example.ExampleMapper;
28-
2927
/**
3028
* 通用Mapper接口,其他接口继承该接口即可
3129
* <p/>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
* The MIT License (MIT)
3+
*
4+
* Copyright (c) 2014 [email protected]
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy
7+
* of this software and associated documentation files (the "Software"), to deal
8+
* in the Software without restriction, including without limitation the rights
9+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
* copies of the Software, and to permit persons to whom the Software is
11+
* furnished to do so, subject to the following conditions:
12+
*
13+
* The above copyright notice and this permission notice shall be included in
14+
* all copies or substantial portions of the Software.
15+
*
16+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22+
* THE SOFTWARE.
23+
*/
24+
25+
package com.github.abel533.mapper.example;
26+
27+
import com.github.abel533.provider.MapperProvider;
28+
import org.apache.ibatis.annotations.DeleteProvider;
29+
30+
/**
31+
* 通用Mapper接口,Example查询
32+
*
33+
* @param <T> 不能为空
34+
* @author liuzh
35+
*/
36+
public interface DeleteByExampleMapper<T> {
37+
38+
@DeleteProvider(type = MapperProvider.class, method = "dynamicSQL")
39+
int deleteByExample(Object example);
40+
41+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
* The MIT License (MIT)
3+
*
4+
* Copyright (c) 2014 [email protected]
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy
7+
* of this software and associated documentation files (the "Software"), to deal
8+
* in the Software without restriction, including without limitation the rights
9+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
* copies of the Software, and to permit persons to whom the Software is
11+
* furnished to do so, subject to the following conditions:
12+
*
13+
* The above copyright notice and this permission notice shall be included in
14+
* all copies or substantial portions of the Software.
15+
*
16+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22+
* THE SOFTWARE.
23+
*/
24+
25+
package com.github.abel533.mapper.example;
26+
27+
import com.github.abel533.provider.MapperProvider;
28+
import org.apache.ibatis.annotations.SelectProvider;
29+
30+
import java.util.List;
31+
32+
/**
33+
* 通用Mapper接口,Example查询
34+
*
35+
* @param <T> 不能为空
36+
* @author liuzh
37+
*/
38+
public interface SelectByExampleMapper<T> {
39+
40+
@SelectProvider(type = MapperProvider.class, method = "dynamicSQL")
41+
List<T> selectByExample(Object example);
42+
43+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
* The MIT License (MIT)
3+
*
4+
* Copyright (c) 2014 [email protected]
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy
7+
* of this software and associated documentation files (the "Software"), to deal
8+
* in the Software without restriction, including without limitation the rights
9+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
* copies of the Software, and to permit persons to whom the Software is
11+
* furnished to do so, subject to the following conditions:
12+
*
13+
* The above copyright notice and this permission notice shall be included in
14+
* all copies or substantial portions of the Software.
15+
*
16+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22+
* THE SOFTWARE.
23+
*/
24+
25+
package com.github.abel533.mapper.example;
26+
27+
import com.github.abel533.provider.MapperProvider;
28+
import org.apache.ibatis.annotations.SelectProvider;
29+
30+
/**
31+
* 通用Mapper接口,Example查询
32+
*
33+
* @param <T> 不能为空
34+
* @author liuzh
35+
*/
36+
public interface SelectCountByExampleMapper<T> {
37+
38+
@SelectProvider(type = MapperProvider.class, method = "dynamicSQL")
39+
int selectCountByExample(Object example);
40+
41+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*
2+
* The MIT License (MIT)
3+
*
4+
* Copyright (c) 2014 [email protected]
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy
7+
* of this software and associated documentation files (the "Software"), to deal
8+
* in the Software without restriction, including without limitation the rights
9+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
* copies of the Software, and to permit persons to whom the Software is
11+
* furnished to do so, subject to the following conditions:
12+
*
13+
* The above copyright notice and this permission notice shall be included in
14+
* all copies or substantial portions of the Software.
15+
*
16+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22+
* THE SOFTWARE.
23+
*/
24+
25+
package com.github.abel533.mapper.example;
26+
27+
import com.github.abel533.provider.MapperProvider;
28+
import org.apache.ibatis.annotations.Param;
29+
import org.apache.ibatis.annotations.UpdateProvider;
30+
31+
/**
32+
* 通用Mapper接口,Example查询
33+
*
34+
* @param <T> 不能为空
35+
* @author liuzh
36+
*/
37+
public interface UpdateByExampleMapper<T> {
38+
39+
@UpdateProvider(type = MapperProvider.class, method = "dynamicSQL")
40+
int updateByExample(@Param("record") T record, @Param("example") Object example);
41+
42+
}

src/main/java/com/github/abel533/mapper/example/ExampleMapper.java renamed to src/main/java/com/github/abel533/mapper/example/UpdateByExampleSelectiveMapper.java

+3-16
Original file line numberDiff line numberDiff line change
@@ -25,31 +25,18 @@
2525
package com.github.abel533.mapper.example;
2626

2727
import com.github.abel533.provider.MapperProvider;
28-
import org.apache.ibatis.annotations.*;
29-
30-
import java.util.List;
28+
import org.apache.ibatis.annotations.Param;
29+
import org.apache.ibatis.annotations.UpdateProvider;
3130

3231
/**
3332
* 通用Mapper接口,Example查询
3433
*
3534
* @param <T> 不能为空
3635
* @author liuzh
3736
*/
38-
public interface ExampleMapper<T> {
39-
40-
@SelectProvider(type = MapperProvider.class, method = "dynamicSQL")
41-
List<T> selectByExample(Object example);
42-
43-
@SelectProvider(type = MapperProvider.class, method = "dynamicSQL")
44-
int selectCountByExample(Object example);
45-
46-
@DeleteProvider(type = MapperProvider.class, method = "dynamicSQL")
47-
int deleteByExample(Object example);
37+
public interface UpdateByExampleSelectiveMapper<T> {
4838

4939
@UpdateProvider(type = MapperProvider.class, method = "dynamicSQL")
5040
int updateByExampleSelective(@Param("record") T record, @Param("example") Object example);
5141

52-
@UpdateProvider(type = MapperProvider.class, method = "dynamicSQL")
53-
int updateByExample(@Param("record") T record, @Param("example") Object example);
54-
5542
}

0 commit comments

Comments
 (0)