|
@@ -1,4 +1,6 @@
|
|
|
package com.txz.operating.controller;
|
|
|
+
|
|
|
+import com.txz.operating.core.ResultGenerator;
|
|
|
import com.txz.operating.model.*;
|
|
|
import com.txz.operating.result.Result;
|
|
|
import com.txz.operating.service.*;
|
|
@@ -27,14 +29,14 @@ import java.util.List;
|
|
|
|
|
|
|
|
|
/**
|
|
|
-* Created by CodeGenerator on 2025/09/19.
|
|
|
-*/
|
|
|
+ * Created by CodeGenerator on 2025/09/19.
|
|
|
+ */
|
|
|
@Api(tags = "[后台]addr管理")
|
|
|
@RestController
|
|
|
@RequestMapping("/addr")
|
|
|
public class AddrController {
|
|
|
|
|
|
-private static Logger log = LoggerFactory.getLogger(AddrController.class);
|
|
|
+ private static Logger log = LoggerFactory.getLogger(AddrController.class);
|
|
|
|
|
|
@Resource
|
|
|
private AddrService addrService;
|
|
@@ -43,7 +45,7 @@ private static Logger log = LoggerFactory.getLogger(AddrController.class);
|
|
|
private DivisionsService divisionsService;
|
|
|
|
|
|
@Resource
|
|
|
- private DistrictsService districtsService;
|
|
|
+ private DistrictsService districtsService;
|
|
|
|
|
|
@Resource
|
|
|
private UpazilasService upazilasService;
|
|
@@ -52,11 +54,10 @@ private static Logger log = LoggerFactory.getLogger(AddrController.class);
|
|
|
private UnionsService unionsService;
|
|
|
|
|
|
|
|
|
-
|
|
|
@PostMapping("/delData")
|
|
|
@ApiOperation(value = "delData")
|
|
|
public Result delData() {
|
|
|
- List<Addr> addrList = new ArrayList<>();
|
|
|
+ List<Addr> addrList = new ArrayList<>();
|
|
|
|
|
|
// List<Divisions> allDivisions = divisionsService.findAll();
|
|
|
// for (Divisions divisions : allDivisions) {
|
|
@@ -136,90 +137,88 @@ private static Logger log = LoggerFactory.getLogger(AddrController.class);
|
|
|
// }
|
|
|
|
|
|
|
|
|
-
|
|
|
for (Addr addr1 : addrList) {
|
|
|
- try{
|
|
|
+ try {
|
|
|
addrService.save(addr1);
|
|
|
- }catch(Exception e){
|
|
|
- log.error(e+"");
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error(e + "");
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
- return Result.success();
|
|
|
+ return ResultGenerator.genSuccessResult();
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
@PostMapping("/add")
|
|
|
@ApiOperation(value = "addr新增")
|
|
|
public Result add(@RequestBody Addr addr) {
|
|
|
- if(addr == null){
|
|
|
- return Result.fail(ResultCode.OBJECT_IS_NULL);
|
|
|
+ if (addr == null) {
|
|
|
+ return ResultGenerator.genFailResult(ResultCode.OBJECT_IS_NULL);
|
|
|
}
|
|
|
try {
|
|
|
|
|
|
- // addr.setCreateUserId(userId);
|
|
|
- addrService.save(addr);
|
|
|
+ // addr.setCreateUserId(userId);
|
|
|
+ addrService.save(addr);
|
|
|
} catch (Exception e) {
|
|
|
- log.error("新增对象操作异常e:{}",e);
|
|
|
- return Result.fail(ResultCode.INTERNAL_SERVER_ERROR);
|
|
|
+ log.error("新增对象操作异常e:{}", e);
|
|
|
+ return ResultGenerator.genFailResult(ResultCode.INTERNAL_SERVER_ERROR);
|
|
|
}
|
|
|
- return Result.success();
|
|
|
+ return ResultGenerator.genSuccessResult();
|
|
|
}
|
|
|
|
|
|
@PostMapping("/delete")
|
|
|
@ApiOperation(value = "addr删除")
|
|
|
public Result delete(@RequestParam Long id) {
|
|
|
- if(id == null){
|
|
|
- return Result.fail(ResultCode.ID_IS_NULL);
|
|
|
+ if (id == null) {
|
|
|
+ return ResultGenerator.genFailResult(ResultCode.ID_IS_NULL);
|
|
|
}
|
|
|
try {
|
|
|
- Addr addr = new Addr();
|
|
|
+ Addr addr = new Addr();
|
|
|
|
|
|
|
|
|
- addrService.update(addr);
|
|
|
+ addrService.update(addr);
|
|
|
} catch (Exception e) {
|
|
|
- log.error("删除对象操作异常e:{}",e);
|
|
|
- return Result.fail(ResultCode.INTERNAL_SERVER_ERROR);
|
|
|
+ log.error("删除对象操作异常e:{}", e);
|
|
|
+ return ResultGenerator.genFailResult(ResultCode.INTERNAL_SERVER_ERROR);
|
|
|
}
|
|
|
- return Result.success();
|
|
|
+ return ResultGenerator.genSuccessResult();
|
|
|
}
|
|
|
|
|
|
@PostMapping("/update")
|
|
|
@ApiOperation(value = "addr更新")
|
|
|
public Result update(@RequestBody Addr addr) {
|
|
|
- if(addr == null){
|
|
|
- return Result.fail(ResultCode.OBJECT_IS_NULL);
|
|
|
+ if (addr == null) {
|
|
|
+ return ResultGenerator.genFailResult(ResultCode.OBJECT_IS_NULL);
|
|
|
}
|
|
|
- if(addr.getId() == null){
|
|
|
- return Result.fail(ResultCode.ID_IS_NULL);
|
|
|
+ if (addr.getId() == null) {
|
|
|
+ return ResultGenerator.genFailResult(ResultCode.ID_IS_NULL);
|
|
|
}
|
|
|
try {
|
|
|
|
|
|
- // addr.setUpdateUserId(userId);
|
|
|
- addrService.update(addr);
|
|
|
+ // addr.setUpdateUserId(userId);
|
|
|
+ addrService.update(addr);
|
|
|
} catch (Exception e) {
|
|
|
- log.error("更新对象操作异常e:{}",e);
|
|
|
- return Result.fail(ResultCode.INTERNAL_SERVER_ERROR);
|
|
|
+ log.error("更新对象操作异常e:{}", e);
|
|
|
+ return ResultGenerator.genFailResult(ResultCode.INTERNAL_SERVER_ERROR);
|
|
|
}
|
|
|
- return Result.success();
|
|
|
+ return ResultGenerator.genSuccessResult();
|
|
|
}
|
|
|
|
|
|
@PostMapping("/detail")
|
|
|
@ApiOperation(value = "addr获取详情")
|
|
|
public Result<Addr> detail(@RequestParam Long id) {
|
|
|
- if(id == null){
|
|
|
- return Result.fail(ResultCode.ID_IS_NULL);
|
|
|
+ if (id == null) {
|
|
|
+ return ResultGenerator.genFailResult(ResultCode.ID_IS_NULL);
|
|
|
}
|
|
|
Addr addr = null;
|
|
|
try {
|
|
|
- addr = addrService.findById(id);
|
|
|
+ addr = addrService.findById(id);
|
|
|
} catch (Exception e) {
|
|
|
- log.error("查询对象操作异常e:{}",e);
|
|
|
- return Result.fail(ResultCode.INTERNAL_SERVER_ERROR);
|
|
|
+ log.error("查询对象操作异常e:{}", e);
|
|
|
+ return ResultGenerator.genFailResult(ResultCode.INTERNAL_SERVER_ERROR);
|
|
|
}
|
|
|
- return Result.success(addr);
|
|
|
+ return ResultGenerator.genSuccessResult(addr);
|
|
|
}
|
|
|
|
|
|
@PostMapping("/list")
|
|
@@ -233,12 +232,12 @@ private static Logger log = LoggerFactory.getLogger(AddrController.class);
|
|
|
condition.setOrderByClause("create_time DESC");
|
|
|
PageInfo pageInfo = null;
|
|
|
try {
|
|
|
- List<Addr> list = addrService.findByCondition(condition);
|
|
|
- pageInfo = new PageInfo(list);
|
|
|
+ List<Addr> list = addrService.findByCondition(condition);
|
|
|
+ pageInfo = new PageInfo(list);
|
|
|
} catch (Exception e) {
|
|
|
- log.error("查询对象操作异常e:{}",e);
|
|
|
- return Result.fail(ResultCode.INTERNAL_SERVER_ERROR);
|
|
|
+ log.error("查询对象操作异常e:{}", e);
|
|
|
+ return ResultGenerator.genFailResult(ResultCode.INTERNAL_SERVER_ERROR);
|
|
|
}
|
|
|
- return Result.success(pageInfo);
|
|
|
+ return ResultGenerator.genSuccessResult(pageInfo);
|
|
|
}
|
|
|
}
|