package com.yuanchu.mom.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yuanchu.mom.annotation.CustomClazzName;
import com.yuanchu.mom.annotation.ValueAuth;
import com.yuanchu.mom.annotation.ValueClassify;
import com.yuanchu.mom.common.GetLook;
import com.yuanchu.mom.pojo.SupplierManagement;
import com.yuanchu.mom.service.ProcurementSuppliesContentsService;
import com.yuanchu.mom.service.SupplierManagementService;
import com.yuanchu.mom.vo.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;
/**
*
* 前端控制器
*
*
* @author 芯导软件(江苏)有限公司
* @since 2024-11-15 02:46:45
*/
@Api(tags = "供应商管理")
@RestController
@RequestMapping("/supplierManagement")
@AllArgsConstructor
//@CustomClazzName(name = "供应商管理", index = 10)
public class SupplierManagementController {
@Autowired
private SupplierManagementService supplierManagementService;
@Autowired
private ProcurementSuppliesContentsService procurementSuppliesContentsService;
private GetLook getLook;
@ValueAuth
@ApiOperation("查询供方名录")
@GetMapping("/selectSupplierManagementByParentId/{parentId}")
public Result> selectSupplierManagementByParentId(@PathVariable Integer parentId) throws Exception {
return Result.success(supplierManagementService.selectSupplierManagementByParentId(parentId));
}
@ValueClassify(value = "供应商管理")
@ApiOperation("分页查询合格供方名录")
@GetMapping("/selectQualifiedSupplierManagementPage")
public Result> selectQualifiedSupplierManagement(SupplierManagement supplierManagement, Page page) throws Exception {
return Result.success(supplierManagementService.selectQualifiedSupplierManagement(page, supplierManagement));
}
@ValueAuth
@ApiOperation("根据ID查询供应商")
@GetMapping("/selectQualifiedSupplierManagementById/{supplierManagementId}")
public Result> selectQualifiedSupplierManagementById(@PathVariable Integer supplierManagementId) throws Exception {
return Result.success(supplierManagementService.selectQualifiedSupplierManagementById(supplierManagementId));
}
@ValueClassify(value = "供应商管理")
@ApiOperation("新增供应商")
@PostMapping("/addSupplierManagement")
public Result addSupplierManagement(@RequestBody SupplierManagement supplierManagement) {
Map map1 = getLook.selectPowerByMethodAndUserId("selectRoleLists");
supplierManagement.setCreateUser(map1.get("userId"));
return Result.success(supplierManagementService.save(supplierManagement));
}
@ValueClassify(value = "供应商管理")
@ApiOperation("修改供应商")
@PostMapping("/updateSupplierManagement")
public Result updateSupplierManagement(@RequestBody SupplierManagement supplierManagement) {
return Result.success(supplierManagementService.updateById(supplierManagement));
}
@ValueClassify(value = "供应商管理")
@ApiOperation("删除供应商")
@PostMapping("/delSupplierManagement/{id}")
public Result delSupplierManagement(@PathVariable Integer id) {
return Result.success(supplierManagementService.removeById(id));
}
@ValueClassify(value = "供应商管理")
@ApiOperation("导出供应商")
@PostMapping("/exportSupplierManagement/{parentId}")
public void exportSupplierManagement(@PathVariable Integer parentId, HttpServletResponse response) throws Exception {
supplierManagementService.exportSupplierManagement(parentId, response);
}
@ValueAuth
@ApiOperation("查询全部供方名录")
@GetMapping("/selectSupplierManagementAll")
public Result> selectSupplierManagementAll() throws Exception {
return Result.success(supplierManagementService.selectSupplierManagementAll());
}
}