From 4ec9556d0c48f2e9696ee2ca2d4cca9b98e5a466 Mon Sep 17 00:00:00 2001 From: p87sjbg3f <1239676507@qq.com> Date: Fri, 28 Jun 2024 20:27:42 +0800 Subject: [PATCH] ADD file via upload --- SystemCarController.java | 62 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 SystemCarController.java diff --git a/SystemCarController.java b/SystemCarController.java new file mode 100644 index 0000000..bf102e2 --- /dev/null +++ b/SystemCarController.java @@ -0,0 +1,62 @@ +package com.qsd.orange.controller; + +import com.qsd.orange.global.R; +import com.qsd.orange.po.BusCar; +import com.qsd.orange.service.CarService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.core.Authentication; +import org.springframework.security.core.userdetails.User; +import org.springframework.web.bind.annotation.*; + +import javax.validation.Valid; + +@RestController +@RequestMapping("system/car") +public class SystemCarController { + + @Autowired + private CarService carService; + + @GetMapping("all") + public R all( + @RequestParam(value = "page", required = false, defaultValue = "1") Integer page, + @RequestParam(value = "limit", required = false, defaultValue = "9") Integer limit, + @RequestParam(value = "status", required = false, defaultValue = "-1")Integer status + ){ + return R.success().page(carService.queryAllCarSys(page, limit, status)); + } + + @GetMapping("search") + public R search( + @RequestParam(value = "page", required = false, defaultValue = "1") Integer page, + @RequestParam(value = "limit", required = false, defaultValue = "9") Integer limit, + @RequestParam(value = "status", required = false, defaultValue = "-1") Integer status, + @RequestParam(value = "brand", required = false, defaultValue = "") String brand, + @RequestParam(value = "color", required = false, defaultValue = "") String color + ){ + return R.success().page(carService.queryCarSys(page, limit, status, brand, color)); + } + + @PostMapping("add") + public R add(@Valid BusCar car, Authentication authentication){ + User users = (User)authentication.getPrincipal(); + String username = users.getUsername(); + return R.choose(carService.add(username, car) > 0); + } + + @PostMapping("update/all") + public R add(@Valid BusCar car){ + return R.choose(carService.update(car) > 0); + } + + @PostMapping("update/exist/enable") + public R enable(String number){ + return R.choose(carService.updateExist(number, 1) > 0); + } + + @PostMapping("update/exist/unable") + public R unable(String number){ + return R.choose(carService.updateExist(number, 0) > 0); + } + +}