OrganizationMapper.xml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  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.bz.smart_city.dao.OrganizationMapper">
  4. <!--auto generated Code-->
  5. <resultMap id="BaseResultMap" type="com.bz.smart_city.entity.Organization">
  6. <result column="id" property="id" jdbcType="INTEGER"/>
  7. <result column="parent_id" property="parentId" jdbcType="INTEGER"/>
  8. <result column="name" property="name" jdbcType="VARCHAR"/>
  9. <result column="type" property="type" jdbcType="INTEGER"/>
  10. <result column="address" property="address" jdbcType="VARCHAR"/>
  11. <result column="status" property="status" jdbcType="INTEGER"/>
  12. <result column="create_date" property="createDate" jdbcType="TIMESTAMP"/>
  13. <result column="create_by" property="createBy" jdbcType="VARCHAR"/>
  14. <result column="update_date" property="updateDate" jdbcType="TIMESTAMP"/>
  15. <result column="update_by" property="updateBy" jdbcType="VARCHAR"/>
  16. <result column="site_id" property="siteId" jdbcType="INTEGER"/>
  17. <result column="collections" property="collections" jdbcType="VARCHAR"/>
  18. </resultMap>
  19. <!--auto generated Code-->
  20. <sql id="Base_Column_List">
  21. id,
  22. parent_id,
  23. name,
  24. type,
  25. address,
  26. status,
  27. create_date,
  28. create_by,
  29. update_date,
  30. update_by,
  31. site_id,
  32. collections
  33. </sql>
  34. <sql id="Base_Column_List_Org">
  35. org.id,
  36. org.parent_id,
  37. org.name,
  38. org.type,
  39. org.address,
  40. org.status,
  41. org.create_date,
  42. org.create_by,
  43. org.update_date,
  44. org.update_by,
  45. org.site_id,
  46. org.collections
  47. </sql>
  48. <!--auto generated Code-->
  49. <insert id="insert" useGeneratedKeys="true" keyProperty="organization.id">
  50. INSERT INTO sc_organization (
  51. id,
  52. parent_id,
  53. name,
  54. type,
  55. address,
  56. status,
  57. create_date,
  58. create_by,
  59. update_date,
  60. update_by,
  61. site_id,
  62. collections,
  63. customer_id
  64. ) VALUES (
  65. #{organization.id,jdbcType=INTEGER},
  66. #{organization.parentId,jdbcType=INTEGER},
  67. #{organization.name,jdbcType=VARCHAR},
  68. #{organization.type,jdbcType=INTEGER},
  69. #{organization.address,jdbcType=VARCHAR},
  70. #{organization.status,jdbcType=INTEGER},
  71. #{organization.createDate,jdbcType=TIMESTAMP},
  72. #{organization.createBy,jdbcType=VARCHAR},
  73. #{organization.updateDate,jdbcType=TIMESTAMP},
  74. #{organization.updateBy,jdbcType=VARCHAR},
  75. #{organization.siteId,jdbcType=INTEGER},
  76. #{organization.collections,jdbcType=VARCHAR},
  77. #{organization.customerId,jdbcType=BIGINT}
  78. )
  79. </insert>
  80. <!--auto generated Code-->
  81. <insert id="insertSelective" useGeneratedKeys="true" keyProperty="organization.id">
  82. INSERT INTO sc_organization
  83. <trim prefix="(" suffix=")" suffixOverrides=",">
  84. <if test="organization.id!=null"> id,</if>
  85. <if test="organization.parentId!=null"> parent_id,</if>
  86. <if test="organization.name!=null"> name,</if>
  87. <if test="organization.type!=null"> type,</if>
  88. <if test="organization.address!=null"> address,</if>
  89. <if test="organization.status!=null"> status,</if>
  90. <if test="organization.createDate!=null"> create_date,</if>
  91. <if test="organization.createBy!=null"> create_by,</if>
  92. <if test="organization.updateDate!=null"> update_date,</if>
  93. <if test="organization.updateBy!=null"> update_by,</if>
  94. <if test="organization.siteId!=null"> site_id,</if>
  95. <if test="organization.collections!=null"> collections</if>
  96. </trim>
  97. VALUES
  98. <trim prefix="(" suffix=")" suffixOverrides=",">
  99. <if test="organization.id!=null"> #{organization.id,jdbcType=INTEGER},</if>
  100. <if test="organization.parentId!=null"> #{organization.parentId,jdbcType=INTEGER},</if>
  101. <if test="organization.name!=null"> #{organization.name,jdbcType=VARCHAR},</if>
  102. <if test="organization.type!=null"> #{organization.type,jdbcType=INTEGER},</if>
  103. <if test="organization.address!=null"> #{organization.address,jdbcType=VARCHAR},</if>
  104. <if test="organization.status!=null"> #{organization.status,jdbcType=INTEGER},</if>
  105. <if test="organization.createDate!=null"> #{organization.createDate,jdbcType=TIMESTAMP},</if>
  106. <if test="organization.createBy!=null"> #{organization.createBy,jdbcType=VARCHAR},</if>
  107. <if test="organization.updateDate!=null"> #{organization.updateDate,jdbcType=TIMESTAMP},</if>
  108. <if test="organization.updateBy!=null"> #{organization.updateBy,jdbcType=VARCHAR},</if>
  109. <if test="organization.siteId!=null"> #{organization.siteId,jdbcType=INTEGER},</if>
  110. <if test="organization.collections!=null"> #{organization.collections,jdbcType=VARCHAR}</if>
  111. </trim>
  112. </insert>
  113. <!--auto generated Code-->
  114. <insert id="insertList">
  115. INSERT INTO sc_organization(
  116. id,
  117. parent_id,
  118. name,
  119. type,
  120. address,
  121. status,
  122. create_date,
  123. create_by,
  124. update_date,
  125. update_by,
  126. site_id,
  127. collections
  128. )VALUES
  129. <foreach collection="organizations" item="organization" index="index" separator=",">
  130. (
  131. #{organization.id,jdbcType=INTEGER},
  132. #{organization.parentId,jdbcType=INTEGER},
  133. #{organization.name,jdbcType=VARCHAR},
  134. #{organization.type,jdbcType=INTEGER},
  135. #{organization.address,jdbcType=VARCHAR},
  136. #{organization.status,jdbcType=INTEGER},
  137. #{organization.createDate,jdbcType=TIMESTAMP},
  138. #{organization.createBy,jdbcType=VARCHAR},
  139. #{organization.updateDate,jdbcType=TIMESTAMP},
  140. #{organization.updateBy,jdbcType=VARCHAR},
  141. #{organization.siteId,jdbcType=INTEGER},
  142. #{organization.collections,jdbcType=VARCHAR}
  143. )
  144. </foreach>
  145. </insert>
  146. <!--auto generated Code-->
  147. <update id="updateByPrimaryKeySelective">
  148. UPDATE sc_organization
  149. <set>
  150. <if test="organization.id != null"> id = #{organization.id,jdbcType=INTEGER},</if>
  151. <if test="organization.parentId != null"> parent_id = #{organization.parentId,jdbcType=INTEGER},</if>
  152. <if test="organization.name != null"> name = #{organization.name,jdbcType=VARCHAR},</if>
  153. <if test="organization.type != null"> type = #{organization.type,jdbcType=INTEGER},</if>
  154. <if test="organization.address != null"> address = #{organization.address,jdbcType=VARCHAR},</if>
  155. <if test="organization.status != null"> status = #{organization.status,jdbcType=INTEGER},</if>
  156. <if test="organization.createDate != null"> create_date = #{organization.createDate,jdbcType=TIMESTAMP},</if>
  157. <if test="organization.createBy != null"> create_by = #{organization.createBy,jdbcType=VARCHAR},</if>
  158. <if test="organization.updateDate != null"> update_date = #{organization.updateDate,jdbcType=TIMESTAMP},</if>
  159. <if test="organization.updateBy != null"> update_by = #{organization.updateBy,jdbcType=VARCHAR},</if>
  160. <if test="organization.siteId != null"> site_id = #{organization.siteId,jdbcType=INTEGER},</if>
  161. <if test="organization.collections != null"> collections = #{organization.collections,jdbcType=VARCHAR}</if>
  162. </set>
  163. WHERE id = #{organization.id,jdbcType=INTEGER}
  164. </update>
  165. <select id="findList" resultType="com.bz.smart_city.dto.OrganizationDto">
  166. select <include refid="Base_Column_List"/> from sc_organization
  167. where status = 1
  168. <if test="siteId != null"> and site_id = #{siteId} </if>
  169. order by create_date desc
  170. </select>
  171. <select id="findListForCustomer" resultType="com.bz.smart_city.dto.OrganizationDto">
  172. select <include refid="Base_Column_List"/>
  173. from sc_organization
  174. where status = 1
  175. <if test="customerId != null"> and customer_id = #{customerId} </if>
  176. order by create_date desc
  177. </select>
  178. <select id="findListByCustomer" resultType="com.bz.smart_city.dto.OrganizationDto">
  179. select <include refid="Base_Column_List_Org"/>
  180. from sc_organization org
  181. inner join sc_customer cus on cus.customer_org_id=org.id
  182. where org.status = 1
  183. <if test="customerId != null"> and org.customer_id = #{customerId} </if>
  184. order by org.create_date desc
  185. </select>
  186. <select id="findByNameUnique" resultType="int">
  187. select count(1) from sc_organization
  188. where status = 1 and name = #{name} and parent_id = #{parentId}
  189. and site_id = #{siteId}
  190. <if test="id != null"> and id != #{id} </if>
  191. </select>
  192. <select id="countParentId" resultType="java.lang.Integer">
  193. select count(1) from sc_organization where status = 1 and parent_id = #{id}
  194. </select>
  195. <select id="findListByIds" resultType="com.bz.smart_city.entity.Organization">
  196. select <include refid="Base_Column_List"/>
  197. from
  198. sc_organization
  199. where
  200. status = 1
  201. and id in
  202. <foreach collection="orgIds" item="orgId" open="(" separator="," close=")">#{orgId}</foreach>
  203. </select>
  204. <select id="fingByOrganizationOne" resultType="com.bz.smart_city.dto.OrganizationDto">
  205. select <include refid="Base_Column_List"/>
  206. from sc_organization
  207. where status = 1 and parent_id = '0'
  208. <if test="customerId != null"> and customer_id = #{customerId} </if>
  209. <if test="siteId != null">and site_id =#{siteId}</if>
  210. order by create_date desc
  211. </select>
  212. <select id="findListLikeOrgin" resultType="com.bz.smart_city.dto.OrganizationDto">
  213. select <include refid="Base_Column_List"/>
  214. from sc_organization
  215. where status = 1
  216. <if test="customerId != null"> and customer_id = #{customerId} </if>
  217. <if test="siteId != null">and site_id =#{siteId}</if>
  218. <if test="id != null">
  219. and collections like concat('%',#{id},'%')
  220. </if>
  221. order by create_date desc
  222. </select>
  223. <select id="findOrginName" resultType="java.lang.String">
  224. select name as "name"
  225. from sc_organization
  226. where status = 1
  227. <if test="customerId != null"> and customer_id = #{customerId} </if>
  228. <if test="siteId != null">and site_id =#{siteId}</if>
  229. <if test="id != null">
  230. and id=#{id}
  231. </if>
  232. </select>
  233. </mapper>