mirror of
https://github.com/PlayEdu/PlayEdu
synced 2025-12-26 12:49:28 +08:00
代码格式化
This commit is contained in:
@@ -1,22 +1,26 @@
|
||||
/**
|
||||
* This file is part of the PlayEdu.
|
||||
* (c) 杭州白书科技有限公司
|
||||
*/
|
||||
package xyz.playedu.api.bus;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import xyz.playedu.api.config.PlayEduConfig;
|
||||
import xyz.playedu.api.constant.SystemConstant;
|
||||
|
||||
/**
|
||||
* @Author 杭州白书科技有限公司
|
||||
*
|
||||
* @create 2023/2/19 12:06
|
||||
*/
|
||||
@Component
|
||||
public class AppBus {
|
||||
|
||||
@Autowired
|
||||
private PlayEduConfig playEduConfig;
|
||||
@Autowired private PlayEduConfig playEduConfig;
|
||||
|
||||
public boolean isDev() {
|
||||
return !playEduConfig.getEnv().equals(SystemConstant.ENV_PROD);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,7 +1,12 @@
|
||||
/**
|
||||
* This file is part of the PlayEdu.
|
||||
* (c) 杭州白书科技有限公司
|
||||
*/
|
||||
package xyz.playedu.api.bus;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import xyz.playedu.api.BCtx;
|
||||
import xyz.playedu.api.constant.BackendConstant;
|
||||
import xyz.playedu.api.domain.AdminRole;
|
||||
@@ -16,14 +21,11 @@ import java.util.List;
|
||||
@Component
|
||||
public class BackendBus {
|
||||
|
||||
@Autowired
|
||||
private AdminPermissionService permissionService;
|
||||
@Autowired private AdminPermissionService permissionService;
|
||||
|
||||
@Autowired
|
||||
private AdminRoleService adminRoleService;
|
||||
@Autowired private AdminRoleService adminRoleService;
|
||||
|
||||
@Autowired
|
||||
private AdminUserService adminUserService;
|
||||
@Autowired private AdminUserService adminUserService;
|
||||
|
||||
public static boolean inUnAuthWhitelist(String uri) {
|
||||
return BackendConstant.UN_AUTH_URI_WHITELIST.contains(uri);
|
||||
@@ -41,9 +43,9 @@ public class BackendBus {
|
||||
|
||||
List<Integer> permissionIds;
|
||||
|
||||
if (roleIds.contains(superRole.getId())) {//包含超级管理角色的话返回全部权限
|
||||
if (roleIds.contains(superRole.getId())) { // 包含超级管理角色的话返回全部权限
|
||||
permissionIds = permissionService.allIds();
|
||||
} else {//根据相应的roleIds读取权限
|
||||
} else { // 根据相应的roleIds读取权限
|
||||
permissionIds = adminRoleService.getPermissionIdsByRoleIds(roleIds);
|
||||
if (permissionIds.size() == 0) {
|
||||
return permissions;
|
||||
@@ -54,7 +56,7 @@ public class BackendBus {
|
||||
}
|
||||
|
||||
public static String valueHidden(String permissionSlug, String type, String value) {
|
||||
if (BCtx.isNull()) {//非后管环境返回原值
|
||||
if (BCtx.isNull()) { // 非后管环境返回原值
|
||||
return value;
|
||||
}
|
||||
HashMap<String, Boolean> permissions = BCtx.getAdminPer();
|
||||
@@ -84,5 +86,4 @@ public class BackendBus {
|
||||
}
|
||||
return roleIds.contains(superRole.getId());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,9 +1,14 @@
|
||||
/**
|
||||
* This file is part of the PlayEdu.
|
||||
* (c) 杭州白书科技有限公司
|
||||
*/
|
||||
package xyz.playedu.api.bus;
|
||||
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import xyz.playedu.api.FCtx;
|
||||
import xyz.playedu.api.caches.UserLastLearnTimeCache;
|
||||
import xyz.playedu.api.domain.Course;
|
||||
@@ -17,27 +22,24 @@ import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author 杭州白书科技有限公司
|
||||
*
|
||||
* @create 2023/3/20 14:56
|
||||
*/
|
||||
@Component
|
||||
public class UserBus {
|
||||
|
||||
@Autowired
|
||||
private CourseService courseService;
|
||||
@Autowired private CourseService courseService;
|
||||
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
@Autowired private UserService userService;
|
||||
|
||||
@Autowired
|
||||
private UserLastLearnTimeCache userLastLearnTimeCache;
|
||||
@Autowired private UserLastLearnTimeCache userLastLearnTimeCache;
|
||||
|
||||
@Autowired
|
||||
private ApplicationContext ctx;
|
||||
@Autowired private ApplicationContext ctx;
|
||||
|
||||
public boolean canSeeCourse(User user, Course course) {
|
||||
List<Integer> courseDepIds = courseService.getDepIdsByCourseId(course.getId());
|
||||
if (courseDepIds == null || courseDepIds.size() == 0) {
|
||||
//线上课无所属部门=>任何学员都可以学习
|
||||
// 线上课无所属部门=>任何学员都可以学习
|
||||
return true;
|
||||
}
|
||||
List<Integer> userDepIds = userService.getDepIdsByUserId(user.getId());
|
||||
@@ -59,7 +61,8 @@ public class UserBus {
|
||||
|
||||
userLastLearnTimeCache.put(user.getId(), curTime);
|
||||
|
||||
ctx.publishEvent(new UserLearnCourseUpdateEvent(this, user.getId(), course.getId(), hour.getId(), lastTime, curTime));
|
||||
ctx.publishEvent(
|
||||
new UserLearnCourseUpdateEvent(
|
||||
this, user.getId(), course.getId(), hour.getId(), lastTime, curTime));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user