|
@@ -0,0 +1,130 @@
|
|
|
+package com.txz.operating.controller;
|
|
|
+import com.txz.operating.result.Result;
|
|
|
+import com.txz.operating.model.Addr;
|
|
|
+import com.txz.operating.service.AddrService;
|
|
|
+
|
|
|
+import com.txz.operating.core.ResultCode;
|
|
|
+
|
|
|
+import com.github.pagehelper.PageHelper;
|
|
|
+import com.github.pagehelper.PageInfo;
|
|
|
+import org.springframework.web.bind.annotation.PostMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestBody;
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestParam;
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
+import io.swagger.annotations.Api;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
+
|
|
|
+import tk.mybatis.mapper.entity.Condition;
|
|
|
+import tk.mybatis.mapper.entity.Example.Criteria;
|
|
|
+
|
|
|
+import javax.annotation.Resource;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Date;
|
|
|
+
|
|
|
+/**
|
|
|
+* Created by CodeGenerator on 2025/09/19.
|
|
|
+*/
|
|
|
+@Api(tags = "[后台]addr管理")
|
|
|
+@RestController
|
|
|
+@RequestMapping("/addr")
|
|
|
+public class AddrController {
|
|
|
+
|
|
|
+private static Logger log = LoggerFactory.getLogger(AddrController.class);
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private AddrService addrService;
|
|
|
+
|
|
|
+ @PostMapping("/add")
|
|
|
+ @ApiOperation(value = "addr新增")
|
|
|
+ public Result add(@RequestBody Addr addr) {
|
|
|
+ if(addr == null){
|
|
|
+ return Result.fail(ResultCode.OBJECT_IS_NULL);
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ addr.setCreateTime(new Date());
|
|
|
+ // addr.setCreateUserId(userId);
|
|
|
+ addrService.save(addr);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("新增对象操作异常e:{}",e);
|
|
|
+ return Result.fail(ResultCode.INTERNAL_SERVER_ERROR);
|
|
|
+ }
|
|
|
+ return Result.success();
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("/delete")
|
|
|
+ @ApiOperation(value = "addr删除")
|
|
|
+ public Result delete(@RequestParam Long id) {
|
|
|
+ if(id == null){
|
|
|
+ return Result.fail(ResultCode.ID_IS_NULL);
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ Addr addr = new Addr();
|
|
|
+ addr.setId(id);
|
|
|
+ addr.setIsDelete(1);
|
|
|
+ addrService.update(addr);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("删除对象操作异常e:{}",e);
|
|
|
+ return Result.fail(ResultCode.INTERNAL_SERVER_ERROR);
|
|
|
+ }
|
|
|
+ return Result.success();
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("/update")
|
|
|
+ @ApiOperation(value = "addr更新")
|
|
|
+ public Result update(@RequestBody Addr addr) {
|
|
|
+ if(addr == null){
|
|
|
+ return Result.fail(ResultCode.OBJECT_IS_NULL);
|
|
|
+ }
|
|
|
+ if(addr.getId() == null){
|
|
|
+ return Result.fail(ResultCode.ID_IS_NULL);
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ addr.setUpdateTime(new Date());
|
|
|
+ // addr.setUpdateUserId(userId);
|
|
|
+ addrService.update(addr);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("更新对象操作异常e:{}",e);
|
|
|
+ return Result.fail(ResultCode.INTERNAL_SERVER_ERROR);
|
|
|
+ }
|
|
|
+ return Result.success();
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("/detail")
|
|
|
+ @ApiOperation(value = "addr获取详情")
|
|
|
+ public Result<Addr> detail(@RequestParam Long id) {
|
|
|
+ if(id == null){
|
|
|
+ return Result.fail(ResultCode.ID_IS_NULL);
|
|
|
+ }
|
|
|
+ Addr addr = null;
|
|
|
+ try {
|
|
|
+ addr = addrService.findById(id);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("查询对象操作异常e:{}",e);
|
|
|
+ return Result.fail(ResultCode.INTERNAL_SERVER_ERROR);
|
|
|
+ }
|
|
|
+ return Result.success(addr);
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("/list")
|
|
|
+ @ApiOperation(value = "addr获取列表")
|
|
|
+ public Result<List<Addr>> list(@RequestBody Addr addr, @RequestParam(defaultValue = "1") Integer page, @RequestParam(defaultValue = "10") Integer size) {
|
|
|
+ PageHelper.startPage(page, size);
|
|
|
+
|
|
|
+ Condition condition = new Condition(addr.getClass());
|
|
|
+ Criteria criteria = condition.createCriteria();
|
|
|
+ criteria.andEqualTo("isDelete", 0);
|
|
|
+ condition.setOrderByClause("create_time DESC");
|
|
|
+ PageInfo pageInfo = null;
|
|
|
+ try {
|
|
|
+ List<Addr> list = addrService.findByCondition(condition);
|
|
|
+ pageInfo = new PageInfo(list);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("查询对象操作异常e:{}",e);
|
|
|
+ return Result.fail(ResultCode.INTERNAL_SERVER_ERROR);
|
|
|
+ }
|
|
|
+ return Result.success(pageInfo);
|
|
|
+ }
|
|
|
+}
|