分类品牌增删改查

This commit is contained in:
bunny 2023-12-16 10:25:37 +08:00
parent 09b8120630
commit 0657d7185c
5 changed files with 85 additions and 5 deletions

View File

@ -10,10 +10,7 @@ import com.github.pagehelper.PageInfo;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
@Tag(name = "分类品牌列表接口")
@RestController
@ -22,12 +19,34 @@ public class CategoryBrandController {
@Autowired
private CategoryBrandService categoryBrandService;
@Operation(summary = "删除分类品牌", description = "删除分类品牌")
@DeleteMapping("/deleteById/{id}")
private Result deleteById(@PathVariable Long id) {
categoryBrandService.deleteById(id);
return Result.build(null, ResultCodeEnum.SUCCESS);
}
@Operation(summary = "分类品牌修改功能", description = "分类品牌修改功能")
@PutMapping("updateById")
public Result updateById(@RequestBody CategoryBrand categoryBrand) {
categoryBrandService.updateById(categoryBrand);
return Result.build(null, ResultCodeEnum.SUCCESS);
}
@Operation(summary = "分类品牌添加", description = "分类品牌添加")
@PostMapping("save")
public Result save(@RequestBody CategoryBrand categoryBrand) {
categoryBrandService.save(categoryBrand);
return Result.build(null, ResultCodeEnum.SUCCESS);
}
@Operation(summary = "分类品牌条件分页查询", description = "分类品牌条件分页查询")
@GetMapping("/{page}/{limit}")
public Result findByPage(@PathVariable("page") Integer page,
@PathVariable("limit") Integer limit,
CategoryBrandDto categoryBrandDto) {
PageInfo<CategoryBrand> categoryBrandPageInfo = categoryBrandService.findByPage(page, limit,categoryBrandDto);
PageInfo<CategoryBrand> categoryBrandPageInfo = categoryBrandService.findByPage(page, limit, categoryBrandDto);
return Result.build(categoryBrandPageInfo, ResultCodeEnum.SUCCESS);
}
}

View File

@ -10,4 +10,13 @@ import java.util.List;
public interface CategoryBrandMapper {
// 分类品牌条件分页查询
public List<CategoryBrand> findByPage(CategoryBrandDto categoryBrandDto);
// 分类品牌添加
void save(CategoryBrand categoryBrand);
// 品牌修改功能
void updateById(CategoryBrand categoryBrand);
// 删除分类品牌
void deleteById(Long id);
}

View File

@ -7,4 +7,13 @@ import com.github.pagehelper.PageInfo;
public interface CategoryBrandService {
// 分类品牌条件分页查询
PageInfo<CategoryBrand> findByPage(Integer page, Integer limit, CategoryBrandDto categoryBrandDto);
// 分类品牌添加
void save(CategoryBrand categoryBrand);
// 品牌修改功能
void updateById(CategoryBrand categoryBrand);
// 删除分类品牌
void deleteById(Long id);
}

View File

@ -25,4 +25,23 @@ public class CategoryBrandServiceImpl implements CategoryBrandService {
return new PageInfo<CategoryBrand>(categoryBrandDtoList);
}
// 分类品牌添加
@Override
public void save(CategoryBrand categoryBrand) {
categoryBrandMapper.save(categoryBrand);
}
// 品牌修改功能
@Override
public void updateById(CategoryBrand categoryBrand) {
categoryBrandMapper.updateById(categoryBrand);
}
// 删除分类品牌
@Override
public void deleteById(Long id) {
categoryBrandMapper.deleteById(id);
}
}

View File

@ -8,6 +8,30 @@
id,brand_id,category_id,create_time,update_time,is_deleted
</sql>
<!-- 分类品牌添加 -->
<insert id="save">
insert into category_brand (id, brand_id, category_id, create_time, update_time, is_deleted)
values (#{id},#{brandId},#{categoryId},now(),now(),0);
</insert>
<!-- 品牌修改功能 -->
<update id="updateById">
update category_brand set
<if test="brandId != null and brandId != ''">
brand_id=#{brandId}
</if>
<if test="categoryId !=null and categoryId!=''">
category_id=#{categoryId}
</if>
update_timen==now()
where id=#{id}
</update>
<!-- 删除分类品牌 -->
<delete id="deleteById">
update category_brand set update_time=now(),is_deleted=1 where id=#{id}
</delete>
<!-- 分类品牌条件分页查询 -->
<select id="findByPage" resultType="cn.bunny.common.spzx.model.entity.product.CategoryBrand">
select cb.*,c.name as categoryName,b.name as brandName,b.logo