| | |
| | | * @author 江苏鵷雏网络科技有限公司 |
| | | * @since 2023-07-11 |
| | | */ |
| | | @Api(tags = "标准库-->⭐⭐⭐") |
| | | @Api(tags = "标准库-->1、⭐⭐⭐") |
| | | @RestController |
| | | @RequestMapping("/standards") |
| | | public class StandardsController { |
| | |
| | | @Autowired |
| | | private StandardsService standardsService; |
| | | |
| | | @ApiOperation("标准库-->添加标准") |
| | | @ApiOperation("添加标准") |
| | | @PostMapping("/add") |
| | | public Result<?> addStandardsInformation(@RequestHeader("X-Token") String token, @RequestBody Standards standards) 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); |
| | | standards.setUserId((Integer) unmarshal.get("id")); |
| | | Integer isStandardsSuccess = standardsService.addStandardsInformation(standards); |
| | |
| | | return Result.fail("添加【"+ standards.getName() +"】失败!"); |
| | | } |
| | | |
| | | @ApiOperation("标准库-->侧边栏查询所有标准数据") |
| | | @ApiOperation("侧边栏查询所有标准数据") |
| | | @GetMapping("/list") |
| | | public Result<?> listStandardsInformation(){ |
| | | List<Map<String, Object>> list = standardsService.listStandardsInformation(); |
| | | return Result.success(list); |
| | | } |
| | | |
| | | @ApiOperation("标准库-->点击全部:分页查询所有标准数据") |
| | | @ApiOperation("点击全部:分页查询所有标准数据") |
| | | @ApiImplicitParams(value = { |
| | | @ApiImplicitParam(name = "pageNo", value = "起始页", dataTypeClass = Integer.class, required = true), |
| | | @ApiImplicitParam(name = "pageSize", value = "每一页数量", dataTypeClass = Integer.class, required = true), |
| | |
| | | map.put("total", listPage.getTotal()); |
| | | return Result.success(map); |
| | | } |
| | | |
| | | @ApiOperation("根据Id修改参数") |
| | | @PutMapping("/update") |
| | | public Result<?> updateStandardsInformation(@RequestHeader("X-Token") String token, @RequestBody Standards standards) throws Exception { |
| | | Object object = RedisUtil.get(token); |
| | | Map<String, Object> unmarshal = JackSonUtil.unmarshal(JackSonUtil.marshal(object), Map.class); |
| | | standards.setUserId((Integer) unmarshal.get("id")); |
| | | Integer isUpdateSuccess = standardsService.updateStandardsInformation(standards); |
| | | if (isUpdateSuccess == 1){ |
| | | return Result.success("更新成功!"); |
| | | } |
| | | return Result.fail("更新失败!"); |
| | | } |
| | | |
| | | @ApiOperation("根据ID删除数据") |
| | | @DeleteMapping("/delete") |
| | | public Result<?> deleteStandardsInformation(String standardsId) { |
| | | Integer isDeleteSuccess = standardsService.deleteStandardsInformation(standardsId); |
| | | if (isDeleteSuccess == 1){ |
| | | return Result.success("删除成功!"); |
| | | } |
| | | return Result.fail("删除失败!"); |
| | | } |
| | | } |