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));
|
}
|
|
}
|