123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540 |
- <?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.diagbot.mapper.UserMapper">
- <!-- 通用查询映射结果 -->
- <resultMap id="BaseResultMap" type="com.diagbot.entity.User">
- <id column="id" property="id"/>
- <result column="is_deleted" property="isDeleted"/>
- <result column="gmt_create" property="gmtCreate"/>
- <result column="gmt_modified" property="gmtModified"/>
- <result column="creator" property="creator"/>
- <result column="modifier" property="modifier"/>
- <result column="password" property="password"/>
- <result column="username" property="username"/>
- <result column="dept" property="dept"/>
- <result column="position" property="position"/>
- <result column="linkman" property="linkman"/>
- <result column="email" property="email"/>
- <result column="type" property="type"/>
- </resultMap>
- <resultMap id="UserOrgDTO" type="com.diagbot.dto.UserOrgDTO">
- <id column="user_id" property="userId"/>
- <result column="username" property="username"/>
- <result column="linkman" property="linkman"/>
- <result column="email" property="email"/>
- <result column="org_id" property="orgId"/>
- <result column="org_name" property="orgName"/>
- <result column="is_reject" property="isReject"/>
- <result column="au_status" property="auStatus"/>
- <result column="sub_num" property="subNum"/>
- </resultMap>
- <select id="findByName" resultMap="BaseResultMap" parameterType="java.lang.String">
- select * from sys_user
- where username = #{username} and is_deleted = 'N'
- </select>
- <select id="selectUserListPage" resultMap="BaseResultMap">
- select u.*
- from sys_user u
- LEFT JOIN sys_user_role ur on u.id= ur.user_id
- LEFT JOIN sys_role r on ur.role_id=r.id
- where u.is_deleted = 'N'
- <if test="user.id != null">
- and u.id = #{user.id}
- </if>
- </select>
- <select id="indexPage" resultMap="BaseResultMap">
- select u.* from sys_user u where u.is_deleted = 'N'
- <if test="user.id != null">
- and u.id = #{user.id}
- </if>
- <if test="user.username != null and user.username != '' ">
- and u.username like concat('%',#{user.username},'%')
- </if>
- </select>
- <select id="getByIds" resultMap="BaseResultMap">
- select u.* from sys_user u where u.is_deleted = 'N'
- and u.id in
- <foreach collection="list" item="ids" open="(" close=")" separator=",">
- #{ids}
- </foreach>
- </select>
- <select id="getUserOrgDTOByIds" resultMap="UserOrgDTO">
- select u.id user_id ,u.username username, u.email email, u.linkman linkman , org.id org_id,
- org.name org_name, ua.is_reject is_reject, ua.status au_status,org.sub_num
- from sys_user u, sys_user_organization uo, sys_organization org , sys_user_authentication ua
- where u.is_deleted = 'N' and uo.is_deleted = 'N' and org.is_deleted = 'N'
- and u.id = uo.user_id and uo.organization_id = org.id and u.id = ua.user_id
- and u.id in
- <foreach collection="list" item="ids" open="(" close=")" separator=",">
- #{ids}
- </foreach>
- </select>
- <select id="getUserByOrgName" resultMap="BaseResultMap">
- select a.* from sys_user a, sys_organization org, sys_user_organization uo
- where a.is_deleted = 'N' and org.is_deleted = 'N' and uo.is_deleted = 'N'
- and a.id = uo.user_id and uo.organization_id = org.id and org.`name` like concat('%' ,#{orgName}, '%')
- </select>
- <!-- <select id="selectUserInfoListPage" resultMap="BaseResultMap">
- select u.*
- LEFT JOIN sys_user_role ur on u.id= ur.user_id
- LEFT JOIN
- sys_role r on ur.role_id=r.id
- where u.is_deleted = 'N' and type = "0"
- ORDER BY gmt_create DESC
- </select> -->
- <!-- <select id="selectUserInfoPage" parameterType="com.diagbot.dto.UserInfoDTO" resultType="com.diagbot.dto.UserInfoDTO">
- SELECT
- u.id AS userId,
- u.gmt_create as userGmtCreate,
- u.username as userName,
- u.linkman as linKman,
- u.email as email,
- org.id AS orgId,
- org.gmt_create as orgGmtCreate,
- org.name as orgName
- FROM sys_user u
- LEFT JOIN sys_user_organization uorg ON u.id = uorg.user_id
- LEFT JOIN sys_organization org ON uorg.organization_id = org.id
- WHERE u.is_deleted = 'N' AND u.TYPE = 0 ORDER BY u.gmt_create DESC
- </select> -->
- <select id="selectUserInfoListPage" resultType="com.diagbot.dto.UserInfoDTO">
- SELECT
- u.id AS userId,
- u.gmt_create AS userGmtCreate,
- u.username AS userName,
- u.linkman AS linKman,
- u.email AS email,
- org.id AS orgId,
- org.gmt_create AS orgGmtCreate,
- org.name AS orgName,
- org.type as orgType,
- org.principal AS orgPrincipal,
- org.address as orgAddress,
- org.parent_id as orgParent_id,
- org.sub_num as orgSub_num,
- aut.position as autPosition,
- aut.is_reject as autIsReject,
- aut.status as autStatus
- FROM sys_user u
- LEFT JOIN sys_user_organization uorg ON u.id = uorg.user_id
- LEFT JOIN sys_organization org ON uorg.organization_id = org.id
- LEFT JOIN sys_user_authentication aut ON u.id = aut.user_id
- WHERE u.is_deleted = 'N' AND u.TYPE = 0
- <if test="userInfo.orgName != null">
- AND org.name LIKE CONCAT('%', #{userInfo.orgName}, '%')
- </if>
- <if test="userInfo.autStatus != null">
- AND aut.status = #{userInfo.autStatus}
- </if>
- ORDER BY u.gmt_create DESC
- </select>
- <update id="updateUserInfoAll" parameterType="java.util.Map">
- UPDATE sys_user u ,sys_user_organization a ,
- sys_organization b ,sys_user_authentication c
- SET u.remark = "0"
- <if test="userMap.email != null">
- <if test="userMap.gmtModified !=null">
- ,u.gmt_modified=#{userMap.gmtModified}
- </if>
- <if test="userMap.modifier != null">
- ,u.modifier=#{userMap.modifier}
- </if>
- ,u.email=#{userMap.email}
- </if>
- <if test="userMap.principal != null || userMap.address != null || userMap.type != null">
- <if test="userMap.gmtModified !=null">
- ,b.gmt_modified=#{userMap.gmtModified}
- </if>
- <if test="userMap.modifier != null">
- ,b.modifier=#{userMap.modifier}
- </if>
- <if test="userMap.principal != null">
- ,b.principal=#{userMap.principal}
- </if>
- <if test="userMap.address != null">
- ,b.address=#{userMap.address}
- </if>
- <if test="userMap.type != null">
- ,b.type=#{userMap.type}
- </if>
- </if>
- <!-- <if test="position != null || isReject != null || rejectType !=null || rejectComment !=null || status != null"> -->
- <if test="userMap.position != null">
- <if test="userMap.gmtModified !=null">
- ,c.gmt_modified=#{userMap.gmtModified}
- </if>
- <if test="userMap.modifier != null">
- ,c.modifier=#{userMap.modifier}
- </if>
- ,c.position=#{userMap.position}
- </if>
- <!-- <if test="isReject != null">
- ,c.is_reject=#{isReject}
- </if>
- <if test="rejectType !=null">
- ,c.reject_type=#{rejectType}
- </if>
- <if test="rejectComment !=null">
- ,c.reject_comment=#{rejectComment}
- </if>
- <if test="status != null">
- ,c.status = #{status}
- </if> -->
- <!-- </if> -->
- WHERE
- u.is_deleted = "N"
- AND u.id = #{userMap.userId}
- AND c.user_id= #{userMap.userId}
- AND a.user_id = #{userMap.userId}
- AND a.organization_id =b.id
- </update>
- <update id="updateDeleted" parameterType="java.util.Map">
- UPDATE sys_user u ,sys_user_organization a ,
- sys_organization b,sys_user_authentication c, sys_user_role r
- SET u.is_deleted = "Y",a.is_deleted= "Y",b.is_deleted= "Y",c.is_deleted="Y", r.is_deleted="Y"
- <if test="map.gmtModified !=null">
- ,u.gmt_modified=#{map.gmtModified}
- ,a.gmt_modified=#{map.gmtModified}
- ,b.gmt_modified=#{map.gmtModified}
- ,c.gmt_modified=#{map.gmtModified}
- ,r.gmt_modified=#{map.gmtModified}
- </if>
- <if test="map.modifier != null">
- ,u.modifier=#{map.modifier}
- ,a.modifier=#{map.modifier}
- ,b.modifier=#{map.modifier}
- ,c.modifier=#{map.modifier}
- ,r.modifier=#{map.modifier}
- </if>
- WHERE u.id = #{map.userId}
- AND c.user_id= #{map.userId}
- AND a.user_id = #{map.userId}
- AND a.organization_id =b.id
- AND r.user_id= #{map.userId}
- </update>
- <update id="auditUserInfoAll" parameterType="java.util.Map">
- UPDATE sys_user_authentication
- <trim prefix="set" suffixOverrides=",">
- <if test="auditMap.gmtModified !=null">gmt_modified=#{auditMap.gmtModified},</if>
- <if test="auditMap.modifier != null">modifier=#{auditMap.modifier},</if>
- <if test="auditMap.isReject != null">is_reject = #{auditMap.isReject} ,</if>
- <if test="auditMap.certificationDate != null">certification_date = #{auditMap.certificationDate},</if>
- <if test="auditMap.rejectType != null">reject_type =#{auditMap.rejectType},</if>
- <if test="auditMap.rejectComment != null">reject_comment= #{auditMap.rejectComment},
- </if>
- <if test="auditMap.status != null">STATUS= #{auditMap.status}</if>
- </trim>
- WHERE
- user_id = #{auditMap.userId}
- AND is_deleted = "N"
- </update>
- <select id="dependentuserInfoByTime" parameterType="java.util.Map"
- resultType="com.diagbot.dto.UserInfoDTO">
- SELECT
- u.id AS userId,
- u.gmt_create AS userGmtCreate,
- u.gmt_modified AS userGmtModified,
- u.username AS userName,
- u.linkman AS linKman,
- u.email AS email,
- org.id AS orgId,
- org.gmt_create AS orgGmtCreate,
- org.name AS orgName,
- org.type as orgType,
- org.principal AS orgPrincipal,
- org.address as orgAddress,
- org.parent_id as orgParent_id,
- org.sub_num as orgSub_num,
- aut.position as autPosition,
- aut.is_reject as autIsReject,
- aut.status as autStatus
- FROM sys_user u
- LEFT JOIN sys_user_organization uorg ON u.id = uorg.user_id
- LEFT JOIN sys_organization org ON uorg.organization_id = org.id
- LEFT JOIN sys_user_authentication aut ON u.id = aut.user_id
- WHERE
- u.is_deleted = 'N'
- AND u.TYPE = "0"
- <if test="userExport.orgName != null">
- AND org.name LIKE CONCAT('%', #{userExport.orgName}, '%')
- </if>
- <if test="userExport.userName != null">
- AND u.username LIKE CONCAT('%', #{userExport.userName}, '%')
- </if>
- <if test="userExport.autStatus != null">
- AND aut.status = #{userExport.autStatus}
- </if>
- <if test="userExport.startTime != null and userExport.endTime != null">
- AND u.gmt_create BETWEEN #{userExport.startTime} and #{userExport.endTime}
- </if>
- ORDER BY u.gmt_create DESC
- </select>
- <select id="queryUserInformation" resultType="com.diagbot.dto.UserAllDTO">
- SELECT
- u.id AS userId,
- u.gmt_create AS userGmtCreate,
- u.username AS userName,
- u.linkman AS linKman,
- u.email AS email,
- org.id AS orgId,
- org.name AS orgName,
- aut.status AS autStatus
- FROM sys_user u
- LEFT JOIN sys_user_organization uorg ON u.id = uorg.user_id
- LEFT JOIN sys_organization org ON uorg.organization_id = org.id
- LEFT JOIN sys_user_authentication aut ON u.id = aut.user_id
- WHERE u.is_deleted = 'N' AND u.TYPE = 0
- <if test="userInformation.userName != null">
- AND u.username LIKE CONCAT('%', #{userInformation.userName}, '%')
- </if>
- <if test="userInformation.autStatus != null">
- AND aut.status = #{userInformation.autStatus}
- </if>
- <if test="userInformation.startTime != null and userInformation.endTime != null">
- AND u.gmt_create BETWEEN #{userInformation.startTime} and #{userInformation.endTime}
- </if>
- ORDER BY u.gmt_create DESC
- </select>
-
- <!-- <select id="queryMechanismInformation(jiude)" resultType="com.diagbot.dto.OrganizationDTO">
- SELECT
- u.id AS userId,
- u.linkman AS linKman,
- org.id AS orgId,
- org.gmt_create AS orgGmtCreate,
- org.name AS orgName,
- org.type AS orgType,
- org.principal AS orgPrincipal,
- org.address AS orgAddress,
- org.parent_id AS orgParent_id,
- org.sub_num AS orgSub_num
- FROM sys_user u
- LEFT JOIN sys_user_organization uorg ON u.id = uorg.user_id
- LEFT JOIN sys_organization org ON uorg.organization_id = org.id
- LEFT JOIN sys_user_authentication aut ON u.id = aut.user_id
- WHERE u.is_deleted = 'N' AND u.TYPE = 0
- <if test="mechanism.orgName != null">
- AND org.name LIKE CONCAT('%', #{mechanism.orgName}, '%')
- </if>
- <if test="mechanism.autStatus != null">
- AND aut.status = #{mechanism.autStatus}
- </if>
- <if test="mechanism.startTime != null and mechanism.endTime != null">
- AND u.gmt_create BETWEEN #{mechanism.startTime} and #{mechanism.endTime}
- </if>
- ORDER BY u.gmt_create DESC
- </select> -->
- <select id="queryMechanismInformation" resultType="com.diagbot.dto.OrganizationDTO">
- SELECT
- u.id AS userId,
- org.id AS orgId,
- org.gmt_create AS orgGmtCreate,
- org.name AS orgName,
- org.principal AS orgPrincipal,
- org.type AS orgType,
- org.address AS orgAddress,
- u.linkman AS linkman,
- aut.status AS autStatus,
- org.parent_id AS orgParent_id,
- org.sub_num AS orgSub_num
- FROM
- sys_organization org
- LEFT JOIN sys_user_organization uorg ON org.id = uorg.organization_id
- LEFT JOIN sys_user u ON uorg.user_id = u.id
- LEFT JOIN sys_user_authentication aut ON u.id = aut.user_id
- WHERE org.is_deleted = 'N'
- <if test="mechanism.orgName != null">
- AND org.name LIKE CONCAT('%', #{mechanism.orgName}, '%')
- </if>
- <if test="mechanism.autStatus != null">
- AND aut.status = #{mechanism.autStatus}
- </if>
- <if test="mechanism.startTime != null and mechanism.endTime != null">
- AND org.gmt_create BETWEEN #{mechanism.startTime} and #{mechanism.endTime}
- </if>
- ORDER BY org.gmt_create DESC
- </select>
-
- <select id="queryVerifiedUserOrganizationProduct" resultType="com.diagbot.dto.UserOrgizationProductDTO">
- SELECT
- u.id AS userId,
- u.gmt_create AS userGmtCreate,
- u.username AS userName,
- u.linkman AS linKman,
- u.email AS email,
- org.id AS orgId,
- org.gmt_create AS orgGmtCreate,
- org.name AS orgName,
- org.type AS orgType,
- org.principal AS orgPrincipal,
- org.address AS orgAddress,
- org.parent_id AS orgParent_id,
- org.sub_num AS orgSub_num,
- aut.certification_date AS certificationDate,
- aut.position AS autPosition,
- aut.status AS autStatus
- FROM sys_user u
- LEFT JOIN sys_user_organization uorg ON u.id = uorg.user_id
- LEFT JOIN sys_organization org ON uorg.organization_id = org.id
- LEFT JOIN sys_user_authentication aut ON u.id = aut.user_id
- WHERE u.is_deleted = 'N' AND u.TYPE = 0
- <if test="userOrg.orgName != null">
- AND org.name LIKE CONCAT('%', #{userOrg.orgName}, '%')
- </if>
- <if test="userOrg.userName != null">
- AND u.username LIKE CONCAT('%', #{userOrg.userName}, '%')
- </if>
- <if test="userOrg.startTime != null and userOrg.endTime != null">
- AND u.gmt_create BETWEEN #{userOrg.startTime} and #{userOrg.endTime}
- </if>
- AND aut.status = 1
- ORDER BY u.gmt_create DESC
- </select>
- <select id="queryAuthentication" resultType="com.diagbot.dto.AuthenticationDTO">
- SELECT
- u.id AS userId,
- u.gmt_create AS userGmtCreate,
- u.username AS userName,
- u.linkman AS linKman,
- u.email AS email,
- org.id AS orgId,
- org.gmt_create AS orgGmtCreate,
- org.name AS orgName,
- org.type AS orgType,
- org.principal AS orgPrincipal,
- org.address AS orgAddress,
- org.parent_id AS orgParent_id,
- org.sub_num AS orgSub_num,
- aut.position AS autPosition,
- aut.status AS autStatus
- FROM sys_user u
- LEFT JOIN sys_user_organization uorg ON u.id = uorg.user_id
- LEFT JOIN sys_organization org ON uorg.organization_id = org.id
- LEFT JOIN sys_user_authentication aut ON u.id = aut.user_id
- WHERE u.is_deleted = 'N' AND u.TYPE = 0
- <if test="authen.orgName != null">
- AND org.name LIKE CONCAT('%', #{authen.orgName}, '%')
- </if>
- <if test="authen.userName != null">
- AND u.username LIKE CONCAT('%', #{authen.userName}, '%')
- </if>
- <if test="authen.startTime != null and authen.endTime != null">
- AND u.gmt_create BETWEEN #{authen.startTime} and #{authen.endTime}
- </if>
- AND aut.status = 2
- ORDER BY u.gmt_create DESC
- </select>
- <update id="updateUserInfo" parameterType="java.util.Map">
- UPDATE
- sys_user a
- JOIN sys_user_authentication b ON a.id = b.user_id
- <trim prefix="set" suffixOverrides=",">
- <if test="amendUserInfo.linKman != null">
- a.linkman = #{amendUserInfo.linKman},
- </if>
- <if test="amendUserInfo.email != null">
- a.email = #{amendUserInfo.email},
- </if>
- <if test="amendUserInfo.autPosition != null">
- b.position = #{amendUserInfo.autPosition},
- </if>
- <if test="amendUserInfo.gmtModified != null">
- a.gmt_modified =#{amendUserInfo.gmtModified},
- </if>
- <if test="amendUserInfo.gmtModified != null">
- b.gmt_modified = #{amendUserInfo.gmtModified},
- </if>
- <if test="amendUserInfo.modifier != null">
- a.modifier = #{amendUserInfo.modifier},
- </if>
- <if test="amendUserInfo.modifier != null">
- b.modifier = #{amendUserInfo.modifier}
- </if>
- </trim>
- WHERE
- a.is_deleted = "N"
- AND b.is_deleted = "N"
- AND a.id = #{amendUserInfo.userId}
- </update>
- <update id="updateOrganizations" parameterType="java.util.Map">
- UPDATE sys_organization a
- <trim prefix="set" suffixOverrides=",">
- <if test="amendOrg.address != null">
- a.address = #{amendOrg.address},
- </if>
- <if test="amendOrg.type != null">
- a.type = #{amendOrg.type},
- </if>
- <if test="amendOrg.subMum != null">
- a.sub_num = #{amendOrg.subMum},
- </if>
- <if test="amendOrg.gmtModified != null">
- a.gmt_modified =#{amendOrg.gmtModified},
- </if>
- <if test="amendOrg.modifier != null">
- a.modifier =#{amendOrg.modifier}
- </if>
- </trim>
- WHERE
- a.is_deleted = "N"
- AND a.id = #{amendOrg.orgId}
- </update>
- <select id="exportOrganizations" parameterType="java.util.Map"
- resultType="com.diagbot.dto.UserInfoDTO">
- SELECT
- u.id AS userId,
- u.gmt_create AS userGmtCreate,
- u.gmt_modified AS userGmtModified,
- u.username AS userName,
- u.linkman AS linKman,
- u.email AS email,
- org.id AS orgId,
- org.gmt_create AS orgGmtCreate,
- org.name AS orgName,
- org.type AS orgType,
- org.principal AS orgPrincipal,
- org.address AS orgAddress,
- org.parent_id AS orgParent_id,
- org.sub_num AS orgSub_num,
- aut.position AS autPosition,
- aut.is_reject AS autIsReject,
- aut.status AS autStatus
- FROM
- sys_organization org
- LEFT JOIN sys_user_organization uorg ON org.id = uorg.organization_id
- LEFT JOIN sys_user u ON uorg.user_id = u.id
- LEFT JOIN sys_user_authentication aut ON u.id = aut.user_id
- WHERE org.is_deleted = 'N'
- <if test="exportOrg.orgName != null">
- AND org.name LIKE CONCAT('%', #{exportOrg.orgName}, '%')
- </if>
- <if test="exportOrg.startTime != null and exportOrg.endTime != null">
- AND org.gmt_create BETWEEN #{exportOrg.startTime} and #{exportOrg.endTime}
- </if>
- ORDER BY org.gmt_create DESC
- </select>
- </mapper>
|