|
@@ -1,54 +1,51 @@
|
|
|
package org.eco.als.controller;
|
|
|
|
|
|
-import cn.dev33.satoken.annotation.SaCheckPermission;
|
|
|
-import jakarta.annotation.Resource;
|
|
|
-import jakarta.servlet.http.HttpServletResponse;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
-import org.eco.als.domain.bo.AlsFaultCaseBo;
|
|
|
-import org.eco.als.domain.vo.AlsFaultCaseVo;
|
|
|
-import org.eco.als.service.IAlsFaultCaseService;
|
|
|
+import jakarta.servlet.http.HttpServletResponse;
|
|
|
+import cn.hutool.core.collection.CollUtil;
|
|
|
+import cn.dev33.satoken.annotation.SaCheckPermission;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+import org.springframework.validation.annotation.Validated;
|
|
|
import org.eco.common.core.core.domain.CommonResult;
|
|
|
-import org.eco.common.core.core.domain.model.LoginUser;
|
|
|
-import org.eco.common.core.core.page.PageResult;
|
|
|
import org.eco.common.log.annotation.Log;
|
|
|
import org.eco.common.log.enums.BusinessType;
|
|
|
import org.eco.common.security.utils.LoginHelper;
|
|
|
+import org.eco.common.core.core.domain.model.LoginUser;
|
|
|
import org.eco.common.web.annotation.RepeatSubmit;
|
|
|
+import org.eco.common.excel.utils.ExcelUtil;
|
|
|
import org.eco.common.web.core.BaseController;
|
|
|
-import org.springframework.validation.annotation.Validated;
|
|
|
-import org.springframework.web.bind.annotation.DeleteMapping;
|
|
|
-import org.springframework.web.bind.annotation.GetMapping;
|
|
|
-import org.springframework.web.bind.annotation.PathVariable;
|
|
|
-import org.springframework.web.bind.annotation.PostMapping;
|
|
|
-import org.springframework.web.bind.annotation.PutMapping;
|
|
|
-import org.springframework.web.bind.annotation.RequestBody;
|
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
-import org.springframework.web.bind.annotation.RestController;
|
|
|
+import jakarta.annotation.Resource;
|
|
|
+import org.eco.als.domain.vo.FaultCaseImportVo;
|
|
|
+import org.eco.als.domain.vo.FaultCaseVo;
|
|
|
+import org.eco.als.domain.bo.FaultCaseBo;
|
|
|
+import org.eco.als.service.IFaultCaseService;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
+ import org.eco.common.core.core.page.PageResult;
|
|
|
|
|
|
import java.util.List;
|
|
|
+import java.util.ArrayList;
|
|
|
|
|
|
/**
|
|
|
* 故障案例Controller
|
|
|
*
|
|
|
* @author wgk
|
|
|
- * @date 2024-07-18
|
|
|
+ * @date 2024-10-25
|
|
|
*/
|
|
|
@Validated
|
|
|
@RequiredArgsConstructor
|
|
|
@RestController
|
|
|
@RequestMapping("/als/faultCase")
|
|
|
-public class AlsFaultCaseController extends BaseController {
|
|
|
+public class FaultCaseController extends BaseController {
|
|
|
@Resource
|
|
|
- private IAlsFaultCaseService alsFaultCaseService;
|
|
|
+ private IFaultCaseService faultCaseService;
|
|
|
|
|
|
- /**
|
|
|
- * 查询故障案例列表
|
|
|
- */
|
|
|
- @SaCheckPermission("als:faultCase:list")
|
|
|
- @GetMapping("/list")
|
|
|
- public CommonResult<PageResult<AlsFaultCaseVo>> list(AlsFaultCaseBo alsFaultCaseBo) {
|
|
|
- return CommonResult.success(alsFaultCaseService.selectPage(alsFaultCaseBo));
|
|
|
+/**
|
|
|
+ * 查询故障案例列表
|
|
|
+ */
|
|
|
+@SaCheckPermission("als:faultCase:list")
|
|
|
+@GetMapping("/list")
|
|
|
+ public CommonResult<PageResult<FaultCaseVo>> list(FaultCaseBo faultCaseBo) {
|
|
|
+ return CommonResult.success(faultCaseService.selectPage(faultCaseBo));
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -57,13 +54,22 @@ public class AlsFaultCaseController extends BaseController {
|
|
|
@SaCheckPermission("als:faultCase:export")
|
|
|
@Log(title = "故障案例", businessType = BusinessType.EXPORT)
|
|
|
@PostMapping("/export")
|
|
|
- public CommonResult<Void> export(HttpServletResponse response, AlsFaultCaseBo alsFaultCaseBo) {
|
|
|
+ public CommonResult<Void> export(FaultCaseBo faultCaseBo) {
|
|
|
LoginUser loginUser = LoginHelper.getLoginUser();
|
|
|
- List<AlsFaultCaseVo> list = alsFaultCaseService.selectList(alsFaultCaseBo);
|
|
|
- alsFaultCaseService.asyncExport(list, "故障案例", loginUser);
|
|
|
+ List<FaultCaseVo> list = faultCaseService.selectList(faultCaseBo);
|
|
|
+ if (CollUtil.isEmpty(list)) {
|
|
|
+ return CommonResult.fail("导出列表为空");
|
|
|
+ }
|
|
|
+ faultCaseService.asyncExport(list, "故障案例", loginUser);
|
|
|
return CommonResult.success();
|
|
|
}
|
|
|
|
|
|
+ @SaCheckPermission("als:faultCase:import")
|
|
|
+ @PostMapping("/importTemplate")
|
|
|
+ public void importTemplate(HttpServletResponse response) {
|
|
|
+ ExcelUtil.exportExcel(new ArrayList<>(), "故障案例", FaultCaseImportVo.class, response);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 导入故障案例列表
|
|
|
*/
|
|
@@ -72,7 +78,7 @@ public class AlsFaultCaseController extends BaseController {
|
|
|
@PostMapping("/importData")
|
|
|
public CommonResult<Void> importData(MultipartFile file, boolean updateSupport) {
|
|
|
LoginUser loginUser = LoginHelper.getLoginUser();
|
|
|
- alsFaultCaseService.asyncImportData(file, updateSupport, loginUser);
|
|
|
+ faultCaseService.asyncImportData(file, updateSupport, loginUser);
|
|
|
return CommonResult.success();
|
|
|
}
|
|
|
|
|
@@ -81,8 +87,8 @@ public class AlsFaultCaseController extends BaseController {
|
|
|
*/
|
|
|
@SaCheckPermission("als:faultCase:query")
|
|
|
@GetMapping(value = "/{id}")
|
|
|
- public CommonResult<AlsFaultCaseVo> getInfo(@PathVariable Long id) {
|
|
|
- return CommonResult.success(alsFaultCaseService.selectById(id));
|
|
|
+ public CommonResult<FaultCaseVo> getInfo(@PathVariable Long id) {
|
|
|
+ return CommonResult.success(faultCaseService.selectById(id));
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -92,8 +98,8 @@ public class AlsFaultCaseController extends BaseController {
|
|
|
@Log(title = "故障案例", businessType = BusinessType.INSERT)
|
|
|
@RepeatSubmit()
|
|
|
@PostMapping
|
|
|
- public CommonResult<Void> add(@Validated @RequestBody AlsFaultCaseBo alsFaultCaseBo) {
|
|
|
- boolean inserted = alsFaultCaseService.insert(alsFaultCaseBo);
|
|
|
+ public CommonResult<Void> add(@Validated @RequestBody FaultCaseBo faultCaseBo) {
|
|
|
+ boolean inserted = faultCaseService.insert(faultCaseBo);
|
|
|
if (!inserted) {
|
|
|
return CommonResult.fail("新增故障案例记录失败!");
|
|
|
}
|
|
@@ -107,8 +113,8 @@ public class AlsFaultCaseController extends BaseController {
|
|
|
@Log(title = "故障案例", businessType = BusinessType.UPDATE)
|
|
|
@RepeatSubmit()
|
|
|
@PutMapping
|
|
|
- public CommonResult<Void> edit(@Validated @RequestBody AlsFaultCaseBo alsFaultCaseBo) {
|
|
|
- boolean updated = alsFaultCaseService.update(alsFaultCaseBo);
|
|
|
+ public CommonResult<Void> edit(@Validated @RequestBody FaultCaseBo faultCaseBo) {
|
|
|
+ boolean updated = faultCaseService.update(faultCaseBo);
|
|
|
if (!updated) {
|
|
|
return CommonResult.fail("修改故障案例记录失败!");
|
|
|
}
|
|
@@ -122,7 +128,7 @@ public class AlsFaultCaseController extends BaseController {
|
|
|
@Log(title = "故障案例", businessType = BusinessType.DELETE)
|
|
|
@DeleteMapping("/{ids}")
|
|
|
public CommonResult<Void> remove(@PathVariable Long[] ids) {
|
|
|
- boolean deleted = alsFaultCaseService.deleteByIds(ids);
|
|
|
+ boolean deleted = faultCaseService.deleteByIds(ids);
|
|
|
if (!deleted) {
|
|
|
return CommonResult.fail("删除故障案例记录失败!");
|
|
|
}
|