From 55bc4967ae96a1c51b71d5bd4c73fe0fd568df90 Mon Sep 17 00:00:00 2001 From: pixljb9os <505784337@qq.com> Date: Fri, 28 Jun 2024 20:18:36 +0800 Subject: [PATCH 01/12] ADD file via upload --- readme2.md | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 readme2.md diff --git a/readme2.md b/readme2.md new file mode 100644 index 0000000..56a0fbe --- /dev/null +++ b/readme2.md @@ -0,0 +1,2 @@ +# c7-523 + -- 2.34.1 From 5a90e004136cf97b417122f6b537e706649ab45f Mon Sep 17 00:00:00 2001 From: paxb98fip <15281417752@163.com> Date: Fri, 28 Jun 2024 20:26:59 +0800 Subject: [PATCH 02/12] ADD file via upload --- LI | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 LI diff --git a/LI b/LI new file mode 100644 index 0000000..fc314f7 --- /dev/null +++ b/LI @@ -0,0 +1,15 @@ +package com.qsd.orange.service; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.qsd.orange.po.SysAnnouncement; + +public interface AnnouncementService { + + //查询全部公告 + IPage all(Integer page, Integer limit); + //新增一条公告 + int add(SysAnnouncement announcement, String username); + //更新一条公告 + int update(SysAnnouncement announcement); + +} -- 2.34.1 From 01cc4fcf66ac7db57eded5048472eeb8435bf11c Mon Sep 17 00:00:00 2001 From: p87sjbg3f <1239676507@qq.com> Date: Fri, 28 Jun 2024 20:27:07 +0800 Subject: [PATCH 03/12] ADD file via upload --- RentController.java | 97 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 RentController.java diff --git a/RentController.java b/RentController.java new file mode 100644 index 0000000..61fef3c --- /dev/null +++ b/RentController.java @@ -0,0 +1,97 @@ +package com.qsd.orange.controller; + +import com.qsd.orange.global.HttpResult; +import com.qsd.orange.global.R; +import com.qsd.orange.service.RentService; +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 java.util.Map; +@RestController +@RequestMapping("rent") +public class RentController { + + @Autowired + private RentService rentService; + + @PostMapping("add") + public R add(String identity, String number, String returnTime, Authentication authentication){ + User users = (User)authentication.getPrincipal(); + String username = users.getUsername(); + int add = rentService.add(identity, number, returnTime, username); + switch (add){ + case -1: + return R.error(HttpResult.CAR_IS_RENTING); + case 0: + return R.error(HttpResult.USER_INFO_ERROR); + case 1: + return R.success(); + default: + return R.error(HttpResult.SERVER_ERROR); + } + } + + @GetMapping("all") + public R all( + @RequestParam(value = "page", required = false, defaultValue = "1") Integer page, + @RequestParam(value = "limit", required = false, defaultValue = "9") Integer limit + ){ + return R.success().page(rentService.all(page, limit)); + } + + @GetMapping("search") + public R search( + @RequestParam(value = "page", required = false, defaultValue = "1") Integer page, + @RequestParam(value = "limit", required = false, defaultValue = "9") Integer limit, + String keyword, + Integer type + ){ + switch (type){ + case 0: + return R.success().page(rentService.search(page, limit, "id", keyword)); + case 1: + return R.success().page(rentService.search(page, limit, "customer_identity", keyword)); + case 2: + return R.success().page(rentService.search(page, limit, "car_number", keyword)); + default: + return R.error(HttpResult.PARAM_ERROR); + } + } + + @PostMapping("update/returnTime") + public R update(String id, String returnTime){ + int i = rentService.updateReturnTime(id, returnTime); + switch (i){ + case -3: + return R.error(HttpResult.PARAM_ERROR); + case -2: + case -1: + return R.error(HttpResult.DATE_ERROR); + case 0: + return R.error(HttpResult.NOT_FOUND); + case 1: + return R.success(); + default: + return R.error(HttpResult.SERVER_ERROR); + } + } + + @GetMapping("info") + public R info(String id){ + Map info = rentService.info(id); + int status = (Integer) info.get("status"); + info.remove("status"); + switch (status){ + case -1: + return R.error(HttpResult.CAR_IS_RETURN); + case 0: + return R.error(HttpResult.NOT_FOUND); + default: + return R.success().data(info); + } + + } + +} -- 2.34.1 From 484b7d50001f3d7db42e7cda520738cf967a0e95 Mon Sep 17 00:00:00 2001 From: p87sjbg3f <1239676507@qq.com> Date: Fri, 28 Jun 2024 20:27:17 +0800 Subject: [PATCH 04/12] ADD file via upload --- RouteController.java | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 RouteController.java diff --git a/RouteController.java b/RouteController.java new file mode 100644 index 0000000..66e5a8a --- /dev/null +++ b/RouteController.java @@ -0,0 +1,35 @@ +package com.qsd.orange.controller; + +import com.qsd.orange.po.SysUser; +import com.qsd.orange.service.UserService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.core.Authentication; +import org.springframework.security.core.userdetails.User; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.GetMapping; + +@Controller +public class RouteController { + + @Autowired + private UserService userService; + + @GetMapping("") + public String index(Model model, Authentication authentication){ + User users = (User)authentication.getPrincipal(); + SysUser user = userService.getInfo(users.getUsername()); + model.addAttribute("name", user.getName()); + model.addAttribute("type", user.getType()); + return "index"; + } + + @GetMapping("self") + public String self(Model model, Authentication authentication){ + User users = (User)authentication.getPrincipal(); + SysUser user = userService.getInfo(users.getUsername()); + model.addAttribute("user", user); + return "self"; + } + +} -- 2.34.1 From ddd8e926760bd3aa4132a119e528ca3fe6778dda Mon Sep 17 00:00:00 2001 From: p87sjbg3f <1239676507@qq.com> Date: Fri, 28 Jun 2024 20:27:30 +0800 Subject: [PATCH 05/12] ADD file via upload --- StatisticsController.java | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 StatisticsController.java diff --git a/StatisticsController.java b/StatisticsController.java new file mode 100644 index 0000000..6207049 --- /dev/null +++ b/StatisticsController.java @@ -0,0 +1,32 @@ +package com.qsd.orange.controller; + +import com.qsd.orange.dao.StatisticsDao; +import com.qsd.orange.global.R; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequestMapping("statistics") +public class StatisticsController { + + @Autowired + private StatisticsDao statisticsDao; + + @GetMapping("region") + public R region(){ + return R.success().data("items", statisticsDao.getRegionVo()); + } + + @GetMapping("salesman/{year}") + public R salesman(@PathVariable("year") String year){ + return R.success().data("items", statisticsDao.getSalesman(year)); + } + @GetMapping("company/{year}") + public R company(@PathVariable("year") String year){ + return R.success().data("items", statisticsDao.getCompany(year)); + } + +} -- 2.34.1 From 6632ca1e355a42c2bcfc48889ce26a43e5ee4324 Mon Sep 17 00:00:00 2001 From: p87sjbg3f <1239676507@qq.com> Date: Fri, 28 Jun 2024 20:27:36 +0800 Subject: [PATCH 06/12] ADD file via upload --- SystemAnnouncementController.java | 34 +++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 SystemAnnouncementController.java diff --git a/SystemAnnouncementController.java b/SystemAnnouncementController.java new file mode 100644 index 0000000..8521656 --- /dev/null +++ b/SystemAnnouncementController.java @@ -0,0 +1,34 @@ +package com.qsd.orange.controller; + +import com.qsd.orange.global.R; +import com.qsd.orange.po.SysAnnouncement; +import com.qsd.orange.service.AnnouncementService; +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.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import javax.validation.Valid; + +@RestController +@RequestMapping("system/announcement") +public class SystemAnnouncementController { + + @Autowired + private AnnouncementService announcementService; + + @PostMapping("add") + public R add(@Valid SysAnnouncement announcement, Authentication authentication){ + User user = (User)authentication.getPrincipal(); + String username = user.getUsername(); + return R.choose(announcementService.add(announcement, username) > 0); + } + + @PostMapping("update") + public R update(SysAnnouncement announcement){ + return R.choose(announcementService.update(announcement) > 0); + } + +} -- 2.34.1 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 07/12] 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); + } + +} -- 2.34.1 From 2e3e5becd5d703823ce156ca55ef5d9807790f27 Mon Sep 17 00:00:00 2001 From: p87sjbg3f <1239676507@qq.com> Date: Fri, 28 Jun 2024 20:27:47 +0800 Subject: [PATCH 08/12] ADD file via upload --- SystemCheckController.java | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 SystemCheckController.java diff --git a/SystemCheckController.java b/SystemCheckController.java new file mode 100644 index 0000000..80026c4 --- /dev/null +++ b/SystemCheckController.java @@ -0,0 +1,31 @@ +package com.qsd.orange.controller; + +import com.qsd.orange.global.R; +import com.qsd.orange.service.CheckService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequestMapping("system/check") +public class SystemCheckController { + + @Autowired + private CheckService checkService; + + @GetMapping("all") + public R all( + @RequestParam(value = "page", required = false, defaultValue = "1") Integer page, + @RequestParam(value = "limit", required = false, defaultValue = "9") Integer limit + ){ + return R.success().page(checkService.all(page, limit)); + } + + @GetMapping("search") + public R search(String id){ + return R.success().data("item", checkService.search(id)); + } + +} -- 2.34.1 From b6a74fce8518471425c9108593a3c5df5b8a2a81 Mon Sep 17 00:00:00 2001 From: p87sjbg3f <1239676507@qq.com> Date: Fri, 28 Jun 2024 20:27:53 +0800 Subject: [PATCH 09/12] ADD file via upload --- SystemRentController.java | 49 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 SystemRentController.java diff --git a/SystemRentController.java b/SystemRentController.java new file mode 100644 index 0000000..9ad3bfd --- /dev/null +++ b/SystemRentController.java @@ -0,0 +1,49 @@ +package com.qsd.orange.controller; + +import com.qsd.orange.global.HttpResult; +import com.qsd.orange.global.R; +import com.qsd.orange.service.RentService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + + +@RestController +@RequestMapping("system/rent") +public class SystemRentController { + + @Autowired + private RentService rentService; + + @GetMapping("all") + public R all( + @RequestParam(value = "page", required = false, defaultValue = "1") Integer page, + @RequestParam(value = "limit", required = false, defaultValue = "9") Integer limit + ){ + return R.success().page(rentService.sysAll(page, limit)); + } + + @GetMapping("search") + public R search( + @RequestParam(value = "page", required = false, defaultValue = "1") Integer page, + @RequestParam(value = "limit", required = false, defaultValue = "9") Integer limit, + Integer status, + String keyword, + Integer type + ){ + switch (type){ + case 0: + return R.success().page(rentService.sysSearch(page, limit, status, "id", keyword)); + case 1: + return R.success().page(rentService.sysSearch(page, limit, status, "customer_identity", keyword)); + case 2: + return R.success().page(rentService.sysSearch(page, limit, status, "car_number", keyword)); + default: + return R.error(HttpResult.PARAM_ERROR); + } + } + + +} -- 2.34.1 From a905f09131975bb4e09246f7e9d4a5f0edbcec8e Mon Sep 17 00:00:00 2001 From: p87sjbg3f <1239676507@qq.com> Date: Fri, 28 Jun 2024 20:27:59 +0800 Subject: [PATCH 10/12] ADD file via upload --- SystemResourceController.java | 67 +++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 SystemResourceController.java diff --git a/SystemResourceController.java b/SystemResourceController.java new file mode 100644 index 0000000..69a0312 --- /dev/null +++ b/SystemResourceController.java @@ -0,0 +1,67 @@ +package com.qsd.orange.controller; + +import cn.hutool.core.io.IoUtil; +import cn.hutool.core.io.file.FileWriter; +import cn.hutool.system.SystemUtil; +import com.qsd.orange.global.R; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; + +import javax.servlet.http.HttpServletResponse; +import java.io.*; + +@RestController +@RequestMapping("system/resource/image") +public class SystemResourceController { + + public static final String IMAGE_PATH = SystemUtil.get("user.dir"); + + @PostMapping + public R updateImage(MultipartFile file){ + String temp = file.getName(); + System.out.println(temp); + temp = "png"; + String name = System.currentTimeMillis() + "." + temp; + BufferedOutputStream outputStream = null; + try(InputStream inputStream = file.getInputStream();) { + File f = new File(IMAGE_PATH, name); + if (!f.exists()){ + f.createNewFile(); + } + FileWriter fileWriter = new FileWriter(f); + outputStream = fileWriter.getOutputStream(); + IoUtil.copy(inputStream, outputStream); + } catch (IOException e) { + e.printStackTrace(); + return R.error(); + }finally { + try { + outputStream.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + return R.success().data("image", name); + } + + @GetMapping("{name}") + public void show(@PathVariable("name") String name, HttpServletResponse response) { + FileInputStream inputStream = null; + try { + inputStream = new FileInputStream(new File(IMAGE_PATH, name)); + response.setContentType("image/png"); + IoUtil.copy(inputStream, response.getOutputStream()); + } catch (FileNotFoundException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } finally { + try { + inputStream.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + +} -- 2.34.1 From e659097eb480834802e66cbbb884c7b337c4d547 Mon Sep 17 00:00:00 2001 From: p87sjbg3f <1239676507@qq.com> Date: Fri, 28 Jun 2024 20:28:10 +0800 Subject: [PATCH 11/12] ADD file via upload --- SystemUserController.java | 41 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 SystemUserController.java diff --git a/SystemUserController.java b/SystemUserController.java new file mode 100644 index 0000000..1395188 --- /dev/null +++ b/SystemUserController.java @@ -0,0 +1,41 @@ +package com.qsd.orange.controller; + +import com.qsd.orange.global.R; +import com.qsd.orange.po.SysUser; +import com.qsd.orange.service.UserService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import javax.validation.Valid; + +@RestController +@RequestMapping("system/user") +public class SystemUserController { + + @Autowired + private UserService userService; + + @GetMapping("all") + public R all(){ + return R.success().data("items", userService.all()); + } + + @PostMapping("add") + public R add(@Valid SysUser user){ + return R.choose(userService.add(user) > 0); + } + + @PostMapping("update") + public R update(@Valid SysUser user){ + return R.choose(userService.update(user) > 0); + } + + @GetMapping("reset") + public R reset(String username){ + return R.choose(userService.reset(username) > 0); + } + +} -- 2.34.1 From c347b94b1fd0d428dc600e5e09d4873abf951fdd Mon Sep 17 00:00:00 2001 From: p87sjbg3f <1239676507@qq.com> Date: Fri, 28 Jun 2024 20:28:19 +0800 Subject: [PATCH 12/12] ADD file via upload --- UserController.java | 54 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 UserController.java diff --git a/UserController.java b/UserController.java new file mode 100644 index 0000000..caf8ab3 --- /dev/null +++ b/UserController.java @@ -0,0 +1,54 @@ +package com.qsd.orange.controller; + +import com.qsd.orange.global.HttpResult; +import com.qsd.orange.global.R; +import com.qsd.orange.po.SysUser; +import com.qsd.orange.service.UserService; +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.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequestMapping("user") +public class UserController { + + @Autowired + private UserService userService; + + @PostMapping("info") + public R info(Authentication authentication){ + User users = (User)authentication.getPrincipal(); + String username = users.getUsername(); + SysUser info = userService.getInfo(username); + return R.success().data("item", info); + } + + @PostMapping("update/info") + public R updateInfo(SysUser user, Authentication authentication){ + User users = (User)authentication.getPrincipal(); + String username = users.getUsername(); + user.setUsername(username); + return R.choose(userService.update(user) > 0); + } + + @PostMapping("update/password") + public R updatePassword(String oldPassword, String newPassword, Authentication authentication){ + User users = (User)authentication.getPrincipal(); + String username = users.getUsername(); + int i = userService.updatePassword(username, oldPassword, newPassword); + switch (i){ + case -2: + return R.error(HttpResult.USERNAME_OR_PASSWORD_ERROR); + case -1: + return R.error(HttpResult.PASSWORD_NOT_SAME); + case 1: + return R.success(); + default: + return R.error(); + } + } + +} -- 2.34.1