AppMapper.xml 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  3. "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
  4. <mapper namespace="com.zhyc.xps.sys.mapper.AppMapper">
  5. <resultMap id="AppDtoResultMap" type="com.zhyc.xps.sys.dto.AppDto" >
  6. <result column="app_id" property="appId" jdbcType="BIGINT" /><!--App ID-->
  7. <result column="app_cat_id" property="appCatId" jdbcType="BIGINT" />
  8. <result column="app_cat_title" property="appCatTitle" jdbcType="VARCHAR"/>
  9. <result column="app_title" property="appTitle" jdbcType="VARCHAR"/>
  10. <result column="app_code" property="appCode" jdbcType="VARCHAR"/>
  11. <result column="app_desc" property="appDesc" jdbcType="VARCHAR"/>
  12. <result column="app_logo" property="appLogo" jdbcType="VARCHAR"/>
  13. <result column="app_url" property="appUrl" jdbcType="VARCHAR"/>
  14. <result column="app_param" property="appParam" jdbcType="VARCHAR"/>
  15. <result column="app_desc" property="appDesc" jdbcType="VARCHAR"/>
  16. <result column="status" property="status" jdbcType="BIGINT" />
  17. <result column="if_store" property="ifStore" jdbcType="BIGINT" />
  18. </resultMap>
  19. <sql id="AppDto_Cols">
  20. A.app_id,
  21. A.app_cat_id,
  22. B.app_cat_title,
  23. A.app_desc,
  24. A.app_code,
  25. A.app_title,
  26. A.app_url,
  27. A.app_param,
  28. A.app_logo,
  29. A.status,
  30. A.if_store
  31. </sql>
  32. <!--基于ID查询-->
  33. <select id="getById" resultMap="AppDtoResultMap">
  34. SELECT
  35. <include refid="AppDto_Cols"/>
  36. FROM app AS A
  37. LEFT JOIN app_cat AS B ON (A.app_cat_id = B.app_cat_id)
  38. WHERE A.app_id = #{appId ,jdbcType=BIGINT} AND A.deleted_flag = 0
  39. </select>
  40. <!--基于Key查询-->
  41. <select id="getByCode" resultMap="AppDtoResultMap">
  42. SELECT
  43. <include refid="AppDto_Cols"/>
  44. FROM app AS A
  45. LEFT JOIN app_cat AS B ON (A.app_cat_id = B.app_cat_id)
  46. WHERE A.app_code = #{appCode ,jdbcType=VARCHAR} AND A.deleted_flag = 0
  47. </select>
  48. <!--列表查询-->
  49. <select id="getByList" parameterType="java.util.Map" resultMap="AppDtoResultMap">
  50. SELECT
  51. <include refid="AppDto_Cols"/>
  52. FROM app AS A
  53. LEFT JOIN app_cat AS B ON (A.app_cat_id = B.app_cat_id)
  54. WHERE A.deleted_flag = 0
  55. <if test="appId !=null">
  56. AND A.app_id = #{appId ,jdbcType=BIGINT}
  57. </if>
  58. <if test="keywords != null and keywords != ''">
  59. AND A.app_title like "%"#{keyword}"%"
  60. </if>
  61. <if test="appCatId != null">
  62. AND A.app_cat_id = #{appCatId ,jdbcType=BIGINT}
  63. </if>
  64. <if test="status != null">
  65. AND A.status = #{status ,jdbcType=BIGINT}
  66. </if>
  67. <if test="ifStore != null">
  68. AND A.if_store = #{ifStore ,jdbcType=BIGINT}
  69. </if>
  70. ORDER BY A.app_id ASC
  71. </select>
  72. <!--分页查询-->
  73. <select id="getByPage" parameterType="java.util.Map" resultMap="AppDtoResultMap">
  74. SELECT
  75. <include refid="AppDto_Cols"/>
  76. FROM app AS A
  77. LEFT JOIN app_cat AS B ON (A.app_cat_id = B.app_cat_id)
  78. WHERE A.deleted_flag = 0
  79. <if test="appId !=null">
  80. AND A.app_id = #{appId ,jdbcType=BIGINT}
  81. </if>
  82. <if test="keywords != null and keywords != ''">
  83. AND A.app_title like "%"#{keyword}"%"
  84. </if>
  85. <if test="appCatId != null">
  86. AND A.app_cat_id = #{appCatId ,jdbcType=BIGINT}
  87. </if>
  88. <if test="status != null">
  89. AND A.status = #{status ,jdbcType=BIGINT}
  90. </if>
  91. ORDER BY A.app_id ASC
  92. </select>
  93. <!--新增-->
  94. <insert id="create" parameterType="com.zhyc.xps.sys.entity.App" keyProperty="appId">
  95. INSERT INTO app
  96. <trim prefix="(" suffix=")" suffixOverrides=",">
  97. <if test="appId != null">
  98. app_id,
  99. </if>
  100. <if test="appCatId != null">
  101. app_cat_id,
  102. </if>
  103. <if test="appTitle != null and appTitle!=''">
  104. app_title,
  105. </if>
  106. <if test="appCode!= null and appCode!=''">
  107. app_code,
  108. </if>
  109. <if test="appDesc != null and appDesc != ''">
  110. app_desc,
  111. </if>
  112. <if test="appLogo != null and appLogo != ''">
  113. app_logo,
  114. </if>
  115. <if test="appUrl != null and appUrl != ''">
  116. app_url,
  117. </if>
  118. <if test="appParam != null and appParam != ''">
  119. app_param,
  120. </if>
  121. <if test="status != null">
  122. status,
  123. </if>
  124. <if test="ifStore != null">
  125. if_store,
  126. </if>
  127. <if test="createdBy != null">
  128. created_by,
  129. </if>
  130. <if test="createdAt != null">
  131. created_at,
  132. </if>
  133. </trim>
  134. <trim prefix="values (" suffix=")" suffixOverrides=",">
  135. <if test="appId != null">
  136. #{appId ,jdbcType=BIGINT},
  137. </if>
  138. <if test="appCatId != null">
  139. #{appCatId ,jdbcType=BIGINT},
  140. </if>
  141. <if test="appTitle != null and appTitle!=''">
  142. #{appTitle ,jdbcType=VARCHAR},
  143. </if>
  144. <if test="appCode!= null and appCode!=''">
  145. #{appCode ,jdbcType=VARCHAR},
  146. </if>
  147. <if test="appDesc != null and appDesc != ''">
  148. #{appDesc ,jdbcType=VARCHAR},
  149. </if>
  150. <if test="appLogo != null and appLogo != ''">
  151. #{appLogo ,jdbcType=VARCHAR},
  152. </if>
  153. <if test="appUrl != null and appUrl != ''">
  154. #{appUrl ,jdbcType=VARCHAR},
  155. </if>
  156. <if test="appParam != null and appParam != ''">
  157. #{appParam ,jdbcType=VARCHAR},
  158. </if>
  159. <if test="status != null">
  160. #{status ,jdbcType=BIGINT},
  161. </if>
  162. <if test="ifStore != null">
  163. #{ifStore ,jdbcType=BIGINT},
  164. </if>
  165. <if test="createdBy != null">
  166. #{createdBy ,jdbcType=BIGINT},
  167. </if>
  168. <if test="createdAt != null">
  169. #{createdAt ,jdbcType=TIMESTAMP},
  170. </if>
  171. </trim>
  172. </insert>
  173. <!--更新-->
  174. <update id="update" parameterType="com.zhyc.xps.sys.entity.App">
  175. UPDATE app
  176. <trim suffixOverrides=",">
  177. <set>
  178. <if test="appCatId != null">
  179. app_cat_id = #{appCatId ,jdbcType=BIGINT},
  180. </if>
  181. <if test="appTitle != null and appTitle != ''">
  182. app_title =#{appTitle ,jdbcType=VARCHAR},
  183. </if>
  184. <if test="appCode!= null and appCode!=''">
  185. app_code = #{appCode ,jdbcType=VARCHAR},
  186. </if>
  187. <if test="appDesc != null">
  188. app_desc = #{appDesc ,jdbcType=VARCHAR},
  189. </if>
  190. <if test="appLogo != null and appLogo != ''">
  191. app_logo = #{appLogo ,jdbcType=VARCHAR},
  192. </if>
  193. <if test="appUrl != null and appUrl != ''">
  194. app_url = #{appUrl ,jdbcType=VARCHAR},
  195. </if>
  196. <if test="appParam != null">
  197. app_param = #{appParam ,jdbcType=VARCHAR},
  198. </if>
  199. <if test="status != null">
  200. status = #{status ,jdbcType=BIGINT},
  201. </if>
  202. <if test="ifStore != null">
  203. if_store = #{ifStore ,jdbcType=BIGINT},
  204. </if>
  205. <if test="updatedBy != null">
  206. updated_by = #{updatedBy ,jdbcType=BIGINT},
  207. </if>
  208. <if test="updatedAt != null">
  209. updated_at = #{updatedAt ,jdbcType=TIMESTAMP},
  210. </if>
  211. </set>
  212. </trim>
  213. WHERE app_id = #{appId, jdbcType=BIGINT}
  214. </update>
  215. <!--删除 -->
  216. <update id="delete" parameterType="java.util.Map">
  217. UPDATE app
  218. <trim suffixOverrides=",">
  219. <set>
  220. <if test="deletedBy != null">
  221. deleted_by = #{deletedBy ,jdbcType=BIGINT},
  222. </if>
  223. <if test="deletedAt != null">
  224. deleted_at = #{deletedAt ,jdbcType=DATE},
  225. </if>
  226. <if test="deletedFlag != null">
  227. deleted_flag = #{deletedFlag ,jdbcType=BIGINT},
  228. </if>
  229. </set>
  230. </trim>
  231. WHERE app_id = #{appId, jdbcType=BIGINT}
  232. </update>
  233. </mapper>