sxwz2.0/src/main/resources/mapper/SysUserMapper.xml

209 lines
7.5 KiB
XML

<?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.kexue.skills.mapper.SysUserMapper">
<resultMap type="com.kexue.skills.entity.SysUser" id="SysUserMap">
<result property="userId" column="user_id" jdbcType="INTEGER"/>
<result property="userName" column="user_name" jdbcType="VARCHAR"/>
<result property="pwd" column="pwd" jdbcType="VARCHAR"/>
<result property="realName" column="real_name" jdbcType="VARCHAR"/>
<result property="tel" column="tel" jdbcType="VARCHAR"/>
<result property="email" column="email" jdbcType="VARCHAR"/>
<result property="salt" column="salt" jdbcType="VARCHAR"/>
<result property="remark" column="remark" jdbcType="VARCHAR"/>
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
<result property="enable" column="enable" jdbcType="OTHER"/>
<result property="deleteFlag" column="delete_flag" jdbcType="OTHER"/>
</resultMap>
<!--查询单个-->
<select id="queryById" resultMap="SysUserMap">
select
user_id, user_name, pwd, real_name, tel, email, salt, remark, create_time, enable, delete_flag
from sys_user
where user_id = #{userId}
</select>
<!--查询指定行数据-->
<select id="getPageList" resultMap="SysUserMap">
select
user_id, user_name, pwd, real_name, tel, email, salt, remark, create_time, enable, delete_flag
from sys_user
<where>
<if test="userId != null">
and user_id = #{userId}
</if>
<if test="userName != null and userName != ''">
and user_name = #{userName}
</if>
<if test="pwd != null and pwd != ''">
and pwd = #{pwd}
</if>
<if test="realName != null and realName != ''">
and real_name = #{realName}
</if>
<if test="tel != null and tel != ''">
and tel = #{tel}
</if>
<if test="email != null and email != ''">
and email = #{email}
</if>
<if test="salt != null and salt != ''">
and salt = #{salt}
</if>
<if test="remark != null and remark != ''">
and remark = #{remark}
</if>
<if test="createTime != null">
and create_time = #{createTime}
</if>
<if test="enable != null">
and enable = #{enable}
</if>
<if test="deleteFlag != null">
and delete_flag = #{deleteFlag}
</if>
</where>
</select>
<!--查询指定行数据-->
<select id="queryAllByLimit" resultMap="SysUserMap">
select
user_id, user_name, pwd, real_name, tel, email, salt, remark, create_time, enable, delete_flag
from sys_user
limit #{offset}, #{limit}
</select>
<!--通过实体作为筛选条件查询-->
<select id="queryAll" resultMap="SysUserMap">
select
user_id, user_name, pwd, real_name, tel, email, salt, remark, create_time, enable, delete_flag
from sys_user
<where>
<if test="userId != null">
and user_id = #{userId}
</if>
<if test="userName != null and userName != ''">
and user_name = #{userName}
</if>
<if test="pwd != null and pwd != ''">
and pwd = #{pwd}
</if>
<if test="realName != null and realName != ''">
and real_name = #{realName}
</if>
<if test="tel != null and tel != ''">
and tel = #{tel}
</if>
<if test="email != null and email != ''">
and email = #{email}
</if>
<if test="salt != null and salt != ''">
and salt = #{salt}
</if>
<if test="remark != null and remark != ''">
and remark = #{remark}
</if>
<if test="createTime != null">
and create_time = #{createTime}
</if>
<if test="enable != null">
and enable = #{enable}
</if>
<if test="deleteFlag != null">
and delete_flag = #{deleteFlag}
</if>
</where>
</select>
<!--新增所有列-->
<insert id="insert" keyProperty="userId" useGeneratedKeys="true">
insert into sys_user(user_name, pwd, real_name, tel, email, salt, remark, create_time, enable, delete_flag)
values (#{userName}, #{pwd}, #{realName}, #{tel}, #{email}, #{salt}, #{remark}, #{createTime}, #{enable}, #{deleteFlag})
</insert>
<insert id="insertBatch" parameterType="java.util.List">
INSERT INTO sys_user (
<!-- 动态生成列名 -->
<foreach collection="list" item="item" index="index" open="" close="" separator="" >
<if test="index == 0">
<foreach collection="tableInfo.fullColumn" item="column" open="" close="" separator=",">
${column.name}
</foreach>
</if>
</foreach>
) VALUES
<!-- 动态生成值 -->
<foreach collection="list" item="item" index="index" open="" close="" separator=",">
(
<foreach collection="tableInfo.fullColumn" item="column" open="" close="" separator=",">
#{item.${column.property}}
</foreach>
)
</foreach>
</insert>
<!--通过主键修改数据-->
<update id="update">
update sys_user
<set>
<if test="userName != null and userName != ''">
user_name = #{userName},
</if>
<if test="pwd != null and pwd != ''">
pwd = #{pwd},
</if>
<if test="realName != null and realName != ''">
real_name = #{realName},
</if>
<if test="tel != null and tel != ''">
tel = #{tel},
</if>
<if test="email != null and email != ''">
email = #{email},
</if>
<if test="salt != null and salt != ''">
salt = #{salt},
</if>
<if test="remark != null and remark != ''">
remark = #{remark},
</if>
<if test="createTime != null">
create_time = #{createTime},
</if>
<if test="enable != null">
enable = #{enable},
</if>
<if test="deleteFlag != null">
delete_flag = #{deleteFlag},
</if>
</set>
where user_id = #{userId}
</update>
<!--通过主键删除-->
<delete id="deleteById">
delete from sys_user where user_id = #{userId}
</delete>
<select id="getByUsername" resultMap="SysUserMap">
select
user_id, user_name, pwd, real_name, tel, email, salt, remark, create_time, enable, delete_flag
from sys_user
where user_name = #{userName}
and delete_flag = 0
limit 1
</select>
<select id="getByTel" resultMap="SysUserMap">
select
user_id, user_name, pwd, real_name, tel, email, salt, remark, create_time, enable, delete_flag
from sys_user
where tel = #{tel}
and delete_flag = 0
limit 1
</select>
</mapper>