<?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.gk.hotwork.Mapper.UserInfoMapper" >
|
<resultMap id="BaseResultMap" type="com.gk.hotwork.Domain.UserInfo" >
|
<!-- -->
|
<id column="id" property="id" jdbcType="BIGINT" />
|
<result column="username" property="username" jdbcType="VARCHAR" />
|
<result column="password" property="password" jdbcType="VARCHAR" />
|
<result column="email" property="email" jdbcType="VARCHAR" />
|
<result column="company" property="company" jdbcType="VARCHAR" />
|
<result column="department" property="department" jdbcType="VARCHAR" />
|
<result column="job" property="job" jdbcType="VARCHAR" />
|
<result column="createdby" property="createdby" jdbcType="VARCHAR" />
|
<result column="createddate" property="createddate" jdbcType="TIMESTAMP" />
|
<result column="lastmodifiedby" property="lastmodifiedby" jdbcType="VARCHAR" />
|
<result column="lastmodifieddate" property="lastmodifieddate" jdbcType="TIMESTAMP" />
|
<result column="status" property="status" jdbcType="TINYINT" />
|
<result column="expiredate" property="expiredate" jdbcType="TIMESTAMP" />
|
<result column="isdel" property="isdel" jdbcType="TINYINT" />
|
<result column="type" property="type" jdbcType="INTEGER" />
|
<result column="realname" property="realname" jdbcType="VARCHAR" />
|
<result column="idcard" property="idcard" jdbcType="VARCHAR" />
|
<result column="iscompany" property="iscompany" jdbcType="TINYINT" />
|
<result column="isdepartment" property="isdepartment" jdbcType="TINYINT" />
|
<result column="isupload" property="isupload" jdbcType="TINYINT" />
|
<result column="empno" property="empNo" jdbcType="VARCHAR" />
|
<result column="deviceno" property="deviceNo" jdbcType="VARCHAR" />
|
<result column="cardid" property="cardId" jdbcType="BIGINT" />
|
<result column="crossx" property="crossX" jdbcType="DECIMAL" />
|
<result column="crossy" property="crossY" jdbcType="DECIMAL" />
|
<result column="updateat" property="updateat" jdbcType="TIMESTAMP" />
|
<result column="issecurityofficer" property="issecurityofficer" jdbcType="TINYINT" />
|
<result column="departmentname" property="departmentname" jdbcType="VARCHAR" />
|
</resultMap>
|
|
<resultMap id="UserVo" type="com.gk.hotwork.Domain.Vo.UserVo" >
|
<id column="id" property="id" jdbcType="BIGINT" />
|
<result column="username" property="username" jdbcType="VARCHAR" />
|
<result column="password" property="password" jdbcType="VARCHAR" />
|
<result column="email" property="email" jdbcType="VARCHAR" />
|
<result column="company" property="company" jdbcType="VARCHAR" />
|
<result column="companyid" property="companyid" jdbcType="BIGINT" />
|
<result column="department" property="department" jdbcType="VARCHAR" />
|
<result column="job" property="job" jdbcType="VARCHAR" />
|
<result column="createdby" property="createdby" jdbcType="VARCHAR" />
|
<result column="createddate" property="createddate" jdbcType="TIMESTAMP" />
|
<result column="lastmodifiedby" property="lastmodifiedby" jdbcType="VARCHAR" />
|
<result column="lastmodifieddate" property="lastmodifieddate" jdbcType="TIMESTAMP" />
|
<result column="status" property="status" jdbcType="TINYINT" />
|
<result column="expiredate" property="expiredate" jdbcType="TIMESTAMP" />
|
<result column="isdel" property="isdel" jdbcType="TINYINT" />
|
<result column="type" property="type" jdbcType="INTEGER" />
|
<result column="realname" property="realname" jdbcType="VARCHAR" />
|
<result column="idcard" property="idcard" jdbcType="VARCHAR" />
|
<result column="iscompany" property="iscompany" jdbcType="TINYINT" />
|
<result column="isdepartment" property="isdepartment" jdbcType="TINYINT" />
|
<result column="isupload" property="isupload" jdbcType="TINYINT" />
|
<result column="ispass" property="ispass" jdbcType="TINYINT" />
|
<result column="starttime" property="starttime" jdbcType="TIMESTAMP" />
|
<result column="endtime" property="endtime" jdbcType="TIMESTAMP" />
|
<result column="departmentname" property="departmentname" jdbcType="VARCHAR" />
|
<result column="empno" property="empNo" jdbcType="VARCHAR" />
|
<result column="deviceno" property="deviceNo" jdbcType="VARCHAR" />
|
<result column="cardid" property="cardId" jdbcType="BIGINT" />
|
<result column="crossx" property="crossX" jdbcType="DECIMAL" />
|
<result column="crossy" property="crossY" jdbcType="DECIMAL" />
|
<result column="issecurityofficer" property="issecurityofficer" jdbcType="TINYINT" />
|
<result column="updateat" property="updateat" jdbcType="TIMESTAMP" />
|
<result column="executive_level" property="executiveLevel" jdbcType="INTEGER" />
|
<result column="province" property="province" jdbcType="VARCHAR" />
|
<result column="city" property="city" jdbcType="VARCHAR" />
|
<result column="county" property="county" jdbcType="VARCHAR" />
|
<result column="professional_level" property="professionalLevel" jdbcType="INTEGER" />
|
<result column="speciality_id" property="specialityId" jdbcType="BIGINT" />
|
<result column="speciality_name" property="specialityName" jdbcType="VARCHAR" />
|
<association property="companyInfo" javaType="com.gk.hotwork.Domain.CompanyInfo">
|
<result column="company_id" property="id" />
|
<result column="company" property="company" />
|
</association>
|
<association property="specialityInfo" javaType="com.gk.hotwork.Domain.SpecialityInfo">
|
<result column="speciality_id" property="id" />
|
<result column="speciality_name" property="name" />
|
</association>
|
</resultMap>
|
<sql id="Base_Column_List" >
|
<!-- -->
|
id, username, password, email,company, department, job, createdby,
|
createddate, lastmodifiedby, lastmodifieddate,status, expiredate, isdel, type,
|
realname, idcard, iscompany, isdepartment, isupload, empno, deviceno, cardid,issecurityofficer
|
crossx, crossy, updateat
|
</sql>
|
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long" >
|
<!-- -->
|
select
|
<include refid="Base_Column_List" />
|
from user
|
where id = #{id,jdbcType=BIGINT}
|
</select>
|
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long" >
|
<!-- -->
|
delete from user
|
where id = #{id,jdbcType=BIGINT}
|
</delete>
|
<select id="selectUserDataGrid" resultMap="UserVo">
|
SELECT
|
user.id,
|
user.username,
|
user.email,
|
c.company,
|
c.id company_id,
|
user.department,
|
user.job,
|
user.createdby,
|
user.createddate,
|
user.lastmodifiedby,
|
user.lastmodifieddate,
|
user.status,
|
user.expiredate,
|
user.isdel,
|
user.type,
|
user.realname,
|
user.idcard,
|
user.iscompany,
|
user.isdepartment,
|
user.isupload,
|
user.empno,
|
user.deviceno,
|
user.cardid,
|
user.crossx,
|
user.crossy,
|
user.updateat,
|
user.issecurityofficer,
|
d.department departmentname
|
FROM
|
`user` as user
|
left join company as c on c.id = user.companyid
|
left join department as d on d.id = user.department and d.isdel = 0
|
<where>
|
`user`.status = 1
|
and user.type != 1
|
<if test="record.username != null and record.username !=''">
|
and user.username like concat ('%',#{record.username,jdbcType=VARCHAR},'%')
|
</if>
|
<if test="record.realname != null and record.realname !=''">
|
and user.realname like concat ('%',#{record.realname,jdbcType=VARCHAR},'%')
|
</if>
|
<if test="record.company != null and record.company !=''">
|
and c.company like concat ('%',#{record.company,jdbcType=VARCHAR},'%')
|
</if>
|
<if test="record.department != null and record.department !=''">
|
and user.department like concat ('%',#{record.department,jdbcType=VARCHAR},'%')
|
</if>
|
<if test="record.isMain != null ">
|
and c.isMain = #{record.isMain}
|
</if>
|
</where>
|
</select>
|
|
<select id="selectCompanyUserDataList" resultMap="UserVo">
|
SELECT
|
user.id,
|
user.username,
|
user.email,
|
c.company,
|
c.id company_id,
|
user.department,
|
user.job,
|
user.createdby,
|
user.createddate,
|
user.lastmodifiedby,
|
user.lastmodifieddate,
|
user.status,
|
user.expiredate,
|
user.isdel,
|
user.type,
|
user.realname,
|
user.idcard,
|
user.iscompany,
|
user.isdepartment,
|
user.isupload,
|
user.empno,
|
user.deviceno,
|
user.cardid,
|
user.crossx,
|
user.crossy,
|
user.updateat,
|
user.issecurityofficer,
|
user.province,
|
user.city,
|
user.county,
|
user.executive_level
|
FROM
|
`user` as user
|
left join company as c on c.id = user.companyid
|
left join userroles as r on r.userid = `user`.id
|
<where>
|
`user`.status = 1
|
and user.type = 3
|
<if test="record.username != null and record.username !=''">
|
and user.username like concat ('%',#{record.username,jdbcType=VARCHAR},'%')
|
</if>
|
<if test="record.realname != null and record.realname !=''">
|
and user.realname like concat ('%',#{record.realname,jdbcType=VARCHAR},'%')
|
</if>
|
<if test="record.company != null and record.company !=''">
|
and c.company like concat ('%',#{record.company,jdbcType=VARCHAR},'%')
|
</if>
|
<if test="record.job != null and record.job !=''">
|
and user.job like concat ('%',#{record.job,jdbcType=VARCHAR},'%')
|
</if>
|
<if test="record.roleId != null">
|
and r.roleid = #{record.roleId}
|
</if>
|
</where>
|
</select>
|
<select id="selectSuperviseUserDataList" resultMap="UserVo">
|
SELECT
|
user.id,
|
user.username,
|
user.email,
|
user.company,
|
c.id company_id,
|
user.department,
|
user.job,
|
user.createdby,
|
user.createddate,
|
user.lastmodifiedby,
|
user.lastmodifieddate,
|
user.status,
|
user.expiredate,
|
user.isdel,
|
user.type,
|
user.realname,
|
user.idcard,
|
user.iscompany,
|
user.isdepartment,
|
user.isupload,
|
user.empno,
|
user.deviceno,
|
user.cardid,
|
user.crossx,
|
user.crossy,
|
user.updateat,
|
user.issecurityofficer,
|
user.province,
|
user.city,
|
user.county,
|
user.executive_level
|
FROM
|
`user` as user
|
left join company as c on c.id = user.companyid
|
left join userroles as r on r.userid = `user`.id
|
<where>
|
`user`.status = 1
|
and user.type = 2
|
<if test="record.username != null and record.username !=''">
|
and user.username like concat ('%',#{record.username,jdbcType=VARCHAR},'%')
|
</if>
|
<if test="record.realname != null and record.realname !=''">
|
and user.realname like concat ('%',#{record.realname,jdbcType=VARCHAR},'%')
|
</if>
|
<if test="record.company != null and record.company !=''">
|
and user.company like concat ('%',#{record.company,jdbcType=VARCHAR},'%')
|
</if>
|
<if test="record.job != null and record.job !=''">
|
and user.job like concat ('%',#{record.job,jdbcType=VARCHAR},'%')
|
</if>
|
<if test="record.roleId != null">
|
and r.roleid = #{record.roleId}
|
</if>
|
<if test="record.province != null and record.province !=''">
|
and user.province = #{record.province}
|
</if>
|
<if test="record.city != null and record.city !=''">
|
and user.city = #{record.city}
|
</if>
|
<if test="record.county != null and record.county !=''">
|
and user.county = #{record.county}
|
</if>
|
</where>
|
</select>
|
<select id="selectExpertUserDataList" resultMap="UserVo">
|
SELECT
|
user.id,
|
user.username,
|
user.email,
|
user.company,
|
c.id company_id,
|
user.department,
|
user.job,
|
user.createdby,
|
user.createddate,
|
user.lastmodifiedby,
|
user.lastmodifieddate,
|
user.status,
|
user.expiredate,
|
user.isdel,
|
user.type,
|
user.realname,
|
user.idcard,
|
user.iscompany,
|
user.isdepartment,
|
user.isupload,
|
user.empno,
|
user.deviceno,
|
user.cardid,
|
user.crossx,
|
user.crossy,
|
user.updateat,
|
user.issecurityofficer,
|
user.province,
|
user.city,
|
user.county,
|
user.executive_level,
|
user.professional_level,
|
user.speciality_id,
|
s.name as speciality_name
|
FROM
|
`user` as user
|
left join company as c on c.id = user.companyid
|
left join userroles as r on r.userid = `user`.id
|
left join speciality as s on s.id = `user`.speciality_id
|
<where>
|
`user`.status = 1
|
and user.type = 4
|
<if test="record.username != null and record.username !=''">
|
and user.username like concat ('%',#{record.username,jdbcType=VARCHAR},'%')
|
</if>
|
<if test="record.realname != null and record.realname !=''">
|
and user.realname like concat ('%',#{record.realname,jdbcType=VARCHAR},'%')
|
</if>
|
<if test="record.company != null and record.company !=''">
|
and user.company like concat ('%',#{record.company,jdbcType=VARCHAR},'%')
|
</if>
|
<if test="record.job != null and record.job !=''">
|
and user.job like concat ('%',#{record.job,jdbcType=VARCHAR},'%')
|
</if>
|
<if test="record.roleId != null">
|
and r.roleid = #{record.roleId}
|
</if>
|
<if test="record.province != null and record.province !=''">
|
and user.province = #{record.province}
|
</if>
|
<if test="record.city != null and record.city !=''">
|
and user.city = #{record.city}
|
</if>
|
<if test="record.county != null and record.county !=''">
|
and user.county = #{record.county}
|
</if>
|
</where>
|
</select>
|
<select id="selectUserInfo" resultType="com.gk.hotwork.Domain.UserInfo">
|
select user.*,d.department departmentname
|
from user as user
|
left join department as d on d.id = user.department and d.isdel = 0
|
<where>
|
1=1
|
and user.status = 1
|
<if test="id != null">
|
and user.id != #{id}
|
</if>
|
<if test="username != null and username !=''">
|
and user.username = #{username}
|
</if>
|
</where>
|
</select>
|
<select id="selectUserVoByName" resultType="com.gk.hotwork.Domain.Vo.UserVo">
|
select
|
`user`.*,
|
c.ismain AS isMainCompany,
|
d.department departmentname,
|
s.name as speciality_name
|
from `user` as user
|
LEFT JOIN company as c ON c.id = `user`.companyid
|
left join department as d on d.id = user.department and d.isdel = 0
|
left join speciality as s on s.id = `user`.speciality_id
|
where
|
`user`.username = #{username,jdbcType=VARCHAR}
|
and `user`.status = 1
|
</select>
|
<select id="selectByRealName" resultType="com.gk.hotwork.Domain.UserInfo">
|
select user.*,d.department departmentname
|
from user as user
|
left join department as d on d.id = user.department and d.isdel = 0
|
<where>
|
1=1
|
and user.status = 1
|
<if test="id != null">
|
and user.id != #{id}
|
</if>
|
<if test="realname != null and realname !=''">
|
and user.realname = #{realname}
|
</if>
|
</where>
|
</select>
|
|
<select id="getByRealName" resultType="com.gk.hotwork.Domain.UserInfo">
|
select user.*,d.department departmentname
|
from user as user
|
left join department as d on d.id = user.department and d.isdel = 0
|
where user.realname = #{realname}
|
and d.department = #{depName}
|
and user.isdel = 0
|
</select>
|
|
<select id="selectByIdCard" resultType="com.gk.hotwork.Domain.UserInfo">
|
select user.*,d.department departmentname
|
from user as user
|
left join department as d on d.id = user.department and d.isdel = 0
|
<where>
|
1=1
|
and user.status = 1
|
<if test="id != null">
|
and user.id != #{id}
|
</if>
|
<if test="idcard != null and idcard !=''">
|
and user.idcard = #{idcard}
|
</if>
|
</where>
|
</select>
|
<select id="selectNotUpload" resultType="com.gk.hotwork.Domain.UserInfo">
|
select user.*,d.department departmentname
|
from user as user
|
left join department as d on d.id = user.department and d.isdel = 0
|
where
|
user.status = 1
|
and user.isupload = 0
|
and user.type = 3
|
</select>
|
<select id="selectAll" resultType="com.gk.hotwork.Domain.Vo.UserVo">
|
SELECT
|
`user`.*,d.department departmentname
|
FROM
|
`user` as user
|
left join company as c on c.id = user.companyid and c.isdel = 0
|
left join department as d on d.id = user.department and d.isdel = 0
|
<where>
|
`user`.status = 1
|
and user.type != 1
|
<if test="record.company != null and record.company !=''">
|
and c.company like concat ('%',#{record.company,jdbcType=VARCHAR},'%')
|
</if>
|
<if test="record.department != null and record.department !=''">
|
and d.department like concat ('%',#{record.department,jdbcType=VARCHAR},'%')
|
</if>
|
</where>
|
</select>
|
|
<select id="getUserList" resultType="com.gk.hotwork.Domain.Vo.UserVo">
|
SELECT
|
`user`.*,d.department departmentname,u.roleid
|
FROM
|
`user` as user
|
left join department as d on d.id = user.department and d.isdel = 0
|
left join userroles as u on user.id = u.userid
|
where
|
user.status = 1
|
and user.type != 1
|
</select>
|
<select id="selectCountForExam" parameterType="java.util.Map" resultType="java.lang.Integer">
|
select count(0)
|
from user as user
|
left join company as c on c.id = user.companyid and c.isdel = 0
|
left join department as d on d.id = user.department and d.isdel = 0
|
where
|
user.status = 1
|
and user.type != 1
|
<if test="name != null and name != ''">
|
and user.realname like concat("%",#{name},"%")
|
</if>
|
<if test="department != null and department != ''">
|
and d.department like concat("%",#{department},"%")
|
</if>
|
<if test="company != null and company != ''">
|
and c.company like concat("%",#{company},"%")
|
</if>
|
<if test="idno != null and idno != ''">
|
and user.idcard like concat("%",#{idno},"%")
|
</if>
|
<if test="tel != null and tel != ''">
|
and user.username like concat("%",#{tel},"%")
|
</if>
|
</select>
|
<select id="selectPageForExam" parameterType="java.util.Map" resultMap="BaseResultMap">
|
|
select user.*,d.department departmentname
|
from user as user
|
left join company as c on c.id = user.companyid and c.isdel = 0
|
left join department as d on d.id = user.department and d.isdel = 0
|
where
|
status = 1
|
and type != 1
|
<if test="name != null and name != ''">
|
and user.realname like concat("%",#{name},"%")
|
</if>
|
<if test="department != null and department != ''">
|
and d.department like concat("%",#{department},"%")
|
</if>
|
<if test="company != null and company != ''">
|
and c.company like concat("%",#{company},"%")
|
</if>
|
<if test="idno != null and idno != ''">
|
and user.idcard like concat("%",#{idno},"%")
|
</if>
|
<if test="tel != null and tel != ''">
|
and user.username like concat("%",#{tel},"%")
|
</if>
|
order by createddate desc
|
<if test="first != null and pageSize != null">
|
limit #{first},#{pageSize}
|
</if>
|
</select>
|
|
<select id="getAccountByDepartment" resultType="com.gk.hotwork.Domain.Vo.AccountUserVo">
|
select
|
`username`,password
|
from
|
account_user
|
<where>
|
<if test="department != null and department != ''">
|
department = #{department}
|
</if>
|
</where>
|
order by
|
RAND()
|
LIMIT 1
|
</select>
|
|
<!--UserInfo getUserByRealName(String trim);-->
|
<select id="getUserByRealName" resultType="com.gk.hotwork.Domain.UserInfo">
|
select * from user where isdel = 0 and realname = #{trim}
|
limit 1
|
</select>
|
|
<!-- UserInfo getUserByRealNameAndDep(String name, String dep);-->
|
<select id="getUserByRealNameAndDep" resultType="com.gk.hotwork.Domain.UserInfo">
|
select * from user where isdel = 0 and realname = #{name} and department = #{dep}
|
</select>
|
|
|
<select id="getAccountByUsername" resultType="com.gk.hotwork.Domain.Vo.AccountUserVo">
|
select
|
`username`, password
|
from
|
account_user
|
<where>
|
<if test="username != null and username != ''">
|
`username` = #{username}
|
</if>
|
</where>
|
</select>
|
|
<!--UserInfo getByUserId(Long userId);-->
|
<select id="getByUserId" resultMap="BaseResultMap">
|
select * from user where id = #{userId}
|
</select>
|
|
<select id="selectExpertList" resultType="com.gk.hotwork.Domain.UserInfo">
|
select u.id,u.realname
|
from user u
|
left join userroles r on r.userid = u.id
|
where
|
u.status = 1
|
and u.type = 4
|
<if test="realname != null and realname != ''">
|
u.realname like concat("%",#{realname},"%")
|
</if>
|
|
</select>
|
|
<select id="selectUserVoById" resultType="com.gk.hotwork.Domain.Vo.UserVo">
|
select
|
`user`.*,
|
c.ismain AS isMainCompany,
|
d.department departmentname,
|
s.name as speciality_name
|
from `user` as user
|
LEFT JOIN company as c ON c.id = `user`.companyid
|
left join department as d on d.id = user.department and d.isdel = 0
|
left join speciality as s on s.id = `user`.speciality_id
|
where
|
`user`.id = #{userId}
|
and `user`.status = 1
|
</select>
|
|
</mapper>
|