You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

56 lines
2.0 KiB

9 months ago
<?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.example.springboot.mapper.AdminMapper">
<insert id="save">
insert into admin(username, password, phone, email)
values(#{username}, #{password}, #{phone}, #{email})
</insert>
<update id="updateById">
update admin set username = #{username}, phone = #{phone}, email = #{email}, updatetime = #{updatetime}, status = #{status} where id = #{id}
</update>
<update id="updatePassword">
update admin set password = #{newPass} where username = #{username} and password = #{password}
</update>
<delete id="deleteById">
delete from admin where id = #{id}
</delete>
<select id="list" resultType="com.example.springboot.entity.Admin">
select * from admin order by id desc
</select>
<select id="listByCondition" resultType="com.example.springboot.entity.Admin">
select * from admin
<where>
<if test="username != null and username != ''">
username like concat('%', #{username}, '%')
</if>
<if test="phone != null and phone != ''">
and phone like concat('%', #{ phone }, '%')
</if>
<if test="email != null and email != ''">
and email like concat('%', #{email}, '%')
</if>
</where>
order by id desc
</select>
<select id="getById" resultType="com.example.springboot.entity.Admin">
select * from admin where id = #{id}
</select>
<select id="getByUsernameAndPassword" resultType="com.example.springboot.entity.Admin">
select * from admin where username = #{username} and password = #{password}
</select>
<select id="getByUsername" resultType="com.example.springboot.entity.Admin">
select * from admin where username = #{username}
</select>
</mapper>