AmbSystemMapper.xml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307
  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.goafanti.common.dao.AmbSystemMapper">
  4. <resultMap id="BaseResultMap" type="com.goafanti.common.model.AmbSystem">
  5. <id column="id" jdbcType="BIGINT" property="id" />
  6. <result column="parent_id" jdbcType="BIGINT" property="parentId" />
  7. <result column="ancestors" jdbcType="VARCHAR" property="ancestors" />
  8. <result column="name" jdbcType="VARCHAR" property="name" />
  9. <result column="order_num" jdbcType="INTEGER" property="orderNum" />
  10. <result column="leader" jdbcType="VARCHAR" property="leader" />
  11. <result column="status" jdbcType="CHAR" property="status" />
  12. <result column="create_by" jdbcType="VARCHAR" property="createBy" />
  13. <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
  14. <result column="update_by" jdbcType="VARCHAR" property="updateBy" />
  15. <result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
  16. <result column="lvl" jdbcType="INTEGER" property="lvl" />
  17. <result column="finance_id" jdbcType="VARCHAR" property="financeId" />
  18. <result column="ancestors_names" jdbcType="VARCHAR" property="ancestorsNames" />
  19. <result column="accountant" jdbcType="VARCHAR" property="accountant" />
  20. <result column="remarks" jdbcType="VARCHAR" property="remarks" />
  21. </resultMap>
  22. <sql id="Base_Column_List">
  23. id, parent_id, ancestors, `name`, order_num, leader, `status`, create_by, create_time,
  24. update_by, update_time, lvl, finance_id, ancestors_names, accountant, remarks
  25. </sql>
  26. <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
  27. select
  28. <include refid="Base_Column_List" />
  29. from amb_system
  30. where id = #{id,jdbcType=BIGINT}
  31. </select>
  32. <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
  33. delete from amb_system
  34. where id = #{id,jdbcType=BIGINT}
  35. </delete>
  36. <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.goafanti.common.model.AmbSystem" useGeneratedKeys="true">
  37. insert into amb_system (parent_id, ancestors, `name`,
  38. order_num, leader, `status`,
  39. create_by, create_time, update_by,
  40. update_time, lvl, finance_id,
  41. ancestors_names, accountant, remarks
  42. )
  43. values (#{parentId,jdbcType=BIGINT}, #{ancestors,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR},
  44. #{orderNum,jdbcType=INTEGER}, #{leader,jdbcType=VARCHAR}, #{status,jdbcType=CHAR},
  45. #{createBy,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, #{updateBy,jdbcType=VARCHAR},
  46. #{updateTime,jdbcType=TIMESTAMP}, #{lvl,jdbcType=INTEGER}, #{financeId,jdbcType=VARCHAR},
  47. #{ancestorsNames,jdbcType=VARCHAR}, #{accountant,jdbcType=VARCHAR}, #{remarks,jdbcType=VARCHAR}
  48. )
  49. </insert>
  50. <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.goafanti.common.model.AmbSystem" useGeneratedKeys="true">
  51. insert into amb_system
  52. <trim prefix="(" suffix=")" suffixOverrides=",">
  53. <if test="parentId != null">
  54. parent_id,
  55. </if>
  56. <if test="ancestors != null">
  57. ancestors,
  58. </if>
  59. <if test="name != null">
  60. `name`,
  61. </if>
  62. <if test="orderNum != null">
  63. order_num,
  64. </if>
  65. <if test="leader != null">
  66. leader,
  67. </if>
  68. <if test="status != null">
  69. `status`,
  70. </if>
  71. <if test="createBy != null">
  72. create_by,
  73. </if>
  74. <if test="createTime != null">
  75. create_time,
  76. </if>
  77. <if test="updateBy != null">
  78. update_by,
  79. </if>
  80. <if test="updateTime != null">
  81. update_time,
  82. </if>
  83. <if test="lvl != null">
  84. lvl,
  85. </if>
  86. <if test="financeId != null">
  87. finance_id,
  88. </if>
  89. <if test="ancestorsNames != null">
  90. ancestors_names,
  91. </if>
  92. <if test="accountant != null">
  93. accountant,
  94. </if>
  95. <if test="remarks != null">
  96. remarks,
  97. </if>
  98. </trim>
  99. <trim prefix="values (" suffix=")" suffixOverrides=",">
  100. <if test="parentId != null">
  101. #{parentId,jdbcType=BIGINT},
  102. </if>
  103. <if test="ancestors != null">
  104. #{ancestors,jdbcType=VARCHAR},
  105. </if>
  106. <if test="name != null">
  107. #{name,jdbcType=VARCHAR},
  108. </if>
  109. <if test="orderNum != null">
  110. #{orderNum,jdbcType=INTEGER},
  111. </if>
  112. <if test="leader != null">
  113. #{leader,jdbcType=VARCHAR},
  114. </if>
  115. <if test="status != null">
  116. #{status,jdbcType=CHAR},
  117. </if>
  118. <if test="createBy != null">
  119. #{createBy,jdbcType=VARCHAR},
  120. </if>
  121. <if test="createTime != null">
  122. #{createTime,jdbcType=TIMESTAMP},
  123. </if>
  124. <if test="updateBy != null">
  125. #{updateBy,jdbcType=VARCHAR},
  126. </if>
  127. <if test="updateTime != null">
  128. #{updateTime,jdbcType=TIMESTAMP},
  129. </if>
  130. <if test="lvl != null">
  131. #{lvl,jdbcType=INTEGER},
  132. </if>
  133. <if test="financeId != null">
  134. #{financeId,jdbcType=VARCHAR},
  135. </if>
  136. <if test="ancestorsNames != null">
  137. #{ancestorsNames,jdbcType=VARCHAR},
  138. </if>
  139. <if test="accountant != null">
  140. #{accountant,jdbcType=VARCHAR},
  141. </if>
  142. <if test="remarks != null">
  143. #{remarks,jdbcType=VARCHAR},
  144. </if>
  145. </trim>
  146. </insert>
  147. <update id="updateByPrimaryKeySelective" parameterType="com.goafanti.common.model.AmbSystem">
  148. update amb_system
  149. <set>
  150. <if test="parentId != null">
  151. parent_id = #{parentId,jdbcType=BIGINT},
  152. </if>
  153. <if test="ancestors != null">
  154. ancestors = #{ancestors,jdbcType=VARCHAR},
  155. </if>
  156. <if test="name != null">
  157. `name` = #{name,jdbcType=VARCHAR},
  158. </if>
  159. <if test="orderNum != null">
  160. order_num = #{orderNum,jdbcType=INTEGER},
  161. </if>
  162. <if test="leader != null">
  163. leader = #{leader,jdbcType=VARCHAR},
  164. </if>
  165. <if test="status != null">
  166. `status` = #{status,jdbcType=CHAR},
  167. </if>
  168. <if test="createBy != null">
  169. create_by = #{createBy,jdbcType=VARCHAR},
  170. </if>
  171. <if test="createTime != null">
  172. create_time = #{createTime,jdbcType=TIMESTAMP},
  173. </if>
  174. <if test="updateBy != null">
  175. update_by = #{updateBy,jdbcType=VARCHAR},
  176. </if>
  177. <if test="updateTime != null">
  178. update_time = #{updateTime,jdbcType=TIMESTAMP},
  179. </if>
  180. <if test="lvl != null">
  181. lvl = #{lvl,jdbcType=INTEGER},
  182. </if>
  183. <if test="financeId != null">
  184. finance_id = #{financeId,jdbcType=VARCHAR},
  185. </if>
  186. <if test="ancestorsNames != null">
  187. ancestors_names = #{ancestorsNames,jdbcType=VARCHAR},
  188. </if>
  189. <if test="accountant != null">
  190. accountant = #{accountant,jdbcType=VARCHAR},
  191. </if>
  192. <if test="remarks != null">
  193. remarks = #{remarks,jdbcType=VARCHAR},
  194. </if>
  195. </set>
  196. where id = #{id,jdbcType=BIGINT}
  197. </update>
  198. <update id="updateByPrimaryKey" parameterType="com.goafanti.common.model.AmbSystem">
  199. update amb_system
  200. set parent_id = #{parentId,jdbcType=BIGINT},
  201. ancestors = #{ancestors,jdbcType=VARCHAR},
  202. `name` = #{name,jdbcType=VARCHAR},
  203. order_num = #{orderNum,jdbcType=INTEGER},
  204. leader = #{leader,jdbcType=VARCHAR},
  205. `status` = #{status,jdbcType=CHAR},
  206. create_by = #{createBy,jdbcType=VARCHAR},
  207. create_time = #{createTime,jdbcType=TIMESTAMP},
  208. update_by = #{updateBy,jdbcType=VARCHAR},
  209. update_time = #{updateTime,jdbcType=TIMESTAMP},
  210. lvl = #{lvl,jdbcType=INTEGER},
  211. finance_id = #{financeId,jdbcType=VARCHAR},
  212. ancestors_names = #{ancestorsNames,jdbcType=VARCHAR},
  213. accountant = #{accountant,jdbcType=VARCHAR},
  214. remarks = #{remarks,jdbcType=VARCHAR}
  215. where id = #{id,jdbcType=BIGINT}
  216. </update>
  217. <update id="updateAncestorsNames">
  218. update amb_system
  219. set ancestors_names=replace(ancestors_names,#{useName},#{name})
  220. where FIND_IN_SET( #{id},ancestors)
  221. </update>
  222. <select id="getAncestorsList" resultType="com.goafanti.ambSystem.bo.AmbAll">
  223. select id,name,lvl,parent_id parentId
  224. from amb_system where status=0
  225. <if test="list !=null and list.size>0 ">
  226. and id in
  227. <foreach close=")" collection="list" item="id" open="(" separator=",">
  228. #{id}
  229. </foreach>
  230. </if>
  231. </select>
  232. <select id="selectAmbSystemList" resultType="com.goafanti.ambSystem.bo.OutAmb">
  233. select a.id,a.name ,a.ancestors_names ancestorsNames ,a.status,
  234. b.name leaderName,c.name financeName,d.name accountantName,
  235. date_format(a.create_time,'%Y-%m-%d %H:%i:%s')createTimes
  236. from amb_system a
  237. left join admin b on a.leader =b.id
  238. left join admin c on a.finance_id =c.id
  239. left join admin d on a.accountant =d.id
  240. where 1=1
  241. <if test="lvl &lt; 5">
  242. and a.lvl= #{lvl}
  243. </if>
  244. <if test="lvl &gt; 4">
  245. and a.lvl in(5,6)
  246. </if>
  247. <if test="leader !=null">
  248. and a.leader= #{leader}
  249. </if>
  250. <if test="name !=null">
  251. and a.name like concat('%',#{name},'%')
  252. </if>
  253. <if test="ancestors !=null">
  254. and (a.id=#{ancestors} or find_in_set( #{ancestors} ,a.ancestors))
  255. </if>
  256. order by id
  257. <if test="page_sql !=null">
  258. ${page_sql}
  259. </if>
  260. </select>
  261. <select id="selectAmbSystemCount" resultType="java.lang.Integer">
  262. select count(*)
  263. from amb_system a
  264. left join admin b on a.leader =b.id
  265. left join admin c on a.finance_id =c.id
  266. where 1=1
  267. <if test="lvl &lt; 5">
  268. and a.lvl= #{lvl}
  269. </if>
  270. <if test="lvl &gt; 4">
  271. and a.lvl in(5,6)
  272. </if>
  273. <if test="leader !=null">
  274. and a.leader= #{leader}
  275. </if>
  276. <if test="name !=null">
  277. and a.name like concat('%',#{name},'%')
  278. </if>
  279. <if test="ancestors !=null">
  280. and (a.id=#{ancestors} or find_in_set( #{ancestors} ,a.ancestors))
  281. </if>
  282. </select>
  283. <select id="selectByParentId" parameterType="java.lang.Long" resultMap="BaseResultMap">
  284. select
  285. <include refid="Base_Column_List" />
  286. from amb_system
  287. where parent_id = #{id,jdbcType=BIGINT}
  288. </select>
  289. <select id="selectByName" resultType="java.lang.Integer">
  290. select
  291. count(*)
  292. from amb_system
  293. where name= #{name}
  294. </select>
  295. <select id="selectDtailsAmb" resultType="com.goafanti.ambSystem.bo.OutAmbDtails">
  296. select a.id,a.name,a.parent_id parentId,a.accountant,a.lvl,a.status,a.ancestors, a.ancestors_names ancestorsNames,
  297. a.order_num orderNum,a.remarks, date_format(a.create_time,'%Y-%m-%d %H:%i:%s')createTimes, a.leader,
  298. a.finance_id financeId, b.name leaderName,c.name financeName,d.name accountantName
  299. from amb_system a left join admin b on a.leader =b.id left join admin c on a.finance_id =c.id
  300. left join admin d on a.accountant =d.id
  301. where a.id= #{id}
  302. </select>
  303. </mapper>