JobMapper.xml 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  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.JobMapper">
  5. <resultMap id="JobDtoResultMap" type="com.zhyc.xps.sys.dto.JobDto">
  6. <result column="job_id" property="jobId" jdbcType="BIGINT" />
  7. <result column="job_title" property="jobTitle" jdbcType="VARCHAR" />
  8. <result column="job_desc" property="jobDesc" jdbcType="VARCHAR" />
  9. <result column="job_type" property="jobType" jdbcType="BIGINT" />
  10. <result column="status" property="status" jdbcType="BIGINT" />
  11. <result column="job_code" property="jobCode" jdbcType="VARCHAR" />
  12. <result column="job_cron" property="jobCron" jdbcType="VARCHAR" />
  13. <result column="job_class_id" property="jobClassId" jdbcType="BIGINT" />
  14. <result column="job_class" property="jobClass" jdbcType="VARCHAR" />
  15. <result column="cycle_title" property="cycleTitle" jdbcType="VARCHAR" />
  16. <result column="cycle_period" property="cyclePeriod" jdbcType="BIGINT" />
  17. <result column="cycle_unit" property="cycleUnit" jdbcType="BIGINT" />
  18. </resultMap>
  19. <sql id="JobDto_Cols">
  20. A.job_id,
  21. A.job_title,
  22. A.job_desc,
  23. A.status,
  24. A.job_type,
  25. A.job_code,
  26. A.job_cron,
  27. A.job_class_id,
  28. B.job_class,
  29. A.cycle_title,
  30. A.cycle_period,
  31. A.cycle_unit
  32. </sql>
  33. <!--基于ID查询-->
  34. <select id="getById" parameterType="java.lang.Long" resultMap="JobDtoResultMap">
  35. SELECT
  36. <include refid="JobDto_Cols"/>
  37. FROM job AS A
  38. LEFT JOIN job_class AS B ON (A.job_class_id = B.job_class_id)
  39. WHERE A.job_id = #{jobId, jdbcType=BIGINT}
  40. </select>
  41. <!--分页查询-->
  42. <select id="getByPage" parameterType="java.util.Map" resultMap="JobDtoResultMap">
  43. SELECT
  44. <include refid="JobDto_Cols"/>
  45. FROM job AS A
  46. LEFT JOIN job_class AS B ON (A.job_class_id = B.job_class_id)
  47. WHERE A.deleted_flag = 0
  48. <if test="keywords != null and keywords != ''">
  49. AND A.job_title like "%"#{keywords}"%"
  50. </if>
  51. <if test="status != null">
  52. AND A.status = #{status, jdbcType=BIGINT}
  53. </if>
  54. <if test="jobClassId != null">
  55. AND A.job_class_id = #{jobClassId, jdbcType=BIGINT}
  56. </if>
  57. ORDER BY A.job_id ASC
  58. </select>
  59. <!--列表查询-->
  60. <select id="getByList" parameterType="java.util.Map" resultMap="JobDtoResultMap" >
  61. SELECT
  62. <include refid="JobDto_Cols"/>
  63. FROM job AS A
  64. LEFT JOIN job_class AS B ON (A.job_class_id = B.job_class_id)
  65. WHERE A.deleted_flag = 0
  66. <if test="keywords != null and keywords != ''">
  67. AND A.job_title like "%"#{keywords}"%"
  68. </if>
  69. <if test="status != null">
  70. AND A.status = #{status, jdbcType=BIGINT}
  71. </if>
  72. <if test="jobClassId != null">
  73. AND A.job_class_id = #{jobClassId, jdbcType=BIGINT}
  74. </if>
  75. ORDER BY A.job_id ASC
  76. </select>
  77. <!--新增-->
  78. <insert id="create" useGeneratedKeys="true" keyProperty="jobId" parameterType="com.zhyc.xps.sys.entity.Job">
  79. INSERT INTO job
  80. <trim prefix="(" suffix=")" suffixOverrides=",">
  81. <if test="jobId != null">
  82. job_id,
  83. </if>
  84. <if test="jobTitle != null and jobTitle != ''">
  85. job_title,
  86. </if>
  87. <if test="jobDesc != null and jobDesc != ''">
  88. job_desc,
  89. </if>
  90. <if test="status != null">
  91. status,
  92. </if>
  93. <if test="jobType != null">
  94. job_type,
  95. </if>
  96. <if test="jobCode != null and jobCode !=''">
  97. job_code,
  98. </if>
  99. <if test="jobCron != null and jobCron !=''">
  100. job_cron,
  101. </if>
  102. <if test="jobClassId != null">
  103. job_class_id,
  104. </if>
  105. <if test="cycleTitle != null">
  106. cycle_title,
  107. </if>
  108. <if test="cyclePeriod != null">
  109. cycle_period,
  110. </if>
  111. <if test="cycleUnit != null">
  112. cycle_unit,
  113. </if>
  114. <if test="createdBy != null">
  115. created_by,
  116. </if>
  117. <if test="createdAt != null">
  118. created_at,
  119. </if>
  120. </trim>
  121. <trim prefix="values (" suffix=")" suffixOverrides=",">
  122. <if test="jobId != null">
  123. #{jobId, jdbcType=BIGINT},
  124. </if>
  125. <if test="jobTitle != null and jobTitle != ''">
  126. #{jobTitle, jdbcType=VARCHAR},
  127. </if>
  128. <if test="jobDesc != null and jobDesc != ''">
  129. #{jobDesc, jdbcType=VARCHAR},
  130. </if>
  131. <if test="status != null">
  132. #{status, jdbcType=BIGINT},
  133. </if>
  134. <if test="jobType != null">
  135. #{jobType, jdbcType=BIGINT},
  136. </if>
  137. <if test="jobCode != null and jobCode != ''">
  138. #{jobCode,jdbcType=VARCHAR},
  139. </if>
  140. <if test="jobCron != null and jobCron != ''">
  141. #{jobCron, jdbcType=VARCHAR},
  142. </if>
  143. <if test="jobClassId != null">
  144. #{jobClassId,jdbcType=BIGINT},
  145. </if>
  146. <if test="cycleTitle != null and cycleTitle != ''">
  147. #{cycleTitle, jdbcType=BIGINT},
  148. </if>
  149. <if test="cyclePeriod != null">
  150. #{cyclePeriod, jdbcType=BIGINT},
  151. </if>
  152. <if test="cycleUnit != null">
  153. #{cycleUnit, jdbcType=BIGINT},
  154. </if>
  155. <if test="createdBy != null">
  156. #{createdBy,jdbcType=BIGINT},
  157. </if>
  158. <if test="createdAt != null">
  159. #{createdAt,jdbcType=DATE},
  160. </if>
  161. </trim>
  162. </insert>
  163. <!--更新-->
  164. <update id="update" parameterType="com.zhyc.xps.sys.entity.Job">
  165. UPDATE job
  166. <trim suffixOverrides=",">
  167. <set>
  168. <if test="jobTitle != null and jobTitle != ''">
  169. job_title = #{jobTitle, jdbcType=VARCHAR},
  170. </if>
  171. <if test="jobDesc != null and jobDesc != ''">
  172. job_desc = #{jobDesc, jdbcType=VARCHAR},
  173. </if>
  174. <if test="status != null">
  175. status = #{status, jdbcType=BIGINT},
  176. </if>
  177. <if test="jobType != null">
  178. job_type = #{jobType, jdbcType=BIGINT},
  179. </if>
  180. <if test="jobCode != null and jobCode !=''">
  181. job_code = #{jobCode, jdbcType=VARCHAR},
  182. </if>
  183. <if test="jobCron != null and jobCron !=''">
  184. job_cron = #{jobCron, jdbcType=VARCHAR},
  185. </if>
  186. <if test="jobClassId != null">
  187. job_class_id = #{jobClassId,jdbcType=BIGINT},
  188. </if>
  189. <if test="cycleTitle != null and cycleTitle !=''">
  190. cycle_title = #{cycleTitle, jdbcType=VARCHAR},
  191. </if>
  192. <if test="cyclePeriod != null">
  193. cycle_period = #{cyclePeriod, jdbcType=BIGINT},
  194. </if>
  195. <if test="cycleUnit != null">
  196. cycle_unit = #{cycleUnit, jdbcType=BIGINT},
  197. </if>
  198. <if test="updatedBy != null">
  199. updated_by = #{updatedBy,jdbcType=BIGINT},
  200. </if>
  201. <if test="updatedAt != null">
  202. updated_at = #{updatedAt,jdbcType=DATE},
  203. </if>
  204. </set>
  205. </trim>
  206. WHERE job_id = #{jobId, jdbcType=BIGINT}
  207. </update>
  208. <!--删除 -->
  209. <update id="delete" parameterType="java.util.Map">
  210. UPDATE job
  211. <trim suffixOverrides=",">
  212. <set>
  213. <if test="deletedBy != null">
  214. deleted_by = #{deletedBy ,jdbcType=BIGINT},
  215. </if>
  216. <if test="deletedAt != null">
  217. deleted_at = #{deletedAt ,jdbcType=DATE},
  218. </if>
  219. <if test="deletedFlag != null">
  220. deleted_flag = #{deletedFlag ,jdbcType=BIGINT},
  221. </if>
  222. </set>
  223. </trim>
  224. WHERE job_id = #{jobId, jdbcType=BIGINT}
  225. </update>
  226. </mapper>