17 小时以前 2b8f88856e90e530ddbfce88aea107a0ec894d5d
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
package cn.iocoder.yudao.module.srm.controller.admin.supplier;
 
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.srm.dal.dataobject.SrmSupplierCategoryDO;
import cn.iocoder.yudao.module.srm.service.supplier.SrmSupplierCategoryService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
 
import java.util.List;
 
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
 
@Tag(name = "管理后台 - SRM 供应商分类")
@RestController
@RequestMapping("/srm/supplier-category")
@Validated
public class SrmSupplierCategoryController {
 
    @Resource
    private SrmSupplierCategoryService supplierCategoryService;
 
    @PostMapping("/assign")
    @Operation(summary = "分配供应商分类")
    @PreAuthorize("@ss.hasPermission('srm:supplier:update')")
    public CommonResult<Boolean> assignCategory(@RequestParam("supplierId") Long supplierId,
                                                @RequestParam("categoryId") Long categoryId,
                                                @RequestParam("categoryName") String categoryName) {
        supplierCategoryService.assignCategory(supplierId, categoryId, categoryName);
        return success(true);
    }
 
    @DeleteMapping("/remove")
    @Operation(summary = "移除供应商分类")
    @PreAuthorize("@ss.hasPermission('srm:supplier:update')")
    public CommonResult<Boolean> removeCategory(@RequestParam("id") Long id) {
        supplierCategoryService.removeCategory(id);
        return success(true);
    }
 
    @GetMapping("/list-by-supplier")
    @Operation(summary = "根据供应商ID获取分类列表")
    @PreAuthorize("@ss.hasPermission('srm:supplier:query')")
    public CommonResult<List<SrmSupplierCategoryDO>> getCategoryList(@RequestParam("supplierId") Long supplierId) {
        return success(supplierCategoryService.getCategoryListBySupplierId(supplierId));
    }
 
}