IndustryMapper.xml 9.4 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.IndustryMapper">
  5. <resultMap id="IndustryDtoResultMap" type="com.zhyc.xps.sys.dto.IndustryDto" >
  6. <id column="industry_id" property="industryId" jdbcType="BIGINT" />
  7. <result column="industry_code" property="industryCode" jdbcType="VARCHAR" />
  8. <result column="industry_name" property="industryName" jdbcType="VARCHAR" />
  9. <result column="parent_id" property="parentId" jdbcType="BIGINT" />
  10. <result column="parent_name" property="parentName" jdbcType="VARCHAR" />
  11. <result column="root_id" property="rootId" jdbcType="BIGINT" />
  12. <result column="industry_type_id" property="industryTypeId" jdbcType="VARCHAR" />
  13. <result column="industry_logo" property="industryLogo" jdbcType="VARCHAR" />
  14. <result column="industry_desc" property="industryDesc" jdbcType="VARCHAR" />
  15. <result column="sort_no" property="sortNo" jdbcType="BIGINT" />
  16. <result column="node_left" property="nodeLeft" jdbcType="BIGINT" />
  17. <result column="node_right" property="nodeRight" jdbcType="BIGINT" />
  18. <result column="node_level" property="nodeLevel" jdbcType="BIGINT" />
  19. <result column="is_leaf" property="isLeaf" jdbcType="BIGINT" />
  20. </resultMap>
  21. <sql id="IndustryDto_Cols">
  22. A.industry_id,
  23. A.industry_code,
  24. A.industry_name,
  25. A.parent_id,
  26. B.industry_name as parent_name,
  27. A.root_id,
  28. A.industry_logo,
  29. A.industry_type_id,
  30. A.industry_desc,
  31. A.sort_no,
  32. A.node_left,
  33. A.node_right,
  34. A.node_level,
  35. A.is_leaf,
  36. A.created_by,
  37. A.updated_by,
  38. A.created_at,
  39. A.updated_at
  40. </sql>
  41. <!--获取子行业的数目-->
  42. <select id="countOfSubIndustry" resultType="java.lang.Integer" >
  43. SELECT
  44. count(*)
  45. FROM
  46. industry
  47. WHERE 1 = 1 AND deleted_flag = 0
  48. AND parent_id = #{parentId, jdbcType=BIGINT}
  49. </select>
  50. <!--根据ID获取行业信息-->
  51. <select id="getById" resultMap="IndustryDtoResultMap" parameterType="java.lang.Long">
  52. SELECT
  53. <include refid="IndustryDto_Cols"/>
  54. FROM industry AS A
  55. LEFT JOIN industry AS B ON (A.parent_id = B.industry_id)
  56. WHERE A.industry_id = #{industryId, jdbcType=BIGINT}
  57. </select>
  58. <!--列表查询-->
  59. <select id="getByList" parameterType="java.util.Map" resultMap="IndustryDtoResultMap">
  60. SELECT
  61. <include refid="IndustryDto_Cols"/>
  62. FROM industry AS A
  63. LEFT JOIN industry AS B ON (A.parent_id = B.industry_id)
  64. WHERE A.deleted_flag = 0
  65. <if test="industryCode != null and industryCode != ''">
  66. AND A.industry_code = #{industryCode, jdbcType=VARCHAR}
  67. </if>
  68. <if test="industryName != null and industryName != ''">
  69. AND A.industry_name = #{industryName, jdbcType=VARCHAR}
  70. </if>
  71. <if test="industryLogo != null and industryLogo != ''">
  72. AND A.industry_logo = #{industryLogo, jdbcType=VARCHAR}
  73. </if>
  74. <if test="parentId != null">
  75. AND A.parent_id = #{parent_id, jdbcType=BIGINT}
  76. </if>
  77. ORDER BY A.sort_no ASC
  78. </select>
  79. <!--Create 新增-->
  80. <insert id="create" parameterType="com.zhyc.xps.sys.entity.Industry">
  81. INSERT INTO industry
  82. <trim prefix="(" suffix=")" suffixOverrides=",">
  83. <if test="industryId != null">
  84. industry_id,
  85. </if>
  86. <if test="parentId != null">
  87. parent_id,
  88. </if>
  89. <if test="rootId != null">
  90. root_id,
  91. </if>
  92. <if test="industryCode != null and industryCode != ''">
  93. industry_code,
  94. </if>
  95. <if test="industryName != null and industryName != ''">
  96. industry_name,
  97. </if>
  98. <if test="industryLogo != null and industryLogo != ''">
  99. industry_logo,
  100. </if>
  101. <if test="industryTypeId != null">
  102. industry_type_id,
  103. </if>
  104. <if test="industryDesc != null and industryDesc != ''">
  105. industry_desc,
  106. </if>
  107. <if test="sortNo != null">
  108. sort_no,
  109. </if>
  110. <if test="nodeLeft != null">
  111. node_left,
  112. </if>
  113. <if test="nodeRight != null">
  114. node_right,
  115. </if>
  116. <if test="nodeLevel != null">
  117. node_level,
  118. </if>
  119. <if test="isLeaf != null">
  120. is_leaf,
  121. </if>
  122. <if test="createdBy != null">
  123. created_by,
  124. </if>
  125. <if test="createdAt != null">
  126. created_at,
  127. </if>
  128. </trim>
  129. <trim prefix="values (" suffix=")" suffixOverrides=",">
  130. <if test="industryId != null">
  131. #{industryId ,jdbcType=BIGINT},
  132. </if>
  133. <if test="parentId != null">
  134. #{parentId ,jdbcType=BIGINT},
  135. </if>
  136. <if test="rootId != null">
  137. #{rootId ,jdbcType=BIGINT},
  138. </if>
  139. <if test="industryCode != null and industryCode != ''">
  140. #{industryCode ,jdbcType=VARCHAR},
  141. </if>
  142. <if test="industryName != null and industryName != ''">
  143. #{industryName ,jdbcType=VARCHAR},
  144. </if>
  145. <if test="industryLogo != null and industryLogo != ''">
  146. #{industryLogo ,jdbcType=VARCHAR},
  147. </if>
  148. <if test="industryTypeId != null">
  149. #{industryTypeId ,jdbcType=BIGINT},
  150. </if>
  151. <if test="industryDesc != null and industryDesc != ''">
  152. #{industryDesc ,jdbcType=VARCHAR},
  153. </if>
  154. <if test="sortNo != null">
  155. #{sortNo ,jdbcType=BIGINT},
  156. </if>
  157. <if test="nodeLeft != null">
  158. #{nodeLeft ,jdbcType=BIGINT},
  159. </if>
  160. <if test="nodeRight != null">
  161. #{nodeRight ,jdbcType=BIGINT},
  162. </if>
  163. <if test="nodeLevel != null">
  164. #{nodeLevel ,jdbcType=BIGINT},
  165. </if>
  166. <if test="isLeaf != null">
  167. #{isLeaf ,jdbcType=BIGINT},
  168. </if>
  169. <if test="createdBy != null">
  170. #{createdBy ,jdbcType=BIGINT},
  171. </if>
  172. <if test="createdAt != null">
  173. #{createdAt ,jdbcType=DATETIME},
  174. </if>
  175. </trim>
  176. </insert>
  177. <!--Update更新-->
  178. <update id="update" parameterType="com.zhyc.xps.sys.entity.Industry">
  179. UPDATE industry
  180. <set>
  181. <if test="parentId != null">
  182. parent_id = #{parentId,jdbcType=BIGINT},
  183. </if>
  184. <if test="rootId != null">
  185. root_id = #{rootId ,jdbcType=BIGINT},
  186. </if>
  187. <if test="industryCode != null and industryCode != ''">
  188. industry_code = #{industryCode,jdbcType=VARCHAR},
  189. </if>
  190. <if test="industryName != null and industryName != ''">
  191. industry_name = #{industryName,jdbcType=VARCHAR},
  192. </if>
  193. <if test="industryLogo != null and industryLogo != ''">
  194. industry_logo = #{industryLogo,jdbcType=VARCHAR},
  195. </if>
  196. <if test="industryTypeId != null">
  197. industry_type_id = #{industryTypeId,jdbcType=BIGINT},
  198. </if>
  199. <if test="industryDesc != null and industryDesc != ''">
  200. industry_desc = #{industryDesc,jdbcType=VARCHAR},
  201. </if>
  202. <if test="sortNo != null">
  203. sort_no = #{sortNo ,jdbcType=BIGINT},
  204. </if>
  205. <if test="nodeLeft != null">
  206. node_left = #{nodeLeft ,jdbcType=BIGINT},
  207. </if>
  208. <if test="nodeRight != null">
  209. node_right = #{nodeRight ,jdbcType=BIGINT},
  210. </if>
  211. <if test="nodeLevel != null">
  212. node_level = #{nodeLevel ,jdbcType=BIGINT},
  213. </if>
  214. <if test="isLeaf != null">
  215. is_leaf = #{isLeaf ,jdbcType=BIGINT},
  216. </if>
  217. <if test="updatedBy != null">
  218. updated_by = #{updatedBy,jdbcType=BIGINT},
  219. </if>
  220. <if test="updatedAt != null">
  221. updated_at = #{updatedAt,jdbcType=DATETIME},
  222. </if>
  223. </set>
  224. WHERE industry_id = #{industryId ,jdbcType=BIGINT}
  225. </update>
  226. <!--删除-->
  227. <delete id="delete" parameterType="java.util.Map">
  228. DELETE FROM industry
  229. WHERE 1 = 1
  230. <if test="industryId != null">
  231. AND industry_id = #{industryId,jdbcType=BIGINT}
  232. </if>
  233. </delete>
  234. </mapper>