rentaiming
2024-05-27 43c263df4d8ce0cc830f287780c29db8a2b47f0f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
package com.ruoyi.goods.controller.management;
 
 
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.utils.page.PageDTO;
import com.ruoyi.goods.controller.management.dto.GoodsBrandDTO;
import com.ruoyi.goods.controller.management.dto.GoodsBrandQuery;
import com.ruoyi.goods.controller.management.vo.GoodsBrandVO;
import com.ruoyi.goods.service.IGoodsBrandService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
 
/**
 * <p>
 * 品牌表 前端控制器
 * </p>
 *
 * @author mitao
 * @since 2024-05-16
 */
@Slf4j
@RestController
@RequestMapping("/mgt/goods-brand")
@RequiredArgsConstructor
@Api(value = "管理后台商品品牌相关接口", tags = {"管理后台接口"})
public class MgtGoodsBrandController {
 
    private final IGoodsBrandService goodsBrandService;
 
    /**
     * 获取商品品牌列表的分页数据
     *
     * @param query 商品信息查询对象,用于指定分页查询的条件
     * @return 返回一个包含商品品牌分页数据的结果对象,其中包含了分页信息和商品品牌列表
     */
    @ApiOperation(value = "获取商品品牌列表的分页数据", notes = "获取商品品牌列表的分页数据")
    @PostMapping("/page")
    public R<PageDTO<GoodsBrandVO>> getGoodsBrandPage(
            @Validated @RequestBody GoodsBrandQuery query) {
        return R.ok(goodsBrandService.getGoodsBrandPage(query));
    }
 
    /**
     * 添加/编辑商品品牌
     *
     * @param dto 商品品牌数据传输对象,包含商品品牌的详细信息,通过验证后将数据持久化。
     * @return 返回操作结果,如果操作成功,返回一个成功的标识。
     */
    @ApiOperation(value = "添加/编辑 商品品牌", notes = "添加/编辑 商品品牌")
    @PostMapping("/save")
    public R<Void> saveGoodsBrand(@Validated @RequestBody GoodsBrandDTO dto) {
        // 调用服务层方法,保存商品品牌信息
        goodsBrandService.saveGoodsBrand(dto);
        return R.ok();
    }
 
    /**
     * 删除商品品牌
     *
     * @param id 商品品牌的ID,用于指定要删除的品牌
     * @return 返回操作结果,如果删除成功,则返回成功状态
     */
    @ApiOperation(value = "删除商品品牌", notes = "删除商品品牌")
    @DeleteMapping("/{id}")
    public R<Void> deleteGoodsBrand(@PathVariable("id") Long id) {
        // 通过ID删除商品品牌
        goodsBrandService.removeById(id);
        return R.ok();
    }
    
}