package com.book.controller;
import com.book.dto.requestDto.PasswordRequestDto;
import com.book.dto.responseDto.LoginResponseDto;
import com.book.entity.Book;
import com.book.entity.User;
import com.book.service.UserService;
import com.book.util.Md5Util;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;
/**
* (User)表控制层
*
* @author makejava
* @since 2022-05-23 18:31:08
*/
@Api(tags = "用户管理")
@Controller
@RequestMapping("user")
public class UserController extends LoginController {
/**
* 服务对象
*/
@Resource
private UserService userService;
@ApiOperation(value = "跳转用户列表")
@GetMapping("userList")
public String userList() {
request.getSession().setAttribute("pageName", "用户管理");
return "user-list";
}
@ApiOperation(value = "root用户信息")
@GetMapping("userInfoRoot")
public String userInfoRoot() {
request.getSession().setAttribute("pageName", "个人信息");
return "userInfoRoot";
}
@ApiOperation(value = "root用户信息")
@GetMapping("userInfoRoot1")
public String userInfoRoot1() {
request.getSession().setAttribute("pageName", "修改个人信息");
return "userInfoRoot1";
}
@ApiOperation(value = "用户信息")
@GetMapping("selectUser")
public String userSelect() {
request.getSession().setAttribute("pageName", "用户详情");
return "selectUser";
}
@ApiOperation(value = "修改用户信息")
@GetMapping("userUpdate")
public String userUpdate() {
request.getSession().setAttribute("pageName", "修改用户");
return "updateUser";
}
@ApiOperation(value = "添加用户信息")
@GetMapping("insertUser")
public String insertUser() {
request.getSession().setAttribute("pageName", "添加用户");
return "insertUser";
}
@ApiOperation(value = "用户信息")
@GetMapping("userInfo")
public String userInfo() {
request.getSession().setAttribute("pageName", "个人信息");
return "userInfo";
}
@ApiOperation(value = "用户信息")
@GetMapping("userInfo1")
public String userInfo1() {
request.getSession().setAttribute("pageName", "修改个人信息");
return "userInfo1";
}
@ApiOperation(value = "修改密码")
@GetMapping("userPassword")
public String userPassword() {
request.getSession().setAttribute("pageName", "修改密码");
return "userPassword";
}
@ApiOperation(value = "修改root密码")
@GetMapping("userPasswordRoot")
public String userPasswordRoot() {
request.getSession().setAttribute("pageName", "修改密码");
return "userPasswordRoot";
}
@PostMapping("queryUser")
@ApiOperation(value = "查看指定用户信息")
@ResponseBody
public Map<String, Object> queryUserByUsername() {
Map<String, Object> map = new HashMap<>();
User user = null;
try {
LoginResponseDto userInfo = (LoginResponseDto) request.getSession().getAttribute("userInfo");
String username = userInfo.getUsername();
user = userService.queryByUsername(username);
} catch (Exception e) {
map.put("success", false);
map.put("errMsg", e.getMessage());
return map;
}
map.put("success", true);
map.put("data", user);
return map;
}
@PostMapping("editPassword")
@ApiOperation(value = "修改指定用户密码")
@ResponseBody
public Map<String, Object> editPassword(@RequestBody PasswordRequestDto requestDto) {
Map<String, Object> map = new HashMap<>();
String oldPassword = requestDto.getOldPassword();
String newPassword = requestDto.getNewPassword();
String rePassword = requestDto.getRePassword();
LoginResponseDto userInfo = (LoginResponseDto) request.getSession().getAttribute("userInfo");
String username = userInfo.getUsername();
User user = userService.queryByUsername(username);
String resultPassword = user.getPassword();
if (resultPassword.equals(Md5Util.getMd5(oldPassword))) {
if (!oldPassword.equals(newPassword)) {
if (newPassword.equals(rePassword)) {
try {
userService.updatePassword(username, newPassword);
} catch (Exception e) {
map.put("success", false);
map.put("errMsg", e.getMessage());
return map;
}
} else {
map.put("success", false);
map.put("errMsg", "确认密码不一致");
return map;
}
} else {
map.put("success", false);
map.put("errMsg", "不能与初始密码相同");
return map;
}
} else {
map.put("success", false);
map.put("errMsg", "旧密码错误");
return map;
}
map.put("success", true);
return map;
}
@PostMapping("updateUser")
@ApiOperation(value = "修改指定用户信息")
@ResponseBody
public Map<String, Object> updateUser(@RequestBody User user) {
HashMap<String, Object> map = new HashMap<>();
if ("".equals(user.getUsername()) || "".equals(user.getSex()) || "".equals(user.getEmail()) || "".equals(user.getPhone())) {
map.put("success", false);
map.put("errMsg", "不能有空白项");
return map;
} else {
if (user.getPhone().length() != 11) {
map.put("success", false);
map.put("errMsg", "手机号格式错误");
return map;
} else {
try {
userService.update(user);
map.put("success", true);
return map;
} catch (Exception e) {
map.put("success", false);
map.put("errMsg", "用户名/邮箱/手机号重复");
return map;
}
}
}
}
@ApiOperation(value = "查询列表数据(包括分页,模糊,条件查询)")
@PostMapping("getList")
@ResponseBody
public Map<String, Object> getList(@RequestBody User user) {
Map<String, Object> map = null;
try {
map = userService.queryPageList(user);
} catch (Exception e) {
map = new HashMap<>();
map.put("success", false);
map.put("errMsg", e.getMessage());
}
return map;
}
@PostMapping("userSelect")
@ApiOperation(value = "查看指定用户信息")
@ResponseBody
public Map<String, Object> userSelect(Integer userId) {
Map<String, Object> map = new HashMap<>();
User user = null;
try {
user = userService.queryById(userId);
} catch (Exception e) {
map.put("success", false);
map.put("errMsg", e.getMessage());
return map;
}
map.put("success", true);
map.put("data", user);
return map;
}
@PostMapping("resetPassword")
@ApiOperation(value = "修改指定用户信息")
@ResponseBody
public Map<String, Object> resetPassword(@RequestBody User user) {
HashMap<String, Object> map = new Hash
没有合适的资源?快使用搜索试试~ 我知道了~
资源详情
资源评论
资源推荐
收起资源包目录
基于java+spark的图书推荐系统 (1465个子文件)
$PROJECT_FILE$ 364B
_SUCCESS 0B
_SUCCESS 0B
_SUCCESS 0B
_SUCCESS 0B
_SUCCESS 0B
_SUCCESS 0B
UserController.class 9KB
UserController.class 9KB
BookController.class 8KB
BookController.class 8KB
UserBookController.class 6KB
UserBookController.class 6KB
CsvUtil.class 5KB
CsvUtil.class 5KB
UserServiceImpl.class 5KB
UserServiceImpl.class 5KB
BookServiceImpl.class 4KB
BookServiceImpl.class 4KB
LoginController.class 4KB
LoginController.class 4KB
UserBookServiceImpl.class 4KB
UserBookServiceImpl.class 4KB
CmdUtil.class 4KB
CmdUtil.class 4KB
RegistController.class 3KB
RegistController.class 3KB
LoginRequestDto.class 2KB
LoginRequestDto.class 2KB
SwaggerConfig.class 2KB
SwaggerConfig.class 2KB
Book.class 2KB
Book.class 2KB
UserDao.class 2KB
UserDao.class 2KB
UserBookDao.class 2KB
UserBookDao.class 2KB
LoginInterceptor.class 2KB
LoginInterceptor.class 2KB
User.class 2KB
User.class 2KB
BookDao.class 2KB
BookDao.class 2KB
PageDto.class 2KB
PageDto.class 2KB
Md5Util.class 2KB
Md5Util.class 2KB
RegistRequestDto.class 1KB
RegistRequestDto.class 1KB
PasswordRequestDto.class 1KB
PasswordRequestDto.class 1KB
PythonUtil.class 1KB
PythonUtil.class 1KB
LoginResponseDto.class 1KB
LoginResponseDto.class 1KB
Hit.class 1KB
Hit.class 1KB
UserService.class 1KB
UserService.class 1KB
CodeUtil.class 1KB
CodeUtil.class 1KB
UserBook.class 1000B
UserBook.class 1000B
BookService.class 670B
BookService.class 670B
UserBookService.class 623B
UserBookService.class 623B
BaseController.class 524B
BaseController.class 524B
HitDao.class 484B
HitDao.class 484B
mvnw.cmd 7KB
.part-00001-79596564-17ff-4a7b-8d0f-577e1f40b8bc-c000.snappy.parquet.crc 16B
.part-00008-79596564-17ff-4a7b-8d0f-577e1f40b8bc-c000.snappy.parquet.crc 16B
.part-00070-79596564-17ff-4a7b-8d0f-577e1f40b8bc-c000.snappy.parquet.crc 16B
.part-00004-79596564-17ff-4a7b-8d0f-577e1f40b8bc-c000.snappy.parquet.crc 16B
.part-00017-d921b4d4-21f4-43ed-9ab1-416ad9ed994b-c000.snappy.parquet.crc 16B
.part-00002-d921b4d4-21f4-43ed-9ab1-416ad9ed994b-c000.snappy.parquet.crc 16B
.part-00008-0bc8939a-f9f9-49d1-b508-c85a592951b8-c000.snappy.parquet.crc 16B
.part-00001-0bc8939a-f9f9-49d1-b508-c85a592951b8-c000.snappy.parquet.crc 16B
.part-00014-0bc8939a-f9f9-49d1-b508-c85a592951b8-c000.snappy.parquet.crc 16B
.part-00004-0bc8939a-f9f9-49d1-b508-c85a592951b8-c000.snappy.parquet.crc 16B
.part-00006-0bc8939a-f9f9-49d1-b508-c85a592951b8-c000.snappy.parquet.crc 16B
.part-00009-0bc8939a-f9f9-49d1-b508-c85a592951b8-c000.snappy.parquet.crc 16B
.part-00018-0bc8939a-f9f9-49d1-b508-c85a592951b8-c000.snappy.parquet.crc 16B
.part-00070-0bc8939a-f9f9-49d1-b508-c85a592951b8-c000.snappy.parquet.crc 16B
.part-00012-0bc8939a-f9f9-49d1-b508-c85a592951b8-c000.snappy.parquet.crc 16B
.part-00042-0bc8939a-f9f9-49d1-b508-c85a592951b8-c000.snappy.parquet.crc 16B
.part-00002-0a9ab9c5-d041-4bbc-b404-5bb0ee6e2259-c000.snappy.parquet.crc 16B
.part-00017-0a9ab9c5-d041-4bbc-b404-5bb0ee6e2259-c000.snappy.parquet.crc 16B
.part-00018-0a9ab9c5-d041-4bbc-b404-5bb0ee6e2259-c000.snappy.parquet.crc 16B
.part-00000-79596564-17ff-4a7b-8d0f-577e1f40b8bc-c000.snappy.parquet.crc 12B
.part-00000-d921b4d4-21f4-43ed-9ab1-416ad9ed994b-c000.snappy.parquet.crc 12B
.part-00000.crc 12B
.part-00000-0bc8939a-f9f9-49d1-b508-c85a592951b8-c000.snappy.parquet.crc 12B
.part-00000-0a9ab9c5-d041-4bbc-b404-5bb0ee6e2259-c000.snappy.parquet.crc 12B
.part-00000.crc 12B
._SUCCESS.crc 8B
._SUCCESS.crc 8B
._SUCCESS.crc 8B
共 1465 条
- 1
- 2
- 3
- 4
- 5
- 6
- 15
生气要吃糖吖
- 粉丝: 122
- 资源: 3
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 基于Java与Python混合语言的train项目设计源码
- 基于Java平台的用户档案设计源码及Shell脚本集成方案
- 基于Java语言的Hadoop、Birch聚类、冒泡排序与数据清洗相结合的MapReduce设计源码
- Simulink三相永磁同步电机EKF与AEKF无传感器控制控制方案 电机基于EKF扩展卡尔曼滤波算法和AEKF的永磁同步电机P
- 基于MATLAB小波变换图像拼接技术GUI版
- 基于Python语言的nb_log设计源码下载与优化镜像站
- 基于三峡大学八月暑期实训的Java语言实训项目设计源码
- 基于Java和Shell的广西交投财产保全信息系统设计源码
- 基于Python和Shell语言的公共API设计源码库
- 基于Java及JavaScript、CSS、HTML的智能中医药数据分析系统设计源码
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0