| | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.yuanchu.limslaboratory.pojo.Specifications; |
| | | import com.yuanchu.limslaboratory.pojo.Standards; |
| | | import com.yuanchu.limslaboratory.service.SpecificationsService; |
| | | import com.yuanchu.limslaboratory.utils.JackSonUtil; |
| | | import com.yuanchu.limslaboratory.utils.MyUtil; |
| | | import com.yuanchu.limslaboratory.utils.RedisUtil; |
| | | import com.yuanchu.limslaboratory.vo.ListSpecificationsInformation; |
| | | import com.yuanchu.limslaboratory.vo.Result; |
| | | import com.yuanchu.limslaboratory.pojo.dto.UpdateSpeStateSpecificationsDto; |
| | | import com.yuanchu.limslaboratory.pojo.dto.UpdateSpecificationsInformationDto; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.util.ObjectUtils; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Objects; |
| | | |
| | |
| | | * @author 江苏鵷雏网络科技有限公司 |
| | | * @since 2023-07-11 |
| | | */ |
| | | @Api(tags = "标准库-->型号-->产品规格操作") |
| | | @Api(tags = "标准库-->3、型号-->产品规格") |
| | | @RestController |
| | | @RequestMapping("/specifications") |
| | | public class SpecificationsController { |
| | |
| | | @Autowired |
| | | private SpecificationsService specificationsService; |
| | | |
| | | @ApiOperation("标准库-->产品规格") |
| | | @ApiOperation("添加产品规格") |
| | | @PostMapping("/add") |
| | | public Result<?> addSpecificationsInformation(@RequestHeader("X-Token") String token,@RequestBody Specifications specifications) throws Exception { |
| | | Object object = RedisUtil.get(token); |
| | |
| | | return Result.fail("添加【"+ specifications.getName() +"】失败!"); |
| | | } |
| | | |
| | | @ApiOperation("标准库-->根据型号查询产品规格") |
| | | @ApiOperation("根据型号查询产品规格") |
| | | @ApiImplicitParams(value = { |
| | | @ApiImplicitParam(name = "pageNo", value = "起始页", dataTypeClass = Integer.class, required = true), |
| | | @ApiImplicitParam(name = "pageSize", value = "每一页数量", dataTypeClass = Integer.class, required = true), |
| | | @ApiImplicitParam(name = "specificationsName", value = "规格名称", dataTypeClass = String.class), |
| | | @ApiImplicitParam(name = "serialNumberId", value = "型号ID", dataTypeClass = String.class), |
| | | @ApiImplicitParam(name = "serialNumberId", value = "型号ID", dataTypeClass = String.class,required = true) |
| | | }) |
| | | @GetMapping("/list") |
| | | public Result<?> listSpecificationsInformation(Integer pageNo, |
| | | Integer pageSize, |
| | | String specificationsName, |
| | | String serialNumberId){ |
| | | IPage<ListSpecificationsInformation> pageList= specificationsService.listSpecificationsInformation(specificationsName,serialNumberId,new Page<Objects>(pageNo, pageSize)); |
| | | IPage<Map<String, Objects>> pageList= specificationsService.listSpecificationsInformation(specificationsName,serialNumberId,new Page<Objects>(pageNo, pageSize)); |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("row", pageList.getRecords()); |
| | | map.put("total", pageList.getTotal()); |
| | | return Result.success(map); |
| | | } |
| | | |
| | | @ApiOperation("编辑产品规格") |
| | | @PutMapping("/update") |
| | | public Result<?> updateSpecificationsInformation(@RequestHeader("X-Token") String token, @RequestBody UpdateSpecificationsInformationDto updateSpecificationsInformationDto) throws Exception { |
| | | Object object = RedisUtil.get(token); |
| | | if (ObjectUtils.isEmpty(object)){ |
| | | return Result.fail("对不起,请携带Token!"); |
| | | } |
| | | Map<String, Object> unmarshal = JackSonUtil.unmarshal(JackSonUtil.marshal(object), Map.class); |
| | | updateSpecificationsInformationDto.setUserId((Integer) unmarshal.get("id")); |
| | | Specifications specifications = JackSonUtil.unmarshal(JackSonUtil.marshal(updateSpecificationsInformationDto), Specifications.class); |
| | | Integer isStandardsSuccess = specificationsService.updateSpecificationsInformation(specifications); |
| | | if (isStandardsSuccess == 1) { |
| | | return Result.success("更新【"+ specifications.getName() +"】成功!"); |
| | | } |
| | | return Result.fail("更新【"+ specifications.getName() +"】失败!"); |
| | | } |
| | | |
| | | @ApiOperation("删除产品规格") |
| | | @ApiImplicitParams(value = { |
| | | @ApiImplicitParam(name = "specificationsId", value = "规格Id", dataTypeClass = Integer.class, required = true) |
| | | }) |
| | | @DeleteMapping("/delete") |
| | | public Result<?> deleteSpecificationsInformation(Integer specificationsId) { |
| | | Integer isStandardsSuccess = specificationsService.deleteSpecifications(specificationsId); |
| | | if (isStandardsSuccess == 1) { |
| | | return Result.success("删除成功!"); |
| | | } |
| | | return Result.fail("删除失败!"); |
| | | } |
| | | |
| | | @ApiOperation("更新规格状态") |
| | | @PutMapping("/update_spe_state") |
| | | public Result<?> updateSpeStateSpecifications(@RequestBody UpdateSpeStateSpecificationsDto updateSpeStateSpecificationsDto) { |
| | | Integer isStandardsSuccess = specificationsService.updateSpeStateSpecifications(updateSpeStateSpecificationsDto); |
| | | if (isStandardsSuccess == 1) { |
| | | return Result.success("操作成功!"); |
| | | } |
| | | return Result.fail("操作失败!"); |
| | | } |
| | | } |