From 76e9e8e05cbe7dafeba51a235386f20ebf986e25 Mon Sep 17 00:00:00 2001
From: wang-hao-jie <1550036656@qq.com>
Date: 星期一, 27 十二月 2021 11:54:35 +0800
Subject: [PATCH] 违章记录

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

diff --git a/xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/controller/AccidentController.java b/xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/controller/AccidentController.java
new file mode 100644
index 0000000..ef3f81d
--- /dev/null
+++ b/xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/controller/AccidentController.java
@@ -0,0 +1,79 @@
+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.Accident;
+import cn.exrick.xboot.your.service.IAccidentService;
+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/accident")
+@Transactional
+public class AccidentController {
+
+    @Autowired
+    private IAccidentService iAccidentService;
+
+    @RequestMapping(value = "/get/{id}", method = RequestMethod.GET)
+    @ApiOperation(value = "閫氳繃id鑾峰彇")
+    public Result<Accident> get(@PathVariable String id) {
+
+        Accident accident = iAccidentService.getById(id);
+        return new ResultUtil<Accident>().setData(accident);
+    }
+
+    @RequestMapping(value = "/getAll", method = RequestMethod.GET)
+    @ApiOperation(value = "鑾峰彇鍏ㄩ儴鏁版嵁")
+    public Result<List<Accident>> getAll() {
+
+        List<Accident> list = iAccidentService.list();
+        return new ResultUtil<List<Accident>>().setData(list);
+    }
+
+    @RequestMapping(value = "/getByPage", method = RequestMethod.GET)
+    @ApiOperation(value = "鍒嗛〉鑾峰彇")
+    public Result<IPage<Accident>> getByPage(PageVo page,String carNo) {
+        QueryWrapper<Accident> wrapper = new QueryWrapper<>();
+        if(!StrUtil.isEmpty(carNo))
+            wrapper.like("b.car_no","%"+carNo+"%");
+        IPage<Accident> data = iAccidentService.page2(PageUtil.initMpPage(page),wrapper);
+        return new ResultUtil<IPage<Accident>>().setData(data);
+    }
+
+    @RequestMapping(value = "/insertOrUpdate", method = RequestMethod.POST)
+    @ApiOperation(value = "缂栬緫鎴栨洿鏂版暟鎹�")
+    public Result<Accident> saveOrUpdate(Accident accident) {
+
+        if (iAccidentService.saveOrUpdate(accident)) {
+            return new ResultUtil<Accident>().setData(accident);
+        }
+        return new ResultUtil<Accident>().setErrorMsg("鎿嶄綔澶辫触");
+    }
+
+    @RequestMapping(value = "/delByIds", method = RequestMethod.POST)
+    @ApiOperation(value = "鎵归噺閫氳繃id鍒犻櫎")
+    public Result<Object> delAllByIds(@RequestParam String[] ids) {
+
+        for (String id : ids) {
+            iAccidentService.removeById(id);
+        }
+        return ResultUtil.success("鎵归噺閫氳繃id鍒犻櫎鏁版嵁鎴愬姛");
+    }
+}

--
Gitblit v1.9.1