123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243 |
- <?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.sundata.example.mapper.ExampleSysUserMapper">
-
- <sql id="Base_Column_List">
- account,psw,cnname,email,orgcode,loginname,
- (select orgname from sys_organization a where a.orgcode=sys_user.orgcode) as orgname,
- mobile,tel,userState,logOn,creattime,modifypwdate,certtype,certno,tellerid,admpost,
- partypost,busipost,admorg
- </sql>
- <!-- 插入记录 -->
- <insert id="insert">
- insert into
- sys_user(account,cnname,psw,email,mobile,tel,userState,orgcode,logOn,creattime,modifypwdate
- ,certtype,certno,tellerid,admpost,partypost,busipost,admorg,loginname)
- values(#{account},#{cnname},#{psw},#{email},#{mobile},#{tel},#{userState},
- #{orgcode},#{logOn},#{creattime},#{modifypwdate},#{certtype},#{certno},#{tellerid},#{admpost},
- #{partypost},#{busipost},#{admorg},#{loginname})
- </insert>
- <!-- 根据id,修改记录 -->
- <update id="update">
- update sys_user set
- cnname=#{cnname},
- email=#{email},
- mobile=#{mobile},
- tel=#{tel},
- userState=#{userState},
- orgcode=#{orgcode},
- logOn=#{logOn},
- certtype=#{certtype},
- certno=#{certno},
- tellerid=#{tellerid},
- admpost=#{admpost},
- partypost=#{partypost},
- busipost=#{busipost},
- admorg=#{admorg}
- where account=#{account}
- </update>
-
- <!-- 根据loginname,修改记录,不修改机构 -->
- <update id="updateByLoginname">
- update sys_user set
- cnname=#{cnname},
- email=#{email},
- mobile=#{mobile},
- tel=#{tel},
- userState=#{userState},
- logOn=#{logOn},
- certtype=#{certtype},
- certno=#{certno},
- tellerid=#{tellerid},
- admpost=#{admpost},
- partypost=#{partypost},
- busipost=#{busipost},
- admorg=#{admorg}
- where loginname=#{loginname}
- </update>
- <!-- 修改记录,只修改只不为空的字段 -->
- <update id="updateNotEmpty">
- update sys_user set
- <trim suffixOverrides=",">
- <if test="cnname != null and cnname != '' ">
- cnname=#{cnname},
- </if>
- <if test="psw != null and psw != '' ">
- psw=#{psw},
- </if>
- <if test="email != null and email != '' ">
- email=#{email},
- </if>
- <if test="mobile != null ">
- mobile=#{mobile},
- </if>
- <if test="tel != null ">
- tel=#{tel},
- </if>
- <if test="userState != null ">
- userState=#{userState},
- </if>
- <if test="orgcode != null ">
- orgcode=#{orgcode},
- </if>
- <if test="logOn != null ">
- logOn=#{logOn},
- </if>
- </trim>
- where account=#{account}
- </update>
- <update id="updateNotEmptyByloginname">
- update sys_user set
- <trim suffixOverrides=",">
- <if test="cnname != null and cnname != '' ">
- cnname=#{cnname},
- </if>
- <if test="psw != null and psw != '' ">
- psw=#{psw},
- </if>
- <if test="email != null and email != '' ">
- email=#{email},
- </if>
- <if test="mobile != null ">
- mobile=#{mobile},
- </if>
- <if test="tel != null ">
- tel=#{tel},
- </if>
- <if test="userState != null ">
- userState=#{userState},
- </if>
- <if test="orgcode != null ">
- orgcode=#{orgcode},
- </if>
- <if test="logOn != null ">
- logOn=#{logOn},
- </if>
- </trim>
- where loginname=#{loginname}
- </update>
- <!-- 删除记录 -->
- <delete id="delete">
- delete from sys_user where account in
- <foreach item="item" index="index" collection="account.split(',')" open="(" separator="," close=")">
- #{item}
- </foreach>
- </delete>
- <!-- 根据id查询 系统用户 -->
- <select id="queryOne" resultType="com.sundata.example.model.ExampleSysUserModel">
- select
- <include refid="Base_Column_List" />
- from sys_user where account = #{account}
- </select>
- <select id="queryByloginname" resultType="com.sundata.example.model.ExampleSysUserModel">
- select
- <include refid="Base_Column_List" />
- from sys_user where loginname=#{loginname}
- <if test="orgcode != null and orgcode !=''">
- and orgcode in (
- <foreach item="item" index="index" collection="orgcode.split(',')" open="" separator="," close="">
- #{item}
- </foreach> )
- </if>
- </select>
- <select id="queryPage" resultType="com.sundata.example.model.ExampleSysUserModel">
- <![CDATA[select
- max(psw) as pws,max(cnname) as cnname,max(email) as email,max(loginname) as loginname,
- case when count(1)>1 then '多个机构' else max(orgname) end as orgname,
- max(mobile) as mobile,max(tel) as tel,min(userState) as userState,max(logOn) as logOn,max(creattime) as creattime,
- max(modifypwdate) as modifypwdate,max(certtype) as certtype,max(certno) as certno,max(tellerid) as tellerid,
- max(admpost) as admpost,max(partypost) as partypost,max(busipost) as busipost,max(admorg) as admorg,
- (CASE WHEN max(cnname)='test3' THEN 'checked' ELSE '' END ) checked,
- ]]>
- <if test="dbtype == 'ora' ">
- listagg(account,',') within group(order by loginname) as account,listagg(u.orgcode,',') within group(order by loginname) as orgcode
- </if>
- <if test="dbtype == 'mysql' ">
- group_concat(account) as account,group_concat(u.orgcode) as orgcode
- </if>
- <if test="dbtype == 'db2' ">
- listagg(account,',') as account,listagg(u.orgcode,',') as orgcode
- </if>
- from sys_user u
- left join sys_organization a on a.orgcode=u.orgcode
- <where>
- <if test="cnname != null and cnname != ''">
- and cnname like concat('%',concat(#{cnname},'%'))
- </if>
-
- <if test="orgcode != null and orgcode !=''">
- and u.orgcode in (
- select underorg from sys_orgrelational where orgcode=#{orgcode}
- )
- </if>
- <if test="logOn != null">
- and logOn = #{logOn}
- </if>
- <if test="userState != null">
- <if test="userState == '_check'">
- and userState != 'RESIGN'
- </if>
- <if test="userState != '_check'">
- and userState = #{userState}
- </if>
- </if>
-
- <if test="loginname != null and loginname !=''">
- and loginname like concat('%',concat(#{loginname},'%'))
- </if>
- </where>
- group by loginname
- <if test="ordercol != null and ordercol !=''">
- ORDER BY ${ordercol} ${soertype}
- </if>
- </select>
-
- <select id="getRoleUsersqueryPage" resultType="com.sundata.example.model.ExampleSysUserModel">
- select t.*,r.orgname from sys_user t left join sys_organization r on t.orgcode = r.orgcode
- where account
- <if test="canselect!=null">
- not
- </if>
- <![CDATA[
- in (select account from sys_user_role where roleid=#{roleid})
- and t.ORGCODE in (select org.ORGCODE from sys_organization org
- inner join SYS_ROLE role on roleid=#{roleid}
- where (role.LOWORGTYPE is null or role.LOWORGTYPE='' or role.LOWORGTYPE >= org.orgtype)
- AND (role.highorgtype IS NULL or role.highorgtype='' or role.highorgtype <= org.orgtype)
- AND org.orgcode in (select UNDERORG from SYS_ORGRELATIONAL where ORGCODE=role.orgcode))
- ]]>
- order by t.loginname
- </select>
- <select id="queryAllRole" resultType="String">
- select roleid from SYS_USER_ROLE where account=#{account}
- </select>
-
-
-
- <!-- 查询用户可配置的角色列表 -->
- <select id="getUserDataList" resultType="com.sundata.example.model.ExampleSysRoleModel">
- <![CDATA[
- SELECT a.roleid,a.rolename,a.remark,a.creattime ,
- (CASE WHEN b.ROLEID IS NOT NULL THEN 'checked' ELSE '' END ) checked
- FROM SYS_ROLE a
- inner join SYS_ORGANIZATION org on org.ORGCODE=#{orgcode,jdbcType=VARCHAR}
- LEFT JOIN SYS_USER_ROLE b ON a.ROLEID=b.ROLEID AND b.ACCOUNT=#{account,jdbcType=VARCHAR}
- WHERE a.ORGCODE IN (SELECT c.ORGCODE FROM SYS_ORGRELATIONAL c WHERE c.UNDERORG=#{orgcode,jdbcType=VARCHAR} )
- AND (a.loworgtype IS NULL or a.loworgtype='' or a.loworgtype >= org.orgtype)
- AND (a.highorgtype IS NULL or a.highorgtype='' or a.highorgtype <= org.orgtype)
- ]]>
- </select>
-
-
- </mapper>
|