119 lines
3.4 KiB
XML
119 lines
3.4 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.senmesh.usercenter.user.dao.OrgUserMapper">
|
|
<select id="listOrgUserDTO"
|
|
resultType="com.senmesh.usercenter.user.dto.OrgUserDTO">
|
|
select
|
|
*
|
|
from uc_org_user
|
|
where
|
|
deleted = FALSE
|
|
<if test="param.id != null">
|
|
and id = #{param.id}
|
|
</if>
|
|
<if test="param.userId != null">
|
|
and user_id = #{param.userId}
|
|
</if>
|
|
<if test="param.orgId != null">
|
|
and org_id = #{param.orgId}
|
|
</if>
|
|
<if test="param.administrator != null">
|
|
and administrator = #{param.administrator}
|
|
</if>
|
|
<if test="param.orgName != null and param.orgName != ''">
|
|
and exists (select * from xs_org o where o.id = org_id and org_name = #{param.orgName})
|
|
</if>
|
|
</select>
|
|
|
|
<select id="checkCreateAdministratorUser" resultType="boolean">
|
|
<!-- 不存在机构用户且机构无管理员则校验通过 -->
|
|
select
|
|
CASE WHEN count(*) = 0 THEN 1 ELSE 0 end
|
|
from uc_org_user
|
|
where deleted = FALSE
|
|
and org_id = #{orgId}
|
|
and (user_id = #{userId} or administrator = TRUE)
|
|
</select>
|
|
|
|
<select id="existOrgUser" resultType="boolean">
|
|
select
|
|
CASE WHEN count(*) > 0 THEN 1 ELSE 0 end
|
|
from uc_user u
|
|
where u.type = 1
|
|
and u.deleted = FALSE
|
|
and u.phone = #{phone}
|
|
and exists
|
|
(select *
|
|
from uc_org_user ou
|
|
inner join xs_org o on o.id = ou.org_id
|
|
where ou.user_id = u.id
|
|
and ou.deleted = FALSE
|
|
and o.enable = TRUE
|
|
)
|
|
</select>
|
|
|
|
|
|
<select id="listLoginOrgByUser"
|
|
resultType="com.senmesh.usercenter.user.login.dto.OrgDetailDTO">
|
|
SELECT
|
|
distinct
|
|
t1.id orgId,
|
|
t1.org_name,
|
|
t1.type orgType,
|
|
t2.administrator
|
|
FROM
|
|
xs_org t1
|
|
INNER JOIN uc_org_user t2 ON t1.id = t2.org_id
|
|
AND t2.deleted = FALSE
|
|
INNER JOIN uc_user t3 ON t2.user_id = t3.id
|
|
AND t3.deleted = FALSE
|
|
WHERE
|
|
t1.deleted = FALSE
|
|
and t1.enable = TRUE
|
|
AND t3.id = #{userId}
|
|
<if test="orgId != null">
|
|
and t1.id = #{orgId}
|
|
</if>
|
|
|
|
</select>
|
|
<select id="list" resultType="com.senmesh.usercenter.user.dto.OrgUserInfoDTO">
|
|
SELECT
|
|
ou.org_id,
|
|
ou.user_id,
|
|
ou.administrator,
|
|
u.username,
|
|
u.password,
|
|
u.type,
|
|
u.supeiror,
|
|
u.security_code,
|
|
u.nickname,
|
|
u.avatar,
|
|
u.phone,
|
|
u.phone_binding,
|
|
u.real_name,
|
|
u.card_no,
|
|
u.authenticated,
|
|
u.status,
|
|
u.email,
|
|
u.enabled
|
|
FROM
|
|
uc_user u
|
|
LEFT JOIN uc_org_user ou ON u.id = ou.user_id
|
|
WHERE
|
|
u.deleted = FALSE
|
|
AND ou.deleted = FALSE
|
|
<if test="param.userId != null">
|
|
AND u.id = #{param.userId}
|
|
</if>
|
|
<if test="param.orgId != null">
|
|
and ou.org_id = #{param.orgId}
|
|
</if>
|
|
<if test="param.type != null">
|
|
AND u.type = #{param.type}
|
|
</if>
|
|
</select>
|
|
</mapper>
|