290 lines
9.1 KiB
XML
290 lines
9.1 KiB
XML
<?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.bonus.gzrn.rnbmw.manager.dao.UserDao">
|
|
|
|
<sql id="where">
|
|
<where>
|
|
<if test="params.userName != null and params.userName != ''">
|
|
and t.USERNAME like concat('%', #{params.userName}, '%')
|
|
</if>
|
|
<if test="params.status != null and params.status != ''">
|
|
and t.status = #{params.status}
|
|
</if>
|
|
</where>
|
|
</sql>
|
|
|
|
<select id="count" resultType="int">
|
|
select count(1) from sys_user su
|
|
LEFT JOIN sys_role_user sru on sru.userId = su.id
|
|
LEFT JOIN sys_role sr on sr.id = sru.roleId
|
|
LEFT JOIN pm_organization po on po.ID = su.POST_ID and po.TYPE = 3
|
|
LEFT JOIN pm_organization pmo on pmo.ID = su.ORG_ID
|
|
left join pm_company pc on pc.ID = pmo.COMPANY_ID
|
|
left join bm_project bmp on bmp.ID = su.PRO_ID
|
|
left join bm_subcontractor bs on bs.ID = su.SUB_ID
|
|
WHERE
|
|
su.IS_ACTIVE = 1 AND pc.examine_status = 1
|
|
<if test="params.userName != null and params.userName != ''">
|
|
and su.USERNAME like concat('%', #{params.userName}, '%')
|
|
</if>
|
|
<if test="params.companyId != null and params.companyId != ''">
|
|
and pc.ID = #{params.companyId}
|
|
</if>
|
|
<if test="params.proId != null and params.proId != ''">
|
|
and su.PRO_ID = #{params.proId}
|
|
</if>
|
|
<if test="params.phone != null and params.phone != ''">
|
|
and su.PHONE like concat('%', #{params.phone}, '%')
|
|
</if>
|
|
|
|
<if test="params.keyWord != null and params.keyWord != ''">
|
|
and (
|
|
(pc.org_name like concat('%',#{params.keyWord},'%') or
|
|
bmp.name like concat('%',#{params.keyWord},'%') or
|
|
su.USERNAME like concat('%',#{params.keyWord},'%') or
|
|
su.PHONE like concat('%',#{params.keyWord},'%') or
|
|
po.NAME like concat('%',#{params.keyWord},'%') or
|
|
sr.name like concat('%',#{params.keyWord},'%'))
|
|
)
|
|
</if>
|
|
</select>
|
|
|
|
<select id="list" resultType="com.bonus.gzrn.rnbmw.manager.model.SysUser">
|
|
SELECT
|
|
su.ID ,
|
|
su.USERNAME ,
|
|
su.ORG_ID as orgId,
|
|
su.PRO_ID as proId,
|
|
su.POST_ID as postId,
|
|
su.ROLE_ID as roleId,
|
|
su.SUB_ID as subId,
|
|
su.PHONE ,
|
|
su.SEX ,
|
|
su.face_photo ,
|
|
su.create_type ,
|
|
su.examine_status as examineStatus,
|
|
su.examine_remark ,
|
|
CONCAT(case when sr.TYPE like '%1%' then '大屏 ' else '' end,case when sr.TYPE like '%2%' then ' 后台' else '' end,case when sr.TYPE like '%3%' then ' 施工' else '' end,case when sr.TYPE like '%4%' then '监督' else '' end) as type,
|
|
su.status ,
|
|
su.IS_ACTIVE as isActive,
|
|
su.createTime as createTime,
|
|
su.LOGINNAME as loginName,
|
|
sr.name as roleName,
|
|
po.NAME as postType,
|
|
bmp.name as proName,
|
|
bmp.status proStatus,
|
|
bs.SUB_NAME as subName,
|
|
pc.org_name companyName
|
|
FROM
|
|
sys_user su
|
|
LEFT JOIN sys_role_user sru on sru.userId = su.id
|
|
LEFT JOIN sys_role sr on sr.id = sru.roleId
|
|
LEFT JOIN pm_organization po on po.ID = su.POST_ID and po.TYPE = 3
|
|
LEFT JOIN pm_organization pmo on pmo.ID = su.ORG_ID
|
|
left join pm_company pc on pc.ID = pmo.COMPANY_ID
|
|
left join bm_project bmp on bmp.ID = su.PRO_ID
|
|
left join bm_subcontractor bs on bs.ID = su.SUB_ID
|
|
WHERE
|
|
su.IS_ACTIVE = 1 AND pc.examine_status = 1
|
|
<if test="params.userName != null and params.userName != ''">
|
|
and su.USERNAME like concat('%', #{params.userName}, '%')
|
|
</if>
|
|
<if test="params.companyId != null and params.companyId != ''">
|
|
and pc.ID = #{params.companyId}
|
|
</if>
|
|
<if test="params.proId != null and params.proId != ''">
|
|
and su.PRO_ID = #{params.proId}
|
|
</if>
|
|
<if test="params.phone != null and params.phone != ''">
|
|
and su.PHONE like concat('%', #{params.phone}, '%')
|
|
</if>
|
|
|
|
<if test="params.keyWord != null and params.keyWord != ''">
|
|
and (
|
|
(pc.org_name like concat('%',#{params.keyWord},'%') or
|
|
bmp.name like concat('%',#{params.keyWord},'%') or
|
|
su.USERNAME like concat('%',#{params.keyWord},'%') or
|
|
su.PHONE like concat('%',#{params.keyWord},'%') or
|
|
po.NAME like concat('%',#{params.keyWord},'%') or
|
|
sr.name like concat('%',#{params.keyWord},'%'))
|
|
)
|
|
</if>
|
|
GROUP BY su.id
|
|
limit #{offset}, #{limit}
|
|
</select>
|
|
|
|
<insert id="saveUserRoles">
|
|
insert into sys_role_user(roleId, userId) values
|
|
(#{roleId}, #{userId})
|
|
</insert>
|
|
|
|
<insert id="save" useGeneratedKeys="true" keyProperty = "id">
|
|
insert into sys_user(USERNAME, PHONE, TYPE,PASSWORD ,ROLE_ID, ORG_ID, POST_ID, create_type, sex, status, createTime, updateTime,examine_status
|
|
<if test="proId != null and proId != ''">
|
|
,PRO_ID
|
|
</if>
|
|
<if test="subId != null and subId != ''">
|
|
,SUB_ID
|
|
</if>
|
|
|
|
)
|
|
values(#{userName}, #{phone}, #{type},#{password}, #{roleId}, #{orgId}, #{orgId}, '2', #{sex}, #{status}, now(), now(),'1'
|
|
<if test="proId != null and proId != ''">
|
|
, #{proId}
|
|
</if>
|
|
<if test="subId != null and subId != ''">
|
|
,#{subId}
|
|
</if>
|
|
)
|
|
</insert>
|
|
|
|
<update id="updateExamineStatus">
|
|
update sys_user t
|
|
<set>
|
|
<if test="userName != null">
|
|
USERNAME = #{userName},
|
|
</if>
|
|
<if test="type != null and type != ''">
|
|
TYPE = #{type},
|
|
</if>
|
|
<if test="nickname != null and nickname != ''">
|
|
LOGINNAME = #{nickname},
|
|
</if>
|
|
<if test="phone != null and phone != ''">
|
|
PHONE = #{phone},
|
|
</if>
|
|
<if test="roleId != null and roleId != ''">
|
|
ROLE_ID = #{roleId},
|
|
</if>
|
|
<if test="subId != null and subId != ''">
|
|
SUB_ID = #{subId},
|
|
</if>
|
|
<if test="postId != null and postId != ''">
|
|
POST_ID = #{orgId},
|
|
</if>
|
|
<if test="orgId != null and orgId != ''">
|
|
ORG_ID = #{orgId},
|
|
</if>
|
|
<if test="proId != null and proId != ''">
|
|
PRO_ID = #{proId},
|
|
</if>
|
|
<if test="sex != null and sex != ''">
|
|
SEX = #{sex},
|
|
</if>
|
|
<if test="examineStatus != null and examineStatus != ''">
|
|
t.examine_status = #{examineStatus},
|
|
</if>
|
|
<if test="examineRemark != null and examineRemark != ''">
|
|
t.examine_remark = #{examineRemark},
|
|
</if>
|
|
updateTime = #{updateTime}
|
|
</set>
|
|
where t.id = #{userId}
|
|
</update>
|
|
|
|
<update id="update">
|
|
update sys_user t
|
|
<set>
|
|
<if test="userName != null">
|
|
USERNAME = #{userName},
|
|
</if>
|
|
<if test="type != null and type != ''">
|
|
TYPE = #{type},
|
|
</if>
|
|
<if test="nickname != null and nickname != ''">
|
|
LOGINNAME = #{nickname},
|
|
</if>
|
|
<if test="phone != null and phone != ''">
|
|
PHONE = #{phone},
|
|
</if>
|
|
<if test="roleId != null and roleId != ''">
|
|
ROLE_ID = #{roleId},
|
|
</if>
|
|
<if test="subId != null and subId != ''">
|
|
SUB_ID = #{subId},
|
|
</if>
|
|
<if test="orgId != null and orgId != ''">
|
|
POST_ID = #{orgId},
|
|
</if>
|
|
<if test="orgId != null and orgId != ''">
|
|
ORG_ID = #{orgId},
|
|
</if>
|
|
<if test="proId != null and proId != ''">
|
|
PRO_ID = #{proId},
|
|
</if>
|
|
<if test="sex != null and sex != ''">
|
|
SEX = #{sex},
|
|
</if>
|
|
updateTime = #{updateTime}
|
|
</set>
|
|
where t.id = #{id}
|
|
</update>
|
|
|
|
<select id="getProInfo" resultType="com.bonus.gzrn.rnbmw.manager.model.SysUser">
|
|
SELECT bp.id AS proId,bp.name AS proName FROM bm_project bp
|
|
WHERE bp.is_active = '1'
|
|
<if test="companyId != null and companyId != ''">
|
|
and bp.company_id = #{companyId}
|
|
</if>
|
|
<if test="orgId != null and orgId != ''">
|
|
and bp.org_id = #{orgId}
|
|
</if>
|
|
</select>
|
|
|
|
<!-- 获取公司conpanyId-->
|
|
<select id="getCompanyId" resultType="java.lang.String">
|
|
select COMPANY_ID as companyId from pm_organization where ID = #{orgId} and IS_ACTIVE = '1'
|
|
</select>
|
|
|
|
<select id="getSubInfo" resultType="com.bonus.gzrn.rnbmw.manager.model.SysUser">
|
|
SELECT
|
|
bs.ID AS subId,
|
|
bs.SUB_NAME AS subName
|
|
FROM bm_sub_pro_relation bspr
|
|
LEFT JOIN bm_subcontractor bs on bs.ID = bspr.sub_id
|
|
WHERE bspr.pro_id = #{proId} and bs.IS_ACTIVE = 1
|
|
GROUP BY bs.ID
|
|
</select>
|
|
|
|
<select id="getPostInfo" resultType="com.bonus.gzrn.rnbmw.manager.model.SysUser">
|
|
SELECT po.id AS postId,po.NAME AS postType
|
|
FROM pm_organization po
|
|
WHERE po.is_active = '1' and po.type = '3'
|
|
<if test="companyId != null and companyId != ''">
|
|
and po.COMPANY_ID = #{companyId}
|
|
</if>
|
|
</select>
|
|
<select id="getRoleInfo" resultType="com.bonus.gzrn.rnbmw.manager.model.SysUser">
|
|
SELECT sr.id AS roleId,sr.name AS roleName
|
|
FROM sys_role sr
|
|
WHERE sr.is_active = '1'
|
|
<if test="companyId != null and companyId != ''">
|
|
and sr.company_id = #{companyId}
|
|
</if>
|
|
</select>
|
|
|
|
<!--<select id="getRoleInfo" resultType="com.bonus.gzrn.rnbmw.manager.model.SysUser">
|
|
SELECT sr.id AS roleId,sr.name AS roleName
|
|
FROM sys_role sr
|
|
WHERE is_active = '1' and sr.company_id = #{companyId}
|
|
</select>-->
|
|
|
|
|
|
<select id="getById" resultType="com.bonus.gzrn.rnbmw.manager.model.SysUser">
|
|
select
|
|
t.ID ,t.USERNAME ,t.PHONE ,
|
|
sr.TYPE ,t.ROLE_ID ,t.ORG_ID ,
|
|
t.PRO_ID ,t.POST_ID as postId ,t.SUB_ID ,
|
|
t.SEX ,pc.ID companyId,pc.org_name companyName,
|
|
sr.name roleName,po.NAME orgName,
|
|
t.LOGINNAME as loginName
|
|
from sys_user t
|
|
left join bm_project bp on bp.ID = t.PRO_ID
|
|
left join pm_organization po on po.ID = t.ORG_ID
|
|
left join pm_company pc on pc.ID = po.company_id
|
|
LEFT JOIN sys_role_user sru on sru.userId = t.id
|
|
LEFT JOIN sys_role sr on sr.id = sru.roleId
|
|
where t.id = #{id}
|
|
</select>
|
|
</mapper> |