肖海南数据库修改

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. 200
      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; 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.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.security.access.ConfigAttribute;
import org.springframework.security.core.userdetails.UserDetailsService; import org.springframework.security.core.userdetails.UserDetailsService;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
/** /**
* mall-security模块相关配置 * mall-security模块相关配置
* Created by macro on 2019/11/9. * Created by macro on 2019/11/9.
@ -20,7 +15,7 @@ import java.util.concurrent.ConcurrentHashMap;
public class MallSecurityConfig { public class MallSecurityConfig {
@Autowired @Autowired
private UmsAdminService umsadminService; private UmsUserService umsadminService;
// @Autowired // @Autowired
// private UmsResourceService resourceService; // private UmsResourceService resourceService;

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

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

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

@ -1,16 +1,16 @@
package com.teaching.backend.mapper.umsAdmin; package com.teaching.backend.mapper.umsAdmin;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; 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.UmsRole;
import com.teaching.backend.model.entity.umsAdmin.UmsTeacher; 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 com.teaching.backend.model.vo.umsAdmin.UmsStudentVO;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
@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); 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; private String politicalStatus;
/**
* user_id
*/
private Integer userId;
/** /**
* role_id * 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 com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data; import lombok.Data;
import java.io.Serializable; import java.io.Serializable;
import java.time.LocalDateTime;
@Data @Data
@TableName("ums_admin") @TableName("ums_user")
public class UmsAdminParam implements Serializable { public class UmsUserParam implements Serializable {
//用户名 //用户名
private String username; 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 io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
@ -9,7 +9,7 @@ import lombok.Data;
* Created by macro on 2019/10/9. * Created by macro on 2019/10/9.
*/ */
@Data @Data
public class UpdateAdminPasswordParam { public class UpdateUserPasswordParam {
// @NotEmpty // @NotEmpty
@ApiModelProperty(value = "用户名", required = true) @ApiModelProperty(value = "用户名", required = true)
private String username; private String username;

@ -15,11 +15,11 @@ import java.util.stream.Collectors;
*/ */
public class AdminUserDetails implements UserDetails { public class AdminUserDetails implements UserDetails {
//后台用户 //后台用户
private final UmsAdmin umsAdmin; private final UmsUser umsAdmin;
//拥有资源列表 //拥有资源列表
private final List<UmsResource> resourceList; private final List<UmsResource> resourceList;
public AdminUserDetails(UmsAdmin umsAdmin, List<UmsResource> resourceList) { public AdminUserDetails(UmsUser umsAdmin, List<UmsResource> resourceList) {
this.umsAdmin = umsAdmin; this.umsAdmin = umsAdmin;
this.resourceList = resourceList; 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; 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 com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
@ -9,25 +11,23 @@ import java.util.Date;
@Data @Data
@TableName("ums_role") @TableName("ums_role")
public class UmsRole implements Serializable { public class UmsRole implements Serializable {
//主键
@TableId(type = IdType.AUTO)
private Long id; private Long id;
@ApiModelProperty(value = "名称") //名称
private String name; private String name;
@ApiModelProperty(value = "描述") //描述
private String description; private String description;
@ApiModelProperty(value = "后台用户数量") //创建时间
private Integer adminCount;
@ApiModelProperty(value = "创建时间")
private Date createTime; private Date createTime;
@ApiModelProperty(value = "启用状态:0->禁用;1->启用") //启用状态:0->禁用;1->启用
private Integer status; private Integer status;
private Integer sort; //权限id
private String permissionId;
private static final long serialVersionUID = 1L;
} }

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

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

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

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

@ -9,6 +9,7 @@ import lombok.experimental.Accessors;
import java.io.Serializable; import java.io.Serializable;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.List;
/** /**
* <p> * <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; private String politicalStatus;
/**
* user_id
*/
private Integer userId;
/** /**
* role_id * 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.courses.*;
import com.teaching.backend.mapper.know.KnowRelationshipMapper; import com.teaching.backend.mapper.know.KnowRelationshipMapper;
import com.teaching.backend.mapper.records.LearningRecordsMapper; 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.UmsAdminRoleRelationMapper;
import com.teaching.backend.mapper.umsAdmin.UmsTeacherMapper; 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.CoursesDTO;
import com.teaching.backend.model.dto.courses.PageDTO; import com.teaching.backend.model.dto.courses.PageDTO;
import com.teaching.backend.model.entity.chapter.Chapter; import com.teaching.backend.model.entity.chapter.Chapter;
import com.teaching.backend.model.entity.courses.*; import com.teaching.backend.model.entity.courses.*;
import com.teaching.backend.model.entity.know.KnowRelationship; import com.teaching.backend.model.entity.know.KnowRelationship;
import com.teaching.backend.model.entity.records.LearningRecords; 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.UmsAdminRoleRelation;
import com.teaching.backend.model.entity.umsAdmin.UmsTeacher; 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.query.CourseQuery;
import com.teaching.backend.model.vo.courses.CourseObjectivesTreeVO; import com.teaching.backend.model.vo.courses.CourseObjectivesTreeVO;
import com.teaching.backend.model.vo.courses.CoursesVO; import com.teaching.backend.model.vo.courses.CoursesVO;
@ -82,7 +82,7 @@ public class CoursesServiceImpl extends ServiceImpl<CoursesMapper, Courses> impl
@Autowired @Autowired
ObjectivesTypeMapper objectivesTypeMapper; ObjectivesTypeMapper objectivesTypeMapper;
@Autowired @Autowired
UmsAdminMapper umsAdminMapper; UmsUserMapper umsUserMapper;
@Autowired @Autowired
UmsTeacherMapper umsTeacherMapper; UmsTeacherMapper umsTeacherMapper;
@Autowired @Autowired
@ -158,8 +158,8 @@ public class CoursesServiceImpl extends ServiceImpl<CoursesMapper, Courses> impl
// throw new BusinessException(ErrorCode.USERNAME_NOT_EXIT); // throw new BusinessException(ErrorCode.USERNAME_NOT_EXIT);
// } // }
UmsAdmin umsAdmin = umsAdminMapper.selectOne(new LambdaQueryWrapper<UmsAdmin>() UmsUser umsAdmin = umsUserMapper.selectOne(new LambdaQueryWrapper<UmsUser>()
.eq(UmsAdmin::getUsername, username)); .eq(UmsUser::getUsername, username));
UmsAdminRoleRelation umsAdminRoleRelation = umsAdminRoleRelationMapper.selectOne(new LambdaQueryWrapper<UmsAdminRoleRelation>() UmsAdminRoleRelation umsAdminRoleRelation = umsAdminRoleRelationMapper.selectOne(new LambdaQueryWrapper<UmsAdminRoleRelation>()
.eq(UmsAdminRoleRelation::getAdminId, umsAdmin.getId())); .eq(UmsAdminRoleRelation::getAdminId, umsAdmin.getId()));
@ -225,14 +225,14 @@ public class CoursesServiceImpl extends ServiceImpl<CoursesMapper, Courses> impl
List<String> teacherNameList = new ArrayList<>(); List<String> teacherNameList = new ArrayList<>();
String[] teacherIds = coursesVO.getTeacher().split(","); String[] teacherIds = coursesVO.getTeacher().split(",");
for (String teacherId : teacherIds) { for (String teacherId : teacherIds) {
UmsAdmin umsAdminTea = umsAdminMapper.selectOne(new LambdaQueryWrapper<UmsAdmin>() UmsUser umsUserTea = umsUserMapper.selectOne(new LambdaQueryWrapper<UmsUser>()
.eq(UmsAdmin::getUsername, teacherId)); .eq(UmsUser::getUsername, teacherId));
if (umsAdminTea == null) { if (umsUserTea == null) {
throw new BusinessException(ErrorCode.OPERATION_ERROR); throw new BusinessException(ErrorCode.OPERATION_ERROR);
} }
// System.out.println(umsAdminTea); // System.out.println(umsAdminTea);
UmsTeacher umsTeacher = umsTeacherMapper.selectOne(new LambdaQueryWrapper<UmsTeacher>() UmsTeacher umsTeacher = umsTeacherMapper.selectOne(new LambdaQueryWrapper<UmsTeacher>()
.eq(UmsTeacher::getUserId, umsAdminTea.getId())); .eq(UmsTeacher::getUserId, umsUserTea.getId()));
System.out.println(umsTeacher); System.out.println(umsTeacher);
if (umsTeacher == null){ if (umsTeacher == null){
throw new BusinessException(ErrorCode.PARAMS_USER_NOTEXISTS); 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<Courses> list = coursesMapper.selectList(null);
List<CoursesVO> coursesVo = BeanUtil.copyToList(list, CoursesVO.class); List<CoursesVO> coursesVo = BeanUtil.copyToList(list, CoursesVO.class);
coursesVo = coursesVo.stream().map((item) -> { coursesVo = coursesVo.stream().map((item) -> {
item.setTotalHours(countHours(item.getId())); item.setTotalHours(countHours(item.getId()));
item.setTotalchapter(countChapters(item.getId())); item.setTotalchapter(countChapters(item.getId()));
item.setTotalKnow(countKnow(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.exception.BusinessException;
import com.teaching.backend.mapper.courses.CoursesMapper; import com.teaching.backend.mapper.courses.CoursesMapper;
import com.teaching.backend.mapper.courses.StudentCoursesMapper; 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.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.PageDTO;
import com.teaching.backend.model.dto.courses.StudentCoursesDTO; import com.teaching.backend.model.dto.courses.StudentCoursesDTO;
import com.teaching.backend.model.entity.courses.Courses; 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.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.query.CourseQuery;
import com.teaching.backend.model.vo.courses.CoursesVO; import com.teaching.backend.model.vo.courses.CoursesVO;
import com.teaching.backend.service.courses.ICoursesService; import com.teaching.backend.service.courses.ICoursesService;
import com.teaching.backend.service.courses.IStudentCoursesService; import com.teaching.backend.service.courses.IStudentCoursesService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
@ -46,7 +41,7 @@ public class StudentCoursesServiceImpl extends ServiceImpl<StudentCoursesMapper,
@Autowired @Autowired
StudentCoursesMapper studentCoursesMapper; StudentCoursesMapper studentCoursesMapper;
@Autowired @Autowired
UmsAdminMapper umsAdminMapper; UmsUserMapper umsAdminMapper;
@Autowired @Autowired
UmsTeacherMapper umsTeacherMapper; UmsTeacherMapper umsTeacherMapper;
@Autowired @Autowired

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

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

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

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

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?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"> <!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 id="updateUserInformation">
update ums_admin update ums_admin
Loading…
Cancel
Save