|
|
@@ -2,67 +2,63 @@
|
|
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
|
<mapper namespace="com.xpyy.xpyy.mapper.UserMapper">
|
|
|
-
|
|
|
- <sql id="userField">
|
|
|
- id,code,user_name,password,real_name,email,landline,phone,department,role
|
|
|
- </sql>
|
|
|
<!-- 登录 -->
|
|
|
<select id="login" resultType="com.xpyy.xpyy.entity.User">
|
|
|
select
|
|
|
a.id,
|
|
|
a.code,
|
|
|
- a.user_name,
|
|
|
+ a.userName,
|
|
|
a.password,
|
|
|
- a.real_name,
|
|
|
+ a.realName,
|
|
|
a.email,
|
|
|
a.landline,
|
|
|
a.phone,
|
|
|
a.department,
|
|
|
a.role,
|
|
|
b.menu
|
|
|
- from tld_user a
|
|
|
- left join tld_role b on a.role = b.id
|
|
|
- where a.user_name = #{userName} and a.password = #{password}
|
|
|
+ from user a
|
|
|
+ left join role b on a.role = b.id
|
|
|
+ where a.userName = #{userName} and a.password = #{password}
|
|
|
</select>
|
|
|
<!-- 查询所有用户 -->
|
|
|
<select id="getAllUser" resultType="com.xpyy.xpyy.entity.User">
|
|
|
select
|
|
|
a.id,
|
|
|
a.code,
|
|
|
- a.user_name,
|
|
|
+ a.userName,
|
|
|
a.password,
|
|
|
- a.real_name,
|
|
|
+ a.realName,
|
|
|
a.email,
|
|
|
a.landline,
|
|
|
a.phone,
|
|
|
- a.create_time,
|
|
|
+ a.createTime,
|
|
|
c.name as department,
|
|
|
- b.role_name as role,
|
|
|
+ b.roleName as role,
|
|
|
a.role as roleId,
|
|
|
a.menu,
|
|
|
- a.menu_before,
|
|
|
+ a.menuBefore,
|
|
|
a.department as departmentId,
|
|
|
- a.modify_time as modifyTime,
|
|
|
- f.user_name as modifyUser
|
|
|
- from tld_user a
|
|
|
- left join tld_user f on a.modify_user = f.id
|
|
|
- left join tld_role b on a.role = b.id
|
|
|
- left join tld_department c on a.department = c.code
|
|
|
+ a.modifyTime as modifyTime,
|
|
|
+ f.userName as modifyUser
|
|
|
+ from user a
|
|
|
+ left join user f on a.modifyUser = f.id
|
|
|
+ left join role b on a.role = b.id
|
|
|
+ left join department c on a.department = c.code
|
|
|
<trim prefix="WHERE" prefixOverrides="and |or">
|
|
|
<if test="code != null and code != ''">
|
|
|
and a.code like CONCAT(CONCAT('%', #{code}), '%')
|
|
|
</if>
|
|
|
<if test="userName != null and userName != ''">
|
|
|
- and a.user_name like CONCAT(CONCAT('%', #{userName}), '%')
|
|
|
+ and a.userName like CONCAT(CONCAT('%', #{userName}), '%')
|
|
|
</if>
|
|
|
<if test="realName != null and realName != ''">
|
|
|
- and a.real_name like CONCAT(CONCAT('%', #{realName}), '%')
|
|
|
+ and a.realName like CONCAT(CONCAT('%', #{realName}), '%')
|
|
|
</if>
|
|
|
<if test="modifyUser != null and modifyUser != ''">
|
|
|
- and f.user_name like CONCAT(CONCAT('%', #{modifyUser}), '%')
|
|
|
+ and f.userName like CONCAT(CONCAT('%', #{modifyUser}), '%')
|
|
|
</if>
|
|
|
<if test="role != null and role != ''">
|
|
|
- and b.role_name like CONCAT(CONCAT('%', #{role}), '%')
|
|
|
+ and b.roleName like CONCAT(CONCAT('%', #{role}), '%')
|
|
|
</if>
|
|
|
<if test="email != null and email != ''">
|
|
|
and a.email like CONCAT(CONCAT('%', #{email}), '%')
|
|
|
@@ -87,25 +83,25 @@
|
|
|
<selectKey resultType="java.lang.String" order="AFTER" keyProperty="id">
|
|
|
select LAST_INSERT_ID()
|
|
|
</selectKey>
|
|
|
- insert into tld_user(user_name,password,real_name,email,landline,phone,department,role,create_time,modify_user,modify_time)
|
|
|
+ insert into user(userName,password,realName,email,landline,phone,department,role,createTime,modifyUser,modifyTime)
|
|
|
values(#{userName},#{password},#{realName},#{email},#{landline},#{phone},#{department},#{role},NOW(),#{modifyUser},now())
|
|
|
</insert>
|
|
|
<!-- 修改指定用户信息 -->
|
|
|
<update id="updateUser">
|
|
|
- update tld_user
|
|
|
+ update user
|
|
|
<set>
|
|
|
<trim suffixOverrides=",">
|
|
|
<if test="code != null">
|
|
|
code = #{code},
|
|
|
</if>
|
|
|
<if test="userName != null">
|
|
|
- user_name = #{userName},
|
|
|
+ userName = #{userName},
|
|
|
</if>
|
|
|
<if test="password != null">
|
|
|
password = #{password},
|
|
|
</if>
|
|
|
<if test="realName != null">
|
|
|
- real_name = #{realName},
|
|
|
+ realName = #{realName},
|
|
|
</if>
|
|
|
<if test="email != null">
|
|
|
email = #{email},
|
|
|
@@ -123,50 +119,50 @@
|
|
|
menu = #{menu},
|
|
|
</if>
|
|
|
<if test="menuBefore != null">
|
|
|
- menu_before = #{menuBefore},
|
|
|
+ menuBefore = #{menuBefore},
|
|
|
</if>
|
|
|
<if test="role != null">
|
|
|
role = #{role},
|
|
|
</if>
|
|
|
- modify_user = #{modifyUser},modify_time=now(),
|
|
|
+ modifyUser = #{modifyUser},modifyTime=now(),
|
|
|
</trim>
|
|
|
</set>
|
|
|
where id = #{id}
|
|
|
</update>
|
|
|
<!-- 删除用户 -->
|
|
|
<delete id="delUser">
|
|
|
- delete from tld_user where id = #{id}
|
|
|
+ delete from user where id = #{id}
|
|
|
</delete>
|
|
|
<!-- 查询用户名是否存在 -->
|
|
|
<select id="getUserIsNot" resultType="int">
|
|
|
- select count(*) from tld_user where user_name = #{userName} and id != #{id}
|
|
|
+ select count(*) from user where userName = #{userName} and id != #{id}
|
|
|
</select>
|
|
|
<!-- 查询导出数据 -->
|
|
|
<select id="getUserExportData" resultType="java.util.LinkedHashMap">
|
|
|
select
|
|
|
a.code,
|
|
|
- a.user_name,
|
|
|
- if(a.real_name = '', null , a.real_name) as real_name,
|
|
|
+ a.userName,
|
|
|
+ if(a.realName = '', null , a.realName) as realName,
|
|
|
if(a.email = '', null , a.email) as email,
|
|
|
if(a.phone = '', null , a.phone) as phone,
|
|
|
c.name as department,
|
|
|
- b.role_name as role
|
|
|
- from tld_user a
|
|
|
- left join tld_role b on a.role = b.id
|
|
|
- left join tld_department c on a.department = c.code
|
|
|
- left join tld_user f on a.modify_user = f.id
|
|
|
+ b.roleName as role
|
|
|
+ from user a
|
|
|
+ left join role b on a.role = b.id
|
|
|
+ left join department c on a.department = c.code
|
|
|
+ left join user f on a.modifyUser = f.id
|
|
|
<trim prefix="WHERE" prefixOverrides="and |or">
|
|
|
<if test="code != null and code != ''">
|
|
|
and a.code like CONCAT(CONCAT('%', #{code}), '%')
|
|
|
</if>
|
|
|
<if test="userName != null and userName != ''">
|
|
|
- and a.user_name like CONCAT(CONCAT('%', #{userName}), '%')
|
|
|
+ and a.userName like CONCAT(CONCAT('%', #{userName}), '%')
|
|
|
</if>
|
|
|
<if test="realName != null and realName != ''">
|
|
|
- and a.real_name like CONCAT(CONCAT('%', #{realName}), '%')
|
|
|
+ and a.realName like CONCAT(CONCAT('%', #{realName}), '%')
|
|
|
</if>
|
|
|
<if test="role != null and role != ''">
|
|
|
- and b.role_name like CONCAT(CONCAT('%', #{role}), '%')
|
|
|
+ and b.roleName like CONCAT(CONCAT('%', #{role}), '%')
|
|
|
</if>
|
|
|
<if test="email != null and email != ''">
|
|
|
and a.email like CONCAT(CONCAT('%', #{email}), '%')
|
|
|
@@ -178,7 +174,7 @@
|
|
|
and a.phone like CONCAT(CONCAT('%', #{phone}), '%')
|
|
|
</if>
|
|
|
<if test="modifyUser != null and modifyUser != ''">
|
|
|
- and f.user_name like CONCAT(CONCAT('%', #{modifyUser}), '%')
|
|
|
+ and f.userName like CONCAT(CONCAT('%', #{modifyUser}), '%')
|
|
|
</if>
|
|
|
<if test="department != null and department != ''">
|
|
|
and a.department = #{department}
|
|
|
@@ -191,15 +187,15 @@
|
|
|
select
|
|
|
id,
|
|
|
code,
|
|
|
- user_name,
|
|
|
+ userName,
|
|
|
password,
|
|
|
- real_name,
|
|
|
+ realName,
|
|
|
email,
|
|
|
landline,
|
|
|
phone,
|
|
|
department,
|
|
|
role
|
|
|
- from tld_user
|
|
|
+ from user
|
|
|
where id = #{id}
|
|
|
</select>
|
|
|
</mapper>
|