DoctorTeamMapper.xml 7.16 KB
   1
   2
   3
   4
   5
   6
   7
   8
   9
  10
  11
  12
  13
  14
  15
  16
  17
  18
  19
  20
  21
  22
  23
  24
  25
  26
  27
  28
  29
  30
  31
  32
  33
  34
  35
  36
  37
  38
  39
  40
  41
  42
  43
  44
  45
  46
  47
  48
  49
  50
  51
  52
  53
  54
  55
  56
  57
  58
  59
  60
  61
  62
  63
  64
  65
  66
  67
  68
  69
  70
  71
  72
  73
  74
  75
  76
  77
  78
  79
  80
  81
  82
  83
  84
  85
  86
  87
  88
  89
  90
  91
  92
  93
  94
  95
  96
  97
  98
  99
 100
 101
 102
 103
 104
 105
 106
 107
 108
 109
 110
 111
 112
 113
 114
 115
 116
 117
 118
 119
 120
 121
 122
 123
 124
 125
 126
 127
 128
 129
 130
 131
 132
 133
 134
 135
 136
 137
 138
 139
 140
 141
 142
 143
 144
 145
 146
 147
 148
 149
 150
 151
 152
 153
 154
 155
 156
 157
 158
 159
 160
 161
 162
 163
 164
 165
 166
 167
 168
 169
 170
 171
 172
 173
 174
 175
 176
<?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.lyms.platform.permission.dao.master.DoctorTeamMapper">

<resultMap id="DoctorTeamResultMap" type="com.lyms.platform.permission.model.DoctorTeam">
<id column="id" property="id" jdbcType="INTEGER"/>
<result column="team_name" property="teamName" jdbcType="VARCHAR"/>
<result column="org_id" property="orgId" jdbcType="INTEGER"/>
<result column="orgname" property="orgName" jdbcType="VARCHAR"/>
<result column="created" property="created" jdbcType="TIMESTAMP"/>
</resultMap>

<resultMap id="UsersResultMap" type="com.lyms.platform.permission.model.Users">
<id column="id" property="id" jdbcType="INTEGER"/>
<result column="logincenter_id" property="logincenterId" jdbcType="INTEGER"/>
<result column="type" property="type" jdbcType="INTEGER"/>
<result column="org_id" property="orgId" jdbcType="INTEGER"/>
<result column="dept_id" property="deptId" jdbcType="INTEGER"/>
<result column="ks_id" property="ksId" jdbcType="INTEGER"/>
<result column="name" property="name" jdbcType="VARCHAR"/>
<result column="account" property="account" jdbcType="VARCHAR"/>
<result column="pwd" property="pwd" jdbcType="VARCHAR"/>
<result column="phone" property="phone" jdbcType="VARCHAR"/>
<result column="publish_id" property="publishId" jdbcType="INTEGER"/>
<result column="publish_name" property="publishName" jdbcType="VARCHAR"/>
<result column="yn" property="yn" jdbcType="INTEGER"/>
<result column="enable" property="enable" jdbcType="INTEGER"/>
<result column="modified" property="modified" jdbcType="TIMESTAMP"/>
<result column="created" property="created" jdbcType="TIMESTAMP"/>
<result column="remarks" property="remarks" jdbcType="VARCHAR"/>
<result column="last_login_time" property="lastLoginTime" jdbcType="TIMESTAMP"/>
<result column="foreign_id" property="foreignId" jdbcType="VARCHAR"/>
<result column="employee_id" property="employeeId" jdbcType="VARCHAR"/>
<result column="other_account" property="otherAccount" jdbcType="INTEGER"/>
<result column="zhiChenId" property="zhiChenId" jdbcType="INTEGER"/>
<result column="defaultpage" property="defaultPage" jdbcType="INTEGER"/>
<result column="doctorTeam_id" property="doctorTeamId" jdbcType="INTEGER"/>
<result column="teamname" property="teamName" jdbcType="INTEGER"/>
<result column="orgname" property="orgName" jdbcType="VARCHAR"/>
<result column="deptname" property="deptName" jdbcType="VARCHAR"/>

</resultMap>

<insert id="addDoctorTeam" parameterType="com.lyms.platform.permission.model.DoctorTeam">
insert into doctor_team
(team_name,org_id,created)
values
(#{teamName},#{orgId},#{created})
</insert>


<update id="updateDoctorTeam" parameterType="com.lyms.platform.permission.model.DoctorTeam">
update doctor_team
<set>
<if test="teamName != null and teamName != ''">
team_name = #{teamName,jdbcType=VARCHAR}
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>


<delete id="delDoctorTeam" parameterType="java.lang.Integer">
delete from doctor_team where id = #{id,jdbcType=INTEGER}
</delete>



<sql id="DoctorTeamLimit">
<if test="sort != null and sort != '' ">
order by ${sort}
<if test="need != null and need != ''">
limit #{offset, jdbcType=INTEGER} , #{limit, jdbcType=INTEGER}
</if>
</if>
</sql>


<sql id="DoctorTeamCondition">
<where>
1 = 1
<if test="id != null and id >= 0">
and id = #{id,jdbcType=INTEGER}
</if>

<if test="orgId != null and orgId >= 0">
and org_id = #{orgId,jdbcType=INTEGER}
</if>

<if test="teamName != null and teamName != ''">
and team_name like concat("%",#{teamName,jdbcType=VARCHAR},"%")
</if>
</where>
</sql>


<select id="queryListDoctorTeam" resultMap="DoctorTeamResultMap" parameterType="com.lyms.platform.permission.model.DoctorTeam">
select
d.id,d.team_name,d.org_id,o.name as orgname ,d.created
from doctor_team d left join organization o on d.org_id=o.id
<include refid="DoctorTeamCondition"/>
<include refid="DoctorTeamLimit"/>
</select>

<select id="queryListDoctorTeamCount" resultType="int" parameterType="com.lyms.platform.permission.model.UsersQuery">
select count(DISTINCT id)
from doctor_team
<include refid="DoctorTeamCondition"/>
</select>

<sql id="DoctorLimit">
<if test="sort != null and sort != '' ">
order by ${sort}
<if test="need != null and need != ''">
limit #{offset, jdbcType=INTEGER} , #{limit, jdbcType=INTEGER}
</if>
</if>
</sql>


<sql id="DoctorCondition">
<where>
1 = 1
<if test="id != null and id >= 0">
and u.id = #{id,jdbcType=INTEGER}
</if>

<if test="orgId != null and orgId >= 0">
and u.org_id = #{orgId,jdbcType=INTEGER}
</if>

<if test="name != null and name != ''">
and u.name like concat("%",#{name,jdbcType=VARCHAR},"%")
</if>

<if test="deptId != null and deptId >= 0">
and u.dept_id = #{deptId,jdbcType=INTEGER}
</if>

<if test="doctorTeamId != null and doctorTeamId >= 0">
and u.doctorTeam_id = #{doctorTeamId,jdbcType=INTEGER}
</if>
</where>
</sql>

<select id="queryListDoctor" resultMap="UsersResultMap" parameterType="com.lyms.platform.permission.model.UsersQuery">
select
u.id,u.org_id,u.dept_id,u.name,u.phone,u.created,u.remarks,u.doctorTeam_id,
o.name as orgname,d.team_name as teamname,dp.name as deptname
from users u
left join organization o on u.org_id=o.id
left join doctor_team d on u.doctorTeam_id=d.id
left join departments dp on u.dept_id=dp.id
<include refid="DoctorCondition"/>
<include refid="DoctorLimit"/>
</select>

<select id="queryListDoctorCount" resultType="int" parameterType="com.lyms.platform.permission.model.UsersQuery">
select count(DISTINCT u.id)
from users u
left join organization o on u.org_id=o.id
left join doctor_team d on u.doctorTeam_id=d.id
left join departments dp on u.dept_id=dp.id
<include refid="DoctorCondition"/>
</select>

<update id="allotDoctorTeam" parameterType="com.lyms.platform.permission.model.UsersQuery">
update users
<set>
<if test="doctorTeamId != null and doctorTeamId >=0 ">
doctorTeam_id = #{doctorTeamId,jdbcType=VARCHAR}
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
</mapper>