项目介绍
后端技术包含springboot+mybatis+spring security+mysql+redis
前端技术包含 semanticUI + thymeleaf模板引擎
使用教程
-
下载项目之后 等待maven安装对应jar包
-
自行下载redis 并按照资源包下的application.yml要求进行配置
-
自行安装MySQL数据库 执行资源包下的sql文件
使用说明
-
运行redis服务器
-
启动项目
-
访问localhost:8080
-
用户名:admin 密码:admin
注意事项
若导出信息时报错,则需要设置mysql,设置方式如下:
SELECT @@sql_mode; 查看是否包含ONLY_FULL_GROUP_BY;若包含,则执行以下命令:
SET GLOBAL sql_mode=‘STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION’;
SET SESSION sql_mode=‘STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION’;
执行完成后,再通过SELECT @@sql_mode; 来查看;
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
}
user.setIcon(oldUser.getIcon());
userService.updateUser(user);
if(StringUtils.isBlank(user.getId())){
return ResponseEntity.failure("保存用户信息出错");
}
userService.saveUserRoles(user.getId(),user.getRoleLists());
return ResponseEntity.success("操作成功");
}
@RequiresPermissions("sys:user:lock")
@PostMapping("lock")
@ResponseBody
@SysLog("锁定或开启系统用户")
public ResponseEntity lock(@RequestParam(value = "id",required = false)String id){
if(StringUtils.isBlank(id)){
return ResponseEntity.failure("参数错误");
}
User user = userService.getById(id);
if(user == null){
return ResponseEntity.failure("用户不存在");
@PostMapping("edit")
@ResponseBody
@SysLog("保存系统用户编辑数据")
public ResponseEntity edit(@RequestBody User user){
if(StringUtils.isBlank(user.getId())){
return ResponseEntity.failure("用户ID不能为空");
}
if(StringUtils.isBlank(user.getLoginName())){
return ResponseEntity.failure("登录名不能为空");
}
if(user.getRoleLists() == null || user.getRoleLists().size() == 0){
return ResponseEntity.failure("用户角色至少选择一个");
}
User oldUser = userService.findUserById(user.getId());
if(StringUtils.isNotBlank(user.getEmail())){
if(!user.getEmail().equals(oldUser.getEmail())){
if(userService.userCount(user.getEmail())>0){
return ResponseEntity.failure("该邮箱已被使用");
//设置默认密码
if(StringUtils.isBlank(user.getPassword())){
user.setPassword(Constants.DEFAULT_PASSWORD);
}
userService.saveUser(user);
if(StringUtils.isBlank(user.getId())){
return ResponseEntity.failure("保存用户信息出错");
}
//保存用户角色关系
userService.saveUserRoles(user.getId(),user.getRoleLists());
return ResponseEntity.success("操作成功");
}
@RequestMapping("edit")
public String edit(String id,ModelMap modelMap){
User user = userService.findUserById(id);
String roleIds = "";
@PostMapping("edit")
@ResponseBody
@SysLog("保存系统用户编辑数据")
public ResponseEntity edit(@RequestBody User user){
if(StringUtils.isBlank(user.getId())){
return ResponseEntity.failure("用户ID不能为空");
}
if(StringUtils.isBlank(user.getLoginName())){
return ResponseEntity.failure("登录名不能为空");
}
if(user.getRoleLists() == null || user.getRoleLists().size() == 0){
return ResponseEntity.failure("用户角色至少选择一个");
}
User oldUser = userService.findUserById(user.getId());
if(StringUtils.isNotBlank(user.getEmail())){
if(!user.getEmail().equals(oldUser.getEmail())){
if(userService.userCount(user.getEmail())>0){
PageHelper.startPage(page, limit);
List<StuCourseVO> stuCourseVOS = selCourseManageService.selSc(stuCourseVO);
PageInfo pageInfo = new PageInfo(stuCourseVOS);
Map<String, Object> tableData = new HashMap<String, Object>();
//这是layui要求返回的json数据格式
tableData.put("code", 0);
tableData.put("msg", "");
//将全部数据的条数作为count传给前台(一共多少条)
tableData.put("count", pageInfo.getTotal());
//将分页后的数据返回(每页要显示的数据)
tableData.put("data", pageInfo.getList());
// System.out.print(cs);
return tableData;
}
//下面是下拉框
@RequestMapping("selDe")
@ResponseBody
public Object selDe(){
//下面是下拉框
@RequestMapping("selDe")
@ResponseBody
public Object selDe(){
List<DepartmentDB> departmentDBS = selCourseManageService.selDe();
//System.out.println(departmentDBS);
return departmentDBS;
}
@RequestMapping("selMa")
@ResponseBody
public Object selMa(Integer did){
//System.out.println(did);
List<MajorDB> majors = selCourseManageService.selMa(did);
//System.out.println(majors);
return majors;
}
@RequestMapping("selGr")
@ResponseBody
public Object selGr(Integer mid){
if(!confirmPwd.equals(newPwd)){
return ResponseEntity.failure("确认密码与新密码不一致");
}
//小程序修改密码
if(StringUtils.isBlank(userName)){
//PC修改密码
User user = userService.findUserById(MySysUser.id());
byte[] hashPassword = Encodes.sha1(oldPwd.getBytes(), Encodes.SHA1, Encodes.decodeHex(user.getSalt()), Constants.HASH_INTERATIONS);
String password = Encodes.encodeHex(hashPassword);
if(!user.getPassword().equals(password)){
return ResponseEntity.failure("旧密码错误");
}
user.setPassword(newPwd);
Encodes.entryptPassword(user);
userService.updateById(user);
return ResponseEntity.success("操作成功");
}else {
//小程序修改密码
User user = userService.findUserByLoginName(userName);
byte[] hashPassword = Encodes.sha1(oldPwd.getBytes(), Encodes.SHA1, Encodes.decodeHex(user.getSalt()), Constants.HASH_INTERATIONS);
String password = Encodes.encodeHex(hashPassword);
if(!user.getPassword().equals(password)){
}
user.setIcon(oldUser.getIcon());
userService.updateUser(user);
if(StringUtils.isBlank(user.getId())){
return ResponseEntity.failure("保存用户信息出错");
}
userService.saveUserRoles(user.getId(),user.getRoleLists());
return ResponseEntity.success("操作成功");
}
@RequiresPermissions("sys:user:lock")
@PostMapping("lock")
@ResponseBody
@SysLog("锁定或开启系统用户")
public ResponseEntity lock(@RequestParam(value = "id",required = false)String id){
if(StringUtils.isBlank(id)){
return ResponseEntity.failure("参数错误");
}
User user = userService.getById(id);
if(user == null){
return ResponseEntity.failure("用户不存在");
}
userService.lockUser(user);
return ResponseEntity.success("操作成功");
}
if(StringUtils.isNotBlank(user.getTel())){
if(!user.getTel().equals(oldUser.getTel())) {
if (userService.userCount(user.getTel()) > 0) {
return ResponseEntity.failure("该手机号已经被绑定");
}
}
}
userService.updateById(user);
return ResponseEntity.success("操作成功");
}
@RequestMapping("changePassword")
public String changePassword(ModelMap modelMap){
modelMap.put("currentUser",userService.getById(MySysUser.id()));
return "admin/user/changePassword";
modelMap.put("currentUser",userService.getById(MySysUser.id()));
return "admin/user/changePassword";
}
@CrossOrigin
@SysLog("用户修改密码")
@PostMapping("changePassword")
@ResponseBody
public ResponseEntity changePassword(@RequestParam(value = "userName",required = false)String userName,
@RequestParam(value = "oldPwd",required = false)String oldPwd,
@RequestParam(value = "newPwd",required = false)String newPwd,
@RequestParam(value = "confirmPwd",required = false)String confirmPwd){
if(StringUtils.isBlank(oldPwd)){
return ResponseEntity.failure("旧密码不能为空");
@RequestMapping("edit")
public String edit(String id,ModelMap modelMap){
User user = userService.findUserById(id);
String roleIds = "";
if(user != null) {
roleIds = user.getRoleLists().stream().map(role -> role.getId()).collect(Collectors.joining(","));
}
List<Role> roleList = roleService.selectAll();
modelMap.put("localuser",user);
modelMap.put("roleIds",roleIds);
modelMap.put("roleList",roleList);
return "admin/user/edit";
}
@RequiresPermissions("sys:user:edit")
@PostMapping("edit")
@ResponseBody
@SysLog("保存系统用户编辑数据")
public ResponseEntity edit(@RequestBody User user){
if(StringUtils.isBlank(user.getId())){
return ResponseEntity.failure("用户ID不能为空");
}
if(StringUtils.isBlank(user.getLoginName())){
return ResponseEntity.failure("登录名不能为空");
}
if(user.getRoleLists() == null || user.getRoleLists().size() == 0){
return ResponseEntity.failure("用户角色至少选择一个");
}