123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273 |
- <?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.zhyc.xps.hos.mapper.DoctorMapper">
- <!-- 通用查询映射结果 -->
- <resultMap id="DoctorResultMap" type="com.zhyc.xps.hos.dto.DoctorDto">
- <result column="oc_id" property="ocId" jdbcType="BIGINT" />
- <result column="doctor_id" property="doctorId" jdbcType="BIGINT" />
- <result column="doctor_name" property="doctorName" jdbcType="VARCHAR" />
- <result column="doctor_code" property="doctorCode" jdbcType="VARCHAR" />
- <result column="doctor_birth" property="doctorBirth" jdbcType="DATE" />
- <result column="doctor_resume" property="doctorResume" jdbcType="VARCHAR" />
- <result column="doctor_avatar" property="doctorAvatar" jdbcType="VARCHAR" />
- <result column="doctor_professional_id" property="doctorProfessionalId" jdbcType="BIGINT" />
- <result column="group_id" property="groupId" jdbcType="BIGINT" />
- <result column="group_name" property="groupName" jdbcType="VARCHAR" />
- <result column="position_id" property="positionId" jdbcType="BIGINT" />
- <result column="position_name" property="positionName" jdbcType="VARCHAR" />
- <result column="doctor_desc" property="doctorDesc" jdbcType="VARCHAR" />
- <result column="checklist_num" property="checklistNum" jdbcType="BIGINT" />
- </resultMap>
- <!-- 通用查询结果列 -->
- <sql id="DoctorDto_Cols">
- A.oc_id,
- A.doctor_id,
- A.doctor_name,
- A.doctor_code,
- A.doctor_birth,
- A.doctor_resume,
- A.doctor_avatar,
- A.doctor_professional_id,
- A.group_id,
- B.group_name,
- A.position_id,
- C.position_name,
- A.doctor_desc,
- IFNULL(E.checklist_num, 0) AS checklist_num
- </sql>
- <!--基于ID查询-->
- <select id="getById" resultMap="DoctorResultMap">
- SELECT
- <include refid="DoctorDto_Cols"/>
- FROM hos_doctor AS A
- LEFT JOIN s_group AS B ON (A.oc_id = B.oc_id AND A.group_id = B.group_id)
- LEFT JOIN s_position AS C ON (A.oc_id = C.oc_id AND A.position_id = C.position_id)
- LEFT JOIN (
- SELECT oc_id, target_id, count(*) AS checklist_num
- FROM checklist_target
- WHERE oc_id = #{ocId ,jdbcType=BIGINT} AND target_type = 3
- GROUP BY target_id
- ) AS E ON (A.oc_id = E.oc_id AND A.doctor_id = E.target_id)
- WHERE A.oc_id = #{ocId ,jdbcType=BIGINT}
- AND A.doctor_id = #{doctorId ,jdbcType=BIGINT}
- </select>
- <!--基于Code查询-->
- <select id="getByCode" resultMap="DoctorResultMap">
- SELECT
- <include refid="DoctorDto_Cols"/>
- FROM hos_doctor AS A
- LEFT JOIN s_group AS B ON (A.oc_id = B.oc_id AND A.group_id = B.group_id)
- LEFT JOIN s_position AS C ON (A.oc_id = C.oc_id AND A.position_id = C.position_id)
- LEFT JOIN (
- SELECT oc_id, target_id, count(*) AS checklist_num
- FROM checklist_target
- WHERE oc_id = #{ocId ,jdbcType=BIGINT} AND target_type = 3
- GROUP BY target_id
- ) AS E ON (A.oc_id = E.oc_id AND A.doctor_id = E.target_id)
- WHERE A.oc_id = #{ocId, jdbcType=BIGINT}
- AND A.doctor_code = #{doctorCode, jdbcType=VARCHAR}
- </select>
- <!--分页查询-->
- <select id="getByPage" parameterType="java.util.Map" resultMap="DoctorResultMap" >
- SELECT
- <include refid="DoctorDto_Cols"/>
- FROM hos_doctor AS A
- LEFT JOIN s_group AS B ON (A.oc_id = B.oc_id AND A.group_id = B.group_id)
- LEFT JOIN s_position AS C ON (A.oc_id = C.oc_id AND A.position_id = C.position_id)
- LEFT JOIN (
- SELECT oc_id, target_id, count(*) AS checklist_num
- FROM checklist_target
- WHERE oc_id = #{ocId ,jdbcType=BIGINT} AND target_type = 3
- GROUP BY target_id
- ) AS E ON (A.oc_id = E.oc_id AND A.doctor_id = E.target_id)
- WHERE A.deleted_flag = 0 AND A.oc_id = #{ocId ,jdbcType=BIGINT}
- <if test="keywords != null and keywords != ''">
- AND A.doctor_name like "%"#{keywords}"%"
- </if>
- ORDER BY A.oc_id, A.doctor_id
- </select>
- <!--列表查询-->
- <select id="getByList" parameterType="java.util.Map" resultMap="DoctorResultMap">
- SELECT
- <include refid="DoctorDto_Cols"/>
- FROM hos_doctor AS A
- LEFT JOIN s_group AS B ON (A.oc_id = B.oc_id AND A.group_id = B.group_id)
- LEFT JOIN s_position AS C ON (A.oc_id = C.oc_id AND A.position_id = C.position_id)
- LEFT JOIN (
- SELECT oc_id, target_id, count(*) AS checklist_num
- FROM checklist_target
- WHERE oc_id = #{ocId ,jdbcType=BIGINT} AND target_type = 3
- GROUP BY target_id
- ) AS E ON (A.oc_id = E.oc_id AND A.doctor_id = E.target_id)
- WHERE A.deleted_flag = 0 AND A.oc_id = #{ocId ,jdbcType=BIGINT}
- <if test="keywords != null and keywords != ''">
- AND A.doctor_name like "%"#{keywords}"%"
- </if>
- ORDER BY A.oc_id, A.doctor_id
- </select>
- <insert id="create" parameterType="com.zhyc.xps.hos.entity.Doctor">
- INSERT INTO hos_doctor
- <trim prefix="(" suffix=")" suffixOverrides=",">
- <if test="ocId != null">
- oc_id,
- </if>
- <if test="doctorId != null">
- doctor_id,
- </if>
- <if test="doctorName != null and doctorName != ''">
- doctor_name,
- </if>
- <if test="doctorCode != null and doctorCode != ''">
- doctor_code,
- </if>
- <if test="doctorBirth != null">
- doctor_birth,
- </if>
- <if test="doctorResume != null and doctorResume != ''">
- doctor_resume,
- </if>
- <if test="doctorAvatar != null and doctorAvatar != ''">
- doctor_avatar,
- </if>
- <if test="doctorProfessionalId != null">
- doctor_professional_id,
- </if>
- <if test="groupId != null">
- group_id,
- </if>
- <if test="positionId != null">
- position_id,
- </if>
- <if test="doctorDesc != null and doctorDesc != ''">
- doctor_desc,
- </if>
- <if test="createdBy != null">
- created_by,
- </if>
- <if test="createdAt != null">
- created_at,
- </if>
- </trim>
- <trim prefix="values (" suffix=")" suffixOverrides=",">
- <if test="ocId != null">
- #{ocId,jdbcType=BIGINT},
- </if>
- <if test="doctorId != null">
- #{doctorId ,jdbcType=BIGINT},
- </if>
- <if test="doctorName != null and doctorName != ''">
- #{doctorName ,jdbcType=VARCHAR},
- </if>
- <if test="doctorCode != null and doctorCode != ''">
- #{doctorCode ,jdbcType=VARCHAR},
- </if>
- <if test="doctorBirth != null">
- #{doctorBirth ,jdbcType=DATE},
- </if>
- <if test="doctorResume != null and doctorResume != ''">
- #{doctorResume ,jdbcType=VARCHAR},
- </if>
- <if test="doctorAvatar != null and doctorAvatar != ''">
- #{doctorAvatar ,jdbcType=VARCHAR},
- </if>
- <if test="doctorProfessionalId != null">
- #{doctorProfessionalId ,jdbcType=BIGINT},
- </if>
- <if test="groupId != null">
- #{groupId ,jdbcType=BIGINT},
- </if>
- <if test="positionId != null">
- #{positionId ,jdbcType=BIGINT},
- </if>
- <if test="doctorDesc != null and doctorDesc != ''">
- #{doctorDesc ,jdbcType=VARCHAR},
- </if>
- <if test="createdBy != null">
- #{createdBy ,jdbcType=BIGINT},
- </if>
- <if test="createdAt != null">
- #{createdAt ,jdbcType=TIMESTAMP},
- </if>
- </trim>
- </insert>
- <!--更新-->
- <update id="update" parameterType="com.zhyc.xps.hos.entity.Doctor">
- UPDATE hos_doctor
- <trim suffixOverrides=",">
- <set>
- <if test="doctorName != null and doctorName != ''">
- doctor_name = #{doctorName, jdbcType=VARCHAR},
- </if>
- <if test="doctorCode != null and doctorCode != ''">
- doctor_code = #{doctorCode ,jdbcType=VARCHAR},
- </if>
- <if test="doctorBirth != null and doctorBirth != ''">
- doctor_birth = #{doctorBirth ,jdbcType=VARCHAR},
- </if>
- <if test="doctorResume != null and doctorResume != ''">
- doctor_resume = #{doctorResume ,jdbcType=VARCHAR},
- </if>
- <if test="doctorAvatar != null and doctorAvatar != ''">
- doctor_avatar = #{doctorAvatar ,jdbcType=VARCHAR},
- </if>
- <if test="doctorProfessionalId != null">
- doctor_professional_id = #{doctorProfessionalId ,jdbcType=BIGINT},
- </if>
- <if test="groupId != null">
- group_id = #{groupId ,jdbcType=BIGINT},
- </if>
- <if test="positionId != null">
- position_id = #{positionId ,jdbcType=BIGINT},
- </if>
- <if test="doctorDesc != null and doctorDesc != ''">
- doctor_desc = #{doctorDesc, jdbcType=VARCHAR},
- </if>
- <if test="updatedBy != null ">
- updated_by = #{updatedBy ,jdbcType=BIGINT},
- </if>
- <if test="updatedAt != null">
- updated_at = #{updatedAt ,jdbcType=TIMESTAMP},
- </if>
- </set>
- </trim>
- WHERE oc_id = #{ocId ,jdbcType=BIGINT}
- AND doctor_id = #{doctorId ,jdbcType=BIGINT}
- </update>
- <!--删除-->
- <update id="delete" parameterType="java.util.Map">
- UPDATE hos_doctor
- <trim suffixOverrides=",">
- <set>
- <if test="deletedFlag != null">
- deleted_flag = #{deletedFlag,jdbcType=BIGINT},
- </if>
- <if test="deletedTime != null">
- deleted_time = #{deletedTime,jdbcType=TIMESTAMP},
- </if>
- <if test="deletedBy != null">
- deleted_by = #{deletedBy,jdbcType=BIGINT},
- </if>
- </set>
- </trim>
- WHERE 1 = 1
- <if test="ocId != null">
- AND oc_id = #{ocId,jdbcType=BIGINT}
- </if>
- <if test="doctorId != null">
- AND doctor_id = #{doctorId ,jdbcType=BIGINT}
- </if>
- </update>
- </mapper>
|