| | |
| | | package com.yuanchu.limslaboratory.controller; |
| | | |
| | | |
| | | import com.yuanchu.limslaboratory.pojo.SerialNumber; |
| | | import com.yuanchu.limslaboratory.pojo.Product; |
| | | import com.yuanchu.limslaboratory.service.ProductService; |
| | | import com.yuanchu.limslaboratory.utils.JackSonUtil; |
| | | import com.yuanchu.limslaboratory.utils.RedisUtil; |
| | | import com.yuanchu.limslaboratory.vo.Result; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import io.swagger.annotations.*; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.util.ObjectUtils; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | |
| | | * @author 江苏鵷雏网络科技有限公司 |
| | | * @since 2023-07-17 |
| | | */ |
| | | @Api(tags = "标准库-->5、规格-->查看-->子模块") |
| | | @RestController |
| | | @RequestMapping("/product") |
| | | public class ProductController { |
| | |
| | | @Autowired |
| | | private ProductService productService; |
| | | |
| | | @ApiOperation("添加测试标准") |
| | | @PostMapping("/add") |
| | | public Result<?> addProductInformation(@RequestHeader("X-Token") String token, @RequestBody Product product) throws Exception { |
| | | Object userMessage = RedisUtil.get(token); |
| | | if (!ObjectUtils.isEmpty(userMessage)){ |
| | | Map<String, Object> unmarshal = JackSonUtil.unmarshal(JackSonUtil.marshal(userMessage), Map.class); |
| | | product.setUserId(Integer.parseInt(unmarshal.get("id").toString())); |
| | | } else { |
| | | return Result.fail("对不起,Token错误!"); |
| | | } |
| | | Integer isProductSuccess = productService.addProductInformation(product); |
| | | if (isProductSuccess == 1) { |
| | | return Result.success("添加物料【"+ product.getName() +"】成功!"); |
| | | } |
| | | return Result.fail("添加物料【"+ product.getName() +"】失败!"); |
| | | } |
| | | |
| | | @ApiOperation("根据物料ID查询所有测试标准") |
| | | @GetMapping("/list") |
| | | @ApiImplicitParams(value = { |
| | | @ApiImplicitParam(value = "物料ID", name = "materialId", dataTypeClass = String.class) |
| | | }) |
| | | public Result<?> getListProductInformation(String materialId) { |
| | | List<Map<String, Object>> listMaterialInformation = productService.getListProductInformation(materialId); |
| | | return Result.success(listMaterialInformation); |
| | | } |
| | | |
| | | @ApiOperation("根据测试标准ID查询基本信息") |
| | | @GetMapping("/productId") |
| | | @ApiImplicitParams(value = { |
| | | @ApiImplicitParam(value = "测试标准ID", name = "productId", dataTypeClass = String.class) |
| | | }) |
| | | public Result<?> getProductInformation(Integer productId) { |
| | | Map<String, Object> productInformation = productService.getProductInformation(productId); |
| | | return Result.success(productInformation); |
| | | } |
| | | |
| | | @ApiOperation("删除测试标准模块数据") |
| | | @DeleteMapping("/delete") |
| | | @ApiImplicitParams(value = { |
| | | @ApiImplicitParam(value = "测试标准ID", name = "productId", dataTypeClass = String.class) |
| | | }) |
| | | public Result<?> deleteProductInformation(Integer productId) { |
| | | Integer isDeleteProduct = productService.deleteProductInformation(productId); |
| | | if (isDeleteProduct == 1) { |
| | | return Result.success("删除成功!"); |
| | | } |
| | | return Result.fail("删除失败!"); |
| | | } |
| | | |
| | | @ApiOperation("根据测试标准Id修改数据") |
| | | @PutMapping("/update") |
| | | public Result<?> updateMaterialInformation(@RequestBody Product product) { |
| | | Integer isUpdateMaterialSuccess = productService.updateMaterialInformation(product); |
| | | if (isUpdateMaterialSuccess == 1) { |
| | | return Result.success("修改【"+ product.getName() +"】成功!"); |
| | | } |
| | | return Result.fail("修改【"+ product.getName() +"】失败!"); |
| | | } |
| | | } |