| | |
| | | package com.yuanchu.limslaboratory.controller; |
| | | |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.yuanchu.limslaboratory.pojo.SerialNumber; |
| | | import com.yuanchu.limslaboratory.service.SerialNumberService; |
| | | import com.yuanchu.limslaboratory.utils.JackSonUtil; |
| | | import com.yuanchu.limslaboratory.utils.MyUtil; |
| | | import com.yuanchu.limslaboratory.utils.RedisUtil; |
| | | import com.yuanchu.limslaboratory.vo.Result; |
| | | import io.swagger.annotations.Api; |
| | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | |
| | | * @author 江苏鵷雏网络科技有限公司 |
| | | * @since 2023-07-11 |
| | | */ |
| | | @Api(tags = "标准库-->型号操作") |
| | | @Api(tags = "标准库-->2、型号") |
| | | @RestController |
| | | @RequestMapping("/serial-number") |
| | | public class SerialNumberController { |
| | |
| | | @Autowired |
| | | private SerialNumberService serialNumberService; |
| | | |
| | | @ApiOperation("标准库-->添加型号") |
| | | @ApiOperation("添加型号") |
| | | @PostMapping("/add") |
| | | public Result<?> addSerialNumberInformation(@RequestHeader("X-Token") String token,@RequestBody SerialNumber serialNumber) throws Exception { |
| | | Object object = RedisUtil.get(token); |
| | |
| | | return Result.fail("添加【"+ serialNumber.getName() +"】失败!"); |
| | | } |
| | | |
| | | @ApiOperation("标准库-->点击侧边栏标准,查询所有型号") |
| | | @ApiOperation("点击侧边栏标准,分页查询所有型号") |
| | | @ApiImplicitParams(value = { |
| | | @ApiImplicitParam(value = "标准号/标准名称", name = "IdOrNameOfSerialNumber", dataTypeClass = String.class), |
| | | @ApiImplicitParam(value = "标准号Id", name = "standardsId", dataTypeClass = String.class, required = true) |
| | | @ApiImplicitParam(value = "型号/型号名称", name = "IdOrNameOfSerialNumber", dataTypeClass = String.class), |
| | | @ApiImplicitParam(value = "标准号Id", name = "standardsId", dataTypeClass = String.class, required = true), |
| | | @ApiImplicitParam(name = "pageNo", value = "起始页", dataTypeClass = Integer.class, required = true), |
| | | @ApiImplicitParam(name = "pageSize", value = "每一页数量", dataTypeClass = Integer.class, required = true), |
| | | }) |
| | | @GetMapping("/list") |
| | | public Result<?> listSerialNumberInformation(String IdOrNameOfSerialNumber, String standardsId){ |
| | | List<Map<String, Object>> selectStandards= serialNumberService.listSerialNumberInformation(IdOrNameOfSerialNumber,standardsId); |
| | | return Result.success(selectStandards); |
| | | public Result<?> listSerialNumberInformation(String IdOrNameOfSerialNumber, String standardsId, Integer pageNo, Integer pageSize){ |
| | | IPage<Map<String, Object>> selectStandards= serialNumberService.listSerialNumberInformation(IdOrNameOfSerialNumber,standardsId, new Page<Object>(pageNo, pageSize)); |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("row", selectStandards.getRecords()); |
| | | map.put("total", selectStandards.getTotal()); |
| | | return Result.success(map); |
| | | } |
| | | |
| | | @ApiOperation("根据Id修改型号") |
| | | @PutMapping("/update") |
| | | public Result<?> updateSerialNumberInformation(@RequestHeader("X-Token") String token, @RequestBody SerialNumber serialNumber) throws Exception { |
| | | Object object = RedisUtil.get(token); |
| | | Map<String, Object> unmarshal = JackSonUtil.unmarshal(JackSonUtil.marshal(object), Map.class); |
| | | serialNumber.setUserId((Integer) unmarshal.get("id")); |
| | | Integer isUpdateSerialNumberSuccess = serialNumberService.updateSerialNumberInformation(serialNumber); |
| | | if (isUpdateSerialNumberSuccess == 1){ |
| | | return Result.success("更新成功!"); |
| | | } |
| | | return Result.fail("更新失败!"); |
| | | } |
| | | |
| | | @ApiOperation("根据Id删除型号") |
| | | @DeleteMapping("/delete") |
| | | public Result<?> deleteSerialNumberInformation(String serialNumberId) { |
| | | Integer isDeleteSerialNumberSuccess = serialNumberService.deleteSerialNumberInformation(serialNumberId); |
| | | if (isDeleteSerialNumberSuccess == 1){ |
| | | return Result.success("删除成功!"); |
| | | } |
| | | return Result.fail("删除失败!"); |
| | | } |
| | | } |