From d9c152cfc7116e415020434593823efa1e156e30 Mon Sep 17 00:00:00 2001 From: DB <2502523450@qq.com> Date: Thu, 19 Oct 2023 23:09:28 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E8=AE=A2=E6=A8=A1=E5=9D=97=E4=B8=8E?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/application-prod.yml | 6 ++--- .../src/main/resources/application-test.yml | 24 ++++++++++------- .../src/main/resources/application.yml | 4 +-- .../controller/MallRoleController.java | 2 +- .../business/controller/StaffController.java | 4 +-- .../business/controller/LoginController.java | 7 ++--- .../business/controller/MenuController.java | 24 +++++------------ .../system/business/service/LoginService.java | 3 ++- .../service/impl/LoginServiceImpl.java | 27 +++---------------- 9 files changed, 40 insertions(+), 61 deletions(-) diff --git a/Cpop-Mall/Cpop-Mall-Web/src/main/resources/application-prod.yml b/Cpop-Mall/Cpop-Mall-Web/src/main/resources/application-prod.yml index 316b6dc..84d2339 100644 --- a/Cpop-Mall/Cpop-Mall-Web/src/main/resources/application-prod.yml +++ b/Cpop-Mall/Cpop-Mall-Web/src/main/resources/application-prod.yml @@ -16,7 +16,7 @@ cpop: # DataSource Config spring: application: - name: Cpop-Oam-Prod + name: Cpop-Mall-Prod datasource: url: jdbc:mysql://sh-cynosdbmysql-grp-fggo83js.sql.tencentcdb.com:20965/cpop-union?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 username: root @@ -50,9 +50,9 @@ spring: database: rock-blade server: - port: 9420 + port: 9430 servlet: - context-path: /Cpop-Oam + context-path: /Cpop-Mall #Mybatis-Flex mybatis-flex: diff --git a/Cpop-Mall/Cpop-Mall-Web/src/main/resources/application-test.yml b/Cpop-Mall/Cpop-Mall-Web/src/main/resources/application-test.yml index e890337..61980be 100644 --- a/Cpop-Mall/Cpop-Mall-Web/src/main/resources/application-test.yml +++ b/Cpop-Mall/Cpop-Mall-Web/src/main/resources/application-test.yml @@ -16,7 +16,7 @@ cpop: # DataSource Config spring: application: - name: Cpop-Oam-Test + name: Cpop-Mall-Test datasource: url: jdbc:mysql://sh-cynosdbmysql-grp-fggo83js.sql.tencentcdb.com:20965/cpop-union?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 username: root @@ -50,9 +50,9 @@ spring: database: rock-blade server: - port: 9420 + port: 9430 servlet: - context-path: /Cpop-Oam + context-path: /Cpop-Mall #Mybatis-Flex mybatis-flex: @@ -63,8 +63,8 @@ mybatis-flex: knife4j: enable: true openapi: - title: Cpop-OAM开发API - description: PuPu-OAM开发API + title: Cpop-Mall开发API + description: Cpop-Mall开发API email: concat: DB url: https://api.jamboxsys.com @@ -73,9 +73,15 @@ knife4j: license-url: https://stackoverflow.com/ terms-of-service-url: https://api.jamboxsys.com group: - #系统 - system: - group-name: Oam + #商城 + Mall: + group-name: Mall api-rule: package api-rule-resources: - - com.cpop.oam \ No newline at end of file + - com.cpop.mall + #系统 + System: + group-name: System + api-rule: package + api-rule-resources: + - com.cpop.system \ No newline at end of file diff --git a/Cpop-Mall/Cpop-Mall-Web/src/main/resources/application.yml b/Cpop-Mall/Cpop-Mall-Web/src/main/resources/application.yml index 22a3169..0bebdc2 100644 --- a/Cpop-Mall/Cpop-Mall-Web/src/main/resources/application.yml +++ b/Cpop-Mall/Cpop-Mall-Web/src/main/resources/application.yml @@ -8,8 +8,8 @@ cpop: jwt: #密钥 secret: abcdefghijklmnopqrstuvwxyz - #过期时间 - expire: 604800 + #过期时间(半天) + expire: 43200 #token头 header: Authorization #拦截 diff --git a/Cpop-Mall/src/main/java/com/cpop/mall/business/controller/MallRoleController.java b/Cpop-Mall/src/main/java/com/cpop/mall/business/controller/MallRoleController.java index 8c40825..722a3ba 100644 --- a/Cpop-Mall/src/main/java/com/cpop/mall/business/controller/MallRoleController.java +++ b/Cpop-Mall/src/main/java/com/cpop/mall/business/controller/MallRoleController.java @@ -25,7 +25,7 @@ import java.util.List; * @description */ @RestController -@Api(tags = "商城角色定制模块") +@Api(tags = "商城角色定制接口") @RequestMapping("/mallRole") public class MallRoleController { diff --git a/Cpop-Mall/src/main/java/com/cpop/mall/business/controller/StaffController.java b/Cpop-Mall/src/main/java/com/cpop/mall/business/controller/StaffController.java index d88db4d..7d94815 100644 --- a/Cpop-Mall/src/main/java/com/cpop/mall/business/controller/StaffController.java +++ b/Cpop-Mall/src/main/java/com/cpop/mall/business/controller/StaffController.java @@ -25,8 +25,8 @@ import java.util.List; * @since 2023-10-19 */ @RestController -@Api(tags = "商城员工管理接口") -@RequestMapping("/staff") +@Api(tags = "商城员工接口") +@RequestMapping("/mallStaff") public class StaffController { @Autowired diff --git a/Cpop-System/src/main/java/com/cpop/system/business/controller/LoginController.java b/Cpop-System/src/main/java/com/cpop/system/business/controller/LoginController.java index 419bcd2..2092bed 100644 --- a/Cpop-System/src/main/java/com/cpop/system/business/controller/LoginController.java +++ b/Cpop-System/src/main/java/com/cpop/system/business/controller/LoginController.java @@ -11,13 +11,14 @@ import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; import java.util.List; +import java.util.Set; /** * @author DB * @createTime 2023/09/10 11:13 * @description 系统登陆 */ -@Api(tags = "系统登录模块") +@Api(tags = "通用系统登录模块") @RestController public class LoginController { @@ -44,8 +45,8 @@ public class LoginController { **/ @ApiOperation("获取权限码") @GetMapping("/getPermCode") - public R> getPermCode(){ - List list = loginService.getPermCode(); + public R> getPermCode(){ + Set list = loginService.getPermCode(); return R.ok(list); } diff --git a/Cpop-System/src/main/java/com/cpop/system/business/controller/MenuController.java b/Cpop-System/src/main/java/com/cpop/system/business/controller/MenuController.java index 3b3caf1..beae5ad 100644 --- a/Cpop-System/src/main/java/com/cpop/system/business/controller/MenuController.java +++ b/Cpop-System/src/main/java/com/cpop/system/business/controller/MenuController.java @@ -5,25 +5,15 @@ import com.cpop.core.base.R; import com.cpop.core.base.enums.OperationLogEnum; import com.cpop.system.business.bo.MenuBo; import com.cpop.system.business.bo.MenuListBo; -import com.cpop.system.business.vo.MenuVo; -import com.mybatisflex.core.paginate.Page; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.DeleteMapping; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.beans.factory.annotation.Autowired; -import com.cpop.system.business.entity.Menu; import com.cpop.system.business.service.MenuService; -import org.springframework.web.bind.annotation.RestController; +import com.cpop.system.business.vo.MenuVo; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; -import io.swagger.annotations.ApiParam; -import java.io.Serializable; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + import java.util.List; /** @@ -33,7 +23,7 @@ import java.util.List; * @since 2023-10-19 */ @RestController -@Api(tags = "系统菜单表接口") +@Api(tags = "通用系统菜单表接口") @RequestMapping("/menu") public class MenuController { diff --git a/Cpop-System/src/main/java/com/cpop/system/business/service/LoginService.java b/Cpop-System/src/main/java/com/cpop/system/business/service/LoginService.java index 8b01978..0d3c67a 100644 --- a/Cpop-System/src/main/java/com/cpop/system/business/service/LoginService.java +++ b/Cpop-System/src/main/java/com/cpop/system/business/service/LoginService.java @@ -4,6 +4,7 @@ import com.cpop.system.business.vo.LoginUserInfoVo; import com.cpop.system.business.vo.MenuRouteVo; import java.util.List; +import java.util.Set; /** * 系统登陆 @@ -20,7 +21,7 @@ public interface LoginService { /** * 获取权限码 */ - List getPermCode(); + Set getPermCode(); /** * @Description: 获取菜单列表 diff --git a/Cpop-System/src/main/java/com/cpop/system/business/service/impl/LoginServiceImpl.java b/Cpop-System/src/main/java/com/cpop/system/business/service/impl/LoginServiceImpl.java index 9fd4e03..4462bf4 100644 --- a/Cpop-System/src/main/java/com/cpop/system/business/service/impl/LoginServiceImpl.java +++ b/Cpop-System/src/main/java/com/cpop/system/business/service/impl/LoginServiceImpl.java @@ -1,27 +1,18 @@ package com.cpop.system.business.service.impl; import com.alibaba.fastjson.JSONObject; -import com.cpop.common.constant.Constants; import com.cpop.core.base.entity.LoginUser; -import com.cpop.core.service.RedisService; import com.cpop.core.utils.SecurityUtils; -import com.cpop.system.business.entity.Menu; import com.cpop.system.business.service.LoginService; import com.cpop.system.business.service.MenuService; import com.cpop.system.business.vo.LoginUserInfoVo; import com.cpop.system.business.vo.MenuRouteVo; -import com.mybatisflex.core.query.QueryWrapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import java.util.ArrayList; import java.util.Collections; import java.util.List; -import java.util.stream.Collectors; - -import static com.cpop.system.business.entity.table.MenuTableDef.MENU; -import static com.cpop.system.business.entity.table.RoleMenuTableDef.ROLE_MENU; -import static com.cpop.system.business.entity.table.RoleTableDef.ROLE; +import java.util.Set; /** * @author DB @@ -64,20 +55,10 @@ public class LoginServiceImpl implements LoginService { * @return {@link List} **/ @Override - public List getPermCode() { - //获取当前用户所属角色以及菜单信息 + public Set getPermCode() { + //获取当前登录用户信息 LoginUser loginUser = SecurityUtils.getInstance().getLoginUser(); - JSONObject loginStaffInfo = SecurityUtils.getInstance().getLoginStaffInfo(); - if (Constants.SUPER_ADMIN.equals(loginUser.getUsername())){ - return new ArrayList(Collections.singleton(Constants.ALL_PERMISSION)); - } - List list = menuService.list(QueryWrapper.create() - .leftJoin(ROLE_MENU).on(ROLE_MENU.MENU_ID.eq(MENU.ID)) - .leftJoin(ROLE).on(ROLE.ID.eq(ROLE_MENU.ROLE_ID)) - .where(MENU.TYPE.in(1, 2)) - .and(MENU.PERMISSION.ne("")) - .and(ROLE.ID.eq(loginStaffInfo.getString("roleId")))); - return list.stream().map(Menu::getPermission).collect(Collectors.toList()); + return loginUser.getPermissions(); } /**