肖海南数据库修改

master
wenyu441069198 7 months ago
parent 4a5aae6efc
commit 1fb6d20b7a
  1. 9
      src/main/java/com/teaching/backend/config/MallSecurityConfig.java
  2. 81
      src/main/java/com/teaching/backend/controller/umsAdmin/UmsUserController.java
  3. 4
      src/main/java/com/teaching/backend/mapper/umsAdmin/UmsRoleMapper.java
  4. 1
      src/main/java/com/teaching/backend/mapper/umsAdmin/UmsStudentMapper.java
  5. 1
      src/main/java/com/teaching/backend/mapper/umsAdmin/UmsTeacherMapper.java
  6. 6
      src/main/java/com/teaching/backend/mapper/umsAdmin/UmsUserMapper.java
  7. 7
      src/main/java/com/teaching/backend/model/dto/umsAdmin/UmsStudentAndTeacherDTO.java
  8. 9
      src/main/java/com/teaching/backend/model/dto/umsAdmin/UmsUserParam.java
  9. 4
      src/main/java/com/teaching/backend/model/dto/umsAdmin/UpdateUserPasswordParam.java
  10. 4
      src/main/java/com/teaching/backend/model/entity/umsAdmin/AdminUserDetails.java
  11. 41
      src/main/java/com/teaching/backend/model/entity/umsAdmin/UmsMenu.java
  12. 24
      src/main/java/com/teaching/backend/model/entity/umsAdmin/UmsPermission.java
  13. 20
      src/main/java/com/teaching/backend/model/entity/umsAdmin/UmsRole.java
  14. 46
      src/main/java/com/teaching/backend/model/entity/umsAdmin/UmsStudent.java
  15. 46
      src/main/java/com/teaching/backend/model/entity/umsAdmin/UmsTeacher.java
  16. 7
      src/main/java/com/teaching/backend/model/entity/umsAdmin/UmsUser.java
  17. 10
      src/main/java/com/teaching/backend/model/vo/umsAdmin/UmsStudentVO.java
  18. 10
      src/main/java/com/teaching/backend/model/vo/umsAdmin/UmsTeacherVO.java
  19. 19
      src/main/java/com/teaching/backend/service/impl/courses/CoursesServiceImpl.java
  20. 9
      src/main/java/com/teaching/backend/service/impl/courses/StudentCoursesServiceImpl.java
  21. 9
      src/main/java/com/teaching/backend/service/impl/favour/SeResourceFavourServiceImpl.java
  22. 11
      src/main/java/com/teaching/backend/service/umsAdmin/UmsRoleService.java
  23. 22
      src/main/java/com/teaching/backend/service/umsAdmin/UmsUserService.java
  24. 39
      src/main/java/com/teaching/backend/service/umsAdmin/impl/UmsRoleServiceImpl.java
  25. 212
      src/main/java/com/teaching/backend/service/umsAdmin/impl/UmsUserServiceImpl.java
  26. 44
      src/main/resources/mapper/UmsRoleMapper.xml
  27. 8
      src/main/resources/mapper/UmsStudentMapper.xml
  28. 12
      src/main/resources/mapper/UmsTeacherMapper.xml
  29. 2
      src/main/resources/mapper/UmsUserMapper.xml

@ -1,17 +1,12 @@
package com.teaching.backend.config;
import com.teaching.backend.service.umsAdmin.UmsAdminService;
import com.teaching.backend.service.umsAdmin.UmsUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.access.ConfigAttribute;
import org.springframework.security.core.userdetails.UserDetailsService;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
/**
* mall-security模块相关配置
* Created by macro on 2019/11/9.
@ -20,7 +15,7 @@ import java.util.concurrent.ConcurrentHashMap;
public class MallSecurityConfig {
@Autowired
private UmsAdminService umsadminService;
private UmsUserService umsadminService;
// @Autowired
// private UmsResourceService resourceService;

@ -1,16 +1,14 @@
package com.teaching.backend.controller.umsAdmin;
import cn.hutool.core.collection.CollUtil;
import com.teaching.backend.common.CommonResult;
import com.teaching.backend.common.BaseResponse;
import com.teaching.backend.common.ResultUtils;
import com.teaching.backend.model.dto.UmsAdminParam;
import com.teaching.backend.model.dto.UpdateAdminPasswordParam;
import com.teaching.backend.model.dto.umsAdmin.UmsUserParam;
import com.teaching.backend.model.dto.umsAdmin.UpdateUserPasswordParam;
import com.teaching.backend.model.dto.umsAdmin.UmsStudentAndTeacherDTO;
import com.teaching.backend.model.entity.umsAdmin.UmsAdmin;
import com.teaching.backend.model.entity.umsAdmin.UmsRole;
import com.teaching.backend.model.entity.umsAdmin.UmsUser;
import com.teaching.backend.model.vo.courses.TeacherInfVO;
import com.teaching.backend.service.umsAdmin.UmsAdminService;
import com.teaching.backend.service.umsAdmin.UmsUserService;
import com.teaching.backend.service.umsAdmin.UmsRoleService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@ -24,7 +22,6 @@ import java.security.Principal;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
@ -36,31 +33,31 @@ import java.util.stream.Collectors;
@Api(tags = "UmsAdminController")
@RequestMapping("/api/user")
@Slf4j
public class UmsAdminController {
public class UmsUserController {
@Value("${jwt.tokenHeader}")
private String tokenHeader;
@Value("${jwt.tokenHead}")
private String tokenHead;
@Autowired
private UmsAdminService umsAdminService;
private UmsUserService umsUserService;
@Autowired
private UmsRoleService umsRoleService;
@ApiOperation(value = "用户注册")
@PostMapping("/register")
public CommonResult<UmsAdmin> register(@Validated @RequestBody UmsAdminParam umsAdminParam) {
if (umsAdminParam == null) {
public CommonResult<UmsUser> register(@Validated @RequestBody UmsUserParam umsUserParam) {
if (umsUserParam == null) {
return CommonResult.failed();
}
UmsAdmin umsAdmin = umsAdminService.register(umsAdminParam);
return CommonResult.success(umsAdmin);
UmsUser umsUser = umsUserService.register(umsUserParam);
return CommonResult.success(umsUser);
}
@ApiOperation(value = "用户名登录以后返回token")
@PostMapping("/login")
public CommonResult login(@Validated @RequestBody UmsAdmin umsAdmin) {
String token = umsAdminService.login(umsAdmin.getUsername(), umsAdmin.getPassword());
public CommonResult login(@Validated @RequestBody UmsUser umsUser) {
String token = umsUserService.login(umsUser.getUsername(), umsUser.getPassword());
if (token == null) {
return CommonResult.validateFailed("用户名或密码错误");
}
@ -73,7 +70,7 @@ public class UmsAdminController {
@ApiOperation(value = "手机号登录以后返回token")
@PostMapping("/phone/login")
public CommonResult phoneLogin(@RequestParam("phone")String phone) {
String token = umsAdminService.phoneLogin(phone);
String token = umsUserService.phoneLogin(phone);
if (token == null) {
return CommonResult.validateFailed("手机号不存在!");
}
@ -91,24 +88,24 @@ public class UmsAdminController {
@ApiOperation(value = "发送短信返回验证码")
@PostMapping("/code")
public CommonResult<String> sendVerifyCode(@RequestParam("phone")String phone){
return CommonResult.success(umsAdminService.sendVerifyCode(phone));
return CommonResult.success(umsUserService.sendVerifyCode(phone));
}
@ApiOperation(value = "手机号注册")
@PostMapping("/phone/register")
public CommonResult<UmsAdmin> phoneRegister(@Validated @RequestBody UmsAdminParam umsAdminParam) {
public CommonResult<UmsUser> phoneRegister(@Validated @RequestBody UmsUserParam umsAdminParam) {
if (umsAdminParam == null) {
return CommonResult.failed();
}
UmsAdmin umsAdmin = umsAdminService.phoneRegister(umsAdminParam);
return CommonResult.success(umsAdmin);
UmsUser umsUser = umsUserService.phoneRegister(umsAdminParam);
return CommonResult.success(umsUser);
}
@ApiOperation(value = "刷新token")
@GetMapping("/refreshToken")
public CommonResult refreshToken(HttpServletRequest request) {
String token = request.getHeader(tokenHeader);
String refreshToken = umsAdminService.refreshToken(token);
String refreshToken = umsUserService.refreshToken(token);
if (refreshToken == null) {
return CommonResult.failed("token已经过期!");
}
@ -126,26 +123,22 @@ public class UmsAdminController {
return CommonResult.unauthorized("用户名为空");
}
String username = principal.getName();
UmsAdmin umsAdmin = umsAdminService.getAdminByUsername(username);
UmsUser umsUser = umsUserService.getUserByUsername(username);
Map<String, Object> data = new HashMap<>();
data.put("id",umsAdmin.getId());
data.put("username", umsAdmin.getUsername());
data.put("menus", umsRoleService.getMenuList(umsAdmin.getId()));
data.put("phone", umsAdmin.getPhone());
data.put("nickName", umsAdmin.getNickName());
data.put("icon", umsAdmin.getIcon());
List<UmsRole> roleList = umsAdminService.getRoleList(umsAdmin.getId());
if(CollUtil.isNotEmpty(roleList)){
List<String> roles = roleList.stream().map(UmsRole::getName).collect(Collectors.toList());
data.put("roles",roles);
}
data.put("id",umsUser.getId());
data.put("username", umsUser.getUsername());
data.put("permissions", umsRoleService.getPermissionList(umsUser.getRoleId()));
data.put("phone", umsUser.getPhone());
data.put("nickName", umsUser.getNickName());
data.put("icon", umsUser.getIcon());
data.put("roles",umsRoleService.getRoleList(umsUser.getRoleId()));
return CommonResult.success(data);
}
@ApiOperation("修改指定用户信息")
@PostMapping("/update")
public CommonResult updateUms(@RequestBody UmsAdmin umsadmin) {
boolean count = umsAdminService.updateUms(umsadmin);
public CommonResult updateUms(@RequestBody UmsUser umsUser) {
boolean count = umsUserService.updateUms(umsUser);
if (count == true) {
return CommonResult.success(count);
}
@ -154,16 +147,10 @@ public class UmsAdminController {
@ApiOperation("修改指定用户密码")
@PostMapping("/updatePassword")
public CommonResult updatePassword(@Validated @RequestBody UpdateAdminPasswordParam updatePasswordParam) {
int status = umsAdminService.updatePassword(updatePasswordParam);
if (status > 0) {
public CommonResult updatePassword(@Validated @RequestBody UpdateUserPasswordParam updatePasswordParam) {
int status = umsUserService.updatePassword(updatePasswordParam);
if (status == 1) {
return CommonResult.success(status);
} else if (status == -1) {
return CommonResult.failed("提交参数不合法");
} else if (status == -2) {
return CommonResult.failed("找不到该用户");
} else if (status == -3) {
return CommonResult.failed("旧密码错误");
} else {
return CommonResult.failed();
}
@ -175,7 +162,7 @@ public class UmsAdminController {
if (id == null){
return CommonResult.failed("参数为空");
}
Object count = umsAdminService.getByIdPersonalInfo(id);
Object count = umsUserService.getByIdPersonalInfo(id);
if (count == null) {
return CommonResult.failed();
}
@ -185,7 +172,7 @@ public class UmsAdminController {
@ApiOperation("修改指定个人信息")
@PostMapping("/update/PersonalInfo")
public CommonResult updatePersonalInfo(@RequestBody UmsStudentAndTeacherDTO umsStudentAndTeacherDTO) {
boolean count = umsAdminService.updatePersonalInfo(umsStudentAndTeacherDTO);
boolean count = umsUserService.updatePersonalInfo(umsStudentAndTeacherDTO);
if (count == true) {
return CommonResult.success("修改成功");
}
@ -195,7 +182,7 @@ public class UmsAdminController {
@ApiOperation("获取教师信息列表,关联教师的username和name")
@GetMapping("/get_teacherinf_list")
public BaseResponse<List<TeacherInfVO>> getTeacherInfList(){
List<TeacherInfVO> teacherInfVO = umsAdminService.getTeacherInfList();
List<TeacherInfVO> teacherInfVO = umsUserService.getTeacherInfList();
return ResultUtils.success(teacherInfVO);
}

@ -2,8 +2,6 @@ package com.teaching.backend.mapper.umsAdmin;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.teaching.backend.model.entity.umsAdmin.UmsAdminRoleRelation;
import com.teaching.backend.model.entity.umsAdmin.UmsMenu;
import com.teaching.backend.model.entity.umsAdmin.UmsRole;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@ -19,7 +17,7 @@ public interface UmsRoleMapper extends BaseMapper<UmsRole> {
/**
* 根据后台用户ID获取菜单
*/
List<UmsMenu> getMenuList(@Param("adminId") Long adminId);
// List<UmsMenu> getMenuList(@Param("adminId") Long adminId);
// /**
// * 根据角色ID获取菜单
// */

@ -14,4 +14,5 @@ import com.teaching.backend.model.entity.umsAdmin.UmsStudent;
public interface UmsStudentMapper extends BaseMapper<UmsStudent> {
boolean updateStudentInfo(UmsStudent umsStudent);
UmsStudent selectByUserId(Integer userId);
}

@ -14,4 +14,5 @@ import com.teaching.backend.model.entity.umsAdmin.UmsTeacher;
public interface UmsTeacherMapper extends BaseMapper<UmsTeacher> {
boolean updateTeacherInfo(UmsTeacher umsTeacher);
UmsTeacher selectByUserId(Integer userId);
}

@ -1,16 +1,16 @@
package com.teaching.backend.mapper.umsAdmin;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.teaching.backend.model.entity.umsAdmin.UmsAdmin;
import com.teaching.backend.model.entity.umsAdmin.UmsRole;
import com.teaching.backend.model.entity.umsAdmin.UmsTeacher;
import com.teaching.backend.model.entity.umsAdmin.UmsUser;
import com.teaching.backend.model.vo.umsAdmin.UmsStudentVO;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface UmsAdminMapper extends BaseMapper<UmsAdmin> {
public interface UmsUserMapper extends BaseMapper<UmsUser> {
boolean updateUserInformation(UmsAdmin umsadmin);
boolean updateUserInformation(UmsUser umsUser);
UmsRole getByIdRoleInfo(String id);

@ -92,7 +92,7 @@ public class UmsStudentAndTeacherDTO implements Serializable {
/**
* 学位
*/
private String degree;
private String academicDegree;
/**
* 职称
@ -114,6 +114,11 @@ public class UmsStudentAndTeacherDTO implements Serializable {
*/
private String politicalStatus;
/**
* user_id
*/
private Integer userId;
/**
* role_id
*/

@ -1,16 +1,13 @@
package com.teaching.backend.model.dto;
package com.teaching.backend.model.dto.umsAdmin;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.io.Serializable;
import java.time.LocalDateTime;
@Data
@TableName("ums_admin")
public class UmsAdminParam implements Serializable {
@TableName("ums_user")
public class UmsUserParam implements Serializable {
//用户名
private String username;

@ -1,4 +1,4 @@
package com.teaching.backend.model.dto;
package com.teaching.backend.model.dto.umsAdmin;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@ -9,7 +9,7 @@ import lombok.Data;
* Created by macro on 2019/10/9.
*/
@Data
public class UpdateAdminPasswordParam {
public class UpdateUserPasswordParam {
// @NotEmpty
@ApiModelProperty(value = "用户名", required = true)
private String username;

@ -15,11 +15,11 @@ import java.util.stream.Collectors;
*/
public class AdminUserDetails implements UserDetails {
//后台用户
private final UmsAdmin umsAdmin;
private final UmsUser umsAdmin;
//拥有资源列表
private final List<UmsResource> resourceList;
public AdminUserDetails(UmsAdmin umsAdmin, List<UmsResource> resourceList) {
public AdminUserDetails(UmsUser umsAdmin, List<UmsResource> resourceList) {
this.umsAdmin = umsAdmin;
this.resourceList = resourceList;
}

@ -1,41 +0,0 @@
package com.teaching.backend.model.entity.umsAdmin;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
@Data
@TableName("ums_menu")
public class UmsMenu implements Serializable {
private Long id;
@ApiModelProperty(value = "父级ID")
private Long parentId;
@ApiModelProperty(value = "创建时间")
private Date createTime;
@ApiModelProperty(value = "菜单名称")
private String title;
@ApiModelProperty(value = "菜单级数")
private Integer level;
@ApiModelProperty(value = "菜单排序")
private Integer sort;
@ApiModelProperty(value = "前端名称")
private String name;
@ApiModelProperty(value = "前端图标")
private String icon;
@ApiModelProperty(value = "前端隐藏")
private Integer hidden;
private static final long serialVersionUID = 1L;
}

@ -0,0 +1,24 @@
package com.teaching.backend.model.entity.umsAdmin;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
@Data
@TableName("ums_permission")
public class UmsPermission implements Serializable {
//主键
@TableId(type = IdType.AUTO)
private Long id;
//菜单名称
private String name;
//创建时间
private Date createTime;
}

@ -1,5 +1,7 @@
package com.teaching.backend.model.entity.umsAdmin;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@ -9,25 +11,23 @@ import java.util.Date;
@Data
@TableName("ums_role")
public class UmsRole implements Serializable {
//主键
@TableId(type = IdType.AUTO)
private Long id;
@ApiModelProperty(value = "名称")
//名称
private String name;
@ApiModelProperty(value = "描述")
//描述
private String description;
@ApiModelProperty(value = "后台用户数量")
private Integer adminCount;
@ApiModelProperty(value = "创建时间")
//创建时间
private Date createTime;
@ApiModelProperty(value = "启用状态:0->禁用;1->启用")
//启用状态:0->禁用;1->启用
private Integer status;
private Integer sort;
private static final long serialVersionUID = 1L;
//权限id
private String permissionId;
}

@ -26,62 +26,40 @@ public class UmsStudent implements Serializable {
private static final long serialVersionUID = 1L;
@TableId(value = "id", type = IdType.ASSIGN_ID)
@TableId(value = "id", type = IdType.AUTO)
private Integer id;
/**
* 姓名
*/
//姓名
private String name;
/**
* 性别
*/
//性别
private String sex;
/**
* 民族
*/
//民族
private String nationality;
/**
* 学号
*/
//学号
private String number;
/**
* 生日
*/
//生日
private LocalDateTime birthday;
/**
* 手机号
*/
//手机号
private String phone;
/**
* 院系
*/
//院系
private String faculty;
/**
* 专业
*/
//专业
private String major;
/**
* 入学年份
*/
//入学年份
private LocalDate yearAge;
/**
* 班级
*/
//班级
private String className;
/**
* user_id
*/
//user_id
private Integer userId;

@ -28,59 +28,37 @@ public class UmsTeacher implements Serializable {
@TableId(value = "id", type = IdType.AUTO)
private Integer id;
/**
* 姓名
*/
//姓名
private String name;
/**
* 性别
*/
//性别
private String sex;
/**
* 民族
*/
//民族
private String nationality;
/**
* 专业
*/
//专业
private String profession;
/**
* 学历
*/
//学历
private String education;
/**
* 学位
*/
private String degree;
//学位
private String academicDegree;
/**
* 职称
*/
//职称
private String professionalTitle;
/**
* 手机号
*/
//手机号
private String emergencyContact;
/**
* 参加工作时间
*/
//参加工作时间
private LocalDateTime joinWorkTime;
/**
* 政治面貌
*/
//政治面貌
private String politicalStatus;
/**
* user_id
*/
//user_id
private Integer userId;

@ -9,8 +9,8 @@ import java.io.Serializable;
import java.time.LocalDateTime;
@Data
@TableName("ums_admin")
public class UmsAdmin implements Serializable {
@TableName("ums_user")
public class UmsUser implements Serializable {
//主键
@TableId(type = IdType.AUTO)
@ -36,4 +36,7 @@ public class UmsAdmin implements Serializable {
//账号状态
private Integer status;
//角色id
private String roleId;
}

@ -10,6 +10,7 @@ import lombok.experimental.Accessors;
import java.io.Serializable;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;
/**
* <p>
@ -27,7 +28,7 @@ public class UmsStudentVO implements Serializable {
private static final long serialVersionUID = 1L;
@TableId(value = "id", type = IdType.ASSIGN_ID)
@TableId(value = "id", type = IdType.AUTO)
private Integer id;
/**
@ -80,9 +81,14 @@ public class UmsStudentVO implements Serializable {
*/
private String className;
/**
* user_id
*/
private Integer userId;
/**
* role_id
*/
private Integer roleId;
private List<String> roleId;
}

@ -9,6 +9,7 @@ import lombok.experimental.Accessors;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.List;
/**
* <p>
@ -57,7 +58,7 @@ public class UmsTeacherVO implements Serializable {
/**
* 学位
*/
private String degree;
private String academicDegree;
/**
* 职称
@ -79,9 +80,14 @@ public class UmsTeacherVO implements Serializable {
*/
private String politicalStatus;
/**
* user_id
*/
private Integer userId;
/**
* role_id
*/
private Integer roleId;
private List<String> roleId;
}

@ -14,18 +14,18 @@ import com.teaching.backend.mapper.chapter.ChapterMapper;
import com.teaching.backend.mapper.courses.*;
import com.teaching.backend.mapper.know.KnowRelationshipMapper;
import com.teaching.backend.mapper.records.LearningRecordsMapper;
import com.teaching.backend.mapper.umsAdmin.UmsAdminMapper;
import com.teaching.backend.mapper.umsAdmin.UmsAdminRoleRelationMapper;
import com.teaching.backend.mapper.umsAdmin.UmsTeacherMapper;
import com.teaching.backend.mapper.umsAdmin.UmsUserMapper;
import com.teaching.backend.model.dto.courses.CoursesDTO;
import com.teaching.backend.model.dto.courses.PageDTO;
import com.teaching.backend.model.entity.chapter.Chapter;
import com.teaching.backend.model.entity.courses.*;
import com.teaching.backend.model.entity.know.KnowRelationship;
import com.teaching.backend.model.entity.records.LearningRecords;
import com.teaching.backend.model.entity.umsAdmin.UmsAdmin;
import com.teaching.backend.model.entity.umsAdmin.UmsAdminRoleRelation;
import com.teaching.backend.model.entity.umsAdmin.UmsTeacher;
import com.teaching.backend.model.entity.umsAdmin.UmsUser;
import com.teaching.backend.model.query.CourseQuery;
import com.teaching.backend.model.vo.courses.CourseObjectivesTreeVO;
import com.teaching.backend.model.vo.courses.CoursesVO;
@ -82,7 +82,7 @@ public class CoursesServiceImpl extends ServiceImpl<CoursesMapper, Courses> impl
@Autowired
ObjectivesTypeMapper objectivesTypeMapper;
@Autowired
UmsAdminMapper umsAdminMapper;
UmsUserMapper umsUserMapper;
@Autowired
UmsTeacherMapper umsTeacherMapper;
@Autowired
@ -158,8 +158,8 @@ public class CoursesServiceImpl extends ServiceImpl<CoursesMapper, Courses> impl
// throw new BusinessException(ErrorCode.USERNAME_NOT_EXIT);
// }
UmsAdmin umsAdmin = umsAdminMapper.selectOne(new LambdaQueryWrapper<UmsAdmin>()
.eq(UmsAdmin::getUsername, username));
UmsUser umsAdmin = umsUserMapper.selectOne(new LambdaQueryWrapper<UmsUser>()
.eq(UmsUser::getUsername, username));
UmsAdminRoleRelation umsAdminRoleRelation = umsAdminRoleRelationMapper.selectOne(new LambdaQueryWrapper<UmsAdminRoleRelation>()
.eq(UmsAdminRoleRelation::getAdminId, umsAdmin.getId()));
@ -225,14 +225,14 @@ public class CoursesServiceImpl extends ServiceImpl<CoursesMapper, Courses> impl
List<String> teacherNameList = new ArrayList<>();
String[] teacherIds = coursesVO.getTeacher().split(",");
for (String teacherId : teacherIds) {
UmsAdmin umsAdminTea = umsAdminMapper.selectOne(new LambdaQueryWrapper<UmsAdmin>()
.eq(UmsAdmin::getUsername, teacherId));
if (umsAdminTea == null) {
UmsUser umsUserTea = umsUserMapper.selectOne(new LambdaQueryWrapper<UmsUser>()
.eq(UmsUser::getUsername, teacherId));
if (umsUserTea == null) {
throw new BusinessException(ErrorCode.OPERATION_ERROR);
}
// System.out.println(umsAdminTea);
UmsTeacher umsTeacher = umsTeacherMapper.selectOne(new LambdaQueryWrapper<UmsTeacher>()
.eq(UmsTeacher::getUserId, umsAdminTea.getId()));
.eq(UmsTeacher::getUserId, umsUserTea.getId()));
System.out.println(umsTeacher);
if (umsTeacher == null){
throw new BusinessException(ErrorCode.PARAMS_USER_NOTEXISTS);
@ -308,6 +308,7 @@ public class CoursesServiceImpl extends ServiceImpl<CoursesMapper, Courses> impl
// List<Courses> list = coursesMapper.selectList(null);
List<CoursesVO> coursesVo = BeanUtil.copyToList(list, CoursesVO.class);
coursesVo = coursesVo.stream().map((item) -> {
item.setTotalHours(countHours(item.getId()));
item.setTotalchapter(countChapters(item.getId()));
item.setTotalKnow(countKnow(item.getId()));

@ -9,23 +9,18 @@ import com.teaching.backend.common.ErrorCode;
import com.teaching.backend.exception.BusinessException;
import com.teaching.backend.mapper.courses.CoursesMapper;
import com.teaching.backend.mapper.courses.StudentCoursesMapper;
import com.teaching.backend.mapper.umsAdmin.UmsAdminMapper;
import com.teaching.backend.mapper.umsAdmin.UmsUserMapper;
import com.teaching.backend.mapper.umsAdmin.UmsTeacherMapper;
import com.teaching.backend.model.dto.courses.ObjectiveContentKnowDTO;
import com.teaching.backend.model.dto.courses.PageDTO;
import com.teaching.backend.model.dto.courses.StudentCoursesDTO;
import com.teaching.backend.model.entity.courses.Courses;
import com.teaching.backend.model.entity.courses.ObjectiveContentKnow;
import com.teaching.backend.model.entity.courses.StudentCourses;
import com.teaching.backend.model.entity.umsAdmin.UmsAdmin;
import com.teaching.backend.model.entity.umsAdmin.UmsTeacher;
import com.teaching.backend.model.query.CourseQuery;
import com.teaching.backend.model.vo.courses.CoursesVO;
import com.teaching.backend.service.courses.ICoursesService;
import com.teaching.backend.service.courses.IStudentCoursesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Arrays;
@ -46,7 +41,7 @@ public class StudentCoursesServiceImpl extends ServiceImpl<StudentCoursesMapper,
@Autowired
StudentCoursesMapper studentCoursesMapper;
@Autowired
UmsAdminMapper umsAdminMapper;
UmsUserMapper umsAdminMapper;
@Autowired
UmsTeacherMapper umsTeacherMapper;
@Autowired

@ -10,11 +10,10 @@ import com.teaching.backend.exception.BusinessException;
import com.teaching.backend.mapper.courses.CoursesMapper;
import com.teaching.backend.mapper.favour.SeResourceFavourMapper;
import com.teaching.backend.mapper.resource.CourseResourcesMapper;
import com.teaching.backend.mapper.umsAdmin.UmsAdminMapper;
import com.teaching.backend.mapper.umsAdmin.UmsUserMapper;
import com.teaching.backend.model.entity.CourseResources;
import com.teaching.backend.model.entity.courses.Courses;
import com.teaching.backend.model.entity.favour.SeResourceFavour;
import com.teaching.backend.model.entity.umsAdmin.UmsAdmin;
import com.teaching.backend.model.entity.umsAdmin.UmsUser;
import com.teaching.backend.service.resource.CourseResourcesService;
import com.teaching.backend.service.favour.SeResourceFavourService;
import org.springframework.beans.factory.annotation.Autowired;
@ -42,7 +41,7 @@ public class SeResourceFavourServiceImpl extends ServiceImpl<SeResourceFavourMap
private CourseResourcesService courseResourcesService;
@Autowired
private UmsAdminMapper umsAdminMapper;
private UmsUserMapper umsAdminMapper;
@Autowired
private CourseResourcesMapper courseResourcesMapper;
@ -92,7 +91,7 @@ public class SeResourceFavourServiceImpl extends ServiceImpl<SeResourceFavourMap
@Override
public Page<CourseResources> listCourseFavourByPage(String userId, Integer type, Integer page, Integer pageSize) {
UmsAdmin umsAdmin = umsAdminMapper.selectById(userId);
UmsUser umsAdmin = umsAdminMapper.selectById(userId);
if(umsAdmin == null){
throw new BusinessException(ErrorCode.PARAMS_USER_NOTEXISTS);
}

@ -1,10 +1,5 @@
package com.teaching.backend.service.umsAdmin;
import com.teaching.backend.model.entity.umsAdmin.UmsMenu;
import com.teaching.backend.model.entity.umsAdmin.UmsResource;
import com.teaching.backend.model.entity.umsAdmin.UmsRole;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
/**
@ -14,8 +9,10 @@ import java.util.List;
public interface UmsRoleService {
/**
* 根据管理员ID获取对应菜单
* 根据角色id获取对应权限
*/
List<UmsMenu> getMenuList(Long adminId);
List<String> getPermissionList(String roleId);
List<String> getRoleList(String roleId);
}

@ -1,23 +1,23 @@
package com.teaching.backend.service.umsAdmin;
import com.baomidou.mybatisplus.extension.service.IService;
import com.teaching.backend.model.dto.UmsAdminParam;
import com.teaching.backend.model.dto.UpdateAdminPasswordParam;
import com.teaching.backend.model.dto.umsAdmin.UmsUserParam;
import com.teaching.backend.model.dto.umsAdmin.UpdateUserPasswordParam;
import com.teaching.backend.model.dto.umsAdmin.UmsStudentAndTeacherDTO;
import com.teaching.backend.model.entity.umsAdmin.UmsAdmin;
import com.teaching.backend.model.entity.umsAdmin.UmsResource;
import com.teaching.backend.model.entity.umsAdmin.UmsRole;
import com.teaching.backend.model.entity.umsAdmin.UmsUser;
import com.teaching.backend.model.vo.courses.TeacherInfVO;
import org.springframework.security.core.userdetails.UserDetails;
import java.util.List;
public interface UmsAdminService extends IService<UmsAdmin> {
public interface UmsUserService extends IService<UmsUser> {
/**
* 注册功能
*/
UmsAdmin register(UmsAdminParam umsAdminParam);
UmsUser register(UmsUserParam umsUserParam);
/**
* 登录功能
@ -31,12 +31,12 @@ public interface UmsAdminService extends IService<UmsAdmin> {
/**
* 根据用户名获取后台管理员
*/
UmsAdmin getAdminByUsername(String username);
UmsUser getUserByUsername(String username);
/**
* 获取指定用户的可访问的资源
*/
List<UmsResource> getResourceList(Long adminId);
List<UmsResource> getResourceList(Long userId);
/**
* 获取用户信息
@ -52,17 +52,17 @@ public interface UmsAdminService extends IService<UmsAdmin> {
/**
* 获取用户对应角色
*/
List<UmsRole> getRoleList(Long adminId);
List<UmsRole> getRoleList(Long userId);
/**
* 修改指定用户信息
*/
boolean updateUms(UmsAdmin umsadmin);
boolean updateUms(UmsUser umsUser);
/**
* 修改密码
*/
int updatePassword(UpdateAdminPasswordParam updatePasswordParam);
int updatePassword(UpdateUserPasswordParam updatePasswordParam);
/**
* 发送短信
@ -72,7 +72,7 @@ public interface UmsAdminService extends IService<UmsAdmin> {
/**
* 手机号注册
*/
UmsAdmin phoneRegister(UmsAdminParam umsAdminParam);
UmsUser phoneRegister(UmsUserParam umsUserParam);
/**
* 手机号登录

@ -1,26 +1,49 @@
package com.teaching.backend.service.umsAdmin.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.teaching.backend.mapper.umsAdmin.UmsRoleMapper;
import com.teaching.backend.model.entity.umsAdmin.UmsMenu;
import com.teaching.backend.model.entity.umsAdmin.UmsRole;
import com.teaching.backend.service.umsAdmin.UmsRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.*;
import java.util.stream.Collectors;
/**
* 后台角色管理Service实现类
* Created by macro on 2018/9/30.
*/
@Service
public class UmsRoleServiceImpl implements UmsRoleService {
public class UmsRoleServiceImpl extends ServiceImpl<UmsRoleMapper, UmsRole> implements UmsRoleService {
@Override
public List<String> getPermissionList(String roleId) {
Set<String> set = new HashSet<>();
String[] roleList = roleId.split(",");
for (String role : roleList) {
UmsRole umsRole = lambdaQuery().eq(UmsRole::getId, role).one();
if(umsRole.getStatus() == 1){
String[] permissions = umsRole.getPermissionId().split(",");
List<String> permissionList = Arrays.stream(permissions).collect(Collectors.toList());
set.addAll(permissionList);
}
}
List<String> permissionList = new ArrayList<>(set);
@Autowired
private UmsRoleMapper umsRoleMapper;
return permissionList;
}
@Override
public List<UmsMenu> getMenuList(Long adminId) {
return umsRoleMapper.getMenuList(adminId);
public List<String> getRoleList(String roleId) {
List<String> roleList = new ArrayList<>();
String[] roles = roleId.split(",");
for (String role : roles) {
UmsRole umsRole = lambdaQuery().eq(UmsRole::getId, role).one();
if(umsRole.getStatus() == 1){
roleList.add(role);
}
}
return roleList;
}
}

@ -7,31 +7,24 @@ import com.aliyuncs.dysmsapi.model.v20170525.SendSmsResponse;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.google.gson.Gson;
import com.teaching.backend.exception.Asserts;
import com.teaching.backend.exception.BusinessException;
import com.teaching.backend.exception.LyException;
import com.teaching.backend.mapper.umsAdmin.UmsAdminMapper;
import com.teaching.backend.mapper.umsAdmin.UmsAdminRoleRelationMapper;
import com.teaching.backend.mapper.umsAdmin.UmsStudentMapper;
import com.teaching.backend.mapper.umsAdmin.UmsTeacherMapper;
import com.teaching.backend.model.dto.UmsAdminParam;
import com.teaching.backend.model.dto.UpdateAdminPasswordParam;
import com.teaching.backend.mapper.umsAdmin.*;
import com.teaching.backend.model.dto.umsAdmin.UmsUserParam;
import com.teaching.backend.model.dto.umsAdmin.UpdateUserPasswordParam;
import com.teaching.backend.model.dto.umsAdmin.UmsStudentAndTeacherDTO;
import com.teaching.backend.model.entity.umsAdmin.*;
import com.teaching.backend.model.vo.courses.TeacherInfVO;
import com.teaching.backend.model.vo.umsAdmin.UmsStudentVO;
import com.teaching.backend.model.vo.umsAdmin.UmsTeacherVO;
import com.teaching.backend.service.umsAdmin.UmsAdminService;
import com.teaching.backend.service.umsAdmin.UmsUserService;
import com.teaching.backend.utils.JwtTokenUtil;
import com.teaching.backend.utils.RegexUtils;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.RandomStringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.core.context.SecurityContextHolder;
@ -51,9 +44,9 @@ import java.util.UUID;
@Service
@Slf4j
public class UmsAdminServiceImpl extends ServiceImpl<UmsAdminMapper, UmsAdmin> implements UmsAdminService {
public class UmsUserServiceImpl extends ServiceImpl<UmsUserMapper, UmsUser> implements UmsUserService {
private static final Logger LOGGER = LoggerFactory.getLogger(UmsAdminServiceImpl.class);
private static final Logger LOGGER = LoggerFactory.getLogger(UmsUserServiceImpl.class);
@Autowired
private JwtTokenUtil jwtTokenUtil;
@Autowired
@ -65,37 +58,40 @@ public class UmsAdminServiceImpl extends ServiceImpl<UmsAdminMapper, UmsAdmin> i
@Autowired
UmsTeacherMapper umsTeacherMapper;
@Autowired
UmsAdminMapper umsAdminMapper;
UmsUserMapper umsUserMapper;
@Autowired
UmsRoleMapper umsRoleMapper;
@Override
public UmsAdmin register(UmsAdminParam umsAdminParam) {
UmsAdmin umsAdmin = new UmsAdmin();
BeanUtils.copyProperties(umsAdminParam, umsAdmin);
umsAdmin.setCreateTime(LocalDateTime.now());
umsAdmin.setStatus(1);
public UmsUser register(UmsUserParam umsAdminParam) {
UmsUser umsUser = new UmsUser();
BeanUtils.copyProperties(umsAdminParam, umsUser);
umsUser.setCreateTime(LocalDateTime.now());
umsUser.setStatus(1);
//查询是否有相同用户名的用户
List<UmsAdmin> umsAdminList = lambdaQuery()
.eq(UmsAdmin::getUsername, umsAdmin.getUsername())
List<UmsUser> umsAdminList = lambdaQuery()
.eq(UmsUser::getUsername, umsUser.getUsername())
.list();
if (umsAdminList.size() > 0) {
throw new BusinessException(500,"用户已存在");
}
//将密码进行加密操作
String encodePassword = passwordEncoder.encode(umsAdmin.getPassword());
umsAdmin.setPassword(encodePassword);
save(umsAdmin);
String encodePassword = passwordEncoder.encode(umsUser.getPassword());
umsUser.setPassword(encodePassword);
//分配角色(学生)
umsUser.setRoleId("2");
save(umsUser);
//创建学生信息(默认是学生)
UmsAdmin byUsername = lambdaQuery().eq(UmsAdmin::getUsername, umsAdmin.getUsername())
UmsUser byUsername = lambdaQuery().eq(UmsUser::getUsername, umsUser.getUsername())
.one();
UmsStudent umsStudent = new UmsStudent();
umsStudent.setUserId(Math.toIntExact(byUsername.getId()));
umsStudentMapper.insert(umsStudent);
//分配角色(学生)
adminRoleRelation.insert(byUsername.getId(), 2L);
return umsAdmin;
return umsUser;
}
@Override
@ -127,7 +123,7 @@ public class UmsAdminServiceImpl extends ServiceImpl<UmsAdminMapper, UmsAdmin> i
String token = null;
//密码需要客户端加密后传递
try {
UmsAdmin phoneAdmin = lambdaQuery().eq(UmsAdmin::getPhone, phone)
UmsUser phoneAdmin = lambdaQuery().eq(UmsUser::getPhone, phone)
.one();
if (phoneAdmin == null){
throw new BusinessException(400,"手机号未注册");
@ -148,24 +144,39 @@ public class UmsAdminServiceImpl extends ServiceImpl<UmsAdminMapper, UmsAdmin> i
@Override
public Object getByIdPersonalInfo(String id) {
UmsRole umsRole = umsAdminMapper.getByIdRoleInfo(id);
if (umsRole == null){
UmsUser umsUser = lambdaQuery().eq(UmsUser::getId, id).one();
if (umsUser.getRoleId() == null){
throw new BusinessException(500,"用户未分配角色");
}
if(umsRole.getStatus()==0){
String[] roles = umsUser.getRoleId().split(",");
List<String> roleList = new ArrayList<>();
for (String role : roles) {
UmsRole umsRole = umsRoleMapper.selectById(role);
if(umsRole.getStatus() == 1){
roleList.add(role);
}
}
if (roleList == null){
throw new BusinessException(500,"角色被禁用");
}
if (umsRole.getId() == 1){
UmsTeacher teacher = umsAdminMapper.getByIdTeacher(id);
UmsTeacherVO umsTeacherVO = new UmsTeacherVO();
//查询个人信息
UmsTeacher teacher = umsUserMapper.getByIdTeacher(id);
UmsTeacherVO umsTeacherVO = new UmsTeacherVO();
if (teacher != null){
BeanUtils.copyProperties(teacher,umsTeacherVO);
umsTeacherVO.setRoleId(Math.toIntExact(umsRole.getId()));
}
umsTeacherVO.setRoleId(roleList);
if (teacher != null){
return umsTeacherVO;
}else if (umsRole.getId() == 2){
UmsStudentVO student = umsAdminMapper.getByIdStudent(id);
UmsStudentVO umsStudentVO = new UmsStudentVO();
}
UmsStudentVO student = umsUserMapper.getByIdStudent(id);
UmsStudentVO umsStudentVO = new UmsStudentVO();
if (student != null){
BeanUtils.copyProperties(student,umsStudentVO);
umsStudentVO.setRoleId(Math.toIntExact(umsRole.getId()));
}
umsStudentVO.setRoleId(roleList);
if (student != null){
return umsStudentVO;
}
return null;
@ -174,54 +185,59 @@ public class UmsAdminServiceImpl extends ServiceImpl<UmsAdminMapper, UmsAdmin> i
@Override
public boolean updatePersonalInfo(UmsStudentAndTeacherDTO umsStudentAndTeacherDTO) {
if (umsStudentAndTeacherDTO.getRoleId() == 1){
UmsTeacher umsTeacher = new UmsTeacher();
BeanUtils.copyProperties(umsStudentAndTeacherDTO,umsTeacher);
System.out.println(umsTeacher);
UmsTeacher umsTeacher = new UmsTeacher();
BeanUtils.copyProperties(umsStudentAndTeacherDTO,umsTeacher);
UmsTeacher teacher = umsTeacherMapper.selectByUserId(umsTeacher.getUserId());
if (teacher != null){
return umsTeacherMapper.updateTeacherInfo(umsTeacher);
} else if (umsStudentAndTeacherDTO.getRoleId() == 2) {
UmsStudent umsStudent = new UmsStudent();
BeanUtils.copyProperties(umsStudentAndTeacherDTO,umsStudent);
}
UmsStudent umsStudent = new UmsStudent();
BeanUtils.copyProperties(umsStudentAndTeacherDTO,umsStudent);
UmsStudent student = umsStudentMapper.selectByUserId(umsStudent.getUserId());
if (student != null){
return umsStudentMapper.updateStudentInfo(umsStudent);
}
return false;
}
@Override
public boolean updateUms(UmsAdmin umsadmin) {
List<UmsAdmin> adminList = lambdaQuery().eq(UmsAdmin::getUsername, umsadmin.getUsername())
public boolean updateUms(UmsUser umsUser) {
List<UmsUser> adminList = lambdaQuery().eq(UmsUser::getUsername, umsUser.getUsername())
.list();
if (adminList.size() > 0){
throw new BusinessException(400,"用户名已存在");
}
if (!StrUtil.isEmpty(umsadmin.getPassword())){
if (!StrUtil.isEmpty(umsUser.getPassword())){
throw new BusinessException(400,"修改操作错误1");
}
if (umsadmin.getCreateTime() != null){
if (umsUser.getCreateTime() != null){
throw new BusinessException(400,"修改操作错误2");
}
return umsAdminMapper.updateUserInformation(umsadmin);
return umsUserMapper.updateUserInformation(umsUser);
}
@Override
public int updatePassword(UpdateAdminPasswordParam param) {
public int updatePassword(UpdateUserPasswordParam param) {
if(StrUtil.isEmpty(param.getUsername())
||StrUtil.isEmpty(param.getOldPassword())
||StrUtil.isEmpty(param.getNewPassword())){
throw new BusinessException(400,"修改密码操作错误");
}
List<UmsAdmin> adminList = lambdaQuery()
.eq(UmsAdmin::getUsername, param.getUsername())
List<UmsUser> userList = lambdaQuery()
.eq(UmsUser::getUsername, param.getUsername())
.list();
if(CollUtil.isEmpty(adminList)){
if(CollUtil.isEmpty(userList)){
throw new BusinessException(400,"用户名不存在");
}
UmsAdmin umsAdmin = adminList.get(0);
if(!passwordEncoder.matches(param.getOldPassword(),umsAdmin.getPassword())){
UmsUser umsUser = userList.get(0);
if(!passwordEncoder.matches(param.getOldPassword(),umsUser.getPassword())){
throw new BusinessException(400,"密码重复");
}
umsAdmin.setPassword(passwordEncoder.encode(param.getNewPassword()));
updateById(umsAdmin);
umsUser.setPassword(passwordEncoder.encode(param.getNewPassword()));
updateById(umsUser);
return 1;
}
@ -231,14 +247,6 @@ public class UmsAdminServiceImpl extends ServiceImpl<UmsAdminMapper, UmsAdmin> i
throw new BusinessException(400, "手机号格式错误");
}
// UmsAdmin admin = lambdaQuery()
// .eq(UmsAdmin::getPhone, phone)
// .one();
// if (admin != null){
//// throw new ;
// return null;
// }
String code = RandomStringUtils.randomNumeric(5);
String ALIBABA_CLOUD_ACCESS_KEY_ID = "LTAI5tF7fcDC5VTj1cVWKDU6";
@ -267,34 +275,34 @@ public class UmsAdminServiceImpl extends ServiceImpl<UmsAdminMapper, UmsAdmin> i
}
@Override
public UmsAdmin phoneRegister(UmsAdminParam umsAdminParam) {
UmsAdmin umsAdmin = new UmsAdmin();
BeanUtils.copyProperties(umsAdminParam, umsAdmin);
umsAdmin.setCreateTime(LocalDateTime.now());
umsAdmin.setStatus(1);
public UmsUser phoneRegister(UmsUserParam umsUserParam) {
UmsUser umsUser = new UmsUser();
BeanUtils.copyProperties(umsUserParam, umsUser);
umsUser.setCreateTime(LocalDateTime.now());
umsUser.setStatus(1);
//查询是否有相同手机号的用户
List<UmsAdmin> umsAdminList = lambdaQuery()
.eq(UmsAdmin::getPhone,umsAdminParam.getPhone())
List<UmsUser> umsUserList = lambdaQuery()
.eq(UmsUser::getPhone,umsUserParam.getPhone())
.list();
if (umsAdminList.size() > 0 ) {
if (umsUserList.size() > 0 ) {
throw new BusinessException(400,"手机号已存在");
}
//将密码进行加密操作
String encodePassword = passwordEncoder.encode(umsAdmin.getPassword());
umsAdmin.setUsername(randomUsername());
umsAdmin.setPassword(encodePassword);
save(umsAdmin);
String encodePassword = passwordEncoder.encode(umsUser.getPassword());
umsUser.setUsername(randomUsername());
umsUser.setPassword(encodePassword);
//分配角色(学生)
umsUser.setRoleId("2");
save(umsUser);
//创建学生信息(默认是学生)
UmsAdmin byUsername = lambdaQuery().eq(UmsAdmin::getPhone, umsAdmin.getPhone())
UmsUser byUsername = lambdaQuery().eq(UmsUser::getPhone, umsUser.getPhone())
.one();
UmsStudent umsStudent = new UmsStudent();
umsStudent.setUserId(Math.toIntExact(byUsername.getId()));
umsStudentMapper.insert(umsStudent);
//分配角色(学生)
adminRoleRelation.insert(byUsername.getId(), 2L);
return umsAdmin;
return umsUser;
}
/*
@ -302,12 +310,12 @@ public class UmsAdminServiceImpl extends ServiceImpl<UmsAdminMapper, UmsAdmin> i
*/
private String randomUsername(){
String username;
UmsAdmin newUsername = new UmsAdmin();
UmsUser newUsername = new UmsUser();
do {
UUID uuid = UUID.randomUUID();
// 这里只是简单地截取UUID的一部分作为用户名,但你可以根据需要进行更复杂的处理
username = uuid.toString().substring(0, 10); // 截取前10个字符作
newUsername = lambdaQuery().eq(UmsAdmin::getUsername, username)
newUsername = lambdaQuery().eq(UmsUser::getUsername, username)
.one();
} while ( newUsername != null); // 如果用户名已存在,则重新生成
return username;
@ -324,30 +332,38 @@ public class UmsAdminServiceImpl extends ServiceImpl<UmsAdminMapper, UmsAdmin> i
}
@Override
public UmsAdmin getAdminByUsername(String username) {
public UmsUser getUserByUsername(String username) {
//从数据库中获取
UmsAdmin admin = lambdaQuery().eq(UmsAdmin::getUsername, username)
UmsUser user = lambdaQuery().eq(UmsUser::getUsername, username)
.one();
if (admin != null) {
return admin;
if (user != null) {
return user;
}
return null;
}
@Override
public List<UmsResource> getResourceList(Long adminId) {
public List<UmsResource> getResourceList(Long userId) {
//从数据库中获取
List<UmsResource> resourceList = adminRoleRelation.getResourceList(adminId);
List<UmsResource> resourceList = new ArrayList<>();
UmsUser umsUser = lambdaQuery().eq(UmsUser::getId, userId).one();
String[] roles = umsUser.getRoleId().split(",");
List<String> roleList = new ArrayList<>();
for (String role : roles) {
UmsRole umsRole = umsRoleMapper.selectById(role);
resourceList = adminRoleRelation.getResourceList(umsRole.getId());
}
return resourceList;
}
@Override
public UserDetails loadUserByUsername(String username){
//获取用户信息
UmsAdmin admin = getAdminByUsername(username);
if (admin != null) {
List<UmsResource> resourceList = getResourceList(admin.getId());
return new AdminUserDetails(admin,resourceList);
UmsUser user = getUserByUsername(username);
if (user != null) {
List<UmsResource> resourceList = getResourceList(user.getId());
return new AdminUserDetails(user,resourceList);
}
throw new UsernameNotFoundException("用户名或密码错误");
}
@ -359,8 +375,8 @@ public class UmsAdminServiceImpl extends ServiceImpl<UmsAdminMapper, UmsAdmin> i
List<TeacherInfVO> teacherInfList = new ArrayList<>();;
for (UmsTeacher umsTeacher : umsTeachers) {
teacherInfVO = new TeacherInfVO();
UmsAdmin umsAdmin = umsAdminMapper.selectOne(new LambdaQueryWrapper<UmsAdmin>()
.eq(UmsAdmin::getId, umsTeacher.getUserId()));
UmsUser umsAdmin = umsUserMapper.selectOne(new LambdaQueryWrapper<UmsUser>()
.eq(UmsUser::getId, umsTeacher.getUserId()));
teacherInfVO.setName(umsTeacher.getName());
teacherInfVO.setUsername(umsAdmin.getUsername());
teacherInfList.add(teacherInfVO);

@ -2,28 +2,28 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.teaching.backend.mapper.umsAdmin.UmsRoleMapper">
<select id="getMenuList" resultType="com.teaching.backend.model.entity.umsAdmin.UmsMenu">
SELECT
m.id id,
m.parent_id parentId,
m.create_time createTime,
m.title title,
m.level level,
m.sort sort,
m.name name,
m.icon icon,
m.hidden hidden
FROM
ums_admin_role_relation arr
LEFT JOIN ums_role r ON arr.role_id = r.id
LEFT JOIN ums_role_menu_relation rmr ON r.id = rmr.role_id
LEFT JOIN ums_menu m ON rmr.menu_id = m.id
WHERE
arr.admin_id = #{adminId}
AND m.id IS NOT NULL
GROUP BY
m.id
</select>
<!-- <select id="getMenuList" resultType="com.teaching.backend.model.entity.umsAdmin.UmsMenu">-->
<!-- SELECT-->
<!-- m.id id,-->
<!-- m.parent_id parentId,-->
<!-- m.create_time createTime,-->
<!-- m.title title,-->
<!-- m.level level,-->
<!-- m.sort sort,-->
<!-- m.name name,-->
<!-- m.icon icon,-->
<!-- m.hidden hidden-->
<!-- FROM-->
<!-- ums_admin_role_relation arr-->
<!-- LEFT JOIN ums_role r ON arr.role_id = r.id-->
<!-- LEFT JOIN ums_role_menu_relation rmr ON r.id = rmr.role_id-->
<!-- LEFT JOIN ums_menu m ON rmr.menu_id = m.id-->
<!-- WHERE-->
<!-- arr.admin_id = #{adminId}-->
<!-- AND m.id IS NOT NULL-->
<!-- GROUP BY-->
<!-- m.id-->
<!-- </select>-->
<!-- <select id="getMenuListByRoleId" resultType="com.teaching.backend.model.entity.umsAdmin.UmsMenu">-->
<!-- SELECT-->
<!-- m.id id,-->

@ -38,4 +38,12 @@
</set>
where id = #{id,jdbcType=BIGINT}
</update>
<select id="selectByUserId" resultType="com.teaching.backend.model.entity.umsAdmin.UmsStudent">
SELECT
*
FROM
ums_student u
WHERE
u.user_id = #{userId}
</select>
</mapper>

@ -20,8 +20,8 @@
<if test="education != null">
education = #{education,jdbcType=VARCHAR},
</if>
<if test="degree != null">
degree = #{degree,jdbcType=TIMESTAMP},
<if test="academicDegree != null">
academic_degree = #{academicDegree,jdbcType=TIMESTAMP},
</if>
<if test="professionalTitle != null">
professional_title = #{professionalTitle,jdbcType=INTEGER},
@ -38,4 +38,12 @@
</set>
where id = #{id,jdbcType=BIGINT}
</update>
<select id="selectByUserId" resultType="com.teaching.backend.model.entity.umsAdmin.UmsTeacher">
SELECT
*
FROM
ums_teacher u
WHERE
u.user_id = #{userId}
</select>
</mapper>

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.teaching.backend.mapper.umsAdmin.UmsAdminMapper">
<mapper namespace="com.teaching.backend.mapper.umsAdmin.UmsUserMapper">
<update id="updateUserInformation">
update ums_admin
Loading…
Cancel
Save