View Javadoc
1   /*
2    *    Copyright 2009-2022 the original author or authors.
3    *
4    *    Licensed under the Apache License, Version 2.0 (the "License");
5    *    you may not use this file except in compliance with the License.
6    *    You may obtain a copy of the License at
7    *
8    *       https://www.apache.org/licenses/LICENSE-2.0
9    *
10   *    Unless required by applicable law or agreed to in writing, software
11   *    distributed under the License is distributed on an "AS IS" BASIS,
12   *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   *    See the License for the specific language governing permissions and
14   *    limitations under the License.
15   */
16  package org.apache.ibatis.submitted.sqlprovider;
17  
18  import java.lang.annotation.ElementType;
19  import java.lang.annotation.Retention;
20  import java.lang.annotation.RetentionPolicy;
21  import java.lang.annotation.Target;
22  import java.util.List;
23  
24  import org.apache.ibatis.annotations.InsertProvider;
25  import org.apache.ibatis.annotations.Lang;
26  import org.apache.ibatis.annotations.Param;
27  import org.apache.ibatis.annotations.SelectProvider;
28  import org.apache.ibatis.annotations.UpdateProvider;
29  import org.apache.ibatis.scripting.xmltags.XMLLanguageDriver;
30  
31  public interface BaseMapper<T> {
32  
33    @SelectProvider(type = OurSqlBuilder.class, method = "buildSelectByIdProviderContextOnly")
34    @ContainsLogicalDelete
35    T selectById(Integer id);
36  
37    @SelectProvider(type = OurSqlBuilder.class, method = "buildSelectByIdProviderContextOnly")
38    T selectActiveById(Integer id);
39  
40    @SelectProvider(type = OurSqlBuilder.class, method = "buildSelectByNameOneParamAndProviderContext")
41    @ContainsLogicalDelete
42    List<T> selectByName(String name);
43  
44    @SelectProvider(type = OurSqlBuilder.class, method = "buildSelectByNameOneParamAndProviderContext")
45    List<T> selectActiveByName(String name);
46  
47    @SelectProvider(type = OurSqlBuilder.class, method = "buildSelectByIdAndNameMultipleParamAndProviderContextWithAtParam")
48    @ContainsLogicalDelete
49    List<T> selectByIdAndNameWithAtParam(@Param("id") Integer id, @Param("name") String name);
50  
51    @SelectProvider(type = OurSqlBuilder.class, method = "buildSelectByIdAndNameMultipleParamAndProviderContextWithAtParam")
52    List<T> selectActiveByIdAndNameWithAtParam(@Param("id") Integer id, @Param("name") String name);
53  
54    @SelectProvider(type = OurSqlBuilder.class, method = "buildSelectByIdAndNameMultipleParamAndProviderContext")
55    @ContainsLogicalDelete
56    List<T> selectByIdAndName(Integer id, String name);
57  
58    @SelectProvider(type = OurSqlBuilder.class, method = "buildSelectByIdAndNameMultipleParamAndProviderContext")
59    List<T> selectActiveByIdAndName(Integer id, String name);
60  
61    @Lang(XMLLanguageDriver.class)
62    @InsertProvider(type = OurSqlBuilder.class, method = "buildInsertSelective")
63    void insertSelective(T entity);
64  
65    @UpdateProvider(type = OurSqlBuilder.class, method = "buildUpdateSelective")
66    void updateSelective(T entity);
67  
68    @SelectProvider(type = OurSqlBuilder.class, method = "buildGetByEntityQuery")
69    List<T> getByEntity(T entity);
70  
71    @Retention(RetentionPolicy.RUNTIME)
72    @Target(ElementType.METHOD)
73    @interface ContainsLogicalDelete {
74      boolean value() default false;
75    }
76  
77    @Retention(RetentionPolicy.RUNTIME)
78    @Target(ElementType.TYPE)
79    @interface Meta {
80      String tableName();
81    }
82  
83    @Retention(RetentionPolicy.RUNTIME)
84    @Target(ElementType.FIELD)
85    @interface Column {
86      String value() default "";
87    }
88  
89  }