From 172c5525cbdba1c3b32b47cb60bd35bed707101c Mon Sep 17 00:00:00 2001
From: kongdeqiang <123456>
Date: 星期一, 27 三月 2023 17:18:48 +0800
Subject: [PATCH] 增加功能

---
 xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/controller/AreaController.java |   89 ++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 89 insertions(+), 0 deletions(-)

diff --git a/xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/controller/AreaController.java b/xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/controller/AreaController.java
new file mode 100644
index 0000000..b1cbb90
--- /dev/null
+++ b/xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/controller/AreaController.java
@@ -0,0 +1,89 @@
+package cn.exrick.xboot.your.controller;
+
+import cn.exrick.xboot.core.common.utils.PageUtil;
+import cn.exrick.xboot.core.common.utils.ResultUtil;
+import cn.exrick.xboot.core.common.vo.PageVo;
+import cn.exrick.xboot.core.common.vo.Result;
+import cn.exrick.xboot.your.entity.Area;
+import cn.exrick.xboot.your.entity.Car;
+import cn.exrick.xboot.your.service.IAreaService;
+import cn.hutool.core.util.StrUtil;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.List;
+
+/**
+ * @author zhangzeli
+ */
+@Slf4j
+@RestController
+@Api(tags = "閰嶉�佺墖鍖虹鐞嗘帴鍙�")
+@RequestMapping("/xboot/area")
+@Transactional
+public class AreaController {
+
+    @Autowired
+    private IAreaService iAreaService;
+
+    @RequestMapping(value = "/get/{id}", method = RequestMethod.GET)
+    @ApiOperation(value = "閫氳繃id鑾峰彇")
+    public Result<Area> get(@PathVariable String id) {
+
+        Area area = iAreaService.getById(id);
+        return new ResultUtil<Area>().setData(area);
+    }
+
+    @RequestMapping(value = "/getAll", method = RequestMethod.GET)
+    @ApiOperation(value = "鑾峰彇鍏ㄩ儴鏁版嵁")
+    public Result<List<Area>> getAll() {
+        QueryWrapper<Area> wrapper = new QueryWrapper<>();
+        wrapper.orderByAsc("name");
+        List<Area> list = iAreaService.list();
+        return new ResultUtil<List<Area>>().setData(list);
+    }
+
+    @RequestMapping(value = "/getByPage", method = RequestMethod.GET)
+    @ApiOperation(value = "鍒嗛〉鑾峰彇")
+    public Result<IPage<Area>> getByPage(String name,PageVo page) {
+        QueryWrapper<Area> wrapper = new QueryWrapper<>();
+        if (!StrUtil.isEmpty(name))
+            wrapper.like("a.name",name);
+        IPage<Area> data = iAreaService.page2(PageUtil.initMpPage(page),wrapper);
+        return new ResultUtil<IPage<Area>>().setData(data);
+    }
+
+    @RequestMapping(value = "/insertOrUpdate", method = RequestMethod.POST)
+    @ApiOperation(value = "缂栬緫鎴栨洿鏂版暟鎹�")
+    public Result<Area> saveOrUpdate(Area area) {
+        QueryWrapper<Area> wrapper = new QueryWrapper<>();
+        if (StrUtil.isNotEmpty(area.getCarId())){
+            wrapper.eq("car_id",area.getCarId());
+            Area area1 = iAreaService.getOne(wrapper);
+            if (area1 != null && !area.getId().equals(area1.getId())){
+                return new ResultUtil<Area>().setErrorMsg("璇ヨ溅杈嗗凡琚叾瀹冪墖鍖虹粦瀹�,璇峰厛瑙g粦");
+            }
+        }
+
+        if (iAreaService.saveOrUpdate(area)) {
+            return new ResultUtil<Area>().setData(area);
+        }
+        return new ResultUtil<Area>().setErrorMsg("鎿嶄綔澶辫触");
+    }
+
+    @RequestMapping(value = "/delByIds", method = RequestMethod.POST)
+    @ApiOperation(value = "鎵归噺閫氳繃id鍒犻櫎")
+    public Result<Object> delAllByIds(@RequestParam String[] ids) {
+
+        for (String id : ids) {
+            iAreaService.removeById(id);
+        }
+        return ResultUtil.success("鎵归噺閫氳繃id鍒犻櫎鏁版嵁鎴愬姛");
+    }
+}

--
Gitblit v1.9.1