SlOpendoorApplyMapper.xml 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="com.zd.smartlock.mapper.SlOpendoorApplyMapper">
  6. <resultMap type="com.zd.smartlock.domain.vo.SlOpendoorApplyVo" id="SlOpendoorApplyResult">
  7. <result property="id" column="id"/>
  8. <result property="userId" column="user_id"/>
  9. <result property="userName" column="user_name"/>
  10. <result property="deptId" column="dept_id"/>
  11. <result property="deptName" column="dept_name"/>
  12. <result property="userCode" column="user_code"/>
  13. <result property="userSex" column="user_sex"/>
  14. <result property="phonenumber" column="phonenumber"/>
  15. <result property="userId2" column="user_id2"/>
  16. <result property="userName2" column="user_name2"/>
  17. <result property="userCode2" column="user_code2"/>
  18. <result property="userSex2" column="user_sex2"/>
  19. <result property="phonenumber2" column="phonenumber2"/>
  20. <result property="subjectId" column="subject_id"/>
  21. <result property="subjectName" column="subject_name"/>
  22. <result property="safeUserId" column="safe_user_id"/>
  23. <result property="safeUserName" column="safe_user_name"/>
  24. <result property="safeUserPhone" column="safe_user_phone"/>
  25. <result property="position" column="position"/>
  26. <result property="college" column="college"/>
  27. <result property="applyStatus" column="apply_status"/>
  28. <result property="applyNumber" column="apply_number"/>
  29. <result property="illustrate" column="illustrate"/>
  30. <result property="approvalUser" column="approval_user"/>
  31. <result property="approvalTime" column="approval_time"/>
  32. <result property="creatTime" column="creat_time"/>
  33. </resultMap>
  34. <sql id="selectSlOpendoorApplyVo">
  35. select id,
  36. user_id,
  37. user_name,
  38. dept_id,
  39. dept_name,
  40. user_code,
  41. user_sex,
  42. phonenumber,
  43. user_id2,
  44. user_name2,
  45. user_code2,
  46. user_sex2,
  47. phonenumber2,
  48. subject_id,
  49. subject_name,
  50. safe_user_id,
  51. safe_user_name,
  52. safe_user_phone,
  53. position,
  54. college,
  55. apply_status,
  56. apply_number,
  57. illustrate,
  58. approval_user,
  59. approval_time,
  60. creat_time
  61. from sl_opendoor_apply t
  62. </sql>
  63. <sql id="selectSlOpendoorApplyListVo">
  64. select t.id,
  65. t.user_id,
  66. t.user_name,
  67. t.dept_id,
  68. t.dept_name,
  69. t.user_code,
  70. t.user_sex,
  71. t.phonenumber,
  72. t.user_id2,
  73. t.user_name2,
  74. t.user_code2,
  75. t.user_sex2,
  76. t.phonenumber,
  77. t.subject_id,
  78. t.subject_name,
  79. t.safe_user_id,
  80. t.safe_user_name,
  81. t.safe_user_phone,
  82. t.position,
  83. t.college,
  84. t.apply_status,
  85. t.apply_number,
  86. t.illustrate,
  87. t.approval_user,
  88. t.approval_time,
  89. t.creat_time,
  90. (select GROUP_CONCAT(safe_user_name) from sl_subject_relation r where r.subject_id= t.subject_id ) authName,
  91. date_add(t.creat_time, interval 1 hour) loseTime
  92. from sl_opendoor_apply as t
  93. LEFT JOIN sys_dept d on t.dept_id=d.dept_id
  94. LEFT JOIN sys_user u on t.user_id=u.user_id
  95. </sql>
  96. <select id="selectSlOpendoorApplyList" parameterType="com.zd.smartlock.domain.vo.SlOpendoorApplyVo"
  97. resultMap="SlOpendoorApplyResult">
  98. <include refid="selectSlOpendoorApplyListVo"/>
  99. <where>
  100. <if test="userId != null ">and t.user_id = #{userId}</if>
  101. <if test="userName != null and userName != ''">and user_name like concat('%', #{userName}, '%')</if>
  102. <if test="deptId != null ">and t.dept_id = #{deptId}</if>
  103. <if test="deptName != null ">and t.dept_name = #{deptName}</if>
  104. <if test="userCode != null ">and t.user_code = #{userCode}</if>
  105. <if test="userSex != null ">and t.user_sex = #{userSex}</if>
  106. <if test="phonenumber != null ">and t.phonenumber = #{phonenumber}</if>
  107. <if test="userId2 != null ">and t.user_id2 = #{userId2}</if>
  108. <if test="userName2 != null and userName2 != ''">and t.user_name2 = #{userName2}</if>
  109. <if test="userCode2 != null ">and t.user_code2 = #{userCode2}</if>
  110. <if test="userSex2 != null ">and t.user_sex2 = #{userSex2}</if>
  111. <if test="phonenumber2 != null ">and t.phonenumber2 = #{phonenumber2}</if>
  112. <if test="subjectId != null ">and t.subject_id = #{subjectId}</if>
  113. <if test="subjectName != null and subjectName != ''">and t.subject_name like concat('%', #{subjectName},
  114. '%')
  115. </if>
  116. <if test="safeUserId != null and position != ''">and t.safe_user_id = #{safeUserId}</if>
  117. <if test="safeUserName != null and position != ''">and t.safe_user_name = #{safeUserName}</if>
  118. <if test="position != null and position != ''">and t.position = #{position}</if>
  119. <if test="college != null and college != ''">and t.college = #{college}</if>
  120. <if test="applyStatus != null ">and t.apply_status = #{applyStatus}</if>
  121. <if test="applyNumber != null ">and t.apply_number = #{applyNumber}</if>
  122. <if test="illustrate != null ">and t.illustrate = #{illustrate}</if>
  123. <if test="approvalUser != null ">and t.approval_user = #{approvalUser}</if>
  124. <if test="approvalTime != null ">and t.approval_time = #{approvalTime}</if>
  125. <if test="creatTime != null ">and t.creat_time = #{creatTime}</if>
  126. <if test="searchValue != null and searchValue != ''">
  127. and
  128. (t.user_name like concat('%', #{searchValue}, '%') or
  129. t.user_name2 like concat('%', #{searchValue}, '%') or
  130. t.subject_name like concat('%', #{searchValue}, '%')
  131. )
  132. </if>
  133. <if test="startTime != null "> and date_format(t.creat_time,'%Y-%m-%d') &gt;= date_format(#{startTime},'%Y-%m-%d')</if>
  134. <if test="endTime != null "> and date_format(t.creat_time,'%Y-%m-%d') &lt;= date_format(#{endTime},'%Y-%m-%d')</if>
  135. </where>
  136. <!-- 数据范围过滤 -->
  137. ${params.dataScope}
  138. </select>
  139. <select id="getListByIds" resultMap="SlOpendoorApplyResult">
  140. <include refid="selectSlOpendoorApplyVo"/>
  141. <where>
  142. id in
  143. <foreach item="id" collection="list" open="(" separator="," close=")">
  144. #{id}
  145. </foreach>
  146. </where>
  147. </select>
  148. <select id="selectSlOpendoorApplyById" resultMap="SlOpendoorApplyResult">
  149. <include refid="selectSlOpendoorApplyVo"/>
  150. where id = #{id}
  151. </select>
  152. <insert id="insertSlOpendoorApply" parameterType="com.zd.smartlock.domain.SlOpendoorApply" useGeneratedKeys="true"
  153. keyProperty="id">
  154. insert into sl_opendoor_apply
  155. <trim prefix="(" suffix=")" suffixOverrides=",">
  156. <if test="userId != null">user_id,</if>
  157. <if test="userName != null">user_name,</if>
  158. <if test="deptId != null">dept_id,</if>
  159. <if test="deptName != null">dept_name,</if>
  160. <if test="userCode != null">user_code,</if>
  161. <if test="userSex != null">user_sex,</if>
  162. <if test="phonenumber != null">phonenumber,</if>
  163. <if test="userId2 != null">user_id2,</if>
  164. <if test="userName2 != null">user_name2,</if>
  165. <if test="userCode2 != null">user_code2,</if>
  166. <if test="userSex2 != null">user_sex2,</if>
  167. <if test="phonenumber2 != null">phonenumber2,</if>
  168. <if test="subjectId != null">subject_id,</if>
  169. <if test="subjectName != null">subject_name,</if>
  170. <if test="safeUserId != null">safe_user_id,</if>
  171. <if test="safeUserName != null">safe_user_name,</if>
  172. <if test="safeUserPhone != null">safe_user_phone,</if>
  173. <if test="position != null">position,</if>
  174. <if test="college != null">college,</if>
  175. <if test="applyStatus != null">apply_status,</if>
  176. <if test="applyNumber != null">apply_number,</if>
  177. <if test="illustrate != null">illustrate,</if>
  178. <if test="approvalUser != null">approval_user,</if>
  179. <if test="approvalTime != null">approval_time,</if>
  180. <if test="creatTime != null">creat_time,</if>
  181. </trim>
  182. <trim prefix="values (" suffix=")" suffixOverrides=",">
  183. <if test="userId != null">#{userId},</if>
  184. <if test="userName != null">#{userName},</if>
  185. <if test="deptId != null">#{deptId},</if>
  186. <if test="deptName != null">#{deptName},</if>
  187. <if test="userCode != null">#{userCode},</if>
  188. <if test="userSex != null">#{userSex},</if>
  189. <if test="phonenumber != null">#{phonenumber},</if>
  190. <if test="userId2 != null">#{userId2},</if>
  191. <if test="userName2 != null">#{userName2},</if>
  192. <if test="userCode2 != null">#{userCode2},</if>
  193. <if test="userSex2 != null">#{userSex2},</if>
  194. <if test="phonenumber2 != null">#{phonenumber2},</if>
  195. <if test="subjectId != null">#{subjectId},</if>
  196. <if test="subjectName != null">#{subjectName},</if>
  197. <if test="safeUserId != null">#{safeUserId},</if>
  198. <if test="safeUserName != null">#{safeUserName},</if>
  199. <if test="safeUserPhone != null">#{safeUserPhone},</if>
  200. <if test="position != null">#{position},</if>
  201. <if test="college != null">#{college},</if>
  202. <if test="applyStatus != null">#{applyStatus},</if>
  203. <if test="applyNumber != null">#{applyNumber},</if>
  204. <if test="illustrate != null">#{illustrate},</if>
  205. <if test="approvalUser != null">#{approval_user},</if>
  206. <if test="approvalTime != null">#{approval_time},</if>
  207. <if test="creatTime != null">#{creatTime},</if>
  208. </trim>
  209. </insert>
  210. <update id="updateSlOpendoorApply" parameterType="com.zd.smartlock.domain.SlOpendoorApply">
  211. update sl_opendoor_apply
  212. <trim prefix="SET" suffixOverrides=",">
  213. <if test="userId != null">user_id = #{userId},</if>
  214. <if test="userName != null">user_name = #{userName},</if>
  215. <if test="deptId != null">dept_id = #{deptId},</if>
  216. <if test="deptName != null">dept_name = #{deptName},</if>
  217. <if test="userCode != null">user_code = #{userCode},</if>
  218. <if test="userSex != null">user_sex = #{userSex},</if>
  219. <if test="phonenumber != null">phonenumber = #{phonenumber},</if>
  220. <if test="userId2 != null">user_id2 = #{userId2},</if>
  221. <if test="userName2 != null">user_name2 = #{userName2},</if>
  222. <if test="userCode2 != null">user_code2 = #{userCode2},</if>
  223. <if test="userSex2 != null">user_sex2 = #{userSex2},</if>
  224. <if test="phonenumber2 != null">phonenumber2 = #{phonenumber2},</if>
  225. <if test="subjectId != null">subject_id = #{subjectId},</if>
  226. <if test="subjectName != null">subject_name = #{subjectName},</if>
  227. <if test="safeUserId != null">safe_user_id = #{safeUserId},</if>
  228. <if test="safeUserName != null">safe_user_name = #{safeUserName},</if>
  229. <if test="safeUserPhone != null">safe_user_phone = #{safeUserPhone},</if>
  230. <if test="position != null">position = #{position},</if>
  231. <if test="college != null">college = #{college},</if>
  232. <if test="applyStatus != null">apply_status = #{applyStatus},</if>
  233. <if test="applyNumber != null">apply_number = #{applyNumber},</if>
  234. <if test="illustrate != null">illustrate = #{illustrate},</if>
  235. <if test="approvalUser != null">approval_user = #{approvalUser},</if>
  236. <if test="approvalTime != null">approval_time = #{approvalTime},</if>
  237. <if test="creatTime != null">creat_time = #{creatTime},</if>
  238. </trim>
  239. where id = #{id}
  240. </update>
  241. <delete id="deleteSlOpendoorApplyById">
  242. delete
  243. from sl_opendoor_apply
  244. where id = #{id}
  245. </delete>
  246. <delete id="deleteSlOpendoorApplyByIds">
  247. delete from sl_opendoor_apply where id in
  248. <foreach item="id" collection="array" open="(" separator="," close=")">
  249. #{id}
  250. </foreach>
  251. </delete>
  252. </mapper>