dev-v2 #3

Merged
bunny merged 122 commits from dev-v2 into master-v2 2024-03-30 23:40:58 +08:00
5 changed files with 51 additions and 0 deletions
Showing only changes of commit a7afceb704 - Show all commits

View File

@ -29,4 +29,11 @@ public class BrandController {
brandService.save(brand); brandService.save(brand);
return Result.success(); 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 品牌实体类 * @param brand 品牌实体类
*/ */
void save(Brand brand); void save(Brand brand);
/**
* 修改品牌
*
* @param brand 品牌实体类
*/
void updateById(Brand brand);
} }

View File

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

View File

@ -1,8 +1,10 @@
package com.atguigu.spzx.manger.service.impl; package com.atguigu.spzx.manger.service.impl;
import com.atguigu.constant.MessageConstant;
import com.atguigu.spzx.manger.mapper.BrandMapper; import com.atguigu.spzx.manger.mapper.BrandMapper;
import com.atguigu.spzx.manger.service.BrandService; import com.atguigu.spzx.manger.service.BrandService;
import com.atguigu.spzx.model.entity.product.Brand; import com.atguigu.spzx.model.entity.product.Brand;
import com.atguigu.utils.StringEmptyUtil;
import com.github.pagehelper.Page; import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
@ -15,6 +17,8 @@ import java.util.List;
public class BrandServiceImpl implements BrandService { public class BrandServiceImpl implements BrandService {
@Autowired @Autowired
private BrandMapper brandMapper; private BrandMapper brandMapper;
@Autowired
private StringEmptyUtil emptyUtil;
/** /**
* 品牌列表查询 * 品牌列表查询
@ -41,4 +45,16 @@ public class BrandServiceImpl implements BrandService {
public void save(Brand brand) { public void save(Brand brand) {
brandMapper.save(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); values (#{id}, #{name}, #{logo}, now(), now(), 0);
</insert> </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 id="findByPage" resultType="com.atguigu.spzx.model.entity.product.Brand">
select select