EquipmentMapper.xml 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  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.aqpt.mapper.EquipmentMapper">
  4. <resultMap id="EquipmentDtoMap" type="com.zhyc.xps.aqpt.dto.EquipmentDto">
  5. <result column="oc_id" property="ocId" jdbcType="BIGINT" />
  6. <result column="equip_id" property="equipId" jdbcType="BIGINT" />
  7. <result column="group_id" property="groupId" jdbcType="BIGINT" />
  8. <result column="group_name" property="groupName" jdbcType="VARCHAR" />
  9. <result column="equip_title" property="equipTitle" jdbcType="VARCHAR" />
  10. <result column="equip_code" property="equipCode" jdbcType="VARCHAR" />
  11. <result column="equip_cat_id" property="equipCatId" jdbcType="BIGINT" />
  12. <result column="equip_cat_title" property="equipCatTitle" jdbcType="VARCHAR" />
  13. <result column="equip_desc" property="equipDesc" jdbcType="VARCHAR" />
  14. <result column="status" property="status" jdbcType="BIGINT" />
  15. </resultMap>
  16. <!-- 通用查询结果列 -->
  17. <sql id="EquipmentDto_Cols">
  18. A.oc_id,
  19. A.group_id,
  20. C.group_name,
  21. A.equip_id,
  22. A.equip_title,
  23. A.equip_code,
  24. A.equip_cat_id,
  25. B.equip_cat_title,
  26. A.equip_desc,
  27. A.status
  28. </sql>
  29. <!--基于ID查询-->
  30. <select id="getById" resultMap="EquipmentDtoMap">
  31. SELECT
  32. <include refid="EquipmentDto_Cols"/>
  33. FROM equipment AS A
  34. LEFT JOIN equipment_cat AS B ON (A.oc_id = B.oc_id AND A.equip_cat_id = B.equip_cat_id)
  35. LEFT JOIN s_group AS C ON (A.oc_id = C.oc_id AND A.group_id = C.group_id)
  36. WHERE A.deleted_flag = 0
  37. AND A.oc_id = #{ocId ,jdbcType=BIGINT}
  38. AND A.equip_id = #{equipId ,jdbcType=BIGINT}
  39. </select>
  40. <!--基于Code查询-->
  41. <select id="getByCode" resultMap="EquipmentDtoMap">
  42. SELECT
  43. <include refid="EquipmentDto_Cols"/>
  44. FROM equipment AS A
  45. LEFT JOIN equipment_cat AS B ON (A.oc_id = B.oc_id AND A.equip_cat_id = B.equip_cat_id)
  46. LEFT JOIN s_group AS C ON (A.oc_id = C.oc_id AND A.group_id = C.group_id)
  47. WHERE A.deleted_flag = 0
  48. AND A.oc_id = #{ocId, jdbcType=BIGINT}
  49. AND A.equip_code = #{equipCode, jdbcType=VARCHAR}
  50. </select>
  51. <!--分页查询信息-->
  52. <select id="getByPage" parameterType="java.util.Map" resultMap="EquipmentDtoMap">
  53. SELECT
  54. <include refid="EquipmentDto_Cols"/>
  55. FROM equipment AS A
  56. LEFT JOIN equipment_cat AS B ON (A.oc_id = B.oc_id AND A.equip_cat_id = B.equip_cat_id)
  57. LEFT JOIN s_group AS C ON (A.oc_id = C.oc_id AND A.group_id = C.group_id)
  58. WHERE 1 = 1 AND A.deleted_flag = 0
  59. <if test="ocId != null">
  60. AND A.oc_id = #{ocId ,jdbcType=BIGINT}
  61. </if>
  62. <if test="equipCatId != null">
  63. AND A.equip_cat_id = #{equipCatId ,jdbcType=BIGINT}
  64. </if>
  65. <if test="keywords != null and keywords != ''">
  66. and A.equip_title like "%"#{keywords}"%"
  67. </if>
  68. ORDER BY A.equip_id ASC
  69. </select>
  70. <select id="getByList" parameterType="java.util.Map" resultMap="EquipmentDtoMap">
  71. SELECT
  72. <include refid="EquipmentDto_Cols"/>
  73. FROM equipment AS A
  74. LEFT JOIN equipment_cat AS B ON (A.oc_id = B.oc_id AND A.equip_cat_id = B.equip_cat_id)
  75. LEFT JOIN s_group AS C ON (A.oc_id = C.oc_id AND A.group_id = C.group_id)
  76. WHERE 1 = 1 AND A.deleted_flag = 0
  77. <if test="ocId != null">
  78. AND A.oc_id = #{ocId ,jdbcType=BIGINT}
  79. </if>
  80. <if test="equipCatId != null">
  81. AND A.equip_cat_id = #{equipCatId ,jdbcType=BIGINT}
  82. </if>
  83. <if test="keywords != null and keywords != ''">
  84. AND A.equip_title like "%"#{keywords}"%"
  85. </if>
  86. ORDER BY A.equip_id ASC
  87. </select>
  88. <insert id="create" parameterType="com.zhyc.xps.aqpt.entity.Equipment">
  89. INSERT INTO equipment
  90. <trim prefix="(" suffix=")" suffixOverrides=",">
  91. <if test="ocId != null">
  92. oc_id,
  93. </if>
  94. <if test="groupId != null">
  95. group_id,
  96. </if>
  97. <if test="equipId != null">
  98. equip_id,
  99. </if>
  100. <if test="equipTitle != null and equipTitle != ''">
  101. equip_title,
  102. </if>
  103. <if test="equipCode != null and equipCode != ''">
  104. equip_code,
  105. </if>
  106. <if test="equipDesc != null and equipDesc !=''">
  107. equip_desc,
  108. </if>
  109. <if test="equipCatId != null">
  110. equip_cat_id,
  111. </if>
  112. <if test="status != null">
  113. status,
  114. </if>
  115. <if test="createdBy != null">
  116. created_by,
  117. </if>
  118. <if test="createdAt != null">
  119. created_at,
  120. </if>
  121. </trim>
  122. <trim prefix="values (" suffix=")" suffixOverrides=",">
  123. <if test="ocId != null">
  124. #{ocId ,jdbcType=BIGINT},
  125. </if>
  126. <if test="groupId != null">
  127. #{groupId ,jdbcType=BIGINT},
  128. </if>
  129. <if test="equipId != null">
  130. #{equipId ,jdbcType=BIGINT},
  131. </if>
  132. <if test="equipTitle != null and equipTitle != ''">
  133. #{equipTitle ,jdbcType=VARCHAR},
  134. </if>
  135. <if test="equipCode != null and equipCode != ''">
  136. #{equipCode ,jdbcType=VARCHAR},
  137. </if>
  138. <if test="equipDesc != null and equipDesc != ''">
  139. #{equipDesc ,jdbcType=BIGINT},
  140. </if>
  141. <if test="equipCatId != null">
  142. #{equipCatId ,jdbcType=BIGINT},
  143. </if>
  144. <if test="status != null">
  145. #{status ,jdbcType=BIGINT},
  146. </if>
  147. <if test="createdBy != null">
  148. #{createdBy ,jdbcType=BIGINT},
  149. </if>
  150. <if test="createdAt != null">
  151. #{createdAt ,jdbcType=TIMESTAMP},
  152. </if>
  153. </trim>
  154. </insert>
  155. <!--更新-->
  156. <update id="update" parameterType="com.zhyc.xps.aqpt.entity.Equipment">
  157. UPDATE equipment
  158. <trim suffixOverrides=",">
  159. <set>
  160. <if test="groupId != null">
  161. group_id = #{groupId ,jdbcType=BIGINT},
  162. </if>
  163. <if test="equipTitle != null and equipTitle != ''">
  164. equip_title = #{equipTitle, jdbcType=VARCHAR},
  165. </if>
  166. <if test="equipCode != null and equipCode != ''">
  167. equip_code = #{equipCode, jdbcType=VARCHAR},
  168. </if>
  169. <if test="equipDesc != null and equipDesc != ''">
  170. equip_desc = #{equipDesc ,jdbcType=VARCHAR},
  171. </if>
  172. <if test="equipCatId != null">
  173. equip_cat_id = #{equipCatId ,jdbcType=BIGINT},
  174. </if>
  175. <if test="status != null">
  176. status = #{status ,jdbcType=BIGINT},
  177. </if>
  178. <if test="updatedBy != null ">
  179. updated_by = #{updatedBy ,jdbcType=BIGINT},
  180. </if>
  181. <if test="updatedAt != null">
  182. updated_at = #{updatedAt ,jdbcType=TIMESTAMP},
  183. </if>
  184. <if test="layerId != null">
  185. layer_id = #{layerId ,jdbcType=BIGINT},
  186. </if>
  187. </set>
  188. </trim>
  189. WHERE 1 = 1
  190. <if test="ocId != null">
  191. AND oc_id = #{ocId ,jdbcType=BIGINT}
  192. </if>
  193. <if test="equipId != null">
  194. AND equip_id = #{equipId ,jdbcType=BIGINT}
  195. </if>
  196. </update>
  197. <!--删除-->
  198. <update id="delete" parameterType="java.util.Map">
  199. UPDATE equipment
  200. <trim suffixOverrides=",">
  201. <set>
  202. <if test="deletedFlag != null">
  203. deleted_flag = #{deletedFlag,jdbcType=BIGINT},
  204. </if>
  205. <if test="deletedTime != null">
  206. deleted_time = #{deletedTime,jdbcType=TIMESTAMP},
  207. </if>
  208. <if test="deletedBy != null">
  209. deleted_by = #{deletedBy,jdbcType=BIGINT},
  210. </if>
  211. </set>
  212. </trim>
  213. WHERE 1 =1
  214. <if test="equipId != null">
  215. AND equip_id = #{equipId ,jdbcType=BIGINT}
  216. </if>
  217. <if test="ocId != null">
  218. AND oc_id = #{ocId ,jdbcType=BIGINT}
  219. </if>
  220. </update>
  221. </mapper>