权限注解,excel依赖

This commit is contained in:
lhx
2025-12-10 17:22:46 +08:00
parent 068675dc1a
commit c0c95ed1f8
4 changed files with 31 additions and 18 deletions

12
pom.xml
View File

@@ -137,6 +137,15 @@
<artifactId>minio</artifactId>
<version>8.6.0</version>
</dependency>
<!--excel处理-->
<dependency>
<groupId>cn.idev.excel</groupId>
<artifactId>fastexcel</artifactId>
<version>1.3.0</version>
</dependency>
</dependencies>
<build>
@@ -162,17 +171,14 @@
</testResource>
</testResources>
<plugins>
<!-- maven打包插件 -> 将整个工程打成一个 fatjar -->
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<!-- 作用:项目打成jar同时把本地jar包也引入进去 -->
<configuration>
<includeSystemScope>true</includeSystemScope>
<mainClass>com.dc.dc_project.DcProjectApplication</mainClass>
</configuration>
</plugin>
<!--添加配置跳过测试-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>

View File

@@ -1,8 +1,6 @@
package com.dc.dc_project.common.aop;
import cn.dev33.satoken.SaManager;
import cn.dev33.satoken.annotation.handler.SaAnnotationHandlerInterface;
import cn.dev33.satoken.context.SaHolder;
import cn.dev33.satoken.exception.SaTokenException;
import cn.dev33.satoken.stp.StpUtil;
import com.dc.dc_project.utils.PermissionUtils;

View File

@@ -1,20 +1,28 @@
package com.dc.dc_project.config;
import cn.dev33.satoken.SaManager;
import cn.dev33.satoken.context.SaHolder;
import cn.dev33.satoken.interceptor.SaInterceptor;
import cn.dev33.satoken.router.SaRouter;
import cn.dev33.satoken.strategy.SaAnnotationStrategy;
import cn.dev33.satoken.stp.StpUtil;
import com.dc.dc_project.common.aop.CheckPermission;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import jakarta.annotation.PostConstruct;
@Configuration
@ConditionalOnWebApplication(type = ConditionalOnWebApplication.Type.SERVLET)
public class SaTokenConfigure implements WebMvcConfigurer {
@PostConstruct
public void registerAnnotationHandler() {
// 注册自定义权限注解处理器
SaAnnotationStrategy.instance.registerAnnotationHandler(new CheckPermission());
}
@Override
public void addInterceptors(InterceptorRegistry registry) {
System.out.println("----- SaToken 拦截器启动成功!");

View File

@@ -60,6 +60,9 @@ public class PersonnelServiceImpl extends ServiceImpl<PersonnelMapper, Personnel
Personnel personnel = this.getOneByUserId(userId);
Long pOrgId = orgMapper.getOrgIdByPersonnelId(personnel.getId());
if (pOrgId == null) {
return ResponseResult.error("无归属组织,无");
}
List<Long> orgIds = null;
if (dataScopeType != null) {
orgIds = switch (dataScopeType) {
@@ -88,13 +91,6 @@ public class PersonnelServiceImpl extends ServiceImpl<PersonnelMapper, Personnel
personnel.setStatus(1);
personnel.setCreatedBy(userId);
if(personnelDto.getOrgId() != null){
PersonnelOrg personnelOrg = new PersonnelOrg();
personnelOrg.setPersonnelId(personnel.getId());
personnelOrg.setOrgId(personnelDto.getOrgId());
personnelOrg.setCreatedBy(userId);
personnelOrgService.save(personnelOrg);
}
if(personnelDto.getIsUser() == 1){
User user = new User();
user.setUsername(personnel.getName());
@@ -103,13 +99,18 @@ public class PersonnelServiceImpl extends ServiceImpl<PersonnelMapper, Personnel
user.setPhone(personnel.getContactPhone());
user.setStatus(1);
user.setRemark(personnel.getRemark());
userMapper.insert( user);
userMapper.insert(user);
personnel.setUserId(user.getId());
}
if (this.save(personnel)){
return ResponseResult.success();
this.save(personnel);
if(personnelDto.getOrgId() != null){
PersonnelOrg personnelOrg = new PersonnelOrg();
personnelOrg.setPersonnelId(personnel.getId());
personnelOrg.setOrgId(personnelDto.getOrgId());
personnelOrg.setCreatedBy(userId);
personnelOrgService.save(personnelOrg);
}
return ResponseResult.error();
return ResponseResult.success();
}
@Override