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
226 lines
12 KiB
<?xml version="1.0" encoding="UTF-8" ?>
|
|
<!DOCTYPE mapper
|
|
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
<mapper namespace="com.chenhai.vet.mapper.VetPersonalInfoMapper">
|
|
|
|
<resultMap type="VetPersonalInfo" id="VetPersonalInfoResult">
|
|
<!-- 基础字段映射 -->
|
|
<result property="id" column="id"/>
|
|
<result property="userId" column="user_id"/>
|
|
<result property="realName" column="real_name"/>
|
|
<result property="gender" column="gender"/>
|
|
<result property="birthday" column="birthday"/>
|
|
<result property="idCard" column="id_card"/>
|
|
<result property="specialty" column="specialty"/>
|
|
<result property="workExperience" column="work_experience"/>
|
|
<result property="hospital" column="hospital"/>
|
|
<result property="address" column="address"/>
|
|
<result property="iphone" column="iphone"/>
|
|
<result property="introduction" column="introduction"/>
|
|
<result property="title" column="title"/>
|
|
<result property="phone" column="phone"/>
|
|
<result property="expertType" column="expert_type"/>
|
|
<result property="email" column="email"/>
|
|
<result property="nickName" column="nick_name"/>
|
|
<result property="avatar" column="avatar"/>
|
|
<result property="createBy" column="create_by"/>
|
|
<result property="createTime" column="create_time"/>
|
|
<result property="updateBy" column="update_by"/>
|
|
<result property="updateTime" column="update_time"/>
|
|
<result property="auditStatus" column="audit_status"/>
|
|
<result property="auditTime" column="audit_time"/>
|
|
<result property="auditor" column="auditor"/>
|
|
<result property="auditDesc" column="audit_desc"/>
|
|
|
|
<!-- 关联 SysUser 对象 -->
|
|
<association property="user" javaType="SysUser">
|
|
<result property="userId" column="u_user_id"/>
|
|
<result property="nickName" column="u_nick_name"/>
|
|
<result property="email" column="u_email"/>
|
|
<result property="avatar" column="u_avatar"/>
|
|
</association>
|
|
</resultMap>
|
|
|
|
<!-- 基础查询SQL -->
|
|
<sql id="selectVetPersonalInfoVo">
|
|
select id, user_id, real_name, gender, birthday, id_card, specialty, work_experience,
|
|
hospital, address, iphone, introduction, title, phone,
|
|
expert_type, email, nick_name, create_by, create_time, update_by, update_time
|
|
from vet_personal_info
|
|
</sql>
|
|
|
|
<!-- 带用户信息的查询SQL(简化版) -->
|
|
<sql id="selectVetPersonalInfoWithUserVo">
|
|
select
|
|
v.id, v.user_id, v.real_name, v.gender, v.birthday, v.id_card, v.specialty, v.work_experience,
|
|
v.hospital, v.address, v.iphone, v.introduction, v.title, v.phone,
|
|
v.expert_type, v.email, v.nick_name, v.create_by, v.create_time, v.update_by, v.update_time,
|
|
v.audit_status, v.audit_time, v.auditor, v.audit_desc,
|
|
u.user_id as u_user_id,
|
|
u.nick_name as u_nick_name,
|
|
u.avatar as u_avatar,
|
|
u.email as u_email
|
|
from vet_personal_info v
|
|
left join sys_user u on v.user_id = u.user_id
|
|
</sql>
|
|
|
|
|
|
<!-- 列表查询(带用户信息) -->
|
|
<select id="selectVetPersonalInfoList" parameterType="VetPersonalInfo" resultMap="VetPersonalInfoResult">
|
|
<include refid="selectVetPersonalInfoWithUserVo"/>
|
|
<where>
|
|
<!-- 兽医表条件 -->
|
|
<if test="id != null "> and v.id = #{id}</if>
|
|
<if test="userId != null "> and v.user_id = #{userId}</if>
|
|
<if test="realName != null and realName != ''"> and v.real_name like concat('%', #{realName}, '%')</if>
|
|
<if test="gender != null and gender != ''"> and v.gender = #{gender}</if>
|
|
<if test="idCard != null and idCard != ''"> and v.id_card = #{idCard}</if>
|
|
<if test="specialty != null and specialty != ''"> and v.specialty like concat('%', #{specialty}, '%')</if>
|
|
<if test="hospital != null and hospital != ''"> and v.hospital like concat('%', #{hospital}, '%')</if>
|
|
<if test="phone != null and phone != ''"> and v.phone like concat('%', #{phone}, '%')</if>
|
|
<if test="iphone != null and iphone != ''"> and v.iphone like concat('%', #{iphone}, '%')</if>
|
|
<if test="expertType != null and expertType != ''"> and v.expert_type = #{expertType}</if>
|
|
<if test="email != null and email != ''"> and v.email = #{email}</if>
|
|
<if test="specialty != null and specialty != ''"> and v.specialty like concat('%', #{specialty}, '%')</if>
|
|
<!-- 添加审核状态条件 -->
|
|
<if test="auditStatus != null and auditStatus != ''">
|
|
and v.audit_status = #{auditStatus}
|
|
</if>
|
|
|
|
<!-- 用户表条件 -->
|
|
<if test="user != null">
|
|
<if test="user.userName != null and user.userName != ''">
|
|
and u.user_name like concat('%', #{user.userName}, '%')
|
|
</if>
|
|
<if test="user.nickName != null and user.nickName != ''">
|
|
and u.nick_name like concat('%', #{user.nickName}, '%')
|
|
</if>
|
|
<if test="user.userType != null and user.userType != ''">
|
|
and u.user_type = #{user.userType}
|
|
</if>
|
|
<if test="user.status != null and user.status != ''">
|
|
and u.status = #{user.status}
|
|
</if>
|
|
<if test="user.deptId != null">
|
|
and u.dept_id = #{user.deptId}
|
|
</if>
|
|
</if>
|
|
</where>
|
|
order by v.create_time desc
|
|
</select>
|
|
|
|
<!-- 根据ID查询(带用户信息) -->
|
|
<select id="selectVetPersonalInfoById" parameterType="Long" resultMap="VetPersonalInfoResult">
|
|
<include refid="selectVetPersonalInfoWithUserVo"/>
|
|
where v.id = #{id}
|
|
</select>
|
|
|
|
<!-- 根据用户ID查询 -->
|
|
<select id="selectVetPersonalInfoByUserId" parameterType="Long" resultMap="VetPersonalInfoResult">
|
|
<include refid="selectVetPersonalInfoWithUserVo"/>
|
|
where v.user_id = #{userId}
|
|
</select>
|
|
|
|
<!-- 新增兽医个人信息 -->
|
|
<insert id="insertVetPersonalInfo" parameterType="VetPersonalInfo" useGeneratedKeys="true" keyProperty="id">
|
|
insert into vet_personal_info
|
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
|
<if test="userId != null">user_id,</if>
|
|
<if test="realName != null and realName != ''">real_name,</if>
|
|
<if test="gender != null and gender != ''">gender,</if>
|
|
<if test="birthday != null">birthday,</if>
|
|
<if test="idCard != null and idCard != ''">id_card,</if>
|
|
<if test="specialty != null and specialty != ''">specialty,</if>
|
|
<if test="workExperience != null and workExperience != ''">work_experience,</if>
|
|
<if test="hospital != null and hospital != ''">hospital,</if>
|
|
<if test="address != null and address != ''">address,</if>
|
|
<if test="iphone != null and iphone != ''">iphone,</if>
|
|
<if test="introduction != null and introduction != ''">introduction,</if>
|
|
<if test="title != null and title != ''">title,</if>
|
|
<if test="phone != null and phone != ''">phone,</if>
|
|
<if test="expertType != null and expertType != ''">expert_type,</if>
|
|
<if test="email != null and email != ''">email,</if>
|
|
<if test="nickName != null and nickName != ''">nick_name,</if>
|
|
<if test="avatar != null and avatar != ''">avatar,</if>
|
|
<if test="createBy != null">create_by,</if>
|
|
<if test="createTime != null">create_time,</if>
|
|
<if test="updateBy != null">update_by,</if>
|
|
<if test="updateTime != null">update_time,</if>
|
|
</trim>
|
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
|
<if test="userId != null">#{userId},</if>
|
|
<if test="realName != null and realName != ''">#{realName},</if>
|
|
<if test="gender != null and gender != ''">#{gender},</if>
|
|
<if test="birthday != null">#{birthday},</if>
|
|
<if test="idCard != null and idCard != ''">#{idCard},</if>
|
|
<if test="specialty != null and specialty != ''">#{specialty},</if>
|
|
<if test="workExperience != null and workExperience != ''">#{workExperience},</if>
|
|
<if test="hospital != null and hospital != ''">#{hospital},</if>
|
|
<if test="address != null and address != ''">#{address},</if>
|
|
<if test="iphone != null and iphone != ''">#{iphone},</if>
|
|
<if test="introduction != null and introduction != ''">#{introduction},</if>
|
|
<if test="title != null and title != ''">#{title},</if>
|
|
<if test="phone != null and phone != ''">#{phone},</if>
|
|
<if test="expertType != null and expertType != ''">#{expertType},</if>
|
|
<if test="email != null and email != ''">#{email},</if>
|
|
<if test="nickName != null and nickName != ''">#{nickName},</if>
|
|
<if test="avatar != null and avatar != ''">#{avatar},</if>
|
|
<if test="createBy != null">#{createBy},</if>
|
|
<if test="createTime != null">#{createTime},</if>
|
|
<if test="updateBy != null">#{updateBy},</if>
|
|
<if test="updateTime != null">#{updateTime},</if>
|
|
</trim>
|
|
</insert>
|
|
|
|
<!-- 更新兽医个人信息 -->
|
|
<update id="updateVetPersonalInfo" parameterType="VetPersonalInfo">
|
|
update vet_personal_info
|
|
<trim prefix="SET" suffixOverrides=",">
|
|
<if test="userId != null">user_id = #{userId},</if>
|
|
<if test="realName != null and realName != ''">real_name = #{realName},</if>
|
|
<if test="gender != null and gender != ''">gender = #{gender},</if>
|
|
<if test="birthday != null">birthday = #{birthday},</if>
|
|
<if test="idCard != null and idCard != ''">id_card = #{idCard},</if>
|
|
<if test="specialty != null and specialty != ''">specialty = #{specialty},</if>
|
|
<if test="workExperience != null and workExperience != ''">work_experience = #{workExperience},</if>
|
|
<if test="hospital != null and hospital != ''">hospital = #{hospital},</if>
|
|
<if test="address != null and address != ''">address = #{address},</if>
|
|
<if test="iphone != null and iphone != ''">iphone = #{iphone},</if>
|
|
<if test="introduction != null and introduction != ''">introduction = #{introduction},</if>
|
|
<if test="title != null and title != ''">title = #{title},</if>
|
|
<if test="phone != null and phone != ''">phone = #{phone},</if>
|
|
<if test="expertType != null and expertType != ''">expert_type = #{expertType},</if>
|
|
<if test="email != null and email != ''">email = #{email},</if>
|
|
<if test="nickName != null and nickName != ''">nick_name = #{nickName},</if>
|
|
<if test="avatar != null and avatar != ''">avatar = #{avatar},</if>
|
|
<if test="updateBy != null">update_by = #{updateBy},</if>
|
|
<if test="updateTime != null">update_time = #{updateTime},</if>
|
|
</trim>
|
|
where id = #{id}
|
|
</update>
|
|
|
|
<update id="auditVetPersonalInfo" parameterType="VetPersonalInfo">
|
|
UPDATE vet_personal_info
|
|
<set>
|
|
<if test="auditStatus != null">audit_status = #{auditStatus},</if>
|
|
<if test="auditor != null">auditor = #{auditor},</if>
|
|
<if test="auditTime != null">audit_time = #{auditTime},</if>
|
|
<if test="auditDesc != null">audit_desc = #{auditDesc},</if>
|
|
update_time = sysdate()
|
|
</set>
|
|
WHERE id = #{id}
|
|
</update>
|
|
|
|
<!-- 删除操作保持不变 -->
|
|
<delete id="deleteVetPersonalInfoById" parameterType="Long">
|
|
delete from vet_personal_info where id = #{id}
|
|
</delete>
|
|
|
|
<delete id="deleteVetPersonalInfoByIds" parameterType="String">
|
|
delete from vet_personal_info where id in
|
|
<foreach item="id" collection="array" open="(" separator="," close=")">
|
|
#{id}
|
|
</foreach>
|
|
</delete>
|
|
</mapper>
|