| | |
| | | import com.ruoyi.common.basic.PageInfo; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.enums.BusinessType; |
| | | import com.ruoyi.system.model.TItem; |
| | | import com.ruoyi.system.model.TItemType; |
| | | import com.ruoyi.system.query.TItemTypeQuery; |
| | | import com.ruoyi.system.service.TItemService; |
| | | import com.ruoyi.system.service.TItemTypeService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | |
| | | public class TItemTypeController { |
| | | |
| | | private final TItemTypeService itemTypeService; |
| | | private final TItemService itemService; |
| | | @Autowired |
| | | public TItemTypeController(TItemTypeService itemTypeService) { |
| | | public TItemTypeController(TItemTypeService itemTypeService, TItemService itemService) { |
| | | this.itemTypeService = itemTypeService; |
| | | this.itemService = itemService; |
| | | } |
| | | |
| | | /** |
| | |
| | | /** |
| | | * 获取维修物品分类管理列表 |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:itemType:list')") |
| | | @ApiOperation(value = "获取维修物品分类列表") |
| | | @PostMapping(value = "/list") |
| | | public R<List<TItemType>> list() { |
| | |
| | | @ApiOperation(value = "删除维修物品分类") |
| | | @DeleteMapping(value = "/deleteById") |
| | | public R<Boolean> deleteById(@RequestParam String id) { |
| | | long count = itemService.count(Wrappers.lambdaQuery(TItem.class).eq(TItem::getTypeId, id)); |
| | | if (count>0) { |
| | | return R.fail("该分类下有维修物品,无法删除"); |
| | | } |
| | | return R.ok(itemTypeService.removeById(id)); |
| | | } |
| | | |
| | |
| | | @ApiOperation(value = "批量删除维修物品分类") |
| | | @DeleteMapping(value = "/deleteByIds") |
| | | public R<Boolean> deleteByIds(@RequestBody List<String> ids) { |
| | | List<TItem> items = itemService.list(Wrappers.lambdaQuery(TItem.class).in(TItem::getTypeId, ids)); |
| | | for (String id : ids) { |
| | | if (items.stream().anyMatch(t -> t.getTypeId().equals(id))) { |
| | | TItemType itemType = itemTypeService.getById(id); |
| | | return R.fail("该分类["+itemType.getTypeName()+"]下有维修物品,无法删除"); |
| | | } |
| | | } |
| | | return R.ok(itemTypeService.removeByIds(ids)); |
| | | } |
| | | |