You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

226 lines
12 KiB

2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
  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.chenhai.vet.mapper.VetPersonalInfoMapper">
  6. <resultMap type="VetPersonalInfo" id="VetPersonalInfoResult">
  7. <!-- 基础字段映射 -->
  8. <result property="id" column="id"/>
  9. <result property="userId" column="user_id"/>
  10. <result property="realName" column="real_name"/>
  11. <result property="gender" column="gender"/>
  12. <result property="birthday" column="birthday"/>
  13. <result property="idCard" column="id_card"/>
  14. <result property="specialty" column="specialty"/>
  15. <result property="workExperience" column="work_experience"/>
  16. <result property="hospital" column="hospital"/>
  17. <result property="address" column="address"/>
  18. <result property="iphone" column="iphone"/>
  19. <result property="introduction" column="introduction"/>
  20. <result property="title" column="title"/>
  21. <result property="phone" column="phone"/>
  22. <result property="expertType" column="expert_type"/>
  23. <result property="email" column="email"/>
  24. <result property="nickName" column="nick_name"/>
  25. <result property="avatar" column="avatar"/>
  26. <result property="createBy" column="create_by"/>
  27. <result property="createTime" column="create_time"/>
  28. <result property="updateBy" column="update_by"/>
  29. <result property="updateTime" column="update_time"/>
  30. <result property="auditStatus" column="audit_status"/>
  31. <result property="auditTime" column="audit_time"/>
  32. <result property="auditor" column="auditor"/>
  33. <result property="auditDesc" column="audit_desc"/>
  34. <!-- 关联 SysUser 对象 -->
  35. <association property="user" javaType="SysUser">
  36. <result property="userId" column="u_user_id"/>
  37. <result property="nickName" column="u_nick_name"/>
  38. <result property="email" column="u_email"/>
  39. <result property="avatar" column="u_avatar"/>
  40. </association>
  41. </resultMap>
  42. <!-- 基础查询SQL -->
  43. <sql id="selectVetPersonalInfoVo">
  44. select id, user_id, real_name, gender, birthday, id_card, specialty, work_experience,
  45. hospital, address, iphone, introduction, title, phone,
  46. expert_type, email, nick_name, create_by, create_time, update_by, update_time
  47. from vet_personal_info
  48. </sql>
  49. <!-- 带用户信息的查询SQL(简化版) -->
  50. <sql id="selectVetPersonalInfoWithUserVo">
  51. select
  52. v.id, v.user_id, v.real_name, v.gender, v.birthday, v.id_card, v.specialty, v.work_experience,
  53. v.hospital, v.address, v.iphone, v.introduction, v.title, v.phone,
  54. v.expert_type, v.email, v.nick_name, v.create_by, v.create_time, v.update_by, v.update_time,
  55. v.audit_status, v.audit_time, v.auditor, v.audit_desc,
  56. u.user_id as u_user_id,
  57. u.nick_name as u_nick_name,
  58. u.avatar as u_avatar,
  59. u.email as u_email
  60. from vet_personal_info v
  61. left join sys_user u on v.user_id = u.user_id
  62. </sql>
  63. <!-- 列表查询(带用户信息) -->
  64. <select id="selectVetPersonalInfoList" parameterType="VetPersonalInfo" resultMap="VetPersonalInfoResult">
  65. <include refid="selectVetPersonalInfoWithUserVo"/>
  66. <where>
  67. <!-- 兽医表条件 -->
  68. <if test="id != null "> and v.id = #{id}</if>
  69. <if test="userId != null "> and v.user_id = #{userId}</if>
  70. <if test="realName != null and realName != ''"> and v.real_name like concat('%', #{realName}, '%')</if>
  71. <if test="gender != null and gender != ''"> and v.gender = #{gender}</if>
  72. <if test="idCard != null and idCard != ''"> and v.id_card = #{idCard}</if>
  73. <if test="specialty != null and specialty != ''"> and v.specialty like concat('%', #{specialty}, '%')</if>
  74. <if test="hospital != null and hospital != ''"> and v.hospital like concat('%', #{hospital}, '%')</if>
  75. <if test="phone != null and phone != ''"> and v.phone like concat('%', #{phone}, '%')</if>
  76. <if test="iphone != null and iphone != ''"> and v.iphone like concat('%', #{iphone}, '%')</if>
  77. <if test="expertType != null and expertType != ''"> and v.expert_type = #{expertType}</if>
  78. <if test="email != null and email != ''"> and v.email = #{email}</if>
  79. <if test="specialty != null and specialty != ''"> and v.specialty like concat('%', #{specialty}, '%')</if>
  80. <!-- 添加审核状态条件 -->
  81. <if test="auditStatus != null and auditStatus != ''">
  82. and v.audit_status = #{auditStatus}
  83. </if>
  84. <!-- 用户表条件 -->
  85. <if test="user != null">
  86. <if test="user.userName != null and user.userName != ''">
  87. and u.user_name like concat('%', #{user.userName}, '%')
  88. </if>
  89. <if test="user.nickName != null and user.nickName != ''">
  90. and u.nick_name like concat('%', #{user.nickName}, '%')
  91. </if>
  92. <if test="user.userType != null and user.userType != ''">
  93. and u.user_type = #{user.userType}
  94. </if>
  95. <if test="user.status != null and user.status != ''">
  96. and u.status = #{user.status}
  97. </if>
  98. <if test="user.deptId != null">
  99. and u.dept_id = #{user.deptId}
  100. </if>
  101. </if>
  102. </where>
  103. order by v.create_time desc
  104. </select>
  105. <!-- 根据ID查询(带用户信息) -->
  106. <select id="selectVetPersonalInfoById" parameterType="Long" resultMap="VetPersonalInfoResult">
  107. <include refid="selectVetPersonalInfoWithUserVo"/>
  108. where v.id = #{id}
  109. </select>
  110. <!-- 根据用户ID查询 -->
  111. <select id="selectVetPersonalInfoByUserId" parameterType="Long" resultMap="VetPersonalInfoResult">
  112. <include refid="selectVetPersonalInfoWithUserVo"/>
  113. where v.user_id = #{userId}
  114. </select>
  115. <!-- 新增兽医个人信息 -->
  116. <insert id="insertVetPersonalInfo" parameterType="VetPersonalInfo" useGeneratedKeys="true" keyProperty="id">
  117. insert into vet_personal_info
  118. <trim prefix="(" suffix=")" suffixOverrides=",">
  119. <if test="userId != null">user_id,</if>
  120. <if test="realName != null and realName != ''">real_name,</if>
  121. <if test="gender != null and gender != ''">gender,</if>
  122. <if test="birthday != null">birthday,</if>
  123. <if test="idCard != null and idCard != ''">id_card,</if>
  124. <if test="specialty != null and specialty != ''">specialty,</if>
  125. <if test="workExperience != null and workExperience != ''">work_experience,</if>
  126. <if test="hospital != null and hospital != ''">hospital,</if>
  127. <if test="address != null and address != ''">address,</if>
  128. <if test="iphone != null and iphone != ''">iphone,</if>
  129. <if test="introduction != null and introduction != ''">introduction,</if>
  130. <if test="title != null and title != ''">title,</if>
  131. <if test="phone != null and phone != ''">phone,</if>
  132. <if test="expertType != null and expertType != ''">expert_type,</if>
  133. <if test="email != null and email != ''">email,</if>
  134. <if test="nickName != null and nickName != ''">nick_name,</if>
  135. <if test="avatar != null and avatar != ''">avatar,</if>
  136. <if test="createBy != null">create_by,</if>
  137. <if test="createTime != null">create_time,</if>
  138. <if test="updateBy != null">update_by,</if>
  139. <if test="updateTime != null">update_time,</if>
  140. </trim>
  141. <trim prefix="values (" suffix=")" suffixOverrides=",">
  142. <if test="userId != null">#{userId},</if>
  143. <if test="realName != null and realName != ''">#{realName},</if>
  144. <if test="gender != null and gender != ''">#{gender},</if>
  145. <if test="birthday != null">#{birthday},</if>
  146. <if test="idCard != null and idCard != ''">#{idCard},</if>
  147. <if test="specialty != null and specialty != ''">#{specialty},</if>
  148. <if test="workExperience != null and workExperience != ''">#{workExperience},</if>
  149. <if test="hospital != null and hospital != ''">#{hospital},</if>
  150. <if test="address != null and address != ''">#{address},</if>
  151. <if test="iphone != null and iphone != ''">#{iphone},</if>
  152. <if test="introduction != null and introduction != ''">#{introduction},</if>
  153. <if test="title != null and title != ''">#{title},</if>
  154. <if test="phone != null and phone != ''">#{phone},</if>
  155. <if test="expertType != null and expertType != ''">#{expertType},</if>
  156. <if test="email != null and email != ''">#{email},</if>
  157. <if test="nickName != null and nickName != ''">#{nickName},</if>
  158. <if test="avatar != null and avatar != ''">#{avatar},</if>
  159. <if test="createBy != null">#{createBy},</if>
  160. <if test="createTime != null">#{createTime},</if>
  161. <if test="updateBy != null">#{updateBy},</if>
  162. <if test="updateTime != null">#{updateTime},</if>
  163. </trim>
  164. </insert>
  165. <!-- 更新兽医个人信息 -->
  166. <update id="updateVetPersonalInfo" parameterType="VetPersonalInfo">
  167. update vet_personal_info
  168. <trim prefix="SET" suffixOverrides=",">
  169. <if test="userId != null">user_id = #{userId},</if>
  170. <if test="realName != null and realName != ''">real_name = #{realName},</if>
  171. <if test="gender != null and gender != ''">gender = #{gender},</if>
  172. <if test="birthday != null">birthday = #{birthday},</if>
  173. <if test="idCard != null and idCard != ''">id_card = #{idCard},</if>
  174. <if test="specialty != null and specialty != ''">specialty = #{specialty},</if>
  175. <if test="workExperience != null and workExperience != ''">work_experience = #{workExperience},</if>
  176. <if test="hospital != null and hospital != ''">hospital = #{hospital},</if>
  177. <if test="address != null and address != ''">address = #{address},</if>
  178. <if test="iphone != null and iphone != ''">iphone = #{iphone},</if>
  179. <if test="introduction != null and introduction != ''">introduction = #{introduction},</if>
  180. <if test="title != null and title != ''">title = #{title},</if>
  181. <if test="phone != null and phone != ''">phone = #{phone},</if>
  182. <if test="expertType != null and expertType != ''">expert_type = #{expertType},</if>
  183. <if test="email != null and email != ''">email = #{email},</if>
  184. <if test="nickName != null and nickName != ''">nick_name = #{nickName},</if>
  185. <if test="avatar != null and avatar != ''">avatar = #{avatar},</if>
  186. <if test="updateBy != null">update_by = #{updateBy},</if>
  187. <if test="updateTime != null">update_time = #{updateTime},</if>
  188. </trim>
  189. where id = #{id}
  190. </update>
  191. <update id="auditVetPersonalInfo" parameterType="VetPersonalInfo">
  192. UPDATE vet_personal_info
  193. <set>
  194. <if test="auditStatus != null">audit_status = #{auditStatus},</if>
  195. <if test="auditor != null">auditor = #{auditor},</if>
  196. <if test="auditTime != null">audit_time = #{auditTime},</if>
  197. <if test="auditDesc != null">audit_desc = #{auditDesc},</if>
  198. update_time = sysdate()
  199. </set>
  200. WHERE id = #{id}
  201. </update>
  202. <!-- 删除操作保持不变 -->
  203. <delete id="deleteVetPersonalInfoById" parameterType="Long">
  204. delete from vet_personal_info where id = #{id}
  205. </delete>
  206. <delete id="deleteVetPersonalInfoByIds" parameterType="String">
  207. delete from vet_personal_info where id in
  208. <foreach item="id" collection="array" open="(" separator="," close=")">
  209. #{id}
  210. </foreach>
  211. </delete>
  212. </mapper>