2024-03-25 22:06:17 +08:00
|
|
|
<?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.atguigu.spzx.manger.mapper.BrandMapper">
|
|
|
|
<!-- 用于select查询公用抽取的列 -->
|
|
|
|
<sql id="columns">
|
|
|
|
id,name,logo,create_time,update_time,is_deleted
|
|
|
|
</sql>
|
|
|
|
|
2024-03-25 22:12:22 +08:00
|
|
|
<!-- 品牌添加 -->
|
|
|
|
<insert id="save">
|
|
|
|
insert into brand (id, name, logo, create_time, update_time, is_deleted)
|
|
|
|
values (#{id}, #{name}, #{logo}, now(), now(), 0);
|
|
|
|
</insert>
|
|
|
|
|
2024-03-25 22:24:01 +08:00
|
|
|
<!-- 修改品牌 -->
|
|
|
|
<update id="updateById">
|
|
|
|
update brand
|
|
|
|
set
|
|
|
|
<if test="name != null and name != ''">
|
|
|
|
name = #{name},
|
|
|
|
</if>
|
|
|
|
<if test="logo != null and logo != ''">
|
|
|
|
logo = #{logo},
|
|
|
|
</if>
|
|
|
|
update_time = now()
|
|
|
|
where id = #{id}
|
|
|
|
</update>
|
|
|
|
|
2024-03-25 22:31:49 +08:00
|
|
|
<!-- 根据id删除品牌 -->
|
|
|
|
<update id="deleteById">
|
|
|
|
update brand
|
|
|
|
set is_deleted = 1,
|
|
|
|
update_time = now()
|
|
|
|
where id = #{id}
|
|
|
|
</update>
|
|
|
|
|
2024-03-25 22:06:17 +08:00
|
|
|
<!-- 查找分页品牌 -->
|
|
|
|
<select id="findByPage" resultType="com.atguigu.spzx.model.entity.product.Brand">
|
|
|
|
select
|
|
|
|
<include refid="columns"/>
|
|
|
|
from brand
|
|
|
|
where is_deleted = 0
|
|
|
|
order by id desc
|
|
|
|
</select>
|
2024-03-26 10:22:22 +08:00
|
|
|
|
|
|
|
<!-- 品牌列表 -->
|
|
|
|
<select id="findAll" resultType="com.atguigu.spzx.model.entity.product.Brand">
|
|
|
|
select
|
|
|
|
<include refid="columns"/>
|
|
|
|
from brand where is_deleted = 0 order by id desc
|
|
|
|
</select>
|
2024-03-25 22:06:17 +08:00
|
|
|
</mapper>
|