Compare commits
No commits in common. 'main' and 'main' have entirely different histories.
@ -1,26 +0,0 @@
|
||||
package com.qsd.orange.controller;
|
||||
|
||||
import com.qsd.orange.service.AnnouncementService;
|
||||
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.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("announcement")
|
||||
public class AnnouncementController {
|
||||
|
||||
@Autowired
|
||||
private AnnouncementService announcementService;
|
||||
|
||||
@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(announcementService.all(page, limit));
|
||||
}
|
||||
|
||||
}
|
@ -1,56 +0,0 @@
|
||||
package com.qsd.orange.controller;
|
||||
|
||||
import com.qsd.orange.po.BusCar;
|
||||
import com.qsd.orange.service.CarService;
|
||||
import com.qsd.orange.global.R;
|
||||
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("car")
|
||||
public class CarController {
|
||||
|
||||
@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.queryAllCar(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.queryCar(page, limit, status, brand, color));
|
||||
}
|
||||
|
||||
@GetMapping("search/number")
|
||||
public R number(
|
||||
@RequestParam(value = "page", required = false, defaultValue = "1") Integer page,
|
||||
@RequestParam(value = "limit", required = false, defaultValue = "9") Integer limit,
|
||||
@RequestParam(value = "number", required = false, defaultValue = "") String number
|
||||
){
|
||||
return R.success().page(carService.queryCarByNumber(page, limit, number));
|
||||
}
|
||||
|
||||
@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);
|
||||
}
|
||||
|
||||
}
|
@ -1,32 +0,0 @@
|
||||
package com.qsd.orange.controller;
|
||||
|
||||
import com.qsd.orange.service.CheckService;
|
||||
import com.qsd.orange.global.R;
|
||||
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.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("check")
|
||||
public class CheckController {
|
||||
|
||||
@Autowired
|
||||
private CheckService checkService;
|
||||
|
||||
@PostMapping("add")
|
||||
public R add(
|
||||
String id,
|
||||
@RequestParam(value = "problem", required = false, defaultValue = "无") String problem,
|
||||
@RequestParam(value = "compensate", required = false, defaultValue = "0") Double compensate,
|
||||
@RequestParam(value = "description", required = false, defaultValue = "无") String description,
|
||||
Authentication authentication
|
||||
){
|
||||
User users = (User)authentication.getPrincipal();
|
||||
return R.choose(checkService.add(id, problem, compensate, description, users.getUsername()) > 0);
|
||||
}
|
||||
|
||||
}
|
@ -1,63 +0,0 @@
|
||||
package com.qsd.orange.controller;
|
||||
|
||||
import com.qsd.orange.po.BusCustomer;
|
||||
import com.qsd.orange.service.CustomerService;
|
||||
import com.qsd.orange.global.R;
|
||||
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("customer")
|
||||
public class CustomerController {
|
||||
|
||||
@Autowired
|
||||
private CustomerService customerService;
|
||||
|
||||
@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(customerService.queryCustomers(page, limit));
|
||||
}
|
||||
|
||||
@GetMapping("search/identity")
|
||||
public R searchByIdentity(
|
||||
@RequestParam(value = "page", required = false, defaultValue = "1") Integer page,
|
||||
@RequestParam(value = "limit", required = false, defaultValue = "9") Integer limit,
|
||||
String keyword
|
||||
){
|
||||
return R.success().page(customerService.queryByCustomer(page, limit, "identity", keyword));
|
||||
}
|
||||
|
||||
@GetMapping("search/name")
|
||||
public R searchByName(
|
||||
@RequestParam(value = "page", required = false, defaultValue = "1") Integer page,
|
||||
@RequestParam(value = "limit", required = false, defaultValue = "9") Integer limit,
|
||||
String keyword
|
||||
){
|
||||
return R.success().page(customerService.queryByCustomer(page, limit, "name", keyword));
|
||||
}
|
||||
|
||||
@GetMapping("search/one/identity")
|
||||
public R searchOneIdentity(String identity){
|
||||
return R.success().data("item", customerService.queryOne(identity));
|
||||
}
|
||||
|
||||
@PostMapping("add")
|
||||
public R add(@Valid BusCustomer customer, Authentication authentication){
|
||||
User user = (User)authentication.getPrincipal();
|
||||
String username = user.getUsername();
|
||||
return R.choose(customerService.addCustomer(username, customer) > 0);
|
||||
}
|
||||
|
||||
@PostMapping("update")
|
||||
public R update(@Valid BusCustomer customer){
|
||||
return R.choose(customerService.updateCustomer(customer) > 0);
|
||||
}
|
||||
|
||||
}
|
@ -1,15 +0,0 @@
|
||||
package com.qsd.orange.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.qsd.orange.po.SysAnnouncement;
|
||||
|
||||
public interface AnnouncementService {
|
||||
|
||||
//查询全部公告
|
||||
IPage<SysAnnouncement> all(Integer page, Integer limit);
|
||||
//新增一条公告
|
||||
int add(SysAnnouncement announcement, String username);
|
||||
//更新一条公告
|
||||
int update(SysAnnouncement announcement);
|
||||
|
||||
}
|
@ -1,97 +0,0 @@
|
||||
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<String, Object> 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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -1,35 +0,0 @@
|
||||
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";
|
||||
}
|
||||
|
||||
}
|
@ -1,82 +0,0 @@
|
||||
package com.qsd.orange.config;
|
||||
|
||||
import com.qsd.orange.security.AccessFailureHandler;
|
||||
import com.qsd.orange.security.LoginFailureHandler;
|
||||
import com.qsd.orange.security.LoginSuccessHandler;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
|
||||
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
|
||||
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
|
||||
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
|
||||
import org.springframework.security.core.userdetails.UserDetailsService;
|
||||
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||
|
||||
@EnableWebSecurity
|
||||
@EnableGlobalMethodSecurity(prePostEnabled = true)
|
||||
public class SpringSecurityConfig extends WebSecurityConfigurerAdapter {
|
||||
|
||||
@Autowired
|
||||
@Qualifier("userDetailsServiceImpl")
|
||||
private UserDetailsService userDetailsService;
|
||||
@Autowired
|
||||
private LoginSuccessHandler loginSuccessHandler;
|
||||
@Autowired
|
||||
private LoginFailureHandler loginFailureHandler;
|
||||
@Autowired
|
||||
private AccessFailureHandler accessFailureHandler;
|
||||
@Autowired
|
||||
private BCryptPasswordEncoder passwordEncoder;
|
||||
|
||||
//授权规则
|
||||
@Override
|
||||
protected void configure(HttpSecurity http) throws Exception {
|
||||
//拦截规则
|
||||
http.authorizeRequests()
|
||||
.antMatchers("/user/login").permitAll()
|
||||
.antMatchers("/login.html").permitAll()
|
||||
.antMatchers("/image/**").permitAll()
|
||||
.antMatchers("/system/**").hasRole("1")
|
||||
.antMatchers("/statistics/**").hasRole("1")
|
||||
.anyRequest().authenticated();
|
||||
|
||||
//登录配置
|
||||
http.formLogin()
|
||||
.loginPage("/login.html")
|
||||
.loginProcessingUrl("/user/login")
|
||||
.usernameParameter("username")
|
||||
.passwordParameter("password")
|
||||
.successHandler(loginSuccessHandler)
|
||||
.failureHandler(loginFailureHandler);
|
||||
|
||||
//注销配置
|
||||
http.logout()
|
||||
.logoutUrl("/user/logout")
|
||||
.logoutSuccessUrl("/login.html");
|
||||
|
||||
//关闭csrf防护
|
||||
http.csrf().disable();
|
||||
|
||||
//配置iframe请求
|
||||
http.headers().frameOptions().disable();
|
||||
|
||||
//处理认证失败请求
|
||||
http.exceptionHandling().accessDeniedHandler(accessFailureHandler);
|
||||
|
||||
}
|
||||
|
||||
//认证配置
|
||||
@Override
|
||||
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
|
||||
auth.userDetailsService(userDetailsService)
|
||||
.passwordEncoder(passwordEncoder);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public BCryptPasswordEncoder passwordEncoder(){
|
||||
return new BCryptPasswordEncoder();
|
||||
}
|
||||
|
||||
}
|
@ -1,32 +0,0 @@
|
||||
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));
|
||||
}
|
||||
|
||||
}
|
@ -1,34 +0,0 @@
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
@ -1,62 +0,0 @@
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
@ -1,31 +0,0 @@
|
||||
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));
|
||||
}
|
||||
|
||||
}
|
@ -1,49 +0,0 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -1,67 +0,0 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,41 +0,0 @@
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
@ -1,54 +0,0 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
package com.qsd.orange.config;
|
||||
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
@Configuration
|
||||
public class WebConfig implements WebMvcConfigurer {
|
||||
|
||||
}
|
@ -1,2 +0,0 @@
|
||||
# c7-523
|
||||
|
Loading…
Reference in new issue