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.

46 lines
1.6 KiB

<?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.UserMapper">
<insert id="save">
insert into user(name, username, age, sex, phone, address, account)
values(#{name}, #{username}, #{age}, #{sex}, #{phone}, #{address}, #{account})
</insert>
<update id="updateById">
update user set name = #{name}, age = #{age}, sex = #{sex}, phone = #{phone}, address = #{address}, account = #{account}, status = #{status},
updatetime = #{updatetime} where id = #{id}
</update>
<delete id="deleteById">
delete from user where id = #{id}
</delete>
<select id="list" resultType="com.example.springboot.entity.User">
select * from user
</select>
<select id="listByCondition" resultType="com.example.springboot.entity.User">
select * from user
<where>
<if test="name != null and name != ''">
name like concat('%', #{ name }, '%')
</if>
<if test="phone != null and phone != ''">
and phone like concat('%', #{ phone }, '%')
</if>
</where>
order by id desc
</select>
<select id="getById" resultType="com.example.springboot.entity.User">
select * from user where id = #{id}
</select>
<select id="getByUsername" resultType="com.example.springboot.entity.User">
select * from user where username = #{username}
</select>
</mapper>