AdminMapper MyBatis 映射文件 - 用于管理系统管理员信息
<sql id="Base_Column_List">
id, username, password, name, telephone, email, role, create_time, update_time
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from t_admin
where id = #{id,jdbcType=INTEGER}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
delete from t_admin
where id = #{id,jdbcType=INTEGER}
</delete>
<insert id="insert" parameterType="com.xiaoniucr.entity.Admin">
insert into t_admin (id, username, password, name, telephone,email,
role, create_time, update_time
)
values (#{id,jdbcType=INTEGER}, #{username,jdbcType=VARCHAR}, #{password,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR},#{telephone,jdbcType=VARCHAR},#{email,jdbcType=VARCHAR},
#{role,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}
)
</insert>
<insert id="insertSelective" parameterType="com.xiaoniucr.entity.Admin">
insert into t_admin
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="username != null">
username,
</if>
<if test="password != null">
password,
</if>
<if test="name != null">
name,
</if>
<if test="telephone != null">
telephone,
</if>
<if test="email != null">
email,
</if>
<if test="role != null">
role,
</if>
<if test="createTime != null">
create_time,
</if>
<if test="updateTime != null">
update_time,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=INTEGER},
</if>
<if test="username != null">
#{username,jdbcType=VARCHAR},
</if>
<if test="password != null">
#{password,jdbcType=VARCHAR},
</if>
<if test="name != null">
#{name,jdbcType=VARCHAR},
</if>
<if test="telephone != null">
#{telephone,jdbcType=VARCHAR},
</if>
<if test="email != null">
#{email,jdbcType=VARCHAR},
</if>
<if test="role != null">
#{role,jdbcType=INTEGER},
</if>
<if test="createTime != null">
#{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateTime != null">
#{updateTime,jdbcType=TIMESTAMP},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.xiaoniucr.entity.Admin">
update t_admin
<set>
<if test="username != null">
username = #{username,jdbcType=VARCHAR},
</if>
<if test="password != null">
password = #{password,jdbcType=VARCHAR},
</if>
<if test="name != null">
name = #{name,jdbcType=VARCHAR},
</if>
<if test="telephone != null">
telephone = #{telephone,jdbcType=VARCHAR},
</if>
<if test="email != null">
email = #{email,jdbcType=VARCHAR},
</if>
<if test="role != null">
role = #{role,jdbcType=INTEGER},
</if>
<if test="createTime != null">
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateTime != null">
update_time = #{updateTime,jdbcType=TIMESTAMP},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.xiaoniucr.entity.Admin">
update t_admin
set username = #{username,jdbcType=VARCHAR},
password = #{password,jdbcType=VARCHAR},
name = #{name,jdbcType=VARCHAR},
telephone = #{telephone,jdbcType=VARCHAR},
email = #{email,jdbcType=VARCHAR},
role = #{role,jdbcType=INTEGER},
create_time = #{createTime,jdbcType=TIMESTAMP},
update_time = #{updateTime,jdbcType=TIMESTAMP}
where id = #{id,jdbcType=INTEGER}
</update>
<select id="findList" resultMap="BaseResultMap">
select * from t_admin
<where>
<if test="username != null and username !=''">
and username like concat('%',#{username},'%')
</if>
<if test="name != null and name != ''">
and name like concat('%',#{name},'%')
</if>
<if test="role != null and role != ''">
and role = #{role}
</if>
</where>
order by create_time desc
limit #{start},#{limit};
</select>
<select id="findTotal" resultType="java.lang.Integer">
select count(id) from t_admin
<where>
<if test="username != null and username !=''">
and username like concat('%',#{username},'%')
</if>
<if test="name != null and name != ''">
and name like concat('%',#{name},'%')
</if>
<if test="role != null and role != ''">
and role = #{role}
</if>
</where>
</select>
<select id="selectByUsername" resultMap="BaseResultMap">
select * from t_admin where username = #{username};
</select>
<select id="findAllFix" resultType="com.xiaoniucr.entity.Admin">
select * from t_admin where role = 1 order by create_time desc;
</select>
原文地址: https://www.cveoy.top/t/topic/mQV9 著作权归作者所有。请勿转载和采集!