IBaseMapper.kt 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. /*
  2. * ********************************************************************************************************************
  3. *
  4. * iFHS7.
  5. * ;BBMBMBMc rZMBMBR BMB
  6. * MBEr:;PBM, 7MBMMEOBB: BBB RBW
  7. * XK: BO SB. :SZ MBM. c;; ir BBM :FFr :SSF: ;xBMB:r iuGXv. i:. iF2;
  8. * DBBM0r. :D S7 ;XMBMB GMBMu. MBM: BMB MBMBBBMBMS WMBMBMBBK MBMBMBM BMBRBMBW .MBMBMBMBB
  9. * :JMRMMD .. , 1MMRM1; ;MBMBBR: MBM ;MB: BMB: MBM. RMBr sBMH BM0 UMB, BMB. KMBv
  10. * ;. XOW B1; :uM: 1RE, i .2BMBs rMB. MBO MBO JMB; MBB MBM BBS 7MBMBOBM: MBW :BMc
  11. * OBRJ.SEE MRDOWOR, 3DE:7OBM . ;BMB RMR7BM BMB MBB. BMB ,BMR .BBZ MMB rMB, BMM rMB7
  12. * :FBRO0D0 RKXSXPR. JOKOOMPi BMBSSWBMB; BMBB: MBMB0ZMBMS .BMBOXRBMB MBMDE RBM2;SMBM; MBB xBM2
  13. * iZGE O0SHSPO. uGZ7. sBMBMBDL :BMO OZu:BMBK, rRBMB0; ,EBMB xBMBr:ER. RDU :OO;
  14. * ,BZ, 1D0 RPSFHXR. xWZ .SMr . .BBB
  15. * :0BMRDG RESSSKR. 2WOMBW; BMBMR
  16. * i0BM: SWKHKGO MBDv
  17. * .UB OOGDM. MK, Copyright (c) 2015-2019. 斯伯坦机器人
  18. * , XMW ..
  19. * r All rights reserved.
  20. *
  21. * ********************************************************************************************************************
  22. */
  23. package com.persagy.mybatis
  24. import com.persagy.database.SFilter
  25. import com.persagy.database.SGroup
  26. import com.persagy.database.SQueryBuilder
  27. import org.apache.ibatis.annotations.*
  28. /**
  29. * 基础数据库操作影射器
  30. *
  31. * @author 庞利祥 <sybotan@126.com>
  32. */
  33. interface IBaseMapper<ENTITY: Any> {
  34. /**
  35. * 根据条件删除
  36. *
  37. * @param filterArgs 过滤条件
  38. * @param whereArgs whereArgs参数值,由SQlProvider填充
  39. */
  40. @DeleteProvider(type = SSqlProvider::class, method = "delete")
  41. fun delete(@Param("entityClass")entityClass: Class<*>,
  42. @Param("filterArgs")filterArgs: List<SFilter>,
  43. @Param("whereArgs")whereArgs: Map<String, Any>): Boolean
  44. /**
  45. * 删除所有记录
  46. */
  47. @DeleteProvider(type = SSqlProvider::class, method = "deleteAll")
  48. fun deleteAll(@Param("entityClass")entityClass: Class<*>): Boolean
  49. /**
  50. * 在数据库中插入实体
  51. *
  52. * @param entity 插入数据库的实体
  53. * @return 插入是否成功
  54. */
  55. @InsertProvider(type = SSqlProvider::class, method = "insert")
  56. @Options(useGeneratedKeys = true, keyProperty = "entity._id")
  57. fun insert(@Param("entityClass")entityClass: Class<*>,
  58. @Param("entity")entity: Map<String, Any?>): Boolean
  59. /**
  60. * 在数据库中插入实体
  61. *
  62. * @param entity 插入数据库的实体
  63. * @return 插入是否成功
  64. */
  65. @InsertProvider(type = SSqlProvider::class, method = "replace")
  66. fun replace(@Param("entityClass")entityClass: Class<*>,
  67. @Param("entity")entity: Map<String, Any?>,
  68. @Param("keyColumnList")keyColumnList: ArrayList<String>): Boolean
  69. /**
  70. * 根据条件更新
  71. *
  72. * @param entity 更新值
  73. * @param projection 字段映射
  74. * @param filterArgs 过滤条件
  75. * @param whereArgs whereArgs参数值,由SQlProvider填充
  76. */
  77. @UpdateProvider(type = SSqlProvider::class, method = "update")
  78. fun update(@Param("entityClass")entityClass: Class<*>,
  79. @Param("entity")entity: Map<String, Any?>,
  80. @Param("projection")projection: ArrayList<String>?,
  81. @Param("filterArgs")filterArgs: List<SFilter>?,
  82. @Param("whereArgs")whereArgs: Map<String, Any>): Boolean
  83. /**
  84. * 执行查询操作
  85. *
  86. * @param builder 查询查询构造器
  87. * @param whereArgs whereArgs参数值,由SQlProvider填充
  88. * @return 查询到的记录
  89. */
  90. @SelectProvider(type = SSqlProvider::class, method = "execQuery")
  91. fun execQuery(@Param("entityClass")entityClass: Class<*>,
  92. @Param("builder")builder: SQueryBuilder<ENTITY>,
  93. @Param("whereArgs")whereArgs: Map<String, Any>): ArrayList<Map<String, Any?>>
  94. /**
  95. * 执行查询操作
  96. *
  97. * @param builder 查询查询构造器
  98. * @param whereArgs whereArgs参数值,由SQlProvider填充
  99. * @return 查询到的记录
  100. */
  101. @SelectProvider(type = SSqlProvider::class, method = "execCount")
  102. fun execCount(@Param("entityClass")entityClass: Class<*>,
  103. @Param("builder")builder: SQueryBuilder<ENTITY>,
  104. @Param("whereArgs")whereArgs: Map<String, Any>): ArrayList<Long>
  105. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  106. // 级联操作相关
  107. /**
  108. * 查询级联关系
  109. *
  110. * @param table 表名
  111. * @param id1 对象表ID字段名
  112. * @param id2 级联对象ID字段名
  113. * @param self 自身级联
  114. * @param filter 附加过滤条件
  115. * @param idList 对象ID列表
  116. * @return 关系列表
  117. */
  118. @SelectProvider(type = SSqlProvider::class, method = "relationQuery")
  119. fun relationQuery(@Param("table")table: String,
  120. @Param("id1")id1: String,
  121. @Param("id2")id2: String,
  122. @Param("self")self: Boolean,
  123. @Param("filter")filter: String,
  124. @Param("idList")idList: ArrayList<Any>,
  125. @Param("whereArgs")whereArgs: Map<String, Any>): ArrayList<HashMap<String, Any>>
  126. } // Interface IBaseMapper