| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320 |
- <?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="platform.modules.government.dao.UserDao">
- <select id="findByNickName" resultType="platform.modules.government.entity.User">
- SELECT * FROM z_user u WHERE u.nick_name = #{nick_name}
- <if test="user_type != null and user_type !=''">
- and u.user_type=${user_type}
- </if>
- and u.del_flag=0 LIMIT 0 ,1
- </select>
- <select id="findByNickNameOnly" resultType="platform.modules.government.entity.User">
- SELECT * FROM z_user u WHERE u.nick_name = #{nick_name}
- and u.del_flag=0 LIMIT 0 ,1
- </select>
- <select id="findByNickNameReg" resultType="platform.modules.government.entity.User">
- SELECT * FROM z_user u WHERE u.nick_name = #{nick_name}
- <if test="user_type != null and user_type !=''">
- and u.user_type=${user_type}
- </if>
- and u.del_flag=0 and u.is_register != 2 LIMIT 0 ,1
- </select>
- <select id="findByLogin" resultType="platform.modules.government.entity.User">
- SELECT * FROM z_user u
- WHERE (
- (u.nick_name = #{loginName} )
- or( u.phone = #{loginName} )
- or( u.organization_code = #{loginName} and u.user_type = #{companyType})
- )
-
- and u.del_flag=0 LIMIT 0 ,1
- </select>
- <select id="findByMobile" resultType="platform.modules.government.entity.User">
- SELECT * FROM z_user u WHERE u.phone = #{mobile}
- and u.del_flag=0 LIMIT 0 ,1
- </select>
- <select id="getUserByMobile" resultType="platform.modules.government.entity.User">
- SELECT * FROM z_user u WHERE u.phone = #{mobile}
- and u.del_flag=0
- </select>
- <select id="getUserByNickname" resultType="platform.modules.government.entity.User">
- SELECT * FROM z_user u WHERE u.nick_name = #{nickname}
- and u.del_flag=0
- </select>
- <select id="getUserByDepartmentId" resultType="platform.modules.government.entity.User">
- SELECT * FROM z_user u WHERE u.department_id = #{department_id}
- and u.del_flag=0
- </select>
- <select id="findUserIdsByUserId" resultType="Integer">
- SELECT id,approve_level from z_user where department_id =
- (SELECT department_id from z_user where id = #{userId}) and approve_level > (SELECT approve_level from z_user where id = #{userId})
- </select>
- <select id="findDepartmentIdByUserId" resultType="Integer">
- SELECT department_id from z_user where id = #{currentUserId}
- </select>
- <select id="findUserBydepartmentId" resultType="platform.modules.government.entity.User">
- <![CDATA[
- SELECT * FROM z_user where department_id=#{id} AND approve_level > -1 and del_flag = 0
- ]]>
- </select>
- <select id="findUserBydepartmentIdWithoutApprovalLevel" resultType="platform.modules.government.entity.User">
- SELECT * FROM z_user where department_id=#{id} and del_flag = 0
- </select>
- <select id="findUserByCondition" resultType="platform.modules.government.entity.User">
- SELECT distinct u.*
- FROM
- z_user u
- LEFT JOIN s_street street on street.id = u.street_id
- LEFT JOIN sys_user_role ur on u.id = ur.user_id
- LEFT JOIN sys_department dept on dept.id = u.department_id
- WHERE
- u.del_flag =0 and u.is_register=1
- AND
- (street.del_flag = 0 or street.del_flag is null )
- AND
- u.user_type != #{siper}
- <if test="userData.user_type_build != null and userData.user_type_build != ''
- and userData.build_id != null and userData.build_id != ''">
- AND
- u.user_type = #{userData.user_type_build}
- AND
- u.build_id = #{userData.build_id}
- </if>
- <if test="userData.user_type_street != null and userData.user_type_street != ''
- and userData.street_id != null and userData.street_id != ''">
- AND
- u.user_type in (#{userData.user_type_street},#{company})
- AND
- u.street_id = #{userData.street_id}
- <if test="userData.search_user_type != null">
- AND
- u.user_type = #{userData.search_user_type}
- </if>
- </if>
- <if test="userData.user_type_goverment != null ">
- AND
- u.user_type in (#{government},#{company})
- <if test="userData.search_user_type != null">
- AND
- u.user_type = #{userData.search_user_type}
- </if>
- </if>
- <if test="userData.user_type_super != null and userData.user_type_super != ''">
- AND
- u.user_type not in (#{siper})
- <if test="userData.search_user_type != null">
- AND
- u.user_type = #{userData.search_user_type}
- </if>
- </if>
- <if test="userData.user_type_company != null and userData.user_type_company != ''
- and userData.company_id != null and userData.company_id != ''">
- AND
- u.user_type = #{userData.user_type_company}
- AND
- u.company_id = #{userData.company_id}
- </if>
- <if test="userData.keyWord != null and userData.keyWord !=''">
- AND
- ((u.user_name LIKE CONCAT(CONCAT('%',#{userData.keyWord}),'%'))
- OR(u.nick_name LIKE CONCAT(CONCAT('%',#{userData.keyWord}),'%'))
- OR(u.phone LIKE CONCAT(CONCAT('%',#{userData.keyWord}),'%'))
- OR(u.email LIKE CONCAT(CONCAT('%',#{userData.keyWord}),'%'))
- )
- </if>
- <if test="searchCondition.company_name != null and searchCondition.company_name !=''">
- AND (
- u.company_name LIKE CONCAT(CONCAT('%',#{searchCondition.company_name}),'%')
- OR dept.name LIKE CONCAT(CONCAT('%',#{searchCondition.company_name}),'%')
- OR street.name LIKE CONCAT(CONCAT('%',#{searchCondition.company_name}),'%')
- OR u.build_name LIKE CONCAT( CONCAT( '%', #{searchCondition.company_name} ), '%' )
- )
- </if>
- <if test="searchCondition.street_id != null and searchCondition.street_id !=''">
- AND u.street_id = #{searchCondition.street_id}
- </if>
- <if test="searchCondition.role_id != null and searchCondition.role_id !=''">
- AND ur.role_id = #{searchCondition.role_id}
- </if>
- ORDER BY u.create_time DESC
- </select>
- <update id="deleteCompanyUser">
- update z_user set del_flag=1
- where company_id = #{id}
- </update>
- <update id="updateIsRegist">
- update z_user set is_register = #{isRegistration}
- where id = #{id}
- </update>
- <select id="findUsersByPermission" resultType="platform.modules.government.entity.User">
- SELECT
- distinct zuser.*
- FROM
- z_user zuser
- JOIN sys_user_role sys_user_role ON sys_user_role.user_id = zuser.id
- JOIN sys_role_menu sys_role_menu ON sys_role_menu.role_id = sys_user_role.role_id
- JOIN sys_menu sys_menu ON sys_menu.id = sys_role_menu.menu_id
- WHERE
- sys_menu.permission = #{permission}
- </select>
- <select id="selectAllUsers" resultType="platform.modules.government.entity.User">
- SELECT *
- FROM
- z_user u
- WHERE
- u.del_flag =0 and u.is_register=1 and u.is_start=1
- </select>
- <update id="updateByCompanyId">
- update z_user
- <set>
- build_id = #{user.build_id},
- <if test="user.build_name != null">
- build_name = #{user.build_name},
- </if>
- <if test="user.street_id != null">
- street_id = #{user.street_id},
- </if>
- <if test="user.street_name != null">
- street_name = #{user.street_name},
- </if>
- <if test="user.company_name != null">
- company_name = #{user.company_name},
- </if>
- </set>
- where company_id = #{companyId}
- </update>
- <update id="updateApproveLevel">
- update z_user set approve_level=#{user.approve_level}
- where id = #{user.id}
- </update>
- <select id="getAllDepartmentUsers" resultType="platform.modules.government.entity.User">
- SELECT
- u.*
- FROM
- z_user u
- LEFT JOIN sys_department sd ON sd.id = u.department_id
- WHERE
- u.DEL_FLAG = 0
- AND ( sd.id = #{department} OR sd.parent_id = #{department} )
- </select>
- <select id="getUserByName" resultType="platform.modules.government.entity.User">
- SELECT * FROM z_user WHERE user_name LIKE CONCAT('%',#{checkName},'%')
- </select>
- <update id="updateStreetIsStart">
- update z_user
- set is_start = #{isLock}
- where
- <if test="streetId != null and streetId != ''">
- street_id = #{streetId}
- </if>
- <if test="buildId != null and buildId != ''">
- build_id = #{buildId}
- </if>
- </update>
- <select id="findAllGovUsers" resultType="platform.modules.api.dto.UserInfoDto">
- SELECT
- u.id,
- u.user_name userName,
- u.nick_name AS userLoginName,
- d.id AS departmentId,
- d.`name`AS departmentName
- FROM
- z_user u
- LEFT JOIN sys_department d ON d.id = u.department_id
- WHERE
- u.del_flag = 0
- AND u.user_type = 0
- <if test="departmentId != null and departmentId != ''">
- AND u.department_id = #{departmentId}
- </if>
- </select>
- <select id="findAllUsers" resultType="platform.modules.api.dto.UserInfoDto">
- SELECT
- u.id,
- u.user_name userName,
- u.nick_name AS userLoginName,
- u.PASSWORD,
- u.user_type AS userType,
- (SELECT `name` FROM sys_department WHERE id = u.department_id) AS departmentName,
- (SELECT `name` FROM s_street WHERE id = u.street_id) AS streetName,
- (SELECT `name` FROM ic_park WHERE id = u.build_id) AS parkName,
- IFNULL((SELECT company_name FROM y_company WHERE id = u.company_id), u.company_name) AS companyName
- FROM
- z_user u
- WHERE
- u.del_flag = 0 AND u.is_start = 1 AND user_type != 2
- <if test="userType != null and userType != ''">
- AND u.user_type = #{userType}
- </if>
- </select>
- <update id="updateDepartmentName">
- UPDATE z_user set build_name = #{park.name} where build_id = #{park.id}
- </update>
- <select id="findFirstContact" resultType="platform.modules.government.entity.User">
- select c.company_name, u.nick_name, u.user_name, u.phone from z_user u
- LEFT JOIN y_company c ON c.id = u.company_id
- WHERE u.company_id = #{id} ORDER BY create_time ASC LIMIT 1
- </select>
- <select id="findUserById" resultType="platform.modules.government.entity.User">
- select c.company_name, u.nick_name, u.user_name, u.phone from z_user u
- LEFT JOIN y_company c ON c.id = u.company_id
- WHERE u.del_flag = 0 AND u.is_use = 1 AND u.id = #{id}
- </select>
- </mapper>
|