DoctorMapper.xml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  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.hos.mapper.DoctorMapper">
  4. <!-- 通用查询映射结果 -->
  5. <resultMap id="DoctorResultMap" type="com.zhyc.xps.hos.dto.DoctorDto">
  6. <result column="oc_id" property="ocId" jdbcType="BIGINT" />
  7. <result column="doctor_id" property="doctorId" jdbcType="BIGINT" />
  8. <result column="doctor_name" property="doctorName" jdbcType="VARCHAR" />
  9. <result column="doctor_code" property="doctorCode" jdbcType="VARCHAR" />
  10. <result column="doctor_birth" property="doctorBirth" jdbcType="DATE" />
  11. <result column="doctor_resume" property="doctorResume" jdbcType="VARCHAR" />
  12. <result column="doctor_avatar" property="doctorAvatar" jdbcType="VARCHAR" />
  13. <result column="doctor_professional_id" property="doctorProfessionalId" jdbcType="BIGINT" />
  14. <result column="group_id" property="groupId" jdbcType="BIGINT" />
  15. <result column="group_name" property="groupName" jdbcType="VARCHAR" />
  16. <result column="position_id" property="positionId" jdbcType="BIGINT" />
  17. <result column="position_name" property="positionName" jdbcType="VARCHAR" />
  18. <result column="doctor_desc" property="doctorDesc" jdbcType="VARCHAR" />
  19. <result column="checklist_num" property="checklistNum" jdbcType="BIGINT" />
  20. </resultMap>
  21. <!-- 通用查询结果列 -->
  22. <sql id="DoctorDto_Cols">
  23. A.oc_id,
  24. A.doctor_id,
  25. A.doctor_name,
  26. A.doctor_code,
  27. A.doctor_birth,
  28. A.doctor_resume,
  29. A.doctor_avatar,
  30. A.doctor_professional_id,
  31. A.group_id,
  32. B.group_name,
  33. A.position_id,
  34. C.position_name,
  35. A.doctor_desc,
  36. IFNULL(E.checklist_num, 0) AS checklist_num
  37. </sql>
  38. <!--基于ID查询-->
  39. <select id="getById" resultMap="DoctorResultMap">
  40. SELECT
  41. <include refid="DoctorDto_Cols"/>
  42. FROM hos_doctor AS A
  43. LEFT JOIN s_group AS B ON (A.oc_id = B.oc_id AND A.group_id = B.group_id)
  44. LEFT JOIN s_position AS C ON (A.oc_id = C.oc_id AND A.position_id = C.position_id)
  45. LEFT JOIN (
  46. SELECT oc_id, target_id, count(*) AS checklist_num
  47. FROM checklist_target
  48. WHERE oc_id = #{ocId ,jdbcType=BIGINT} AND target_type = 3
  49. GROUP BY target_id
  50. ) AS E ON (A.oc_id = E.oc_id AND A.doctor_id = E.target_id)
  51. WHERE A.oc_id = #{ocId ,jdbcType=BIGINT}
  52. AND A.doctor_id = #{doctorId ,jdbcType=BIGINT}
  53. </select>
  54. <!--基于Code查询-->
  55. <select id="getByCode" resultMap="DoctorResultMap">
  56. SELECT
  57. <include refid="DoctorDto_Cols"/>
  58. FROM hos_doctor AS A
  59. LEFT JOIN s_group AS B ON (A.oc_id = B.oc_id AND A.group_id = B.group_id)
  60. LEFT JOIN s_position AS C ON (A.oc_id = C.oc_id AND A.position_id = C.position_id)
  61. LEFT JOIN (
  62. SELECT oc_id, target_id, count(*) AS checklist_num
  63. FROM checklist_target
  64. WHERE oc_id = #{ocId ,jdbcType=BIGINT} AND target_type = 3
  65. GROUP BY target_id
  66. ) AS E ON (A.oc_id = E.oc_id AND A.doctor_id = E.target_id)
  67. WHERE A.oc_id = #{ocId, jdbcType=BIGINT}
  68. AND A.doctor_code = #{doctorCode, jdbcType=VARCHAR}
  69. </select>
  70. <!--分页查询-->
  71. <select id="getByPage" parameterType="java.util.Map" resultMap="DoctorResultMap" >
  72. SELECT
  73. <include refid="DoctorDto_Cols"/>
  74. FROM hos_doctor AS A
  75. LEFT JOIN s_group AS B ON (A.oc_id = B.oc_id AND A.group_id = B.group_id)
  76. LEFT JOIN s_position AS C ON (A.oc_id = C.oc_id AND A.position_id = C.position_id)
  77. LEFT JOIN (
  78. SELECT oc_id, target_id, count(*) AS checklist_num
  79. FROM checklist_target
  80. WHERE oc_id = #{ocId ,jdbcType=BIGINT} AND target_type = 3
  81. GROUP BY target_id
  82. ) AS E ON (A.oc_id = E.oc_id AND A.doctor_id = E.target_id)
  83. WHERE A.deleted_flag = 0 AND A.oc_id = #{ocId ,jdbcType=BIGINT}
  84. <if test="keywords != null and keywords != ''">
  85. AND A.doctor_name like "%"#{keywords}"%"
  86. </if>
  87. ORDER BY A.oc_id, A.doctor_id
  88. </select>
  89. <!--列表查询-->
  90. <select id="getByList" parameterType="java.util.Map" resultMap="DoctorResultMap">
  91. SELECT
  92. <include refid="DoctorDto_Cols"/>
  93. FROM hos_doctor AS A
  94. LEFT JOIN s_group AS B ON (A.oc_id = B.oc_id AND A.group_id = B.group_id)
  95. LEFT JOIN s_position AS C ON (A.oc_id = C.oc_id AND A.position_id = C.position_id)
  96. LEFT JOIN (
  97. SELECT oc_id, target_id, count(*) AS checklist_num
  98. FROM checklist_target
  99. WHERE oc_id = #{ocId ,jdbcType=BIGINT} AND target_type = 3
  100. GROUP BY target_id
  101. ) AS E ON (A.oc_id = E.oc_id AND A.doctor_id = E.target_id)
  102. WHERE A.deleted_flag = 0 AND A.oc_id = #{ocId ,jdbcType=BIGINT}
  103. <if test="keywords != null and keywords != ''">
  104. AND A.doctor_name like "%"#{keywords}"%"
  105. </if>
  106. ORDER BY A.oc_id, A.doctor_id
  107. </select>
  108. <insert id="create" parameterType="com.zhyc.xps.hos.entity.Doctor">
  109. INSERT INTO hos_doctor
  110. <trim prefix="(" suffix=")" suffixOverrides=",">
  111. <if test="ocId != null">
  112. oc_id,
  113. </if>
  114. <if test="doctorId != null">
  115. doctor_id,
  116. </if>
  117. <if test="doctorName != null and doctorName != ''">
  118. doctor_name,
  119. </if>
  120. <if test="doctorCode != null and doctorCode != ''">
  121. doctor_code,
  122. </if>
  123. <if test="doctorBirth != null">
  124. doctor_birth,
  125. </if>
  126. <if test="doctorResume != null and doctorResume != ''">
  127. doctor_resume,
  128. </if>
  129. <if test="doctorAvatar != null and doctorAvatar != ''">
  130. doctor_avatar,
  131. </if>
  132. <if test="doctorProfessionalId != null">
  133. doctor_professional_id,
  134. </if>
  135. <if test="groupId != null">
  136. group_id,
  137. </if>
  138. <if test="positionId != null">
  139. position_id,
  140. </if>
  141. <if test="doctorDesc != null and doctorDesc != ''">
  142. doctor_desc,
  143. </if>
  144. <if test="createdBy != null">
  145. created_by,
  146. </if>
  147. <if test="createdAt != null">
  148. created_at,
  149. </if>
  150. </trim>
  151. <trim prefix="values (" suffix=")" suffixOverrides=",">
  152. <if test="ocId != null">
  153. #{ocId,jdbcType=BIGINT},
  154. </if>
  155. <if test="doctorId != null">
  156. #{doctorId ,jdbcType=BIGINT},
  157. </if>
  158. <if test="doctorName != null and doctorName != ''">
  159. #{doctorName ,jdbcType=VARCHAR},
  160. </if>
  161. <if test="doctorCode != null and doctorCode != ''">
  162. #{doctorCode ,jdbcType=VARCHAR},
  163. </if>
  164. <if test="doctorBirth != null">
  165. #{doctorBirth ,jdbcType=DATE},
  166. </if>
  167. <if test="doctorResume != null and doctorResume != ''">
  168. #{doctorResume ,jdbcType=VARCHAR},
  169. </if>
  170. <if test="doctorAvatar != null and doctorAvatar != ''">
  171. #{doctorAvatar ,jdbcType=VARCHAR},
  172. </if>
  173. <if test="doctorProfessionalId != null">
  174. #{doctorProfessionalId ,jdbcType=BIGINT},
  175. </if>
  176. <if test="groupId != null">
  177. #{groupId ,jdbcType=BIGINT},
  178. </if>
  179. <if test="positionId != null">
  180. #{positionId ,jdbcType=BIGINT},
  181. </if>
  182. <if test="doctorDesc != null and doctorDesc != ''">
  183. #{doctorDesc ,jdbcType=VARCHAR},
  184. </if>
  185. <if test="createdBy != null">
  186. #{createdBy ,jdbcType=BIGINT},
  187. </if>
  188. <if test="createdAt != null">
  189. #{createdAt ,jdbcType=TIMESTAMP},
  190. </if>
  191. </trim>
  192. </insert>
  193. <!--更新-->
  194. <update id="update" parameterType="com.zhyc.xps.hos.entity.Doctor">
  195. UPDATE hos_doctor
  196. <trim suffixOverrides=",">
  197. <set>
  198. <if test="doctorName != null and doctorName != ''">
  199. doctor_name = #{doctorName, jdbcType=VARCHAR},
  200. </if>
  201. <if test="doctorCode != null and doctorCode != ''">
  202. doctor_code = #{doctorCode ,jdbcType=VARCHAR},
  203. </if>
  204. <if test="doctorBirth != null and doctorBirth != ''">
  205. doctor_birth = #{doctorBirth ,jdbcType=VARCHAR},
  206. </if>
  207. <if test="doctorResume != null and doctorResume != ''">
  208. doctor_resume = #{doctorResume ,jdbcType=VARCHAR},
  209. </if>
  210. <if test="doctorAvatar != null and doctorAvatar != ''">
  211. doctor_avatar = #{doctorAvatar ,jdbcType=VARCHAR},
  212. </if>
  213. <if test="doctorProfessionalId != null">
  214. doctor_professional_id = #{doctorProfessionalId ,jdbcType=BIGINT},
  215. </if>
  216. <if test="groupId != null">
  217. group_id = #{groupId ,jdbcType=BIGINT},
  218. </if>
  219. <if test="positionId != null">
  220. position_id = #{positionId ,jdbcType=BIGINT},
  221. </if>
  222. <if test="doctorDesc != null and doctorDesc != ''">
  223. doctor_desc = #{doctorDesc, jdbcType=VARCHAR},
  224. </if>
  225. <if test="updatedBy != null ">
  226. updated_by = #{updatedBy ,jdbcType=BIGINT},
  227. </if>
  228. <if test="updatedAt != null">
  229. updated_at = #{updatedAt ,jdbcType=TIMESTAMP},
  230. </if>
  231. </set>
  232. </trim>
  233. WHERE oc_id = #{ocId ,jdbcType=BIGINT}
  234. AND doctor_id = #{doctorId ,jdbcType=BIGINT}
  235. </update>
  236. <!--删除-->
  237. <update id="delete" parameterType="java.util.Map">
  238. UPDATE hos_doctor
  239. <trim suffixOverrides=",">
  240. <set>
  241. <if test="deletedFlag != null">
  242. deleted_flag = #{deletedFlag,jdbcType=BIGINT},
  243. </if>
  244. <if test="deletedTime != null">
  245. deleted_time = #{deletedTime,jdbcType=TIMESTAMP},
  246. </if>
  247. <if test="deletedBy != null">
  248. deleted_by = #{deletedBy,jdbcType=BIGINT},
  249. </if>
  250. </set>
  251. </trim>
  252. WHERE 1 = 1
  253. <if test="ocId != null">
  254. AND oc_id = #{ocId,jdbcType=BIGINT}
  255. </if>
  256. <if test="doctorId != null">
  257. AND doctor_id = #{doctorId ,jdbcType=BIGINT}
  258. </if>
  259. </update>
  260. </mapper>