feat(新增): 品牌添加

Signed-off-by: bunny <1319900154@qq.com>
This commit is contained in:
bunny 2024-03-25 22:24:01 +08:00
parent cd1e39271a
commit a7afceb704
5 changed files with 51 additions and 0 deletions

View File

@ -29,4 +29,11 @@ public class BrandController {
brandService.save(brand);
return Result.success();
}
@Operation(summary = "修改品牌", description = "修改品牌")
@PutMapping("updateById")
public Result<Brand> updateById(@RequestBody Brand brand) {
brandService.updateById(brand);
return Result.success();
}
}

View File

@ -18,4 +18,11 @@ public interface BrandMapper {
* @param brand 品牌实体类
*/
void save(Brand brand);
/**
* 修改品牌
*
* @param brand 品牌实体类
*/
void updateById(Brand brand);
}

View File

@ -19,4 +19,11 @@ public interface BrandService {
* @param brand 品牌实体类
*/
void save(Brand brand);
/**
* 修改品牌
*
* @param brand 品牌实体类
*/
void updateById(Brand brand);
}

View File

@ -1,8 +1,10 @@
package com.atguigu.spzx.manger.service.impl;
import com.atguigu.constant.MessageConstant;
import com.atguigu.spzx.manger.mapper.BrandMapper;
import com.atguigu.spzx.manger.service.BrandService;
import com.atguigu.spzx.model.entity.product.Brand;
import com.atguigu.utils.StringEmptyUtil;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
@ -15,6 +17,8 @@ import java.util.List;
public class BrandServiceImpl implements BrandService {
@Autowired
private BrandMapper brandMapper;
@Autowired
private StringEmptyUtil emptyUtil;
/**
* 品牌列表查询
@ -41,4 +45,16 @@ public class BrandServiceImpl implements BrandService {
public void save(Brand brand) {
brandMapper.save(brand);
}
/**
* 修改品牌
*
* @param brand 品牌实体类
*/
@Override
public void updateById(Brand brand) {
emptyUtil.isEmpty(brand, MessageConstant.DELETE_ID_IS_NOT_EMPTY);
brandMapper.updateById(brand);
}
}

View File

@ -12,6 +12,20 @@
values (#{id}, #{name}, #{logo}, now(), now(), 0);
</insert>
<!-- 修改品牌 -->
<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>
<!-- 查找分页品牌 -->
<select id="findByPage" resultType="com.atguigu.spzx.model.entity.product.Brand">
select