肖海南spl修改

master
wenyu441069198 5 months ago
parent 66cf868588
commit 51bcfa9cc7
  1. 38
      src/main/java/com/teaching/backend/mapper/umsAdmin/UmsAdminRoleRelationMapper.java
  2. 13
      src/main/java/com/teaching/backend/mapper/umsAdmin/UmsPermissionMapper.java
  3. 22
      src/main/java/com/teaching/backend/mapper/umsAdmin/UmsRoleResourceMapper.java
  4. 18
      src/main/java/com/teaching/backend/model/entity/umsAdmin/UmsAdminRoleRelation.java
  5. 10
      src/main/java/com/teaching/backend/service/impl/courses/CoursesServiceImpl.java
  6. 5
      src/main/java/com/teaching/backend/service/umsAdmin/UmsUserService.java
  7. 12
      src/main/java/com/teaching/backend/service/umsAdmin/impl/UmsUserServiceImpl.java
  8. 40
      src/main/resources/mapper/UmsAdminRoleRelationMapper.xml
  9. 5
      src/main/resources/mapper/UmsPermissionMapper.xml
  10. 22
      src/main/resources/mapper/UmsRoleResourceMapper.xml
  11. 2
      src/main/resources/mapper/UmsUserMapper.xml

@ -1,38 +0,0 @@
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.UmsResource;
import com.teaching.backend.model.entity.umsAdmin.UmsRole;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 后台用户与角色关系管理自定义Dao
* Created by macro on 2018/10/8.
*/
@Mapper
public interface UmsAdminRoleRelationMapper extends BaseMapper<UmsAdminRoleRelation> {
/**
* 插入用户角色关系
*/
boolean insert(@Param("adminId") Long adminId, @Param("roleId") Long roleId);
/**
* 获取用于所有角色
*/
List<UmsRole> getRoleList(@Param("adminId") Long adminId);
/**
* 获取用户所有可访问资源
*/
List<UmsResource> getResourceList(@Param("adminId") Long adminId);
// /**
// * 获取资源相关用户ID列表
// */
// List<Long> getAdminIdList(@Param("resourceId") Long resourceId);
}

@ -12,16 +12,5 @@ import org.apache.ibatis.annotations.Mapper;
*/
@Mapper
public interface UmsPermissionMapper extends BaseMapper<UmsPermission> {
/**
* 根据后台用户ID获取菜单
*/
// List<UmsMenu> getMenuList(@Param("adminId") Long adminId);
// /**
// * 根据角色ID获取菜单
// */
// List<UmsMenu> getMenuListByRoleId(@Param("roleId") Long roleId);
// /**
// * 根据角色ID获取资源
// */
// List<UmsResource> getResourceListByRoleId(@Param("roleId") Long roleId);
}

@ -0,0 +1,22 @@
package com.teaching.backend.mapper.umsAdmin;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.teaching.backend.model.entity.umsAdmin.UmsPermission;
import com.teaching.backend.model.entity.umsAdmin.UmsResource;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 后台角色管理自定义Dao
* Created by macro on 2020/2/2.
*/
@Mapper
public interface UmsRoleResourceMapper extends BaseMapper<UmsResource> {
/**
* 获取用户所有可访问资源
*/
List<UmsResource> getResourceList(@Param("roleId") Long roleId);
}

@ -1,18 +0,0 @@
package com.teaching.backend.model.entity.umsAdmin;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.io.Serializable;
@Data
@TableName("ums_admin_role_relation")
public class UmsAdminRoleRelation implements Serializable {
private Long id;
private Long adminId;
private Long roleId;
private static final long serialVersionUID = 1L;
}

@ -14,7 +14,6 @@ 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.UmsAdminRoleRelationMapper;
import com.teaching.backend.mapper.umsAdmin.UmsTeacherMapper;
import com.teaching.backend.mapper.umsAdmin.UmsUserMapper;
import com.teaching.backend.model.dto.courses.CoursesDTO;
@ -23,7 +22,6 @@ 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.UmsAdminRoleRelation;
import com.teaching.backend.model.entity.umsAdmin.UmsTeacher;
import com.teaching.backend.model.entity.umsAdmin.UmsUser;
import com.teaching.backend.model.query.CourseQuery;
@ -31,9 +29,7 @@ import com.teaching.backend.model.vo.courses.CourseObjectivesTreeVO;
import com.teaching.backend.model.vo.courses.CoursesVO;
import com.teaching.backend.service.courses.ICoursesService;
import com.teaching.backend.utils.CourseCode;
import org.apache.poi.ss.usermodel.VerticalAlignment;
import org.apache.poi.xwpf.usermodel.*;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.*;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -43,11 +39,7 @@ import org.springframework.util.ResourceUtils;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.time.LocalDateTime;
import java.util.*;
import java.util.stream.Collectors;
@ -86,8 +78,6 @@ public class CoursesServiceImpl extends ServiceImpl<CoursesMapper, Courses> impl
@Autowired
UmsTeacherMapper umsTeacherMapper;
@Autowired
UmsAdminRoleRelationMapper umsAdminRoleRelationMapper;
@Autowired
StudentCoursesMapper studentCoursesMapper;
@Autowired
ObjectiveContentKnowMapper objectiveContentKnowMapper;

@ -49,11 +49,6 @@ public interface UmsUserService extends IService<UmsUser> {
*/
String refreshToken(String oldToken);
/**
* 获取用户对应角色
*/
List<UmsRole> getRoleList(Long userId);
/**
* 修改指定用户信息
*/

@ -52,7 +52,7 @@ public class UmsUserServiceImpl extends ServiceImpl<UmsUserMapper, UmsUser> impl
@Autowired
private PasswordEncoder passwordEncoder;
@Autowired
private UmsAdminRoleRelationMapper adminRoleRelation;
private UmsRoleResourceMapper umsRoleResourceMapper;
@Autowired
private UmsStudentMapper umsStudentMapper;
@Autowired
@ -326,10 +326,10 @@ public class UmsUserServiceImpl extends ServiceImpl<UmsUserMapper, UmsUser> impl
return jwtTokenUtil.refreshHeadToken(oldToken);
}
@Override
public List<UmsRole> getRoleList(Long adminId) {
return adminRoleRelation.getRoleList(adminId);
}
// @Override
// public List<UmsRole> getRoleList(Long adminId) {
// return umsRoleResourceMapper.getRoleList(adminId);
// }
@Override
public UmsUser getUserByUsername(String username) {
@ -352,7 +352,7 @@ public class UmsUserServiceImpl extends ServiceImpl<UmsUserMapper, UmsUser> impl
List<String> roleList = new ArrayList<>();
for (String role : roles) {
UmsRole umsRole = umsRoleMapper.selectById(role);
resourceList = adminRoleRelation.getResourceList(umsRole.getId());
resourceList = umsRoleResourceMapper.getResourceList(umsRole.getId());
}
return resourceList;
}

@ -1,40 +0,0 @@
<?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.UmsAdminRoleRelationMapper">
<insert id="insert">
INSERT INTO ums_admin_role_relation (admin_id, role_id) VALUES (#{adminId,jdbcType=BIGINT},
#{roleId,jdbcType=BIGINT})
</insert>
<select id="getRoleList" resultType="com.teaching.backend.model.entity.umsAdmin.UmsRole">
select r.*
from ums_admin_role_relation ar left join ums_role r on ar.role_id = r.id
where ar.admin_id = #{adminId}
</select>
<select id="getResourceList" resultType="com.teaching.backend.model.entity.umsAdmin.UmsResource">
SELECT
ur.id id,
ur.create_time createTime,
ur.`name` `name`,
ur.url url,
ur.description description,
ur.category_id categoryId
FROM
ums_admin_role_relation ar
LEFT JOIN ums_role r ON ar.role_id = r.id
LEFT JOIN ums_role_resource_relation rrr ON r.id = rrr.role_id
LEFT JOIN ums_resource ur ON ur.id = rrr.resource_id
WHERE
ar.admin_id = #{adminId}
AND ur.id IS NOT NULL
GROUP BY
ur.id
</select>
<!-- <select id="getAdminIdList" resultType="java.lang.Long">-->
<!-- SELECT-->
<!-- DISTINCT ar.admin_id-->
<!-- FROM-->
<!-- ums_role_resource_relation rr-->
<!-- LEFT JOIN ums_admin_role_relation ar ON rr.role_id = ar.role_id-->
<!-- WHERE rr.resource_id=#{resourceId}-->
<!-- </select>-->
</mapper>

@ -0,0 +1,5 @@
<?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.UmsPermissionMapper">
</mapper>

@ -0,0 +1,22 @@
<?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.UmsRoleResourceMapper">
<select id="getResourceList" resultType="com.teaching.backend.model.entity.umsAdmin.UmsResource">
SELECT
ur.id id,
ur.create_time createTime,
ur.`name` `name`,
ur.url url,
ur.description description,
ur.category_id categoryId
FROM
ums_role_resource_relation rrr
LEFT JOIN ums_resource ur ON ur.id = rrr.resource_id
WHERE
rrr.role_id = #{roleId}
AND ur.id IS NOT NULL
GROUP BY
ur.id
</select>
</mapper>

@ -3,7 +3,7 @@
<mapper namespace="com.teaching.backend.mapper.umsAdmin.UmsUserMapper">
<update id="updateUserInformation">
update ums_admin
update ums_user
<set>
<if test="username != null">
username = #{username,jdbcType=VARCHAR},

Loading…
Cancel
Save