| | |
| | | package com.ruoyi.web.controller.api; |
| | | |
| | | |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.ruoyi.common.annotation.Log; |
| | | import com.ruoyi.common.basic.PageInfo; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.enums.BusinessType; |
| | | import com.ruoyi.system.model.TFaultAreaDic; |
| | | import com.ruoyi.system.model.TFaultDescribeDic; |
| | | import com.ruoyi.system.query.TFaultAreaDicQuery; |
| | | import com.ruoyi.system.service.TFaultAreaDicService; |
| | | import com.ruoyi.system.service.TFaultDescribeDicService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | public class TFaultAreaDicController { |
| | | |
| | | private final TFaultAreaDicService faultAreaDicService; |
| | | private final TFaultDescribeDicService faultDescribeDicService; |
| | | @Autowired |
| | | public TFaultAreaDicController(TFaultAreaDicService faultAreaDicService) { |
| | | public TFaultAreaDicController(TFaultAreaDicService faultAreaDicService, TFaultDescribeDicService faultDescribeDicService) { |
| | | this.faultAreaDicService = faultAreaDicService; |
| | | this.faultDescribeDicService = faultDescribeDicService; |
| | | } |
| | | |
| | | /** |
| | |
| | | @ApiOperation(value = "获取故障区域列表") |
| | | @PostMapping(value = "/list") |
| | | public R<List<TFaultAreaDic>> list() { |
| | | return R.ok(faultAreaDicService.list()); |
| | | return R.ok(faultAreaDicService.list(Wrappers.lambdaQuery(TFaultAreaDic.class).orderByDesc(TFaultAreaDic::getSortBy).orderByDesc(TFaultAreaDic::getCreateTime))); |
| | | } |
| | | |
| | | /** |
| | |
| | | @ApiOperation(value = "添加故障区域") |
| | | @PostMapping(value = "/add") |
| | | public R<Boolean> add(@Validated @RequestBody TFaultAreaDic dto) { |
| | | if (faultAreaDicService.isExit(dto)) { |
| | | return R.fail("故障区域名称已存在"); |
| | | } |
| | | return R.ok(faultAreaDicService.save(dto)); |
| | | } |
| | | |
| | |
| | | @ApiOperation(value = "修改故障区域") |
| | | @PostMapping(value = "/update") |
| | | public R<Boolean> update(@Validated @RequestBody TFaultAreaDic dto) { |
| | | if (faultAreaDicService.isExit(dto)) { |
| | | return R.fail("故障区域名称已存在"); |
| | | } |
| | | return R.ok(faultAreaDicService.updateById(dto)); |
| | | } |
| | | |
| | |
| | | @ApiOperation(value = "删除故障区域") |
| | | @DeleteMapping(value = "/deleteById") |
| | | public R<Boolean> deleteById(@RequestParam String id) { |
| | | // 删除故障描述关联信息 |
| | | faultDescribeDicService.remove(Wrappers.lambdaQuery(TFaultDescribeDic.class) |
| | | .eq(TFaultDescribeDic::getFaultId, id)); |
| | | return R.ok(faultAreaDicService.removeById(id)); |
| | | } |
| | | |
| | |
| | | @ApiOperation(value = "批量删除故障区域") |
| | | @DeleteMapping(value = "/deleteByIds") |
| | | public R<Boolean> deleteByIds(@RequestBody List<String> ids) { |
| | | // 删除故障描述关联信息 |
| | | faultDescribeDicService.remove(Wrappers.lambdaQuery(TFaultDescribeDic.class) |
| | | .in(TFaultDescribeDic::getFaultId, ids)); |
| | | return R.ok(faultAreaDicService.removeByIds(ids)); |
| | | } |
| | | |