|
|
@ -1,22 +1,18 @@
|
|
|
|
package com.hzu.bookingsystem.controller;
|
|
|
|
package com.hzu.bookingsystem.controller;
|
|
|
|
|
|
|
|
|
|
|
|
import com.hzu.bookingsystem.VO.ResultVO;
|
|
|
|
import com.hzu.bookingsystem.VO.ResultVO;
|
|
|
|
import com.hzu.bookingsystem.bean.User;
|
|
|
|
import com.hzu.bookingsystem.bean.UserBean;
|
|
|
|
import com.hzu.bookingsystem.service.UserService;
|
|
|
|
import com.hzu.bookingsystem.service.UserService;
|
|
|
|
import com.hzu.bookingsystem.utils.CookieUtil;
|
|
|
|
import com.hzu.bookingsystem.utils.CookieUtil;
|
|
|
|
import com.hzu.bookingsystem.utils.ResultVOUtil;
|
|
|
|
import com.hzu.bookingsystem.utils.ResultVOUtil;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.data.redis.core.RedisTemplate;
|
|
|
|
|
|
|
|
import org.springframework.data.redis.core.StringRedisTemplate;
|
|
|
|
import org.springframework.data.redis.core.StringRedisTemplate;
|
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
|
|
|
|
|
import org.springframework.util.StringUtils;
|
|
|
|
import org.springframework.util.StringUtils;
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
import org.springframework.web.servlet.ModelAndView;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import javax.servlet.http.Cookie;
|
|
|
|
import javax.servlet.http.Cookie;
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
|
|
|
import java.util.Map;
|
|
|
|
import java.util.Map;
|
|
|
|
import java.util.UUID;
|
|
|
|
import java.util.UUID;
|
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
@ -32,11 +28,11 @@ public class UserController {
|
|
|
|
|
|
|
|
|
|
|
|
// 登录
|
|
|
|
// 登录
|
|
|
|
@PostMapping("/login")
|
|
|
|
@PostMapping("/login")
|
|
|
|
public ResultVO login(@RequestBody User user,
|
|
|
|
public ResultVO login(@RequestBody UserBean user,
|
|
|
|
HttpServletResponse response) {
|
|
|
|
HttpServletResponse response) {
|
|
|
|
System.out.println(user);
|
|
|
|
System.out.println(user);
|
|
|
|
//1. openid去和数据库里的数据匹配
|
|
|
|
//1. openid去和数据库里的数据匹配
|
|
|
|
User user1 = userService.findByUnameAndPwd(user.getUsername(),user.getPassword());
|
|
|
|
UserBean user1 = userService.findByUnameAndPwd(user.getUsername(),user.getPassword());
|
|
|
|
System.out.println(user1);
|
|
|
|
System.out.println(user1);
|
|
|
|
if (user1 == null) {
|
|
|
|
if (user1 == null) {
|
|
|
|
return ResultVOUtil.error(-2,"账号或密码不正确");
|
|
|
|
return ResultVOUtil.error(-2,"账号或密码不正确");
|
|
|
@ -71,15 +67,15 @@ public class UserController {
|
|
|
|
|
|
|
|
|
|
|
|
//创建用户
|
|
|
|
//创建用户
|
|
|
|
@PostMapping(value = "/addUser", consumes = "application/json")
|
|
|
|
@PostMapping(value = "/addUser", consumes = "application/json")
|
|
|
|
public ResultVO addUser(@RequestBody User user) {
|
|
|
|
public ResultVO addUser(@RequestBody UserBean user) {
|
|
|
|
userService.add(user);
|
|
|
|
userService.add(user);
|
|
|
|
return ResultVOUtil.success();
|
|
|
|
return ResultVOUtil.success();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//查找用户详情
|
|
|
|
//查找用户详情
|
|
|
|
@GetMapping(value = "/findById")
|
|
|
|
@GetMapping(value = "/findById")
|
|
|
|
public ResultVO<Map<String, User>> findById(@RequestParam("uId") Integer uId) {
|
|
|
|
public ResultVO<Map<String, UserBean>> findById(@RequestParam("uId") Integer uId) {
|
|
|
|
User user = userService.findById(uId);
|
|
|
|
UserBean user = userService.findById(uId);
|
|
|
|
return ResultVOUtil.success(user);
|
|
|
|
return ResultVOUtil.success(user);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -90,7 +86,7 @@ public class UserController {
|
|
|
|
* @return
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@PostMapping(value = "/updateBySelf", consumes = "application/json")
|
|
|
|
@PostMapping(value = "/updateBySelf", consumes = "application/json")
|
|
|
|
public ResultVO updateBySelf(@RequestBody User user,
|
|
|
|
public ResultVO updateBySelf(@RequestBody UserBean user,
|
|
|
|
HttpServletRequest request){
|
|
|
|
HttpServletRequest request){
|
|
|
|
Integer uId = getUIdByCookie(request);
|
|
|
|
Integer uId = getUIdByCookie(request);
|
|
|
|
if (uId == null){
|
|
|
|
if (uId == null){
|
|
|
|