调整用户登陆权限

This commit is contained in:
DB 2023-11-15 09:02:59 +08:00
parent 9d4db6ff48
commit f70c265487
13 changed files with 127 additions and 50 deletions

View File

@ -192,7 +192,7 @@ public interface Constants {
/**
* 隐藏菜单
*/
String HIDE_MENU = "Menu,Brand";
String HIDE_MENU = "Menu";
/**
* 用户类型

View File

@ -1,10 +1,12 @@
package com.cpop.core.strategy.login;
import com.cpop.common.constant.Constants;
import com.cpop.common.utils.StringUtils;
import com.cpop.common.utils.bean.BeanUtils;
import com.cpop.core.base.entity.LoginUser;
import com.cpop.core.base.entity.Permission;
import com.cpop.core.base.entity.loginInfo.MallStaffLoginInfo;
import com.cpop.core.base.enums.InitRoleEnum;
import com.cpop.core.base.enums.SourceType;
import com.cpop.core.base.enums.UserType;
import com.cpop.core.base.exception.CpopAuthenticationException;
@ -14,10 +16,7 @@ import com.mybatisflex.core.row.Row;
import com.mybatisflex.core.row.RowUtil;
import org.springframework.stereotype.Component;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.*;
import java.util.stream.Collectors;
/**
@ -83,12 +82,9 @@ public class MallLoginStrategy implements LoginStrategy{
private Set<String> getPermissionSet(String username, String roleId) {
//获取权限
Set<String> permissionSet = new HashSet<>();
if (Constants.SUPER_ADMIN.equals(username)) {
if (Constants.SUPER_ADMIN.equals(username) || StringUtils.equals(InitRoleEnum.SUPER_MALL_ROLE.getId(), roleId)) {
permissionSet.add(Constants.ALL_PERMISSION);
}
else {
permissionSet.add(Constants.ALL_PERMISSION);
//TODO:测试中所有新建用户都是超级管理员
} else {
//查询员工信息
List<Row> list = DbChain.table("cp_sys_menu")
.select("pom.permission")

View File

@ -1,10 +1,12 @@
package com.cpop.core.strategy.login;
import com.cpop.common.constant.Constants;
import com.cpop.common.utils.StringUtils;
import com.cpop.common.utils.bean.BeanUtils;
import com.cpop.core.base.entity.LoginUser;
import com.cpop.core.base.entity.Permission;
import com.cpop.core.base.entity.loginInfo.OamStaffLoginInfo;
import com.cpop.core.base.enums.InitRoleEnum;
import com.cpop.core.base.enums.UserType;
import com.cpop.core.base.table.SysUser;
import com.mybatisflex.core.row.DbChain;
@ -74,10 +76,9 @@ public class OamLoginStrategy implements LoginStrategy{
private Set<String> getPermissionSet(String username, String roleId) {
//获取权限
Set<String> permissionSet = new HashSet<>();
if (Constants.SUPER_ADMIN.equals(username)) {
if (Constants.SUPER_ADMIN.equals(username) || StringUtils.equals(InitRoleEnum.SUPER_OAM_ROLE.getId(), roleId)) {
permissionSet.add(Constants.ALL_PERMISSION);
} else {
permissionSet.add(Constants.ALL_PERMISSION);
//查询员工信息
List<Row> list = DbChain.table("cp_sys_menu")
.select("pom.permission")

View File

@ -24,7 +24,7 @@ spring:
#端口
port: 6333
#数据库
database: 10
database: 0
#密码
password: Jambox.123*
#连接超时
@ -60,11 +60,11 @@ mybatis-flex:
log-impl: org.apache.ibatis.logging.nologging.NoLoggingImpl
datasource:
mall:
url: jdbc:mysql://sh-cynosdbmysql-grp-fggo83js.sql.tencentcdb.com:20965/cpop_test?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
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
password: Customer0401
jambox:
url: jdbc:mysql://sh-cynosdbmysql-grp-fggo83js.sql.tencentcdb.com:20965/jambox_test?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
url: jdbc:mysql://sh-cynosdbmysql-grp-fggo83js.sql.tencentcdb.com:20965/jambox_association?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
username: root
password: Customer0401
@ -86,8 +86,8 @@ wx:
# 私钥文件
privateCertPath: /root/cpop-union/cpop-mall/script/secretKey/wxPay_cert.pem
#支付通知地址
notifyUrl: https://test.cpopsz.com/onlineShop/wxPay/callback/notify/order
notifyUrl: https://api.jamboxsys.com/Cpop-Mall/wxPay/callback/notify/order
#退款通知地址
notifyRefund: https://test.cpopsz.com/onlineShop/wxPay/callback/notify/refund
notifyRefund: https://api.jamboxsys.com/Cpop-Mall/wxPay/callback/notify/refund
#分账通知地址
notifySharing: https://test.cpopsz.com/onlineShop/wxPay/callback/notify/profitSharing
notifySharing: https://api.jamboxsys.com/Cpop-Mall/wxPay/callback/notify/profitSharing

View File

@ -82,10 +82,10 @@ public class CpopWxPayTests {
//ProfitSharing profitSharing = SpringUtils.getBean(ProfitSharingService.class).getById("77860920238751744");
//profitSharingReturnRequest.setOrderId(profitSharing.getOutProfitSharingId());
//profitSharingReturnRequest.setOutReturnNo(profitSharing.getId());
profitSharingReturnRequest.setOrderId("30001200512023110656192114311");
profitSharingReturnRequest.setOutReturnNo("4200002030202311064693113248");
profitSharingReturnRequest.setOrderId("30000600822023111456560002430");
profitSharingReturnRequest.setOutReturnNo("1724352351424733184");
profitSharingReturnRequest.setDescription("分账退款");
profitSharingReturnRequest.setSubMchId("1650816616");
profitSharingReturnRequest.setSubMchId("1618925571");
profitSharingReturnRequest.setReturnMchid("1618884922");
//profitSharingReturnRequest.setAmount(profitSharing.getAmount());
profitSharingReturnRequest.setAmount(1L);
@ -96,7 +96,6 @@ public class CpopWxPayTests {
* @descriptions 添加分账接收方
* @author DB
* @date 2023/11/03 10:17
* @param
* @return: void
*/
@Test
@ -104,14 +103,14 @@ public class CpopWxPayTests {
//固定商户信息
Map<String, Object> mapReceiver = new HashMap<>(4);
mapReceiver.put("type", "MERCHANT_ID");
//mapReceiver.put("sub_mchid", "1650816616");
mapReceiver.put("sub_mchid", "1618884922");
mapReceiver.put("account", "1618884922");
mapReceiver.put("relation_type", "SERVICE_PROVIDER");
mapReceiver.put("name","果酱盒子");
//添加分账接收方
ProfitSharingReceiverRequest profitSharingReceiver = new ProfitSharingReceiverRequest();
profitSharingReceiver.setReceiver(JSONObject.toJSONString(mapReceiver));
WxPayConfig config = wxPayService.getConfig();
config.setSubMchId("1618925571");
wxPayService.getProfitSharingService().addReceiver(profitSharingReceiver);
}
}

View File

@ -27,6 +27,7 @@
</dependencies>
<build>
<finalName>Cpop-Oam-Web</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>

View File

@ -1,7 +1,7 @@
# 项目相关配置
cpop:
# 文件路径 示例( Windows配置W:/WorkSpace/java/uploadPathLinux配置 /home/baseFramework/uploadPath
profile: /root/jambox-union/jambox-oam/uploadPath/upload
profile: /root/cpop-union/cpop-oam/upload
jwt:
#白名单
whiteList: /login,/getCaptcha,/profile/**,/wxOpen/receiveTicket,/wxOpen/*/callback,/wxOpen/bindOpenAccount/*,/wxCp/portal/*
@ -9,18 +9,14 @@ cpop:
gateway:
rsa-keypair:
# 公钥文件
publicKeyFile: /root/jambox-union/jambox-oam/script/secretKey/publicKey
publicKeyFile: /root/cpop-union/cpop-oam/script/secretKey/publicKey
# 公钥文件
privateKeyFile: /root/jambox-union/jambox-oam/script/secretKey/privateKey
privateKeyFile: /root/cpop-union/cpop-oam/script/secretKey/privateKey
# DataSource Config
spring:
application:
name: Cpop-Oam-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
password: Customer0401
#redis配置
redis:
#地址
@ -28,7 +24,7 @@ spring:
#端口
port: 6333
#数据库
database: 5
database: 0
#密码
password: Jambox.123*
#连接超时
@ -58,3 +54,12 @@ server:
mybatis-flex:
configuration:
log-impl: org.apache.ibatis.logging.nologging.NoLoggingImpl
datasource:
mall:
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
password: Customer0401
jambox:
url: jdbc:mysql://sh-cynosdbmysql-grp-fggo83js.sql.tencentcdb.com:20965/jambox_association?useUnicode=true&characterEncoding=utf-8&allowMultiQueries=true
username: root
password: Customer0401

View File

@ -1,7 +1,7 @@
# 项目相关配置
cpop:
# 文件路径 示例( Windows配置W:/WorkSpace/java/uploadPathLinux配置 /home/baseFramework/uploadPath
profile: /root/jambox-union/jambox-oam/uploadPath/upload
profile: /root/cpop-union/cpop-mall/upload
jwt:
#白名单
whiteList: /login,/getCaptcha,/profile/**,/doc.html,/webjars/**,/favicon.ico,/v2/api-docs/**,/swagger-resources,/wxOpen/receiveTicket,/wxOpen/*/callback,/wxOpen/bindOpenAccount/*,/wxCp/portal/*
@ -17,10 +17,6 @@ cpop:
spring:
application:
name: Cpop-Oam-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
password: Customer0401
#redis配置
redis:
#地址
@ -58,6 +54,15 @@ server:
mybatis-flex:
configuration:
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
datasource:
mall:
url: jdbc:mysql://sh-cynosdbmysql-grp-fggo83js.sql.tencentcdb.com:20965/cpop_test?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
username: root
password: Customer0401
jambox:
url: jdbc:mysql://sh-cynosdbmysql-grp-fggo83js.sql.tencentcdb.com:20965/jambox_test?useUnicode=true&characterEncoding=utf-8&allowMultiQueries=true
username: root
password: Customer0401
# springdoc-openapi项目配置
knife4j:

View File

@ -0,0 +1,68 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Logback configuration. See http://logback.qos.ch/manual/index.html -->
<configuration scan="true" scanPeriod="10 seconds">
<!--<include resource="org/springframework/boot/logging/logback/base.xml" />-->
<!--定义日志文件的存储地址和前缀名-->
<property name="LOG_HOME" value="./logs"/>
<property name="LOG_PREFIX" value="Cpop-Oam"/>
<!--控制台输出 -->
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<encoder charset="UTF-8">
<!--格式化输出:%d表示日期%-5level级别%thread表示线程名%file输出文件名%line文件行数%msg日志消息%n是换行符-->
<pattern>[%d{yyyy-MM-dd HH:mm:ss.SSS}] %level [%thread] %file:%line - %msg%n</pattern>
<charset>UTF-8</charset>
</encoder>
</appender>
<springProfile name="test,prod">
<appender name="SYS_INFO" class="ch.qos.logback.core.rolling.RollingFileAppender">
<File>${LOG_HOME}/${LOG_PREFIX}-info.log</File>
<append>true</append>
<!--过滤器,只打INFO级别的日志-->
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>INFO</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>${LOG_HOME}/${LOG_PREFIX}-info-%d{yyyyMMdd}.log.%d</fileNamePattern>
<maxHistory>7</maxHistory>
</rollingPolicy>
<encoder charset="UTF-8">
<pattern>[%d{yyyy-MM-dd HH:mm:ss.SSS}] %level [%thread] %file:%line - %msg%n</pattern>
<charset>UTF-8</charset>
</encoder>
</appender>
<appender name="SYS_ERROR" class="ch.qos.logback.core.rolling.RollingFileAppender">
<File>${LOG_HOME}/${LOG_PREFIX}-error.log</File>
<append>true</append>
<!--过滤器,只打ERROR级别的日志-->
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>ERROR</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>${LOG_HOME}/${LOG_PREFIX}-error-%d{yyyyMMdd}.log.%d</fileNamePattern>
<maxHistory>7</maxHistory>
</rollingPolicy>
<encoder charset="UTF-8">
<pattern>[%d{yyyy-MM-dd HH:mm:ss.SSS}] %level [%thread] %file:%line - %msg%n</pattern>
<charset>UTF-8</charset>
</encoder>
</appender>
</springProfile>
<!--info和error分开打印-->
<root level="INFO">
<appender-ref ref="CONSOLE"/>
<springProfile name="test,prod">
<appender-ref ref="SYS_INFO"/>
<appender-ref ref="SYS_ERROR"/>
</springProfile>
</root>
<logger name="com.cpop.oam" level="DEBUG"/>
</configuration>

View File

@ -108,22 +108,26 @@ public class OamMallServiceImpl implements OamMallService {
Row roleBrand = Row.ofKey(RowKey.SNOW_FLAKE_ID);
roleBrand.set("brand_id", bo.getBrandId())
.set("role_id", InitRoleEnum.SUPER_MALL_ROLE.getId())
.set("source_type", SourceType.JAMBOX.toString())
.set("create_time", now)
.set("update_time", now)
.set("create_user_id", 1)
.set("update_user_id", 1);
Db.insert("cp_mall_role_brand",roleBrand);
DbChain.table("cp_mall_staff")
.setId(RowKey.SNOW_FLAKE_ID)
.set("name", bo.getName())
Row mallStaff = Row.ofKey(RowKey.SNOW_FLAKE_ID);
mallStaff.set("name", bo.getName())
.set("role_brand_id", roleBrand.getString("id"))
.set("user_id", sysUser.getId())
.set("create_time", now)
.set("update_time", now)
.set("create_user_id", 1)
.set("update_user_id", 1)
.save();
.set("update_user_id", 1);
long count = DbChain.table("cp_j_brand_extend").where("brand_id = ?", bo.getBrandId()).count();
if (count > 0) {
mallStaff.set("source_type", SourceType.JAMBOX.toString());
} else {
mallStaff.set("source_type", SourceType.COMMON.toString());
}
Db.insert("cp_mall_staff", mallStaff);
}
/**

View File

@ -70,7 +70,6 @@ public class RoleController {
* @return: com.cpop.core.base.R<java.lang.Void>
*/
@PreAuthorize("@aps.hasPermission('system:role:insert')")
@OperationLog(operationLogEnumType = OperationLogEnum.INSERT_OAM_ROLE)
@ApiOperation("新增角色")
@PostMapping("/insertSysRole")
public R<Void> insertSysRole(@RequestBody @Validated RoleBo bo) {
@ -100,7 +99,6 @@ public class RoleController {
* @return com.jambox.core.base.R<java.lang.Void>
*/
@PreAuthorize("@aps.hasPermission('system:role:update')")
@OperationLog(operationLogEnumType = OperationLogEnum.UPDATE_OAM_ROLE)
@ApiOperation("修改角色")
@PutMapping("/updateSysRole")
public R<Void> updateSysRole(@RequestBody @Validated RoleBo bo) {
@ -112,7 +110,6 @@ public class RoleController {
* 删除系统角色表
*/
@PreAuthorize("@aps.hasPermission('system:role:remove')")
@OperationLog(operationLogEnumType = OperationLogEnum.REMOVE_OAM_ROLE)
@ApiOperation("删除系统角色表")
@DeleteMapping("/removeSysRole/{id}")
public R<Void> removeSysRole(@PathVariable String id) {
@ -128,7 +125,6 @@ public class RoleController {
* @Date: 2023/5/9 14:13
**/
@PreAuthorize("@aps.hasPermission('system:role:update')")
@OperationLog(operationLogEnumType = OperationLogEnum.UPDATE_OAM_ROLE)
@ApiOperation("设置角色状态")
@PutMapping("/setSysRoleStatus")
public R<Void> setSysRoleStatus(@RequestBody @Validated RoleStatusBo bo) {

View File

@ -95,7 +95,8 @@ public class MenuServiceImpl extends ServiceImpl<MenuMapper, Menu> implements Me
//标题不为空
.and(MENU.TITLE.like(bo.getTitle()))
//构建公共菜单与特有菜单
.and(MENU.USER_TYPE.in("COMMON", user.getUserType()))
.and(MENU.USER_TYPE.eq(user.getUserType()))
.and(MENU.NAME.notIn(Constants.HIDE_MENU.split(",")))
.orderBy(MENU.ORDER_NO.asc()), MenuVo.class));
}

View File

@ -5,6 +5,7 @@ import com.cpop.common.utils.StringUtils;
import com.cpop.common.utils.bean.BeanUtils;
import com.cpop.core.base.entity.LoginUser;
import com.cpop.core.base.entity.PageDomain;
import com.cpop.core.base.enums.InitRoleEnum;
import com.cpop.core.utils.SecurityUtils;
import com.cpop.core.utils.SpringUtils;
import com.cpop.core.utils.sql.SqlUtils;
@ -54,7 +55,7 @@ public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements Ro
Page<RolePageVo> page = this.mapper.paginateAs(pageDomain.getPageNum(), pageDomain.getPageSize(),
QueryWrapper.create()
.select(ROLE.ALL_COLUMNS)
.where(ROLE.ROLE_VALUE.ne(Constants.SUPER_ADMIN_VALUE))
.where(ROLE.ID.ne(InitRoleEnum.SUPER_OAM_ROLE.getId()))
.and(ROLE.ROLE_NAME.like(bo.getRoleName()))
.and(ROLE.STATUS.eq(bo.getStatus()))
.and(ROLE.USER_TYPE.eq(loginUser.getUserType()))