ClientMapper.xml 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
  3. <mapper namespace="com.zhyc.xps.common.mapper.ClientMapper">
  4. <resultMap id="ClientDtoResultMap" type="com.zhyc.xps.common.dto.ClientDto">
  5. <result column="client_id" property="clientId" jdbcType="BIGINT" />
  6. <result column="client_title" property="clientTitle" jdbcType="VARCHAR"/>
  7. <result column="client_app_id" property="clientAppId" jdbcType="VARCHAR"/>
  8. <result column="client_app_key" property="clientAppKey" jdbcType="VARCHAR"/>
  9. <result column="client_app_secret" property="clientAppSecret" jdbcType="VARCHAR"/>
  10. <result column="client_desc" property="clientDesc" jdbcType="VARCHAR"/>
  11. <result column="status" property="status" jdbcType="BIGINT" />
  12. <result column="is_fixed" property="isFixed" jdbcType="BIGINT" />
  13. </resultMap>
  14. <sql id="ClientDto_Cols">
  15. client_id,
  16. client_title,
  17. client_app_id,
  18. client_app_key,
  19. client_app_secret,
  20. client_desc,
  21. status,
  22. is_fixed
  23. </sql>
  24. <!--基于ID查询-->
  25. <select id="getById" resultMap="ClientDtoResultMap">
  26. SELECT
  27. <include refid="ClientDto_Cols"/>
  28. FROM client
  29. WHERE deleted_flag = 0
  30. <if test="clientId != null">
  31. AND client_id = #{clientId ,jdbcType=BIGINT}
  32. </if>
  33. </select>
  34. <!--基于Key查询-->
  35. <select id="getByKey" resultMap="ClientDtoResultMap">
  36. SELECT
  37. <include refid="ClientDto_Cols"/>
  38. FROM client
  39. WHERE deleted_flag = 0
  40. <if test="clientAppId != null and clientAppId != ''">
  41. AND client_app_id = #{clientAppId ,jdbcType=VARCHAR}
  42. </if>
  43. <if test="clientAppKey != null and clientAppKey != ''">
  44. AND client_app_key = #{clientAppKey ,jdbcType=VARCHAR}
  45. </if>
  46. </select>
  47. <!--分页查询-->
  48. <select id="getByPage" parameterType="java.util.Map" resultMap="ClientDtoResultMap">
  49. SELECT
  50. <include refid="ClientDto_Cols"/>
  51. FROM client
  52. WHERE deleted_flag = 0
  53. <if test="clientId != null">
  54. AND client_id = #{clientId ,jdbcType=BIGINT}
  55. </if>
  56. <if test="keywords != null and keywords != ''">
  57. AND client_title like "%"#{keywords}"%"
  58. </if>
  59. ORDER BY client_id ASC
  60. </select>
  61. <!--列表查询-->
  62. <select id="getByList" parameterType="java.util.Map" resultMap="ClientDtoResultMap" >
  63. SELECT
  64. <include refid="ClientDto_Cols"/>
  65. FROM client
  66. WHERE deleted_flag = 0
  67. <if test="clientId != null">
  68. AND client_id = #{clientId ,jdbcType=BIGINT}
  69. </if>
  70. <if test="keywords != null and keywords != ''">
  71. AND client_title LIKE "%"#{keywords}"%"
  72. </if>
  73. </select>
  74. <!--新增Create-->
  75. <insert id="create" parameterType="com.zhyc.xps.common.entity.Client">
  76. INSERT INTO client
  77. <trim prefix="(" suffix=")" suffixOverrides=",">
  78. <if test="clientId != null">
  79. client_id,
  80. </if>
  81. <if test="clientTitle != null and clientTitle !=''">
  82. client_title,
  83. </if>
  84. <if test="clientAppId != null and clientAppId !=''">
  85. client_app_id,
  86. </if>
  87. <if test="clientAppKey != null and clientAppKey !=''">
  88. client_app_key,
  89. </if>
  90. <if test="clientAppSecret != null and clientAppSecret !=''">
  91. client_app_secret,
  92. </if>
  93. <if test="clientDesc != null and clientDesc !=''">
  94. client_desc,
  95. </if>
  96. <if test="status != null">
  97. status,
  98. </if>
  99. <if test="createdBy != null">
  100. created_by,
  101. </if>
  102. <if test="createdAt != null">
  103. created_at,
  104. </if>
  105. </trim>
  106. <trim prefix="values (" suffix=")" suffixOverrides=",">
  107. <if test="clientId != null">
  108. #{clientId ,jdbcType=BIGINT},
  109. </if>
  110. <if test="clientTitle != null and clientTitle != ''">
  111. #{clientTitle ,jdbcType=VARCHAR},
  112. </if>
  113. <if test="clientAppId != null and clientAppId !=''">
  114. #{clientAppId ,jdbcType=VARCHAR},
  115. </if>
  116. <if test="clientAppKey != null and clientAppKey !=''">
  117. #{clientAppKey ,jdbcType=VARCHAR},
  118. </if>
  119. <if test="clientAppSecret != null and clientAppSecret !=''">
  120. #{clientAppSecret ,jdbcType=VARCHAR},
  121. </if>
  122. <if test="clientDesc != null and clientDesc != ''">
  123. #{clientDesc ,jdbcType=VARCHAR},
  124. </if>
  125. <if test="status != null">
  126. #{status ,jdbcType=BIGINT},
  127. </if>
  128. <if test="createdBy != null">
  129. #{createdBy ,jdbcType=BIGINT},
  130. </if>
  131. <if test="createdAt != null">
  132. #{createdAt ,jdbcType=TIMESTAMP},
  133. </if>
  134. </trim>
  135. </insert>
  136. <!--更新Update-->
  137. <update id="update" parameterType="com.zhyc.xps.common.entity.Client">
  138. UPDATE client
  139. <trim suffixOverrides=",">
  140. <set>
  141. <if test="clientTitle != null and clientTitle != ''">
  142. client_title = #{clientTitle, jdbcType=VARCHAR},
  143. </if>
  144. <if test="clientDesc != null and clientDesc != ''">
  145. client_desc = #{clientDesc, jdbcType=VARCHAR},
  146. </if>
  147. <if test="clientAppId != null and clientAppId !=''">
  148. client_app_id = #{clientAppId ,jdbcType=VARCHAR},
  149. </if>
  150. <if test="clientAppKey != null and clientAppKey !=''">
  151. client_app_key = #{clientAppKey ,jdbcType=VARCHAR},
  152. </if>
  153. <if test="clientAppSecret != null and clientAppSecret !=''">
  154. client_app_secret = #{clientAppSecret ,jdbcType=VARCHAR},
  155. </if>
  156. <if test="status != null">
  157. status = #{status ,jdbcType=BIGINT},
  158. </if>
  159. <if test="updatedBy != null ">
  160. updated_by = #{updatedBy ,jdbcType=BIGINT},
  161. </if>
  162. <if test="updatedAt != null">
  163. updated_at = #{updatedAt ,jdbcType=TIMESTAMP},
  164. </if>
  165. </set>
  166. </trim>
  167. WHERE client_id = #{clientId ,jdbcType=BIGINT}
  168. </update>
  169. <!--删除Delete-->
  170. <update id="delete" parameterType="java.util.Map">
  171. UPDATE client
  172. <trim suffixOverrides=",">
  173. <set>
  174. <if test="deletedFlag != null">
  175. deleted_flag = #{deletedFlag,jdbcType=BIGINT},
  176. </if>
  177. <if test="deletedTime != null">
  178. deleted_time = #{deletedTime,jdbcType=VARCHAR},
  179. </if>
  180. <if test="deletedBy != null">
  181. deleted_by = #{deletedBy,jdbcType=BIGINT},
  182. </if>
  183. </set>
  184. </trim>
  185. WHERE client_id = #{clientId ,jdbcType=BIGINT}
  186. </update>
  187. <!--是否存在-->
  188. <select id="isExist" parameterType="java.util.Map" resultType="java.lang.Long">
  189. SELECT count(0)
  190. FROM client AS A
  191. WHERE A.deleted_flag = 0
  192. <if test="clientAppId != null and clientAppId != ''">
  193. AND A.client_app_id = #{clientAppId,jdbcType=VARCHAR}
  194. </if>
  195. <if test="clientAppKey != null and clientAppKey != ''">
  196. AND A.client_app_key = #{clientAppKey,jdbcType=VARCHAR}
  197. </if>
  198. <if test="clientAppSecret != null and clientAppSecret != ''">
  199. AND A.client_app_secret = #{clientAppSecret,jdbcType=VARCHAR}
  200. </if>
  201. </select>
  202. </mapper>