diff --git a/src/main/java/com/yunhai/userhome/controller/api/MenuBarController.java b/src/main/java/com/yunhai/userhome/controller/api/MenuBarController.java index 4b1d6b9..c5e90d1 100644 --- a/src/main/java/com/yunhai/userhome/controller/api/MenuBarController.java +++ b/src/main/java/com/yunhai/userhome/controller/api/MenuBarController.java @@ -30,16 +30,22 @@ public class MenuBarController { @GetMapping("getMenuBarSchList") public List getMenuBarSchList(BoaUser authUserWithDept) { - UserCurrentRole userCurrentRole = userCurrentRoleService.findById(authUserWithDept.getId()) - .orElseThrow(() -> new com.yunhai.platform.apistd.BizException(com.yunhai.platform.utils.exception.ErrorCode.INTERNAL_SERVER_ERROR)); + Optional userCurrentRoleOpt = userCurrentRoleService.findById(authUserWithDept.getId()); + if (!userCurrentRoleOpt.isPresent()) { + return new ArrayList<>(); + } + UserCurrentRole userCurrentRole = userCurrentRoleOpt.get(); return menuBarService.getMenuBarList(userCurrentRole.getSchId()); } @GetMapping("getMenuBarList") public List getMenuBarList(BoaUser authUserWithDept) { List result = new ArrayList<>(); - UserCurrentRole userCurrentRole = userCurrentRoleService.findById(authUserWithDept.getId()) - .orElseThrow(() -> new com.yunhai.platform.apistd.BizException(com.yunhai.platform.utils.exception.ErrorCode.INTERNAL_SERVER_ERROR)); + Optional userCurrentRoleOpt = userCurrentRoleService.findById(authUserWithDept.getId()); + if (!userCurrentRoleOpt.isPresent()) { + return result; + } + UserCurrentRole userCurrentRole = userCurrentRoleOpt.get(); Integer roleId = userCurrentRole.getRoleId(); if (roleId == 7 || roleId == 2) roleId = 2; Boolean isSuperAdmin = authUserWithDept.getType() == 1; diff --git a/src/main/java/com/yunhai/userhome/controller/api/SocketController.java b/src/main/java/com/yunhai/userhome/controller/api/SocketController.java index 7c8c8aa..e6faad1 100644 --- a/src/main/java/com/yunhai/userhome/controller/api/SocketController.java +++ b/src/main/java/com/yunhai/userhome/controller/api/SocketController.java @@ -8,6 +8,8 @@ import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import java.util.HashMap; +import java.util.Map; import java.util.UUID; /** @@ -24,10 +26,12 @@ public class SocketController { private String websocketUrl; @GetMapping("getMsgAddress") - public String getMsgAddress(BoaUser authUserWithDept) { + public Map getMsgAddress(BoaUser authUserWithDept) { Integer uid = authUserWithDept.getId(); UUID uuid = UUID.randomUUID(); MapCacheUtil.getInstance().add(uuid.toString(), uid.toString(), 20 * 1000L); - return this.websocketUrl + "/" + uuid.toString(); + Map result = new HashMap<>(); + result.put("url", this.websocketUrl + "/" + uuid.toString()); + return result; } } diff --git a/src/main/java/com/yunhai/userhome/controller/api/StatsBarController.java b/src/main/java/com/yunhai/userhome/controller/api/StatsBarController.java index 3660957..6cb1a72 100644 --- a/src/main/java/com/yunhai/userhome/controller/api/StatsBarController.java +++ b/src/main/java/com/yunhai/userhome/controller/api/StatsBarController.java @@ -30,16 +30,22 @@ public class StatsBarController { @GetMapping("getStatsBarSchList") public List getStatsBarSchList(BoaUser authUserWithDept) { - UserCurrentRole userCurrentRole = userCurrentRoleService.findById(authUserWithDept.getId()) - .orElseThrow(() -> new com.yunhai.platform.apistd.BizException(com.yunhai.platform.utils.exception.ErrorCode.INTERNAL_SERVER_ERROR)); + Optional userCurrentRoleOpt = userCurrentRoleService.findById(authUserWithDept.getId()); + if (!userCurrentRoleOpt.isPresent()) { + return new ArrayList<>(); + } + UserCurrentRole userCurrentRole = userCurrentRoleOpt.get(); return statsBarService.getStatsBarList(userCurrentRole.getSchId()); } @GetMapping("getStatsBarList") public List getStatsBarList(BoaUser authUserWithDept) { List result = new ArrayList<>(); - UserCurrentRole userCurrentRole = userCurrentRoleService.findById(authUserWithDept.getId()) - .orElseThrow(() -> new com.yunhai.platform.apistd.BizException(com.yunhai.platform.utils.exception.ErrorCode.INTERNAL_SERVER_ERROR)); + Optional userCurrentRoleOpt = userCurrentRoleService.findById(authUserWithDept.getId()); + if (!userCurrentRoleOpt.isPresent()) { + return result; + } + UserCurrentRole userCurrentRole = userCurrentRoleOpt.get(); Integer roleId = userCurrentRole.getRoleId(); if (roleId == 7 || roleId == 2) roleId = 2; Boolean isSuperAdmin = authUserWithDept.getType() == 1; diff --git a/src/main/java/com/yunhai/userhome/controller/api/TeacherCopilotController.java b/src/main/java/com/yunhai/userhome/controller/api/TeacherCopilotController.java index c6813f3..3aff218 100644 --- a/src/main/java/com/yunhai/userhome/controller/api/TeacherCopilotController.java +++ b/src/main/java/com/yunhai/userhome/controller/api/TeacherCopilotController.java @@ -30,16 +30,22 @@ public class TeacherCopilotController { @GetMapping("TeacherCopilot/getSchList") public List getList(BoaUser authUserWithDept) { - UserCurrentRole userCurrentRole = userCurrentRoleService.findById(authUserWithDept.getId()) - .orElseThrow(() -> new com.yunhai.platform.apistd.BizException(com.yunhai.platform.utils.exception.ErrorCode.INTERNAL_SERVER_ERROR)); + Optional userCurrentRoleOpt = userCurrentRoleService.findById(authUserWithDept.getId()); + if (!userCurrentRoleOpt.isPresent()) { + return new ArrayList<>(); + } + UserCurrentRole userCurrentRole = userCurrentRoleOpt.get(); return teacherCopilotService.getList(userCurrentRole.getSchId()); } @GetMapping("TeacherCopilot/getUserList") public List getUserList(BoaUser authUserWithDept) { List result = new ArrayList<>(); - UserCurrentRole userCurrentRole = userCurrentRoleService.findById(authUserWithDept.getId()) - .orElseThrow(() -> new com.yunhai.platform.apistd.BizException(com.yunhai.platform.utils.exception.ErrorCode.INTERNAL_SERVER_ERROR)); + Optional userCurrentRoleOpt = userCurrentRoleService.findById(authUserWithDept.getId()); + if (!userCurrentRoleOpt.isPresent()) { + return result; + } + UserCurrentRole userCurrentRole = userCurrentRoleOpt.get(); Integer roleId = userCurrentRole.getRoleId(); if (roleId == 7 || roleId == 2) roleId = 2; Boolean isSuperAdmin = authUserWithDept.getType() == 1; diff --git a/src/main/java/com/yunhai/userhome/controller/api/UserSettingsController.java b/src/main/java/com/yunhai/userhome/controller/api/UserSettingsController.java index 238cb08..1eff8a2 100644 --- a/src/main/java/com/yunhai/userhome/controller/api/UserSettingsController.java +++ b/src/main/java/com/yunhai/userhome/controller/api/UserSettingsController.java @@ -81,8 +81,10 @@ public class UserSettingsController { } @PostMapping(value = "iconUpload", produces = "application/json") - public String iconUpload(BoaUser authUserWithDept, @RequestParam("file") MultipartFile file) { - return this.upload(file, "icon"); + public Map iconUpload(BoaUser authUserWithDept, @RequestParam("file") MultipartFile file) { + Map result = new HashMap<>(); + result.put("url", this.upload(file, "icon")); + return result; } @PostMapping(value = "deleteWallById", produces = "application/json") @@ -127,16 +129,15 @@ public class UserSettingsController { @GetMapping(value = "getUserSettings") public UserSettings getUserSettings(BoaUser authUserWithDept) { - UserCurrentRole currentRole = userCurrentRoleService.findById(authUserWithDept.getId()) - .orElseThrow(() -> new BizException(ErrorCode.INTERNAL_SERVER_ERROR)); - Integer schId = currentRole.getSchId(); + Optional currentRoleOpt = userCurrentRoleService.findById(authUserWithDept.getId()); + Integer schId = currentRoleOpt.isPresent() ? currentRoleOpt.get().getSchId() : null; UserSettings model = new UserSettings(); Optional optional = userSettingsService.findUserSettings(authUserWithDept.getId()); // TODO 待确认:bschBaseOpenApi.getPcGrzxPage —— 新框架 YschBaseOpenApi 是否有此方法待确认 // List appPageList = bschBaseOpenApi.getPcGrzxPage(authUserWithDept.getId(), schId); List appPageList = Collections.emptyList(); if (optional.isPresent()) model = optional.get(); - if (model.getWallpaperUrl() == null || model.getWallpaperUrl().isEmpty()) { + if ((model.getWallpaperUrl() == null || model.getWallpaperUrl().isEmpty()) && schId != null) { List schList = getSchSettingsWallpaper(schId); if (schList.size() > 0) model.setWallpaperUrl(schList.get(0)); } @@ -155,8 +156,11 @@ public class UserSettingsController { @GetMapping(value = "getUserDesktopAppList") public List getUserDesktopAppList(BoaUser authUserWithDept) { - UserCurrentRole currentRole = userCurrentRoleService.findById(authUserWithDept.getId()) - .orElseThrow(() -> new BizException(ErrorCode.INTERNAL_SERVER_ERROR)); + Optional currentRoleOpt = userCurrentRoleService.findById(authUserWithDept.getId()); + if (!currentRoleOpt.isPresent()) { + return new ArrayList<>(); + } + UserCurrentRole currentRole = currentRoleOpt.get(); Optional optional = userSettingsService.findUserSettings(authUserWithDept.getId()); Integer schId = currentRole.getSchId(), userId = currentRole.getUserId(); UserSettings model = new UserSettings(); @@ -246,16 +250,21 @@ public class UserSettingsController { @GetMapping(value = "getLightAppList", produces = "application/json") public List getLightAppList(BoaUser authUserWithDept) { - UserCurrentRole currentRole = userCurrentRoleService.findById(authUserWithDept.getId()) - .orElseThrow(() -> new BizException(ErrorCode.INTERNAL_SERVER_ERROR)); Integer schId, userId = null; if (authUserWithDept.getType() == 1) { schId = 0; - } else if (currentRole.getRoleId() == 7 || currentRole.getRoleId() == 2) { - schId = currentRole.getSchId(); } else { - schId = currentRole.getSchId(); - userId = currentRole.getUserId(); + Optional currentRoleOpt = userCurrentRoleService.findById(authUserWithDept.getId()); + if (!currentRoleOpt.isPresent()) { + return new ArrayList<>(); + } + UserCurrentRole currentRole = currentRoleOpt.get(); + if (currentRole.getRoleId() == 7 || currentRole.getRoleId() == 2) { + schId = currentRole.getSchId(); + } else { + schId = currentRole.getSchId(); + userId = currentRole.getUserId(); + } } return userSettingsService.findLightAppList(schId, userId); } diff --git a/src/main/java/com/yunhai/userhome/service/impl/MenuBarServiceImpl.java b/src/main/java/com/yunhai/userhome/service/impl/MenuBarServiceImpl.java index f2ead44..4f2e257 100644 --- a/src/main/java/com/yunhai/userhome/service/impl/MenuBarServiceImpl.java +++ b/src/main/java/com/yunhai/userhome/service/impl/MenuBarServiceImpl.java @@ -43,8 +43,11 @@ public class MenuBarServiceImpl implements IMenuBarService { @Override public List findMenuBarById(Integer userId) { - UserCurrentRole userCurrentRole = userCurrentRoleService.findById(userId) - .orElseThrow(() -> new BizException(ErrorCode.INTERNAL_SERVER_ERROR)); + Optional userCurrentRoleOpt = userCurrentRoleService.findById(userId); + if (!userCurrentRoleOpt.isPresent()) { + return Collections.emptyList(); + } + UserCurrentRole userCurrentRole = userCurrentRoleOpt.get(); List list = getMenuBarList(userCurrentRole.getSchId()); List result = list.stream().filter(MenuBar::getIsShow).collect(Collectors.toList()); result = result.stream().sorted(Comparator.comparing(MenuBar::getOrderNum, Comparator.nullsLast(Integer::compareTo))).collect(Collectors.toList()); diff --git a/src/main/java/com/yunhai/userhome/service/impl/StatsBarServiceImpl.java b/src/main/java/com/yunhai/userhome/service/impl/StatsBarServiceImpl.java index 4dd6a31..2567d8c 100644 --- a/src/main/java/com/yunhai/userhome/service/impl/StatsBarServiceImpl.java +++ b/src/main/java/com/yunhai/userhome/service/impl/StatsBarServiceImpl.java @@ -42,8 +42,11 @@ public class StatsBarServiceImpl implements IStatsBarService { @Override public List findStatsBarById(Integer userId) { - UserCurrentRole userCurrentRole = userCurrentRoleService.findById(userId) - .orElseThrow(() -> new BizException(ErrorCode.INTERNAL_SERVER_ERROR)); + Optional userCurrentRoleOpt = userCurrentRoleService.findById(userId); + if (!userCurrentRoleOpt.isPresent()) { + return new ArrayList<>(); + } + UserCurrentRole userCurrentRole = userCurrentRoleOpt.get(); List list = getStatsBarList(userCurrentRole.getSchId()); List result = list.stream().filter(StatsBar::getIsShow).collect(Collectors.toList()); result = result.stream().sorted(Comparator.comparing(StatsBar::getOrderNum, Comparator.nullsLast(Integer::compareTo))).collect(Collectors.toList()); diff --git a/src/main/java/com/yunhai/userhome/service/impl/TeacherCopilotServiceImpl.java b/src/main/java/com/yunhai/userhome/service/impl/TeacherCopilotServiceImpl.java index 1bff689..704a2bd 100644 --- a/src/main/java/com/yunhai/userhome/service/impl/TeacherCopilotServiceImpl.java +++ b/src/main/java/com/yunhai/userhome/service/impl/TeacherCopilotServiceImpl.java @@ -42,8 +42,11 @@ public class TeacherCopilotServiceImpl implements ITeacherCopilotService { @Override public List findById(Integer userId) { - UserCurrentRole userCurrentRole = userCurrentRoleService.findById(userId) - .orElseThrow(() -> new BizException(ErrorCode.INTERNAL_SERVER_ERROR)); + Optional userCurrentRoleOpt = userCurrentRoleService.findById(userId); + if (!userCurrentRoleOpt.isPresent()) { + return new ArrayList<>(); + } + UserCurrentRole userCurrentRole = userCurrentRoleOpt.get(); List list = getList(userCurrentRole.getSchId()); List result = list.stream().filter(TeacherCopilot::getIsShow).collect(Collectors.toList()); result = result.stream().sorted(Comparator.comparing(TeacherCopilot::getOrderNum, Comparator.nullsLast(Integer::compareTo))).collect(Collectors.toList()); diff --git a/src/main/java/com/yunhai/userhome/service/impl/UserSettingsServiceImpl.java b/src/main/java/com/yunhai/userhome/service/impl/UserSettingsServiceImpl.java index 9b8b405..b98c10d 100644 --- a/src/main/java/com/yunhai/userhome/service/impl/UserSettingsServiceImpl.java +++ b/src/main/java/com/yunhai/userhome/service/impl/UserSettingsServiceImpl.java @@ -44,8 +44,11 @@ public class UserSettingsServiceImpl implements IUserSettingsService { @Override public List findWallList(Integer userId) { - UserCurrentRole currentRole = userCurrentRoleService.findById(userId) - .orElseThrow(() -> new BizException(ErrorCode.INTERNAL_SERVER_ERROR)); + Optional currentRoleOpt = userCurrentRoleService.findById(userId); + if (!currentRoleOpt.isPresent()) { + return new ArrayList<>(); + } + UserCurrentRole currentRole = currentRoleOpt.get(); List resultList = new ArrayList<>(); List baseList = wallpaperRepository.findBySchIdAndType(0, 0); List schList = wallpaperRepository.findBySchIdAndType(currentRole.getSchId(), 1); @@ -80,8 +83,11 @@ public class UserSettingsServiceImpl implements IUserSettingsService { @Override public Optional findUserSettings(Integer userId) { - UserCurrentRole currentRole = userCurrentRoleService.findById(userId) - .orElseThrow(() -> new BizException(ErrorCode.INTERNAL_SERVER_ERROR)); + Optional currentRoleOpt = userCurrentRoleService.findById(userId); + if (!currentRoleOpt.isPresent()) { + return Optional.empty(); + } + UserCurrentRole currentRole = currentRoleOpt.get(); return userSettingsRepository.findByUserIdAndSchIdAndRoleId(currentRole.getUserId(), currentRole.getSchId(), currentRole.getRoleId()); } diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 154349c..187c31f 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -41,7 +41,7 @@ yh: enabled: true sso: # CAS 单点登录(浏览器 SSO 重定向 / ticket 校验) - server-url-prefix: https://sso.yunhaixingtong.com/cas/ + server-url-prefix: http://sso.yunhaixingtong.com/cas/ # 本地 context-path=/、端口 8070;prod 由 Nacos 的 yh.sso.client-host-url 覆盖 client-host-url: http://localhost:8070 allow-headers: all @@ -58,7 +58,7 @@ yh: # yh-openapi 开放接口客户端(前缀必须是 yh.open,OpenApiProperties 绑定;base-host + base-path 拼出 # 完整跨仓基址,openapi 客户端再拼 /oapi/** 端点;app-key/app-secret 同时驱动应用间签名) enabled: true - base-host: http://localhost:8060 + base-host: http://base.yunhaixingtong.com base-path: /userbase app-key: 100001 app-secret: ec4e860206374c80938719fff8e14a86 diff --git a/upload/icon/6e322d2d.svg b/upload/icon/6e322d2d.svg new file mode 100644 index 0000000..aa19b16 --- /dev/null +++ b/upload/icon/6e322d2d.svg @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/upload/icon/763ef0ee.svg b/upload/icon/763ef0ee.svg new file mode 100644 index 0000000..6dab515 --- /dev/null +++ b/upload/icon/763ef0ee.svg @@ -0,0 +1,3 @@ + + + diff --git a/upload/icon/76b68c06.svg b/upload/icon/76b68c06.svg new file mode 100644 index 0000000..6dab515 --- /dev/null +++ b/upload/icon/76b68c06.svg @@ -0,0 +1,3 @@ + + + diff --git a/upload/icon/7e5e5cd7.svg b/upload/icon/7e5e5cd7.svg new file mode 100644 index 0000000..aa19b16 --- /dev/null +++ b/upload/icon/7e5e5cd7.svg @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/upload/wallpaper/3dabd97c.png b/upload/wallpaper/3dabd97c.png new file mode 100644 index 0000000..56a1b8e Binary files /dev/null and b/upload/wallpaper/3dabd97c.png differ