| | |
| | | @PostMapping |
| | | @ApiOperation(value = "添加类型") |
| | | public ResponseResult<Type> add(@RequestBody Type type) { |
| | | type.setDel_flag(0); |
| | | boolean success = typeService.save(type); |
| | | if (success) { |
| | | return ResponseResult.success(type); |
| | |
| | | @PostMapping("/batch") |
| | | @ApiOperation(value = "批量添加类型") |
| | | public ResponseResult<Void> batchAdd(@RequestBody List<Type> types) { |
| | | types.forEach(type -> type.setDel_flag(0)); |
| | | |
| | | boolean success = typeService.saveBatch(types); |
| | | if (success) { |
| | | return ResponseResult.success(); |
| | |
| | | public ResponseResult<Void> delete(@PathVariable Integer typeId) { |
| | | Type type = new Type(); |
| | | type.setType_id(typeId); |
| | | type.setDel_flag(1); |
| | | boolean success = typeService.updateById(type); |
| | | if (success) { |
| | | return ResponseResult.success(); |
| | |
| | | @ApiOperation(value = "根据ID查询类型") |
| | | public ResponseResult<Type> getById(@PathVariable Integer typeId) { |
| | | Type type = typeService.getById(typeId); |
| | | if (type != null && type.getDel_flag() != 1) { |
| | | if (type != null ) { |
| | | return ResponseResult.success(type); |
| | | } |
| | | return ResponseResult.error("类型不存在"); |
| | |
| | | List<Type> types = typeIds.stream().map(id -> { |
| | | Type type = new Type(); |
| | | type.setType_id(id); |
| | | type.setDel_flag(1); |
| | | return type; |
| | | }).collect(java.util.stream.Collectors.toList()); |
| | | boolean success = typeService.updateBatchById(types); |
| | |
| | | @RequestParam(required = false) Integer page, |
| | | @RequestParam(required = false) Integer pageSize) { |
| | | LambdaQueryWrapper<Type> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.eq(Type::getDel_flag, 0); |
| | | |
| | | if (page != null && pageSize != null) { |
| | | Page<Type> pageInfo = new Page<>(page, pageSize); |