<?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="cn.com.basic.user.entity.SysUser">
|
<resultMap id="BaseResultMap" type="cn.com.basic.user.entity.SysUser">
|
<id column="id" property="id" jdbcType="VARCHAR" />
|
<result column="org_id" property="orgId" jdbcType="VARCHAR" />
|
<result column="type" property="type" jdbcType="TINYINT" />
|
<result column="number" property="number" jdbcType="VARCHAR" />
|
<result column="is_allow_login" property="isAllowLogin"
|
jdbcType="TINYINT" />
|
<result column="sex" property="sex" jdbcType="VARCHAR" />
|
<result column="login_name" property="loginName" jdbcType="VARCHAR" />
|
<result column="id_card" property="idCard" jdbcType="VARCHAR" />
|
<result column="real_name" property="realName" jdbcType="VARCHAR" />
|
<result column="password" property="password" jdbcType="VARCHAR" />
|
<result column="real_password" property="realPassword"
|
jdbcType="VARCHAR" />
|
<result column="email" property="email" jdbcType="VARCHAR" />
|
<result column="mobile" property="mobile" jdbcType="VARCHAR" />
|
<result column="phone" property="phone" jdbcType="VARCHAR" />
|
<result column="birthday" property="birthday" jdbcType="DATE" />
|
<result column="logo_path" property="logoPath" jdbcType="VARCHAR" />
|
<result column="comment" property="comment" jdbcType="VARCHAR" />
|
<result column="status" property="status" jdbcType="TINYINT" />
|
<result column="is_valid" property="isValid" jdbcType="TINYINT" />
|
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
|
<result column="create_user_id" jdbcType="VARCHAR" property="createUserId" />
|
<result column="update_time" property="updateTime" jdbcType="TIMESTAMP" />
|
<result column="update_user_id" property="updateUserId"
|
jdbcType="VARCHAR" />
|
</resultMap>
|
|
<resultMap id="SysUserTree" type="cn.com.basic.user.entity.SysUserTree">
|
<result column="id" property="id" jdbcType="VARCHAR"/>
|
<result column="org_id" property="orgId" jdbcType="VARCHAR"/>
|
<result column="pid" property="pid" jdbcType="VARCHAR"/>
|
<result column="real_name" property="name" jdbcType="VARCHAR"/>
|
</resultMap>
|
|
<sql id="Base_Column_List">
|
id, org_id, type, number, is_allow_login, sex, login_name, id_card,
|
real_name, password,
|
email, mobile, phone, birthday, logo_path, comment, status, is_valid,
|
create_time,
|
create_user_id, update_time, update_user_id
|
</sql>
|
|
<sql id="Base_Where_Clause">
|
<where>
|
<trim prefixOverrides="and">
|
<if test="id != null"> and ID = #{id}</if>
|
<if test="orgId != null">
|
and org_id = #{orgId,jdbcType=VARCHAR}
|
</if>
|
<if test="type != null">
|
and type = #{type,jdbcType=TINYINT}
|
</if>
|
<if test="type == null">
|
and type !=1
|
</if>
|
<if test="number != null">
|
and number = #{number,jdbcType=VARCHAR}
|
</if>
|
<if test="isAllowLogin != null">
|
and is_allow_login = #{isAllowLogin,jdbcType=TINYINT}
|
</if>
|
<if test="sex != null">
|
and sex = #{sex,jdbcType=VARCHAR}
|
</if>
|
<if test="loginName != null">
|
and login_name = #{loginName,jdbcType=VARCHAR}
|
</if>
|
<if test="idCard != null">
|
and id_card = #{idCard,jdbcType=VARCHAR}
|
</if>
|
<if test="realName != null">
|
and real_name like CONCAT("%",#{realName},"%")
|
</if>
|
<if test="password != null">
|
and password = #{password,jdbcType=VARCHAR}
|
</if>
|
<if test="email != null">
|
and email = #{email,jdbcType=VARCHAR}
|
</if>
|
<if test="mobile != null">
|
and mobile = #{mobile,jdbcType=VARCHAR}
|
</if>
|
<if test="phone != null">
|
and phone = #{phone,jdbcType=VARCHAR}
|
</if>
|
<if test="birthday != null">
|
and birthday = #{birthday,jdbcType=DATE}
|
</if>
|
<if test="logoPath != null">
|
and logo_path = #{logoPath,jdbcType=VARCHAR}
|
</if>
|
<if test="comment != null">
|
and comment = #{comment,jdbcType=VARCHAR}
|
</if>
|
<if test="status != null">
|
and status = #{status,jdbcType=TINYINT}
|
</if>
|
<if test="isValid != null">
|
and is_valid = #{isValid,jdbcType=TINYINT}
|
</if>
|
<if test="updateTime != null">
|
and update_time = #{updateTime,jdbcType=TIMESTAMP}
|
</if>
|
<if test="updateUserId != null">
|
and update_user_id = #{updateUserId,jdbcType=VARCHAR}
|
</if>
|
<!-- 模糊查询 -->
|
<!--<if test="name != null">and name like CONCAT("%",#{name},"%")</if> -->
|
</trim>
|
</where>
|
<!-- <if test="sorting != null">order by ${sorting}</if> -->
|
order by create_time DESC
|
<if test="offset != null and limit != null">
|
limit #{offset}, #{limit}
|
</if>
|
</sql>
|
|
<sql id="Base_Where_Clause_tree">
|
<where>
|
<trim prefixOverrides="and">
|
<if test="id != null"> and ID = #{id}</if>
|
<if test="type != null">
|
and type = #{type,jdbcType=TINYINT}
|
</if>
|
<if test="orgId != null">
|
and org_id = #{orgId,jdbcType=VARCHAR}
|
</if>
|
<if test="isValid != null">
|
and is_valid = #{isValid,jdbcType=TINYINT}
|
</if>
|
<!-- 模糊查询 -->
|
<!--<if test="name != null">and name like CONCAT("%",#{name},"%")</if> -->
|
</trim>
|
</where>
|
<!-- <if test="sorting != null">order by ${sorting}</if> -->
|
order by create_time DESC
|
<if test="offset != null and limit != null">
|
limit #{offset}, #{limit}
|
</if>
|
</sql>
|
|
<!-- 查询总数 -->
|
<select id="selectCount" resultType="java.lang.Long"
|
parameterType="java.util.Map">
|
select count(ID)
|
from t_sys_user
|
<include refid="Base_Where_Clause" />
|
</select>
|
|
<!-- 查询 -->
|
<select id="select" resultMap="BaseResultMap" parameterType="java.util.Map">
|
select
|
<include refid="Base_Column_List" />
|
from t_sys_user
|
<include refid="Base_Where_Clause" />
|
</select>
|
|
<select id="selectTree" resultMap="SysUserTree" parameterType="java.util.Map">
|
select
|
u.id,u.real_name,u.status, u.is_valid
|
from t_sys_user u inner join re_sys_user_role ur on ur.user_id = u.id where ur.role_id = #{roleId}
|
|
</select>
|
|
<!-- 根据ID删除 -->
|
<delete id="deleteById" parameterType="java.lang.String">
|
delete from
|
t_sys_user
|
where ID = #{id}
|
</delete>
|
|
<!-- 根据ID查询 -->
|
<select id="selectById" resultMap="BaseResultMap" parameterType="java.lang.String">
|
select
|
<include refid="Base_Column_List" />
|
from t_sys_user
|
where ID = #{id}
|
</select>
|
<!-- 添加 -->
|
<insert id="insert" parameterType="cn.com.basic.user.entity.SysUser">
|
insert into t_sys_user (id, org_id, type,
|
number, is_allow_login, sex,
|
login_name, id_card, real_name,
|
password, real_password, email, mobile,
|
phone, birthday, logo_path,
|
comment, status, is_valid,
|
create_time, create_user_id, update_time,
|
update_user_id)
|
values (#{id,jdbcType=VARCHAR}, #{orgId,jdbcType=VARCHAR},
|
#{type,jdbcType=TINYINT},
|
#{number,jdbcType=VARCHAR}, #{isAllowLogin,jdbcType=TINYINT}, #{sex,jdbcType=VARCHAR},
|
#{loginName,jdbcType=VARCHAR}, #{idCard,jdbcType=VARCHAR},
|
#{realName,jdbcType=VARCHAR},
|
#{password,jdbcType=VARCHAR},#{realPassword,jdbcType=VARCHAR},
|
#{email,jdbcType=VARCHAR}, #{mobile,jdbcType=VARCHAR},
|
#{phone,jdbcType=VARCHAR}, #{birthday,jdbcType=DATE},
|
#{logoPath,jdbcType=VARCHAR},
|
#{comment,jdbcType=VARCHAR}, #{status,jdbcType=TINYINT}, #{isValid,jdbcType=TINYINT},
|
#{createTime,jdbcType=TIMESTAMP}, #{createUserId,jdbcType=VARCHAR},
|
#{updateTime,jdbcType=TIMESTAMP},
|
#{updateUserId,jdbcType=VARCHAR})
|
</insert>
|
|
<!-- 通过ID更新 -->
|
<update id="updateByIdSelective" parameterType="cn.com.basic.user.entity.SysUser">
|
update t_sys_user
|
<set>
|
<if test="orgId != null">
|
org_id = #{orgId,jdbcType=VARCHAR},
|
</if>
|
<if test="type != null">
|
type = #{type,jdbcType=TINYINT},
|
</if>
|
<if test="number != null">
|
number = #{number,jdbcType=VARCHAR},
|
</if>
|
<if test="isAllowLogin != null">
|
is_allow_login = #{isAllowLogin,jdbcType=TINYINT},
|
</if>
|
<if test="sex != null">
|
sex = #{sex,jdbcType=VARCHAR},
|
</if>
|
<if test="loginName != null">
|
login_name = #{loginName,jdbcType=VARCHAR},
|
</if>
|
<if test="idCard != null">
|
id_card = #{idCard,jdbcType=VARCHAR},
|
</if>
|
<if test="realName != null">
|
real_name = #{realName,jdbcType=VARCHAR},
|
</if>
|
<if test="password != null">
|
password = #{password,jdbcType=VARCHAR},
|
</if>
|
<if test="realPassword != null">
|
real_password = #{realPassword,jdbcType=VARCHAR},
|
</if>
|
<if test="email != null">
|
email = #{email,jdbcType=VARCHAR},
|
</if>
|
<if test="mobile != null">
|
mobile = #{mobile,jdbcType=VARCHAR},
|
</if>
|
<if test="phone != null">
|
phone = #{phone,jdbcType=VARCHAR},
|
</if>
|
<if test="birthday != null">
|
birthday = #{birthday,jdbcType=DATE},
|
</if>
|
<if test="logoPath != null">
|
logo_path = #{logoPath,jdbcType=VARCHAR},
|
</if>
|
<if test="comment != null">
|
comment = #{comment,jdbcType=VARCHAR},
|
</if>
|
<if test="status != null">
|
status = #{status,jdbcType=TINYINT},
|
</if>
|
<if test="isValid != null">
|
is_valid = #{isValid,jdbcType=TINYINT},
|
</if>
|
<if test="updateTime != null">
|
update_time = #{updateTime,jdbcType=TIMESTAMP},
|
</if>
|
<if test="updateUserId != null">
|
update_user_id = #{updateUserId,jdbcType=VARCHAR},
|
</if>
|
</set>
|
where id = #{id,jdbcType=VARCHAR}
|
</update>
|
|
<!-- 根据IDs删除 -->
|
<delete id="deleteByIds">
|
delete from
|
t_sys_user
|
where
|
<foreach collection="array" item="id" open="id in (" close=")"
|
separator=",">
|
'${id}'
|
</foreach>
|
</delete>
|
</mapper>
|