fix: 码全代码添加
This commit is contained in:
38
template/cvbp/.gitignore
vendored
Normal file
38
template/cvbp/.gitignore
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
target/
|
||||
!.mvn/wrapper/maven-wrapper.jar
|
||||
!**/src/main/**/target/
|
||||
!**/src/test/**/target/
|
||||
|
||||
### IntelliJ IDEA ###
|
||||
.idea/*.xml
|
||||
.idea/inspectionProfiles
|
||||
.idea/.gitignore
|
||||
*.iws
|
||||
*.iml
|
||||
*.ipr
|
||||
logs/
|
||||
|
||||
### Eclipse ###
|
||||
.apt_generated
|
||||
.classpath
|
||||
.factorypath
|
||||
.project
|
||||
.settings
|
||||
.springBeans
|
||||
.sts4-cache
|
||||
|
||||
### NetBeans ###
|
||||
/nbproject/private/
|
||||
/nbbuild/
|
||||
/dist/
|
||||
/nbdist/
|
||||
/.nb-gradle/
|
||||
build/
|
||||
!**/src/main/**/build/
|
||||
!**/src/test/**/build/
|
||||
|
||||
### VS Code ###
|
||||
.vscode/
|
||||
|
||||
### Mac OS ###
|
||||
.DS_Store
|
||||
25
template/cvbp/README.md
Normal file
25
template/cvbp/README.md
Normal file
@@ -0,0 +1,25 @@
|
||||
|
||||
### 模块说明
|
||||
```
|
||||
cvbp
|
||||
├── cvbp-app-center -- 统一应用中心
|
||||
├── cvbp-auth-center -- 统一认证中心
|
||||
├── cvbp-base -- 基础能力中心
|
||||
├── cvbp-datasource -- 数据源管理
|
||||
├── cvbp-datav -- 可视化建模
|
||||
├── cvbp-indicator -- 指标中心
|
||||
├── cvbp-mall -- 商城中心
|
||||
├── cvbp-monitor -- 系统监控中心
|
||||
├── cvbp-pay -- 支付中心
|
||||
├── cvbp-public -- 系统公共模块
|
||||
├ ├── cvbp-auth-core -- 统一认证核心配置
|
||||
├ ├── cvbp-cache-core -- 统一缓存配置
|
||||
├ ├── cvbp-common-core -- 统一响应、统一异常与通用工具
|
||||
├ ├── cvbp-common-feign -- 统一远程调用配置
|
||||
├ ├── cvbp-db-core -- 统一数据库操作模块
|
||||
├ ├── cvbp-mq-core -- 统一消息队列配置
|
||||
├ ├── cvbp-public-bom -- 公共依赖版本
|
||||
├ ├── cvbp-web-api -- 服务间调用API
|
||||
├ └── cvbp-web-core -- web自动装配核心模块
|
||||
└── cvbp-workflow -- 工作流模块
|
||||
```
|
||||
41
template/cvbp/cvbp-auth-center/.gitignore
vendored
Normal file
41
template/cvbp/cvbp-auth-center/.gitignore
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
target/
|
||||
!.mvn/wrapper/maven-wrapper.jar
|
||||
!**/src/main/**/target/
|
||||
!**/src/test/**/target/
|
||||
|
||||
### IntelliJ IDEA ###
|
||||
.idea/modules.xml
|
||||
.idea/jarRepositories.xml
|
||||
.idea/compiler.xml
|
||||
.idea/libraries/
|
||||
*.iws
|
||||
*.iml
|
||||
*.ipr
|
||||
logs/
|
||||
|
||||
### Eclipse ###
|
||||
.apt_generated
|
||||
.classpath
|
||||
.factorypath
|
||||
.project
|
||||
.settings
|
||||
.springBeans
|
||||
.sts4-cache
|
||||
|
||||
### NetBeans ###
|
||||
/nbproject/private/
|
||||
/nbbuild/
|
||||
/dist/
|
||||
/nbdist/
|
||||
/.nb-gradle/
|
||||
build/
|
||||
!**/src/main/**/build/
|
||||
!**/src/test/**/build/
|
||||
|
||||
### VS Code ###
|
||||
.vscode/
|
||||
|
||||
### Mac OS ###
|
||||
.DS_Store
|
||||
|
||||
script/
|
||||
107
template/cvbp/cvbp-auth-center/pom.xml
Normal file
107
template/cvbp/cvbp-auth-center/pom.xml
Normal file
@@ -0,0 +1,107 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
~ Copyright (c) 2023 codvision.com All Rights Reserved.
|
||||
-->
|
||||
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<groupId>com.codvision</groupId>
|
||||
<artifactId>cvbp</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>cvbp-auth-center</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
<description>基础平台-统一认证中心</description>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
<maven.compiler.target>8</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<transmittable.threadlocal.version>2.14.2</transmittable.threadlocal.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.codvision</groupId>
|
||||
<artifactId>cvbp-base</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.codvision</groupId>
|
||||
<artifactId>cvbp-monitor</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!--短信包-->
|
||||
<dependency>
|
||||
<groupId>com.aliyun</groupId>
|
||||
<artifactId>aliyun-java-sdk-dysmsapi</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.aliyun</groupId>
|
||||
<artifactId>aliyun-java-sdk-core</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- 验证码工具 -->
|
||||
<dependency>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-captcha</artifactId>
|
||||
</dependency>
|
||||
<!-- 行为验证码 -->
|
||||
<dependency>
|
||||
<groupId>com.anji-plus</groupId>
|
||||
<artifactId>spring-boot-starter-captcha</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- 钉钉 -->
|
||||
<dependency>
|
||||
<groupId>com.aliyun</groupId>
|
||||
<artifactId>alibaba-dingtalk-service-sdk</artifactId>
|
||||
</dependency>
|
||||
<!-- 政务钉钉 -->
|
||||
<dependency>
|
||||
<groupId>com.zwdd</groupId>
|
||||
<artifactId>zwdd-sdk-java</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-http</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>dev</id>
|
||||
<properties>
|
||||
<profiles.active>dev</profiles.active>
|
||||
</properties>
|
||||
<activation>
|
||||
<!-- 默认环境 -->
|
||||
<activeByDefault>true</activeByDefault>
|
||||
</activation>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>prd</id>
|
||||
<properties>
|
||||
<profiles.active>prd</profiles.active>
|
||||
</properties>
|
||||
</profile>
|
||||
</profiles>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
<classifier>exec</classifier>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Copyright (c) 2023 codvision.com All Rights Reserved.
|
||||
*/
|
||||
|
||||
package com.codvision.auth;
|
||||
|
||||
import com.codvision.webcore.util.WebUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
|
||||
/**
|
||||
* 认证中心启动入口
|
||||
*
|
||||
* @author lingee
|
||||
* @date 2023/11/8
|
||||
*/
|
||||
@Slf4j
|
||||
@SpringBootApplication
|
||||
public class AuthCenterApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
ConfigurableApplicationContext application = SpringApplication.run(AuthCenterApplication.class, args);
|
||||
WebUtil.printWebUrl(application.getEnvironment());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.codvision.auth.config;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* @author hxl
|
||||
*/
|
||||
@Data
|
||||
@Component
|
||||
@ConfigurationProperties("sso.service")
|
||||
public class AppClientProperties {
|
||||
private String appKey;
|
||||
private String appSecret;
|
||||
private String serverUrl;
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package com.codvision.auth.config;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.codvision.auth.entity.SysMenu;
|
||||
import com.codvision.auth.entity.SysRole;
|
||||
import com.codvision.auth.service.ISysMenuService;
|
||||
import com.codvision.auth.service.ISysRoleService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.springframework.boot.ApplicationArguments;
|
||||
import org.springframework.boot.ApplicationRunner;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author hxl
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class ApplicationInitRunner implements ApplicationRunner {
|
||||
|
||||
@Resource
|
||||
private ISysRoleService roleService;
|
||||
|
||||
@Resource
|
||||
private ISysMenuService menuService;
|
||||
|
||||
@Override
|
||||
public void run(ApplicationArguments args) {
|
||||
// 初始化超级管理员菜单权限
|
||||
initializeAdminMenus();
|
||||
}
|
||||
|
||||
|
||||
private void initializeAdminMenus() {
|
||||
SysRole sysRole = roleService.getById(1);
|
||||
if (ObjectUtil.isEmpty(sysRole)) {
|
||||
return;
|
||||
}
|
||||
|
||||
List<SysMenu> sysMenuList = menuService.list();
|
||||
if (CollectionUtils.isEmpty(sysMenuList)) {
|
||||
return;
|
||||
}
|
||||
|
||||
List<Integer> menuIdList = sysMenuList.stream().map(SysMenu::getId).collect(Collectors.toList());
|
||||
roleService.setRoleMenu(sysRole.getId(), menuIdList);
|
||||
log.info("The initialization of default system super administrator permissions has been completed...");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright (c) 2023 codvision.com All Rights Reserved.
|
||||
*/
|
||||
|
||||
package com.codvision.auth.config;
|
||||
|
||||
import com.codvision.auth.core.AuthCenterService;
|
||||
import com.codvision.auth.core.token.ITokenManager;
|
||||
import com.codvision.auth.core.token.RedisTokenManager;
|
||||
import com.codvision.authcore.config.AuthProperties;
|
||||
import com.codvision.authcore.service.IAuthService;
|
||||
import com.codvision.authcore.service.impl.AuthService;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Primary;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||
|
||||
/**
|
||||
* 认证中心配置
|
||||
*
|
||||
* @author lingee
|
||||
* @date 2023/11/21
|
||||
*/
|
||||
@Configuration
|
||||
@ConditionalOnProperty(value = "cvbp.auth.enabled", havingValue = "true", matchIfMissing = true)
|
||||
public class AuthCenterConfig {
|
||||
|
||||
@Bean
|
||||
public IAuthService authService() {
|
||||
return new AuthCenterService();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ITokenManager tokenManager() {
|
||||
return new RedisTokenManager();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright (c) 2023 codvision.com All Rights Reserved.
|
||||
*/
|
||||
|
||||
package com.codvision.auth.config;
|
||||
|
||||
import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||
|
||||
/**
|
||||
* 主配置
|
||||
*
|
||||
* @author lingee
|
||||
* @date 2023/11/29
|
||||
*/
|
||||
@Configuration
|
||||
@ComponentScan(basePackages = "com.codvision.auth")
|
||||
@ImportAutoConfiguration(AuthCenterConfig.class)
|
||||
public class MainConfig {
|
||||
|
||||
@Bean
|
||||
public BCryptPasswordEncoder bCryptPasswordEncoder() {
|
||||
return new BCryptPasswordEncoder();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Copyright (c) 2023 codvision.com All Rights Reserved.
|
||||
*/
|
||||
|
||||
package com.codvision.auth.config;
|
||||
|
||||
import com.github.xiaoymin.swaggerbootstrapui.annotations.EnableSwaggerBootstrapUI;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import springfox.documentation.builders.ApiInfoBuilder;
|
||||
import springfox.documentation.builders.PathSelectors;
|
||||
import springfox.documentation.builders.RequestHandlerSelectors;
|
||||
import springfox.documentation.service.ApiInfo;
|
||||
import springfox.documentation.spi.DocumentationType;
|
||||
import springfox.documentation.spring.web.plugins.Docket;
|
||||
import springfox.documentation.swagger2.annotations.EnableSwagger2;
|
||||
|
||||
/**
|
||||
* swagger配置
|
||||
*
|
||||
* @author lingee
|
||||
* @date 2023/11/7
|
||||
*/
|
||||
@EnableSwagger2
|
||||
@EnableSwaggerBootstrapUI
|
||||
@Configuration("authCenterSwaggerConfig")
|
||||
public class SwaggerConfig {
|
||||
|
||||
@Bean
|
||||
public Docket authCenterApiConfig() {
|
||||
return new Docket(DocumentationType.SWAGGER_2)
|
||||
.apiInfo(webApiInfo())
|
||||
.select()
|
||||
.apis(RequestHandlerSelectors.basePackage("com.codvision.auth"))
|
||||
.paths(PathSelectors.any())
|
||||
.build().groupName("统一认证中心");
|
||||
}
|
||||
|
||||
private ApiInfo webApiInfo() {
|
||||
return new ApiInfoBuilder()
|
||||
.title("统一认证中心接口管理")
|
||||
.description("统一认证中心接口文档")
|
||||
.version("1.0")
|
||||
.license("Codvision")
|
||||
.licenseUrl("http://www.codvision.com")
|
||||
.build();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.codvision.auth.controller;
|
||||
|
||||
import com.codvision.auth.entity.vo.CustomCaptchaVO;
|
||||
import com.codvision.auth.service.ICustomCaptchaService;
|
||||
import com.codvision.commoncore.common.ResponseEntity;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* 自定义图片验证码(包含数字、字母)
|
||||
*
|
||||
* @author hxl
|
||||
*/
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping("/customCaptcha")
|
||||
@Api(tags = "用户端-验证码模块")
|
||||
public class CustomCaptchaController {
|
||||
|
||||
@Resource
|
||||
private ICustomCaptchaService customCaptchaService;
|
||||
|
||||
@PostMapping("/get")
|
||||
@ApiOperation(value = "获取验证码", notes = "获取验证码接口")
|
||||
public ResponseEntity<CustomCaptchaVO> get() {
|
||||
return new ResponseEntity<CustomCaptchaVO>().data(customCaptchaService.getPicCaptcha());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,251 @@
|
||||
/*
|
||||
* Copyright (c) 2023 codvision.com All Rights Reserved.
|
||||
*/
|
||||
|
||||
package com.codvision.auth.controller;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import com.aliyuncs.exceptions.ClientException;
|
||||
import com.codvision.auth.core.AuthCaptchaService;
|
||||
import com.codvision.auth.entity.UserOrgRole;
|
||||
import com.codvision.auth.entity.vo.SysUserVO;
|
||||
import com.codvision.auth.service.ISysUserService;
|
||||
import com.codvision.auth.support.SendSms;
|
||||
import com.codvision.auth.support.UserContext;
|
||||
import com.codvision.authcore.bean.SysUserBean;
|
||||
import com.codvision.authcore.service.IAuthService;
|
||||
import com.codvision.authcore.util.AuthUtil;
|
||||
import com.codvision.base.service.ISysConfigService;
|
||||
import com.codvision.cachecore.utils.RedisUtil;
|
||||
import com.codvision.commoncore.common.ResponseEntity;
|
||||
import com.codvision.commoncore.exception.AuthException;
|
||||
import com.codvision.commoncore.exception.BusinessException;
|
||||
import com.codvision.commoncore.utils.Md5Utils;
|
||||
import com.codvision.webcore.annotation.ApiSecret;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static com.codvision.auth.support.CacheContants.USER_LOGIN_MOBILE_CODE;
|
||||
|
||||
/**
|
||||
* 系统用户模块
|
||||
*
|
||||
* @author lingee
|
||||
* @date 2023/11/9
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/v1/sysUser")
|
||||
@Api(tags = "用户端-系统用户模块")
|
||||
public class SysUserController {
|
||||
|
||||
@Resource
|
||||
private ISysUserService sysUserService;
|
||||
|
||||
@Resource
|
||||
private ISysConfigService sysConfigService;
|
||||
|
||||
@Resource
|
||||
@Lazy
|
||||
private IAuthService authService;
|
||||
|
||||
@Resource
|
||||
private AuthCaptchaService authCaptchaService;
|
||||
|
||||
@PostMapping("/resetPwd")
|
||||
@ApiOperation(value = "重置密码", notes = "重置密码接口")
|
||||
public ResponseEntity<String> resetPwd(@ApiParam(value = "用户Id列表", required = true) @RequestBody List<Integer> userIds) {
|
||||
Assert.notEmpty(userIds, "用户Id不能为空");
|
||||
ResponseEntity<String> responseEntity = new ResponseEntity<>();
|
||||
sysUserService.batchResetPwd(userIds);
|
||||
return responseEntity.ok();
|
||||
}
|
||||
|
||||
@PostMapping("/activeOrgRole")
|
||||
@ApiOperation("切换用户所属组织及对应角色")
|
||||
public ResponseEntity<SysUserVO> activeOrgRole(@RequestBody UserOrgRole userOrgRole) {
|
||||
ResponseEntity<SysUserVO> responseEntity = new ResponseEntity<>();
|
||||
SysUserVO user = UserContext.get();
|
||||
if (null == user) {
|
||||
throw new BusinessException(10002);
|
||||
}
|
||||
|
||||
if (userOrgRole.getRoleId() == null || userOrgRole.getOid() == null) {
|
||||
throw new BusinessException(30002);
|
||||
}
|
||||
|
||||
userOrgRole.setUid(user.getId());
|
||||
sysUserService.activeOrgRole(userOrgRole, user);
|
||||
UserContext.set(user);
|
||||
return responseEntity.data(user);
|
||||
}
|
||||
|
||||
@PostMapping("/login")
|
||||
@ApiOperation("用户账号密码登录")
|
||||
public ResponseEntity<SysUserBean> login(@RequestParam(value = "loginName") String loginName,
|
||||
@RequestParam(value = "password") String password,
|
||||
@RequestParam(value = "code", required = false) String code,
|
||||
@RequestParam(value = "reqNo", required = false) String reqNo,
|
||||
@RequestParam(value = "captchaVerification", required = false) String captchaVerification) {
|
||||
authCaptchaService.check(code, reqNo, captchaVerification);
|
||||
ResponseEntity<SysUserBean> responseEntity = new ResponseEntity<>();
|
||||
SysUserBean sysUser = authService.loginByUsernameAndPassword(loginName, password);
|
||||
return responseEntity.data(sysUser);
|
||||
}
|
||||
|
||||
@GetMapping("/pwdRegularCheck")
|
||||
@ApiOperation("用户密码定期更新检查")
|
||||
public ResponseEntity<Boolean> pwdRegularCheck() {
|
||||
ResponseEntity<Boolean> responseEntity = new ResponseEntity<>();
|
||||
SysUserVO userVO = UserContext.get();
|
||||
if (userVO == null) {
|
||||
throw new BusinessException(10002);
|
||||
}
|
||||
return responseEntity.data(sysUserService.isRenewPwd(userVO.getLoginName()));
|
||||
}
|
||||
|
||||
@ApiSecret(ignore = true)
|
||||
@PostMapping("/quickLogin")
|
||||
@ApiOperation("一键登录")
|
||||
public ResponseEntity<SysUserVO> quickLogin(@RequestParam(value = "token") String token,
|
||||
@RequestParam(value = "userInformation") String userInformation) {
|
||||
ResponseEntity<SysUserVO> responseEntity = new ResponseEntity<>();
|
||||
if (StringUtils.isBlank(token) || StringUtils.isBlank(userInformation)) {
|
||||
throw new BusinessException(30002);
|
||||
}
|
||||
|
||||
return loginByMobile(responseEntity, sysUserService.quickLogin(token, userInformation));
|
||||
}
|
||||
|
||||
private ResponseEntity<SysUserVO> loginByMobile(ResponseEntity<SysUserVO> responseEntity, String mobile) {
|
||||
sysUserService.loginByMobile(mobile);
|
||||
|
||||
SysUserVO user = sysUserService.getDetailByLoginName(mobile);
|
||||
if (null == user) {
|
||||
throw new AuthException("账号不存在!");
|
||||
}
|
||||
SysUserBean sysUser = UserContext.set(user);
|
||||
user.setToken(sysUser.getToken());
|
||||
return responseEntity.ok().data(user);
|
||||
}
|
||||
|
||||
@ApiSecret(ignore = true)
|
||||
@PostMapping("/loginSignature")
|
||||
@ApiOperation("用户单点登录")
|
||||
public ResponseEntity<SysUserVO> loginSignature(@RequestParam(value = "loginName") String loginName,
|
||||
@RequestParam(value = "signature") String signature,
|
||||
@RequestParam(value = "ts") Long ts) {
|
||||
ResponseEntity<SysUserVO> responseEntity = new ResponseEntity<>();
|
||||
if (Math.abs(ts - System.currentTimeMillis()) > 10 * 60 * 1000) {
|
||||
throw new BusinessException(10000, "时间戳错误");
|
||||
}
|
||||
|
||||
String md5 = Md5Utils.getMd5(loginName + ts + "codvision");
|
||||
if (!md5.equals(signature)) {
|
||||
throw new BusinessException(10001);
|
||||
}
|
||||
|
||||
SysUserVO user = sysUserService.getDetailByLoginName(loginName);
|
||||
if (null == user) {
|
||||
throw new AuthException("账号不存在!");
|
||||
}
|
||||
SysUserBean sysUser = UserContext.set(user);
|
||||
user.setToken(sysUser.getToken());
|
||||
return responseEntity.ok().data(user);
|
||||
}
|
||||
|
||||
@PostMapping("/loginByMobile")
|
||||
@ApiOperation("用户登录(手机验证码)")
|
||||
public ResponseEntity<SysUserVO> loginByMobile(@RequestParam(value = "mobile") String mobile,
|
||||
@RequestParam(value = "code") String code) {
|
||||
ResponseEntity<SysUserVO> responseEntity = new ResponseEntity<>();
|
||||
if (StringUtils.isBlank(mobile) || StringUtils.isBlank(code)) {
|
||||
throw new BusinessException(30002);
|
||||
}
|
||||
|
||||
String codeCache = RedisUtil.get(USER_LOGIN_MOBILE_CODE + mobile);
|
||||
if (StringUtils.isBlank(codeCache)) {
|
||||
throw new BusinessException(30002, "验证码已过期");
|
||||
}
|
||||
if (!code.equals(codeCache)) {
|
||||
throw new BusinessException(30001, "验证码错误");
|
||||
}
|
||||
|
||||
return loginByMobile(responseEntity, mobile);
|
||||
}
|
||||
|
||||
@PostMapping("/loginPasswordFreeByMobile")
|
||||
@ApiOperation("用户手机号免密登录(配合移动端修改)")
|
||||
public ResponseEntity<SysUserVO> loginPasswordFreeByMobile(@ApiParam(value = "手机号", required = true) @RequestParam(value = "mobile") String mobile) {
|
||||
ResponseEntity<SysUserVO> responseEntity = new ResponseEntity<>();
|
||||
if (StringUtils.isBlank(mobile)) {
|
||||
throw new BusinessException(30002);
|
||||
}
|
||||
return loginByMobile(responseEntity, mobile);
|
||||
}
|
||||
|
||||
@PostMapping(value = "/verifyCode")
|
||||
@ApiOperation("获取手机验证码")
|
||||
public ResponseEntity<String> getVerificationCode(
|
||||
@RequestParam(value = "code", required = false) String code,
|
||||
@RequestParam(value = "reqNo", required = false) String reqNo,
|
||||
@RequestParam(value = "captchaVerification", required = false) String captchaVerification,
|
||||
@ApiParam(value = "手机号", required = true) @RequestParam(value = "mobile") String mobile) {
|
||||
authCaptchaService.check(code, reqNo, captchaVerification);
|
||||
ResponseEntity<String> responseEntity = new ResponseEntity<>();
|
||||
if (StringUtils.isBlank(mobile)) {
|
||||
throw new BusinessException(30002, "请输入手机号");
|
||||
}
|
||||
|
||||
String phoneCode = RandomUtil.randomNumbers(6);
|
||||
JSONObject object = new JSONObject();
|
||||
object.put("product", "基础平台");
|
||||
object.put("code", phoneCode);
|
||||
try {
|
||||
SendSms sendSms = new SendSms(sysConfigService);
|
||||
boolean flag = sendSms.sendWithParam(mobile, "登录验证", "SMS_57155135", object.toString());
|
||||
if (flag) {
|
||||
RedisUtil.set(USER_LOGIN_MOBILE_CODE + mobile, phoneCode, 10, TimeUnit.MINUTES);
|
||||
return responseEntity.message("验证码发送成功!");
|
||||
}
|
||||
} catch (ClientException e) {
|
||||
log.error(e.getMessage());
|
||||
}
|
||||
|
||||
return responseEntity.ok();
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("/logout")
|
||||
@ApiOperation("退出登陆")
|
||||
public ResponseEntity<String> logout() {
|
||||
ResponseEntity<String> responseEntity = new ResponseEntity<>();
|
||||
|
||||
UserContext.remove();
|
||||
return responseEntity.ok();
|
||||
}
|
||||
|
||||
@ApiSecret(ignore = true)
|
||||
@PostMapping("/getUserInfo")
|
||||
@ApiOperation("根据登录状态获取用户信息")
|
||||
public ResponseEntity<SysUserVO> getUserInfo() {
|
||||
ResponseEntity<SysUserVO> responseEntity = new ResponseEntity<>();
|
||||
SysUserBean sysUser = AuthUtil.getCurrentUser();
|
||||
|
||||
SysUserVO vo = new SysUserVO();
|
||||
BeanUtil.copyProperties(sysUser, vo);
|
||||
return responseEntity.ok().data(vo);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,146 @@
|
||||
package com.codvision.auth.controller.manager;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.codvision.auth.entity.Org;
|
||||
import com.codvision.auth.entity.dto.SysOrgQueryDTO;
|
||||
import com.codvision.auth.entity.excel.OrgExcel;
|
||||
import com.codvision.auth.entity.vo.OrgVO;
|
||||
import com.codvision.auth.entity.vo.SysUserVO;
|
||||
import com.codvision.auth.service.IOrgService;
|
||||
import com.codvision.auth.support.UserContext;
|
||||
import com.codvision.authcore.annotation.RequiresPermissions;
|
||||
import com.codvision.base.support.EasyExcelUtil;
|
||||
import com.codvision.commoncore.common.ResponseEntity;
|
||||
import com.codvision.commoncore.exception.BusinessException;
|
||||
import com.codvision.webcore.annotation.ApiSecret;
|
||||
import com.codvision.webcore.bean.QueryPage;
|
||||
import com.codvision.webcore.util.PageUtil;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 组织信息 管理模块
|
||||
*
|
||||
* @author lingee
|
||||
* @date 2023-11-10
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/v1/manager/org")
|
||||
@Api(tags = "平台管理端-组织管理模块")
|
||||
public class ManagerOrgController {
|
||||
|
||||
@Autowired
|
||||
private IOrgService orgService;
|
||||
|
||||
@ApiOperation(value = "获取组织信息分页列表", notes = "获取组织信息分页列表接口")
|
||||
@PostMapping("/all")
|
||||
public ResponseEntity<IPage<OrgVO>> findAll(@RequestParam(required = false) String root,
|
||||
@RequestParam(required = false) String type,
|
||||
@RequestParam(required = false) String keyword,
|
||||
@ApiParam(value = "组织属性id") @RequestParam(value = "orgPropertyId", required = false) Integer orgPropertyId,
|
||||
@ApiParam(value = "最大level") @RequestParam(required = false) Integer maxLevel,
|
||||
@ApiParam(value = "是否忽略wkt") @RequestParam(required = false, defaultValue = "false") Boolean isIgnoreWkt,
|
||||
@ApiParam(value = "是否查询子组织") @RequestParam(required = false, defaultValue = "false") Boolean subQuery,
|
||||
@RequestParam(required = false, defaultValue = "false") Boolean isAll,
|
||||
@RequestParam(required = false, defaultValue = "1") int page,
|
||||
@RequestParam(required = false, defaultValue = "20") int size) {
|
||||
SysOrgQueryDTO queryDTO = new SysOrgQueryDTO(root, type, keyword, orgPropertyId, maxLevel, isIgnoreWkt, subQuery);
|
||||
IPage<OrgVO> pageResult;
|
||||
if (ObjectUtil.isNotEmpty(isAll) && isAll) {
|
||||
pageResult = new Page<>();
|
||||
List<OrgVO> list = orgService.findAll(queryDTO);
|
||||
pageResult.setRecords(list);
|
||||
} else {
|
||||
QueryPage<Org> queryPage = new QueryPage<>(page, size);
|
||||
pageResult = orgService.findAll(queryPage, queryDTO);
|
||||
}
|
||||
return new ResponseEntity<IPage<OrgVO>>().ok().data(pageResult);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取组织信息详情", notes = "获取组织信息详情接口")
|
||||
@PostMapping("/detail")
|
||||
public ResponseEntity<OrgVO> getOrgDetail(@ApiParam(value = "组织信息ID", required = true) @RequestParam Integer oid) {
|
||||
OrgVO vo = orgService.getDetail(oid);
|
||||
return new ResponseEntity<OrgVO>().ok().data(vo);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "新增组织信息", notes = "新增组织信息接口")
|
||||
@PostMapping("/add")
|
||||
@RequiresPermissions("sys_org_add")
|
||||
public ResponseEntity<OrgVO> addOrg(@Valid @RequestBody Org org) {
|
||||
OrgVO vo = orgService.addOrg(org);
|
||||
return new ResponseEntity<OrgVO>().ok().data(vo).message("添加成功");
|
||||
}
|
||||
|
||||
@ApiOperation(value = "删除组织信息", notes = "删除组织信息接口")
|
||||
@PostMapping("/del")
|
||||
@RequiresPermissions("sys_org_del")
|
||||
public ResponseEntity<String> deleteById(@ApiParam(value = "组织信息ID", required = true) @RequestParam Integer oid) {
|
||||
orgService.logicDel(oid);
|
||||
return new ResponseEntity<String>().ok().message("删除成功");
|
||||
}
|
||||
|
||||
@ApiOperation(value = "编辑组织信息", notes = "编辑组织信息接口")
|
||||
@PostMapping("/update")
|
||||
@RequiresPermissions("sys_org_edit")
|
||||
public ResponseEntity<OrgVO> updateOrg(@RequestBody Org org) {
|
||||
if (ObjectUtil.isEmpty(org) && ObjectUtil.isEmpty(org.getOid())) {
|
||||
throw new BusinessException(30002);
|
||||
}
|
||||
OrgVO vo = orgService.updateOrg(org);
|
||||
|
||||
return new ResponseEntity<OrgVO>().ok().data(vo).message("编辑成功");
|
||||
}
|
||||
|
||||
@PostMapping("/tree")
|
||||
@ApiOperation(value = "组织树状展示", notes = "组织树状展示接口")
|
||||
public ResponseEntity<OrgVO> getTree(@RequestParam(value = "root", required = false) Integer root) {
|
||||
return new ResponseEntity<OrgVO>().data(orgService.getTree(root));
|
||||
}
|
||||
|
||||
@ApiSecret(ignore = true)
|
||||
@ApiOperation(value = "下载组织导入模板", notes = "下载组织导入模板接口")
|
||||
@GetMapping("/downloadTemplate")
|
||||
public void downloadTemplate(HttpServletResponse response) {
|
||||
EasyExcelUtil.downloadTemplate("组织模板表", "组织", OrgExcel.class, response);
|
||||
}
|
||||
|
||||
@ApiSecret(ignore = true)
|
||||
@ApiOperation(value = "导入组织", notes = "导入组织接口")
|
||||
@PostMapping("/import")
|
||||
public ResponseEntity<String> excelImport(@RequestPart("file") MultipartFile file) {
|
||||
return new ResponseEntity<String>().data(orgService.excelImport(file));
|
||||
}
|
||||
|
||||
@ApiSecret(ignore = true)
|
||||
@ApiOperation(value = "组织导出", notes = "组织导出接口")
|
||||
@GetMapping("/export")
|
||||
public ResponseEntity<String> excelExport(@RequestParam(required = false) String keyword,
|
||||
@RequestParam(required = false) String root,
|
||||
@RequestParam(required = false) String type) {
|
||||
SysOrgQueryDTO queryDTO = new SysOrgQueryDTO();
|
||||
queryDTO.setKeyword(keyword);
|
||||
if (StrUtil.isNotBlank(root)) {
|
||||
queryDTO.setRoot(root);
|
||||
} else {
|
||||
SysUserVO user = UserContext.get();
|
||||
queryDTO.setRoot(String.valueOf(user.getActiveOid()));
|
||||
}
|
||||
queryDTO.setType(type);
|
||||
queryDTO.setSubQuery(true);
|
||||
|
||||
orgService.excelExport(queryDTO);
|
||||
return new ResponseEntity<String>().ok();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
package com.codvision.auth.controller.manager;
|
||||
|
||||
import com.codvision.authcore.annotation.RequiresPermissions;
|
||||
import com.codvision.commoncore.common.ResponseEntity;
|
||||
import com.codvision.auth.entity.vo.OrgPropertyVO;
|
||||
import com.codvision.auth.entity.OrgProperty;
|
||||
import com.codvision.auth.service.IOrgPropertyService;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.codvision.webcore.annotation.ApiSecret;
|
||||
import com.codvision.webcore.bean.QueryPage;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 组织属性表 管理模块
|
||||
*
|
||||
* @author lingee
|
||||
* @date 2023-11-10
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/v1/manager/orgProperty")
|
||||
@Api(tags = "平台管理端-组织属性管理模块")
|
||||
public class ManagerOrgPropertyController {
|
||||
|
||||
@Autowired
|
||||
private IOrgPropertyService orgPropertyService;
|
||||
|
||||
@ApiOperation(value = "获取组织属性表分页列表", notes = "获取组织属性表分页列表接口")
|
||||
@PostMapping("/findAll")
|
||||
@RequiresPermissions("sys_org_property_list")
|
||||
public ResponseEntity<IPage<OrgPropertyVO>> findAll(@RequestParam(required = false) String keyword,
|
||||
@ApiParam(value = "父级id", required = true) @RequestParam(required = false) Integer pid,
|
||||
@RequestParam(value = "page", required = false, defaultValue = "1") int page,
|
||||
@RequestParam(value = "size", required = false, defaultValue = "10") int size) {
|
||||
OrgProperty queryBean = new OrgProperty();
|
||||
queryBean.setName(keyword);
|
||||
queryBean.setPid(pid);
|
||||
IPage<OrgPropertyVO> pageResult = orgPropertyService.getPageResult(new QueryPage<>(queryBean, page, size));
|
||||
return new ResponseEntity<IPage<OrgPropertyVO>>().ok().data(pageResult);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "新增组织属性表", notes = "新增组织属性表接口")
|
||||
@PostMapping("/add")
|
||||
@RequiresPermissions("sys_org_property_add")
|
||||
public ResponseEntity<String> saveOrgProperty(@Valid @RequestBody OrgProperty orgProperty) {
|
||||
orgPropertyService.save(orgProperty);
|
||||
return new ResponseEntity<String>().ok().message("添加成功");
|
||||
}
|
||||
|
||||
@ApiOperation(value = "删除组织属性表", notes = "删除组织属性表接口")
|
||||
@PostMapping("/del")
|
||||
@RequiresPermissions("sys_org_property_del")
|
||||
public ResponseEntity<String> deleteById(@ApiParam(value = "组织属性表ID", required = true) @RequestParam Integer id) {
|
||||
orgPropertyService.removeById(id);
|
||||
return new ResponseEntity<String>().ok().message("删除成功");
|
||||
}
|
||||
|
||||
@ApiOperation(value = "编辑组织属性表", notes = "编辑组织属性表接口")
|
||||
@PostMapping("/update")
|
||||
@RequiresPermissions("sys_org_property_edit")
|
||||
public ResponseEntity<String> updateOrgProperty(@RequestBody OrgProperty orgProperty) {
|
||||
orgPropertyService.updateById(orgProperty);
|
||||
return new ResponseEntity<String>().ok().message("编辑成功");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
package com.codvision.auth.controller.manager;
|
||||
|
||||
import com.codvision.commoncore.common.ResponseEntity;
|
||||
import com.codvision.auth.entity.vo.SysAppVO;
|
||||
import com.codvision.auth.entity.SysApp;
|
||||
import com.codvision.auth.service.ISysAppService;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.codvision.webcore.bean.QueryPage;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 系统应用 管理模块
|
||||
*
|
||||
* @author lingee
|
||||
* @date 2024-04-29
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/v1/manager/sysApp")
|
||||
@Api(tags = "平台管理端-系统应用模块")
|
||||
public class ManagerSysAppController {
|
||||
|
||||
@Autowired
|
||||
private ISysAppService sysAppService;
|
||||
|
||||
@ApiOperation(value = "获取系统应用详情", notes = "获取系统应用详情接口")
|
||||
@PostMapping("/getDetail")
|
||||
public ResponseEntity<SysAppVO> getById(@ApiParam(value = "系统应用ID", required = true) @RequestParam Integer id) {
|
||||
SysAppVO vo = sysAppService.getDetail(id);
|
||||
return new ResponseEntity<SysAppVO>().ok().data(vo);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取系统应用分页列表", notes = "获取系统应用分页列表接口")
|
||||
@PostMapping("/getPageList")
|
||||
public ResponseEntity<IPage<SysAppVO>> getPageList(
|
||||
@ApiParam(value = "应用名称") @RequestParam(required = false) String name,
|
||||
@ApiParam(value = "页号", required = true, defaultValue = "1") @RequestParam(defaultValue = "1") Integer pageNumber,
|
||||
@ApiParam(value = "页面大小", required = true, defaultValue = "10") @RequestParam(defaultValue = "10") Integer pageSize) {
|
||||
SysApp queryBean = new SysApp();
|
||||
queryBean.setName(name);
|
||||
QueryPage<SysApp> queryPage = new QueryPage<>(queryBean, pageNumber, pageSize);
|
||||
IPage<SysAppVO> pageResult = sysAppService.getPageResult(queryPage);
|
||||
return new ResponseEntity<IPage<SysAppVO>>().ok().data(pageResult);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "新增系统应用", notes = "新增系统应用接口")
|
||||
@PostMapping("/save")
|
||||
public ResponseEntity<String> saveSysApp(@Valid @RequestBody SysApp sysApp) {
|
||||
sysAppService.save(sysApp);
|
||||
return new ResponseEntity<String>().ok().message("添加成功");
|
||||
}
|
||||
|
||||
@ApiOperation(value = "删除系统应用", notes = "删除系统应用接口")
|
||||
@PostMapping("/delete")
|
||||
public ResponseEntity<String> deleteById(@ApiParam(value = "系统应用ID", required = true) @RequestParam Integer id) {
|
||||
sysAppService.removeById(id);
|
||||
return new ResponseEntity<String>().ok().message("删除成功");
|
||||
}
|
||||
|
||||
@ApiOperation(value = "编辑系统应用", notes = "编辑系统应用接口")
|
||||
@PostMapping("/update")
|
||||
public ResponseEntity<String> updateSysApp(@RequestBody SysApp sysApp) {
|
||||
sysAppService.updateById(sysApp);
|
||||
return new ResponseEntity<String>().ok().message("编辑成功");
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取系统应用所有列表" , notes = "获取系统应用所有列表接口")
|
||||
@PostMapping("/listAll")
|
||||
public ResponseEntity<List<SysAppVO>> listAll() {
|
||||
SysApp queryBean = new SysApp();
|
||||
List<SysAppVO> list = sysAppService.listAll(queryBean);
|
||||
return new ResponseEntity<List<SysAppVO>>().ok().data(list);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,117 @@
|
||||
/*
|
||||
* Copyright (c) 2023 codvision.com All Rights Reserved.
|
||||
*/
|
||||
|
||||
package com.codvision.auth.controller.manager;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.codvision.auth.entity.SysMenu;
|
||||
import com.codvision.auth.entity.dto.SysMenuQueryDTO;
|
||||
import com.codvision.auth.entity.vo.SysMenuVO;
|
||||
import com.codvision.auth.service.ISysMenuService;
|
||||
import com.codvision.auth.support.UserContext;
|
||||
import com.codvision.authcore.annotation.RequiresPermissions;
|
||||
import com.codvision.commoncore.common.ResponseEntity;
|
||||
import com.codvision.commoncore.exception.BusinessException;
|
||||
import com.codvision.webcore.annotation.ApiSecret;
|
||||
import com.codvision.webcore.bean.QueryPage;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 系统菜单 管理模块
|
||||
*
|
||||
* @author lingee
|
||||
* @date 2023-11-09
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/v1/manager/sysMenu")
|
||||
@Api(tags = "平台管理端-系统菜单管理模块")
|
||||
public class ManagerSysMenuController {
|
||||
|
||||
@Autowired
|
||||
private ISysMenuService sysMenuService;
|
||||
|
||||
@ApiOperation(value = "获取系统菜单详情", notes = "获取系统菜单详情接口")
|
||||
@PostMapping("/getDetail")
|
||||
public ResponseEntity<SysMenuVO> getById(@ApiParam(value = "系统菜单ID", required = true) @RequestParam Long id) {
|
||||
SysMenuVO vo = sysMenuService.getDetail(id);
|
||||
return new ResponseEntity<SysMenuVO>().ok().data(vo);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取系统菜单分页列表", notes = "获取系统菜单分页列表接口")
|
||||
@PostMapping("/findAll")
|
||||
@RequiresPermissions("sys_menu_list")
|
||||
public ResponseEntity<IPage<SysMenuVO>> findAll(@RequestParam(required = false) String name,
|
||||
@RequestParam(required = false) Integer type,
|
||||
@RequestParam(required = false) Boolean ignoreApi,
|
||||
@ApiParam(value = "菜单路径") @RequestParam(value = "pathName", required = false) String pathName,
|
||||
@ApiParam(value = "菜单类型(多个逗号隔开)") @RequestParam(value = "category", required = false) String category,
|
||||
@RequestParam(value = "page", required = false, defaultValue = "1") int page,
|
||||
@RequestParam(value = "size", required = false, defaultValue = "1000") int size) {
|
||||
QueryPage<SysMenu> queryPage = new QueryPage<>(page, size);
|
||||
|
||||
SysMenuQueryDTO queryDTO = new SysMenuQueryDTO(name, type, ignoreApi, category, category);
|
||||
|
||||
IPage<SysMenuVO> pageResult = sysMenuService.findAll(queryPage, queryDTO);
|
||||
return new ResponseEntity<IPage<SysMenuVO>>().ok().data(pageResult);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "新增系统菜单", notes = "新增系统菜单接口")
|
||||
@PostMapping("/add")
|
||||
@RequiresPermissions("sys_menu_add")
|
||||
public ResponseEntity<String> addSysMenu(@Valid @RequestBody SysMenu sysMenu) {
|
||||
sysMenuService.addSysMenu(sysMenu);
|
||||
return new ResponseEntity<String>().ok().message("添加成功");
|
||||
}
|
||||
|
||||
@ApiOperation(value = "批量删除系统菜单", notes = "批量删除系统菜单接口")
|
||||
@PostMapping("/batchDel")
|
||||
@RequiresPermissions("sys_menu_del")
|
||||
public ResponseEntity<String> batchDel(@ApiParam(value = "系统菜单ID列表", required = true) @RequestBody List<Integer> menuIdList) {
|
||||
if (CollectionUtils.isEmpty(menuIdList)) {
|
||||
throw new BusinessException(30002);
|
||||
}
|
||||
|
||||
sysMenuService.update(Wrappers.<SysMenu>lambdaUpdate().setSql("del_flag = 1, del_key = id").in(SysMenu::getId, menuIdList));
|
||||
return new ResponseEntity<String>().ok().message("删除成功");
|
||||
}
|
||||
|
||||
@ApiOperation(value = "编辑系统菜单", notes = "编辑接系统菜单接口")
|
||||
@PostMapping("/update")
|
||||
@RequiresPermissions("sys_menu_edit")
|
||||
public ResponseEntity<String> updateSysMenu(@RequestBody SysMenu sysMenu) {
|
||||
if (null == sysMenu.getId() || StringUtils.isBlank(sysMenu.getPathName())) {
|
||||
throw new BusinessException(30002);
|
||||
}
|
||||
|
||||
sysMenuService.updateSysMenu(sysMenu);
|
||||
return new ResponseEntity<String>().ok().message("编辑成功");
|
||||
}
|
||||
|
||||
@PostMapping("/getUserMenuList")
|
||||
@ApiOperation(value = "权限菜单列表", notes = "获取权限菜单列表接口")
|
||||
@RequiresPermissions("sys_menu_list")
|
||||
public ResponseEntity<List<SysMenuVO>> getUserMenuList(@RequestParam(required = false) String name,
|
||||
@RequestParam(required = false) Integer type,
|
||||
@ApiParam(value = "pathName") @RequestParam(value = "pathName", required = false) String pathName,
|
||||
@ApiParam(value = "菜单类型(多个逗号隔开)") @RequestParam(value = "category", required = false) String category) {
|
||||
ResponseEntity<List<SysMenuVO>> responseEntity = new ResponseEntity<>();
|
||||
SysMenuQueryDTO queryDTO = new SysMenuQueryDTO(name, type, null, pathName, category);
|
||||
|
||||
queryDTO.setUid(UserContext.get().getId());
|
||||
|
||||
List<SysMenuVO> list = sysMenuService.getUserMenuList(queryDTO);
|
||||
|
||||
return responseEntity.data(list);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
/*
|
||||
* Copyright (c) 2023 codvision.com All Rights Reserved.
|
||||
*/
|
||||
|
||||
package com.codvision.auth.controller.manager;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.codvision.auth.entity.SysRole;
|
||||
import com.codvision.auth.entity.vo.SysRoleVO;
|
||||
import com.codvision.auth.service.ISysRoleService;
|
||||
import com.codvision.auth.support.UserContext;
|
||||
import com.codvision.authcore.annotation.RequiresPermissions;
|
||||
import com.codvision.commoncore.common.ResponseEntity;
|
||||
import com.codvision.commoncore.exception.BusinessException;
|
||||
import com.codvision.webcore.annotation.ApiSecret;
|
||||
import com.codvision.webcore.bean.QueryPage;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 系统角色 管理模块
|
||||
*
|
||||
* @author lingee
|
||||
* @date 2023-11-09
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/v1/manager/sysRole" )
|
||||
@Api(tags = "平台管理端-系统角色管理模块" )
|
||||
public class ManagerSysRoleController {
|
||||
|
||||
@Autowired
|
||||
private ISysRoleService sysRoleService;
|
||||
|
||||
@ApiOperation(value = "获取系统角色分页列表" , notes = "获取系统角色分页列表接口" )
|
||||
@PostMapping("/findAll" )
|
||||
@RequiresPermissions("sys_role_list" )
|
||||
public ResponseEntity<IPage<SysRoleVO>> findAll(@RequestParam(value = "page" , required = false, defaultValue = "1" ) int page,
|
||||
@RequestParam(value = "size" , required = false, defaultValue = "10" ) int size,
|
||||
@ApiParam(value = "角色id" ) @RequestParam(value = "roleId" , required = false, defaultValue = "-1" ) Integer roleId) {
|
||||
QueryPage<SysRole> queryPage = new QueryPage<>(page, size);
|
||||
if (roleId != -1 && !"超级管理员".equals(UserContext.get().getActiveRoleName())) {
|
||||
SysRole queryBean = new SysRole();
|
||||
queryBean.setId(roleId);
|
||||
queryPage.setCondition(queryBean);
|
||||
}
|
||||
IPage<SysRoleVO> pageResult = sysRoleService.getPageResult(queryPage);
|
||||
return new ResponseEntity<IPage<SysRoleVO>>().ok().data(pageResult);
|
||||
}
|
||||
|
||||
@PostMapping("/getAll" )
|
||||
@ApiOperation(value = "获取所有角色名称和id" , notes = "获取所有角色名称和id接口" )
|
||||
public ResponseEntity<List<SysRoleVO>> getAll() {
|
||||
ResponseEntity<List<SysRoleVO>> responseEntity = new ResponseEntity<>();
|
||||
List<SysRoleVO> list = sysRoleService.listAll(null);
|
||||
return responseEntity.ok().data(list);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "新增系统角色" , notes = "新增系统角色接口" )
|
||||
@PostMapping("/add" )
|
||||
@RequiresPermissions("sys_role_add" )
|
||||
public ResponseEntity<String> saveSysRole(@Valid @RequestBody SysRole sysRole) {
|
||||
sysRoleService.save(sysRole);
|
||||
return new ResponseEntity<String>().ok().message("添加成功" );
|
||||
}
|
||||
|
||||
@ApiOperation(value = "删除系统角色" , notes = "删除系统角色接口" )
|
||||
@PostMapping("/del" )
|
||||
@RequiresPermissions("sys_role_del" )
|
||||
public ResponseEntity<String> delRole(@ApiParam(value = "系统角色ID" , required = true) @RequestParam Integer id) {
|
||||
if (ObjectUtil.isEmpty(id)) {
|
||||
throw new BusinessException(30002);
|
||||
}
|
||||
if (id == 1) {
|
||||
throw new BusinessException(20001, "默认的超级管理员不支持删除" );
|
||||
}
|
||||
|
||||
sysRoleService.logicDel(id);
|
||||
return new ResponseEntity<String>().ok().message("删除成功" );
|
||||
}
|
||||
|
||||
@ApiOperation(value = "编辑系统角色" , notes = "编辑接系统角色接口" )
|
||||
@PostMapping("/update" )
|
||||
@RequiresPermissions("sys_role_edit" )
|
||||
public ResponseEntity<String> updateSysRole(@RequestBody SysRole sysRole) {
|
||||
if (ObjectUtil.isEmpty(sysRole)) {
|
||||
throw new BusinessException(30002);
|
||||
}
|
||||
sysRoleService.updateById(sysRole);
|
||||
return new ResponseEntity<String>().ok().message("编辑成功" );
|
||||
}
|
||||
|
||||
@ApiSecret(ignore = true)
|
||||
@PostMapping("/setRoleMenu" )
|
||||
@ApiOperation("设置角色菜单权限" )
|
||||
@RequiresPermissions("sys_role_set_menu" )
|
||||
public ResponseEntity<String> setRoleMenu(@RequestParam(value = "roleId" ) Integer roleId,
|
||||
@RequestBody List<Integer> menuIdList) {
|
||||
ResponseEntity<String> responseEntity = new ResponseEntity<>();
|
||||
if (ObjectUtil.isEmpty(roleId)) {
|
||||
throw new BusinessException(30002);
|
||||
}
|
||||
|
||||
sysRoleService.setRoleMenu(roleId, menuIdList);
|
||||
return responseEntity.ok();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,195 @@
|
||||
/*
|
||||
* Copyright (c) 2023 codvision.com All Rights Reserved.
|
||||
*/
|
||||
|
||||
package com.codvision.auth.controller.manager;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.codvision.auth.entity.SysUser;
|
||||
import com.codvision.auth.entity.dto.SysUserDTO;
|
||||
import com.codvision.auth.entity.dto.SysUserQueryDTO;
|
||||
import com.codvision.auth.entity.excel.SysUserExcel;
|
||||
import com.codvision.auth.entity.vo.SysUserVO;
|
||||
import com.codvision.auth.service.IDingUserService;
|
||||
import com.codvision.auth.service.ISysUserService;
|
||||
import com.codvision.auth.support.AuthConst;
|
||||
import com.codvision.auth.support.CacheContants;
|
||||
import com.codvision.auth.support.UserContext;
|
||||
import com.codvision.authcore.annotation.RequiresPermissions;
|
||||
import com.codvision.base.support.EasyExcelUtil;
|
||||
import com.codvision.commoncore.common.ResponseEntity;
|
||||
import com.codvision.commoncore.exception.BusinessException;
|
||||
import com.codvision.webcore.annotation.ApiSecret;
|
||||
import com.codvision.webcore.bean.QueryPage;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.redisson.api.RLock;
|
||||
import org.redisson.api.RedissonClient;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* 系统用户 管理模块
|
||||
*
|
||||
* @author lingee
|
||||
* @date 2023-11-09
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/v1/manager/sysUser")
|
||||
@Api(tags = "平台管理端-系统用户管理模块")
|
||||
public class ManagerSysUserController {
|
||||
|
||||
@Resource
|
||||
private ISysUserService sysUserService;
|
||||
|
||||
@Resource
|
||||
private IDingUserService dingUserService;
|
||||
|
||||
@Lazy
|
||||
@Resource
|
||||
private RedissonClient redissonClient;
|
||||
|
||||
@ApiOperation(value = "获取系统用户详情", notes = "获取系统用户详情接口")
|
||||
@PostMapping("/detail")
|
||||
@RequiresPermissions("sys_user_detail")
|
||||
public ResponseEntity<SysUserVO> getByUid(@ApiParam(value = "系统用户ID", required = true) @RequestParam(value = "uid") Integer uid) {
|
||||
SysUserVO vo = sysUserService.getDetailByUid(uid);
|
||||
return new ResponseEntity<SysUserVO>().ok().data(vo);
|
||||
}
|
||||
|
||||
@PostMapping("/detailByName")
|
||||
@ApiOperation(value = "根据用户名获取用户详情", notes = "根据用户名获取用户详情接口")
|
||||
@RequiresPermissions("sys_user_detail_name")
|
||||
public ResponseEntity<SysUserVO> getDetailByUid(@ApiParam(value = "用户名", required = true) @RequestParam(value = "loginName") String loginName) {
|
||||
ResponseEntity<SysUserVO> responseEntity = new ResponseEntity<>();
|
||||
|
||||
return responseEntity.data(sysUserService.getDetailByLoginName(loginName));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取系统用户分页列表", notes = "获取系统用户分页列表接口")
|
||||
@PostMapping("/findAll")
|
||||
@RequiresPermissions("sys_user_list")
|
||||
public ResponseEntity<IPage<SysUserVO>> findAll(@ApiParam(value = "关键字") @RequestParam(required = false) String keyword,
|
||||
@ApiParam(value = "组织id") @RequestParam(required = false) Integer oid,
|
||||
@ApiParam(value = "角色id") @RequestParam(required = false) Integer roleId,
|
||||
@RequestParam(value = "page", required = false, defaultValue = "1") int page,
|
||||
@RequestParam(value = "size", required = false, defaultValue = "10") int size,
|
||||
@ApiParam(value = "是否绑定zzdId:0否,1是") @RequestParam(value = "flagBindZzd", required = false) Integer flagBindZzd,
|
||||
@ApiParam(value = "应用code") @RequestParam(value = "appCode", required = false) String appCode,
|
||||
@ApiParam(value = "是否禁用flagForbidden:0否,1是") @RequestParam(value = "flagForbidden", required = false, defaultValue = "-1") Integer flagForbidden) {
|
||||
QueryPage<SysUser> queryPage = new QueryPage<>(page, size);
|
||||
|
||||
SysUserQueryDTO queryDTO = new SysUserQueryDTO(keyword, oid, roleId, flagBindZzd, appCode, flagForbidden);
|
||||
|
||||
IPage<SysUserVO> pageResult = sysUserService.findAll(queryPage, queryDTO);
|
||||
return new ResponseEntity<IPage<SysUserVO>>().ok().data(pageResult);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "新增系统用户", notes = "新增系统用户接口")
|
||||
@PostMapping("/add")
|
||||
@RequiresPermissions("sys_user_add")
|
||||
public ResponseEntity<String> addSysUser(@Valid @RequestBody SysUserDTO sysUserDTO) {
|
||||
Integer userId = sysUserService.addSysUser(sysUserDTO);
|
||||
return new ResponseEntity<String>().ok().data(String.valueOf(userId)).message("添加成功");
|
||||
}
|
||||
|
||||
@ApiOperation(value = "删除系统用户", notes = "删除系统用户接口")
|
||||
@PostMapping("/del")
|
||||
@RequiresPermissions("sys_user_del")
|
||||
public ResponseEntity<String> del(@ApiParam(value = "系统用户ID", required = true) @RequestBody List<Integer> userIds) {
|
||||
if (CollectionUtils.isEmpty(userIds)) {
|
||||
throw new BusinessException(30002);
|
||||
}
|
||||
SysUser updateBean = new SysUser();
|
||||
updateBean.setDelFlag(AuthConst.DEFAULT_ROLE_FLAG);
|
||||
sysUserService.update(Wrappers.<SysUser>lambdaUpdate().setSql("del_flag = 1, del_key = id").in(SysUser::getId, userIds));
|
||||
return new ResponseEntity<String>().ok().message("删除成功");
|
||||
}
|
||||
|
||||
@ApiOperation(value = "更新系统用户", notes = "更新系统用户接口")
|
||||
@PostMapping("/update")
|
||||
@RequiresPermissions("sys_user_edit")
|
||||
public ResponseEntity<String> update(@RequestBody SysUserDTO sysUserDTO) {
|
||||
sysUserService.updateUser(sysUserDTO);
|
||||
return new ResponseEntity<String>().ok().message("更新成功");
|
||||
}
|
||||
|
||||
@ApiOperation(value = "根据用户id列表获取用户列表", notes = "根据用户id列表获取用户列表接口")
|
||||
@PostMapping("/getByUidList")
|
||||
public ResponseEntity<List<SysUserVO>> getByUidList(@RequestBody List<Integer> uidList) {
|
||||
return new ResponseEntity<List<SysUserVO>>().ok().data(sysUserService.getListByIds(uidList));
|
||||
}
|
||||
|
||||
@ApiSecret(ignore = true)
|
||||
@ApiOperation(value = "下载用户导入模板", notes = "下载用户导入模板接口")
|
||||
@GetMapping("/downloadTemplate")
|
||||
public void downloadTemplate(HttpServletResponse response) {
|
||||
EasyExcelUtil.downloadTemplate("用户模板表", "用户", SysUserExcel.class, response);
|
||||
}
|
||||
|
||||
@ApiSecret(ignore = true)
|
||||
@ApiOperation(value = "用户导入", notes = "用户导入接口")
|
||||
@PostMapping("/import")
|
||||
public ResponseEntity<String> excelImport(@RequestPart("file") MultipartFile file) {
|
||||
return new ResponseEntity<String>().ok().data(sysUserService.excelImport(file));
|
||||
}
|
||||
|
||||
@ApiSecret(ignore = true)
|
||||
@ApiOperation(value = "用户导出", notes = "用户导出接口")
|
||||
@GetMapping("/export")
|
||||
public ResponseEntity<String> excelExport(@RequestParam(required = false) String keyword,
|
||||
@RequestParam(required = false) Integer oid,
|
||||
@RequestParam(required = false) Integer roleId) {
|
||||
SysUserQueryDTO queryDTO = new SysUserQueryDTO();
|
||||
queryDTO.setKeyword(keyword);
|
||||
|
||||
if (ObjectUtil.isNotEmpty(oid)) {
|
||||
queryDTO.setOid(oid);
|
||||
} else {
|
||||
SysUserVO user = UserContext.get();
|
||||
queryDTO.setOid(user.getActiveOid());
|
||||
}
|
||||
queryDTO.setRoleId(roleId);
|
||||
|
||||
sysUserService.excelExport(queryDTO);
|
||||
return new ResponseEntity<String>().ok();
|
||||
}
|
||||
|
||||
@ApiSecret(ignore = true)
|
||||
@ApiOperation(value = "同步钉钉组织用户", notes = "同步钉钉组织用户接口")
|
||||
@PostMapping("/syncDing")
|
||||
public ResponseEntity<String> syncDing(@ApiParam(value = "用户绑定默认角色编码", required = true) @RequestParam String roleCode) {
|
||||
RLock lock = redissonClient.getLock(CacheContants.SYNC_DING_LOCK);
|
||||
if (lock.isLocked()) {
|
||||
throw new BusinessException("同步中,请稍后重试");
|
||||
}
|
||||
try {
|
||||
// 等待10秒获取锁,持有锁30秒
|
||||
if (lock.tryLock(10, 30, TimeUnit.SECONDS)) {
|
||||
dingUserService.syncDepartment();
|
||||
dingUserService.syncUser(roleCode);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
throw new BusinessException(e.getMessage());
|
||||
} finally {
|
||||
if (lock.isLocked() && lock.isHeldByCurrentThread()) {
|
||||
lock.unlock();
|
||||
}
|
||||
}
|
||||
return new ResponseEntity<String>().ok().message("同步成功");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
package com.codvision.auth.controller.third;
|
||||
|
||||
import com.codvision.auth.entity.ding.DingConfig;
|
||||
import com.codvision.auth.entity.vo.SysUserVO;
|
||||
import com.codvision.auth.enums.LoginTypeEnum;
|
||||
import com.codvision.auth.service.ISysUserService;
|
||||
import com.codvision.auth.service.third.DingTalkService;
|
||||
import com.codvision.auth.support.UserContext;
|
||||
import com.codvision.authcore.bean.SysUserBean;
|
||||
import com.codvision.commoncore.common.ResponseEntity;
|
||||
import com.codvision.commoncore.exception.AuthException;
|
||||
import com.dingtalk.api.response.OapiV2UserGetResponse;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* @author codvision
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@Api(tags = "用户端-普通钉钉管理")
|
||||
@RequestMapping("/ding")
|
||||
public class DingController {
|
||||
|
||||
@Resource
|
||||
@Lazy
|
||||
private DingTalkService dingTalkService;
|
||||
|
||||
@Resource
|
||||
private ISysUserService sysUserService;
|
||||
|
||||
|
||||
@PostMapping("/login")
|
||||
@ApiOperation("普通钉钉登陆")
|
||||
public ResponseEntity<SysUserBean> handlePostDingLogin(@ApiParam(value = "临时授权码") @RequestParam(value = "code") String code,
|
||||
@ApiParam(value = "登陆类型(0-免登 1-扫码登陆)") @RequestParam(value = "loginType") Integer loginType) {
|
||||
ResponseEntity<SysUserBean> responseEntity = new ResponseEntity<>();
|
||||
|
||||
OapiV2UserGetResponse rsp;
|
||||
try {
|
||||
if (LoginTypeEnum.SCAN_LOGIN.getCode().equals(loginType)) {
|
||||
rsp = dingTalkService.getUserInfoByScan(code);
|
||||
} else {
|
||||
rsp = dingTalkService.getUserInfo(code);
|
||||
}
|
||||
|
||||
OapiV2UserGetResponse.UserGetResponse result = rsp.getResult();
|
||||
SysUserVO user = sysUserService.getByDingTalkUid(result.getUserid());
|
||||
if (null == user) {
|
||||
throw new AuthException(100001, "无该钉钉用户");
|
||||
}
|
||||
|
||||
SysUserBean sysUser = UserContext.set(user);
|
||||
user.setToken(sysUser.getToken());
|
||||
responseEntity.data(sysUser);
|
||||
} catch (Exception ex) {
|
||||
log.error(ex.getMessage());
|
||||
throw new AuthException(10000, "钉钉登陆失败");
|
||||
}
|
||||
|
||||
return responseEntity.ok();
|
||||
}
|
||||
|
||||
@PostMapping("/config")
|
||||
@ApiOperation("鉴权")
|
||||
public DingConfig config(@RequestParam() String url) {
|
||||
return dingTalkService.getConfig(url);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
package com.codvision.auth.controller.third;
|
||||
|
||||
import com.codvision.auth.entity.ding.gov.GovUserInfo;
|
||||
import com.codvision.auth.entity.vo.SysUserVO;
|
||||
import com.codvision.auth.enums.LoginTypeEnum;
|
||||
import com.codvision.auth.service.ISysUserService;
|
||||
import com.codvision.auth.service.third.GovDingService;
|
||||
import com.codvision.auth.support.UserContext;
|
||||
import com.codvision.authcore.bean.SysUserBean;
|
||||
import com.codvision.commoncore.common.ResponseEntity;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
|
||||
/**
|
||||
* @author hxl
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/govDing")
|
||||
@Api(tags = "用户端-专有钉钉(浙政钉)管理")
|
||||
public class GovDingController {
|
||||
|
||||
@Resource
|
||||
@Lazy
|
||||
private GovDingService govDingService;
|
||||
|
||||
@Resource
|
||||
private ISysUserService sysUserService;
|
||||
|
||||
@PostMapping("/login")
|
||||
@ApiOperation("登录")
|
||||
public ResponseEntity<SysUserBean> login(@RequestParam(value = "code") String code,
|
||||
@ApiParam(value = "登陆类型(0-免登 1-扫码登陆)") @RequestParam(value = "loginType") Integer loginType) {
|
||||
ResponseEntity<SysUserBean> responseEntity = new ResponseEntity<>();
|
||||
|
||||
GovUserInfo userInfo;
|
||||
if (LoginTypeEnum.SCAN_LOGIN.getCode().equals(loginType)) {
|
||||
userInfo = govDingService.getUserInfoByScan(code);
|
||||
} else {
|
||||
userInfo = govDingService.getUserInfo(code);
|
||||
}
|
||||
|
||||
String accountId = userInfo.getAccountId().toString();
|
||||
SysUserVO user = sysUserService.getByZzdId(accountId);
|
||||
if (null == user) {
|
||||
return responseEntity.error(100001, "无该浙政钉用户");
|
||||
}
|
||||
|
||||
SysUserBean sysUser = UserContext.set(user);
|
||||
user.setToken(sysUser.getToken());
|
||||
responseEntity.data(sysUser);
|
||||
|
||||
return responseEntity.ok().data(sysUser);
|
||||
}
|
||||
|
||||
@PostMapping("/getTicket")
|
||||
@ApiOperation("鉴权")
|
||||
public ResponseEntity<String> getTicket() {
|
||||
return new ResponseEntity<String>().data(govDingService.getTicket());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
/*
|
||||
* Copyright (c) 2023 codvision.com All Rights Reserved.
|
||||
*/
|
||||
|
||||
package com.codvision.auth.core;
|
||||
|
||||
import com.anji.captcha.model.common.ResponseModel;
|
||||
import com.anji.captcha.model.vo.CaptchaVO;
|
||||
import com.anji.captcha.service.CaptchaService;
|
||||
import com.codvision.auth.enums.CaptchaEnum;
|
||||
import com.codvision.base.entity.SysConfig;
|
||||
import com.codvision.base.service.ISysConfigService;
|
||||
import com.codvision.cachecore.utils.RedisUtil;
|
||||
import com.codvision.commoncore.exception.AuthException;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import static com.codvision.auth.support.CacheContants.CUSTOM_CAPTCHA_CODE;
|
||||
|
||||
/**
|
||||
* 验证码服务
|
||||
*
|
||||
* @author lingee
|
||||
* @date 2023/11/29
|
||||
*/
|
||||
@Component
|
||||
public class AuthCaptchaService {
|
||||
|
||||
@Resource
|
||||
private ISysConfigService configService;
|
||||
|
||||
@Resource
|
||||
private CaptchaService captchaService;
|
||||
|
||||
/**
|
||||
* 校验验证码
|
||||
*
|
||||
* @param request http请求
|
||||
* @return 校验结果
|
||||
*/
|
||||
public boolean check(String code, String reqNo, String captchaVerification) {
|
||||
// 判断当前验证码类型CAPTCHA_TYPE,默认CLOSED 无验证码功能,SIMPLE 普通验证码,BLOCK_PUZZLE 滑块验证码
|
||||
SysConfig config = configService.getByKey("CAPTCHA_TYPE");
|
||||
if (config == null || StringUtils.isBlank(config.getV())) {
|
||||
throw new IllegalArgumentException("验证码配置项CAPTCHA_TYPE不存在或者数值为空");
|
||||
}
|
||||
|
||||
CaptchaEnum captchaEnum = null;
|
||||
try {
|
||||
captchaEnum = CaptchaEnum.valueOf(config.getV());
|
||||
} catch (IllegalArgumentException e) {
|
||||
throw new IllegalArgumentException("不支持的验证码类型:" + config.getV());
|
||||
}
|
||||
|
||||
switch (captchaEnum) {
|
||||
case CLOSED:
|
||||
return true;
|
||||
case SIMPLE:
|
||||
return simple(code, reqNo);
|
||||
case BLOCK_PUZZLE:
|
||||
return blockPuzzle(captchaVerification);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean simple(String code, String reqNo) {
|
||||
if (StringUtils.isBlank(code) || StringUtils.isBlank(reqNo)) {
|
||||
throw new IllegalArgumentException("缺少验证码或请求号!");
|
||||
}
|
||||
|
||||
String verifyCode = RedisUtil.get(CUSTOM_CAPTCHA_CODE + reqNo);
|
||||
if (StringUtils.isBlank(verifyCode)) {
|
||||
throw new AuthException(10002, "验证码已失效,请重新获取");
|
||||
}
|
||||
|
||||
if (!code.equalsIgnoreCase(verifyCode)) {
|
||||
throw new AuthException(30001, "验证码错误");
|
||||
}
|
||||
|
||||
RedisUtil.del(CUSTOM_CAPTCHA_CODE + reqNo);
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean blockPuzzle(String captchaVerification) {
|
||||
if (StringUtils.isBlank(captchaVerification)) {
|
||||
throw new IllegalArgumentException("缺少验证码!");
|
||||
}
|
||||
|
||||
CaptchaVO captchaVO = new CaptchaVO();
|
||||
captchaVO.setCaptchaVerification(captchaVerification);
|
||||
ResponseModel responseModel = captchaService.verification(captchaVO);
|
||||
if (!responseModel.isSuccess()) {
|
||||
throw new AuthException(10002, responseModel.getRepMsg());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,151 @@
|
||||
/*
|
||||
* Copyright (c) 2023 codvision.com All Rights Reserved.
|
||||
*/
|
||||
|
||||
package com.codvision.auth.core;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.codvision.auth.core.token.ITokenManager;
|
||||
import com.codvision.auth.entity.vo.SysRoleVO;
|
||||
import com.codvision.auth.entity.vo.SysUserVO;
|
||||
import com.codvision.auth.service.ISysRoleService;
|
||||
import com.codvision.auth.service.ISysUserService;
|
||||
import com.codvision.auth.support.UserContext;
|
||||
import com.codvision.authcore.bean.SysMenuBean;
|
||||
import com.codvision.authcore.bean.SysUserBean;
|
||||
import com.codvision.authcore.config.AuthProperties;
|
||||
import com.codvision.authcore.service.IAuthService;
|
||||
import com.codvision.authcore.util.RequestUtil;
|
||||
import com.codvision.cachecore.utils.RedisUtil;
|
||||
import com.codvision.commoncore.exception.AuthException;
|
||||
import com.codvision.commoncore.exception.BusinessException;
|
||||
import com.codvision.commoncore.utils.BeanUtil;
|
||||
import com.codvision.commoncore.utils.DecPwdUtil;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static com.codvision.auth.support.AuthConst.LOCK;
|
||||
import static com.codvision.auth.support.AuthConst.USER_LOCK_LIMIT;
|
||||
import static com.codvision.auth.support.CacheContants.USER_LOGIN_COUNT;
|
||||
import static com.codvision.auth.support.CacheContants.USER_LOGIN_LOCK;
|
||||
import static com.codvision.authcore.constants.AuthCoreConstant.IframeDownFlag;
|
||||
|
||||
/**
|
||||
* 认证中心扩展公共认证模块接口
|
||||
* <p>
|
||||
* 通过策略模式切换单体程序和微服务的用户认证
|
||||
*
|
||||
* @author lingee
|
||||
* @date 2023/11/22
|
||||
*/
|
||||
public class AuthCenterService implements IAuthService {
|
||||
|
||||
@Resource
|
||||
private ISysUserService sysUserService;
|
||||
|
||||
@Resource
|
||||
private BCryptPasswordEncoder bCryptEncode;
|
||||
|
||||
@Resource
|
||||
private ITokenManager tokenManager;
|
||||
|
||||
@Resource
|
||||
private AuthProperties authProperties;
|
||||
|
||||
@Resource
|
||||
private ISysRoleService sysRoleService;
|
||||
|
||||
@Override
|
||||
public SysUserBean getCurrentUserInfo(String token) {
|
||||
return tokenManager.getTokenUser(token);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAuthToken(HttpServletRequest request) {
|
||||
String tokenName = authProperties.getTokenName();
|
||||
String cookieName = authProperties.getCookieName();
|
||||
String token = request.getParameter(tokenName);
|
||||
|
||||
if (StrUtil.isNotBlank(token)) {
|
||||
return token;
|
||||
}
|
||||
|
||||
token = RequestUtil.getFromCookie(request, cookieName);
|
||||
if (StrUtil.isNotBlank(token)) {
|
||||
return token;
|
||||
}
|
||||
|
||||
token = request.getHeader(tokenName);
|
||||
if (StrUtil.isNotBlank(token)) {
|
||||
return token;
|
||||
}
|
||||
|
||||
final String iframeDown = request.getParameter(IframeDownFlag);
|
||||
if (StrUtil.isNotBlank(iframeDown)) {
|
||||
token = request.getParameter(tokenName);
|
||||
}
|
||||
|
||||
|
||||
if (StrUtil.isBlank(token)) {
|
||||
token = request.getSession().getId();
|
||||
}
|
||||
return token;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SysMenuBean> getMenuList(String token) {
|
||||
SysUserBean sysUser = getCurrentUserInfo(token);
|
||||
SysRoleVO sysRoleVO = sysRoleService.getDetail(sysUser.getActiveRoleId());
|
||||
if (ObjectUtil.isNotEmpty(sysRoleVO)) {
|
||||
return BeanUtil.copyToList(sysRoleVO.getRoleMenus(), SysMenuBean.class);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SysUserBean loginByUsernameAndPassword(String username, String password) {
|
||||
if (StringUtils.isBlank(username) || StringUtils.isBlank(password)) {
|
||||
throw new BusinessException(30002);
|
||||
}
|
||||
|
||||
RedisUtil.increment(USER_LOGIN_COUNT + username, 1);
|
||||
String lock = RedisUtil.get(USER_LOGIN_LOCK + username);
|
||||
if (LOCK.equals(lock)) {
|
||||
long expire = RedisUtil.getExpire(USER_LOGIN_LOCK + username);
|
||||
String msg = (expire % 3600) / 60 == 0 ? expire % 60 + "秒" : (expire % 3600) / 60 + "分钟" + expire % 60 + "秒";
|
||||
throw new AuthException("您的帐号[" + username + "]已被禁止登录!将于" + msg + "后自动解除锁定状态");
|
||||
}
|
||||
|
||||
SysUserVO sysUserVO = sysUserService.getDetailByLoginName(username);
|
||||
if (ObjectUtil.isEmpty(sysUserVO)) {
|
||||
throw new AuthException(10001);
|
||||
}
|
||||
// 数据库密码
|
||||
String dbPassword = sysUserVO.getPassword();
|
||||
if (StringUtils.isBlank(dbPassword)) {
|
||||
throw new AuthException("当前账号不支持使用密码登陆的方式,请更换其他登陆方式");
|
||||
}
|
||||
if (!bCryptEncode.matches(DecPwdUtil.decryptAes(password), dbPassword)) {
|
||||
Integer count = RedisUtil.get(USER_LOGIN_COUNT + username);
|
||||
int retryCount = USER_LOCK_LIMIT - count;
|
||||
boolean flag = retryCount <= 0;
|
||||
if (flag) {
|
||||
RedisUtil.expire(USER_LOGIN_COUNT + username, 10, TimeUnit.MINUTES);
|
||||
RedisUtil.set(USER_LOGIN_LOCK + username, LOCK, 10, TimeUnit.MINUTES);
|
||||
}
|
||||
String msg = flag ? "您的帐号[" + username + "]十分钟内已被禁止登录" : "您还剩" + retryCount + "次重试的机会";
|
||||
throw new AuthException("用户名或密码错误!" + msg);
|
||||
}
|
||||
|
||||
// 清空计数
|
||||
RedisUtil.del(USER_LOGIN_COUNT + username, USER_LOGIN_LOCK + username);
|
||||
|
||||
return UserContext.set(sysUserVO);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
* Copyright (c) 2023 codvision.com All Rights Reserved.
|
||||
*/
|
||||
|
||||
package com.codvision.auth.core;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.codvision.auth.entity.dto.SysUserQueryDTO;
|
||||
import com.codvision.auth.entity.vo.SysUserVO;
|
||||
import com.codvision.auth.mapper.SysUserMapper;
|
||||
import com.codvision.auth.service.ISysUserService;
|
||||
import com.codvision.webapi.api.SysUserApi;
|
||||
import com.codvision.webapi.bean.RemoteOrg;
|
||||
import com.codvision.webapi.bean.RemoteSysUser;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 系统用户扩展
|
||||
* <p>
|
||||
* 通过策略模式切换单体程序和微服务的用户接口
|
||||
*
|
||||
* @author lingee
|
||||
* @date 2023/12/1
|
||||
*/
|
||||
@Service
|
||||
public class SysUserExtension implements SysUserApi {
|
||||
|
||||
@Resource
|
||||
private ISysUserService sysUserService;
|
||||
|
||||
@Resource
|
||||
private SysUserMapper sysUserMapper;
|
||||
|
||||
@Override
|
||||
public IPage<RemoteSysUser> pageUserList(String keyword, Integer oid, Integer roleId, List<Integer> uidList, int pageNum, int pageSize) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RemoteSysUser> getAllUserList(String keyword, Integer oid, Integer roleId) {
|
||||
SysUserQueryDTO queryDTO = new SysUserQueryDTO(keyword, oid, roleId, null, null, null);
|
||||
List<SysUserVO> sysUserList = sysUserMapper.findAll(null, queryDTO);
|
||||
return BeanUtil.copyToList(sysUserList, RemoteSysUser.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPage<RemoteOrg> pageOrgList(String keyword, Boolean isAll, int pageNum, int pageSize) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer addUser(RemoteSysUser sysUser) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RemoteSysUser getUserDetail(Integer uid) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RemoteSysUser getUserDetail(String loginName) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateUserOrgRole(Integer uid, Integer oid, String roleCode) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright (c) 2023 codvision.com All Rights Reserved.
|
||||
*/
|
||||
|
||||
package com.codvision.auth.core.token;
|
||||
|
||||
import com.codvision.authcore.bean.SysUserBean;
|
||||
|
||||
/**
|
||||
* token管理器接口
|
||||
*
|
||||
* @author lingee
|
||||
* @date 2023/11/22
|
||||
*/
|
||||
public interface ITokenManager {
|
||||
|
||||
/**
|
||||
* 设置token用户
|
||||
*
|
||||
* @param token token
|
||||
* @param sysUser 用户信息
|
||||
*/
|
||||
void setTokenUser(String token, SysUserBean sysUser);
|
||||
|
||||
/**
|
||||
* 获取token用户
|
||||
*
|
||||
* @param token token
|
||||
* @return 用户信息
|
||||
*/
|
||||
SysUserBean getTokenUser(String token);
|
||||
|
||||
/**
|
||||
* 移除token
|
||||
*
|
||||
* @param token token
|
||||
*/
|
||||
void removeTokenUser(String token);
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.codvision.auth.core.token;
|
||||
|
||||
import com.codvision.authcore.bean.SysUserBean;
|
||||
import com.codvision.commoncore.common.ExpiryMap;
|
||||
|
||||
/**
|
||||
* 内存管理token
|
||||
*
|
||||
* @author lingee
|
||||
* @date 2023/11/22
|
||||
*/
|
||||
public class MemoryTokenManager implements ITokenManager {
|
||||
|
||||
private static final ExpiryMap<String, SysUserBean> TOKEN_MAP = new ExpiryMap<>(true);
|
||||
|
||||
@Override
|
||||
public void setTokenUser(String token, SysUserBean sysUser) {
|
||||
sysUser.setToken(token);
|
||||
sysUser.setPassword(null);
|
||||
TOKEN_MAP.put(token, sysUser, 86400000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SysUserBean getTokenUser(String token) {
|
||||
return TOKEN_MAP.get(token);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeTokenUser(String token) {
|
||||
TOKEN_MAP.remove(token);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.codvision.auth.core.token;
|
||||
|
||||
import com.codvision.authcore.bean.SysUserBean;
|
||||
import com.codvision.authcore.constants.AuthCoreConstant;
|
||||
import com.codvision.cachecore.utils.RedisUtil;
|
||||
|
||||
/**
|
||||
* redis管理器接口
|
||||
*
|
||||
* @author lingee
|
||||
* @date 2023/11/22
|
||||
*/
|
||||
public class RedisTokenManager implements ITokenManager {
|
||||
|
||||
|
||||
@Override
|
||||
public void setTokenUser(String token, SysUserBean sysUser) {
|
||||
sysUser.setToken(token);
|
||||
sysUser.setPassword(null);
|
||||
RedisUtil.set(AuthCoreConstant.LOGIN_USER_EXPIRE_PREFIX + token, sysUser);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SysUserBean getTokenUser(String token) {
|
||||
return RedisUtil.get(AuthCoreConstant.LOGIN_USER_EXPIRE_PREFIX + token);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeTokenUser(String token) {
|
||||
String key = AuthCoreConstant.LOGIN_USER_EXPIRE_PREFIX + token;
|
||||
if (RedisUtil.hasKey(key)) {
|
||||
RedisUtil.del(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
package com.codvision.auth.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 组织信息
|
||||
* </p>
|
||||
*
|
||||
* @author lingee
|
||||
* @since 2023-11-10
|
||||
*/
|
||||
@Data
|
||||
@TableName("tbl_org")
|
||||
@ApiModel(value = "Org", description = "组织信息")
|
||||
public class Org implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty("组织id")
|
||||
@TableId(value = "oid", type = IdType.AUTO)
|
||||
private Integer oid;
|
||||
|
||||
@ApiModelProperty("名称")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty("全称")
|
||||
private String fullname;
|
||||
|
||||
@ApiModelProperty("类型")
|
||||
private Integer type;
|
||||
|
||||
@ApiModelProperty("等级")
|
||||
private Short level;
|
||||
|
||||
@ApiModelProperty("父组织编码")
|
||||
private Integer poid;
|
||||
|
||||
private String geom;
|
||||
|
||||
@ApiModelProperty("排序")
|
||||
private Integer orderby;
|
||||
|
||||
@ApiModelProperty("组织路径")
|
||||
private String path;
|
||||
|
||||
@ApiModelProperty("边界数据")
|
||||
private String wkt;
|
||||
|
||||
@ApiModelProperty("组织id路径")
|
||||
private String oidPath;
|
||||
|
||||
private String refOid;
|
||||
|
||||
private String geoJson;
|
||||
|
||||
@ApiModelProperty("备注")
|
||||
private String remark;
|
||||
|
||||
private String refCode;
|
||||
|
||||
@ApiModelProperty("行政区域id")
|
||||
private Integer districtOid;
|
||||
|
||||
@ApiModelProperty("删除标记,1:已删除,0:正常")
|
||||
private Short delFlag;
|
||||
|
||||
@ApiModelProperty("逻辑删除辅助字段")
|
||||
private Integer delKey;
|
||||
|
||||
@ApiModelProperty("专有钉钉部门code")
|
||||
private String zzdOrgCode;
|
||||
|
||||
@ApiModelProperty("创建时间")
|
||||
private Date createTime;
|
||||
|
||||
@ApiModelProperty("更新时间")
|
||||
private Date updateTime;
|
||||
|
||||
@ApiModelProperty("行政区划编码")
|
||||
private String districtCode;
|
||||
|
||||
@ApiModelProperty("组织属性id")
|
||||
private Integer orgPropertyId;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
package com.codvision.auth.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.codvision.commoncore.enums.SqlOperator;
|
||||
import com.codvision.webcore.annotation.QueryCondition;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 组织属性表
|
||||
* </p>
|
||||
*
|
||||
* @author lingee
|
||||
* @since 2023-11-10
|
||||
*/
|
||||
@Data
|
||||
@TableName("tbl_org_property")
|
||||
@ApiModel(value = "OrgProperty", description = "组织属性表")
|
||||
public class OrgProperty implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty("主键id")
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Integer id;
|
||||
|
||||
@ApiModelProperty("上级id")
|
||||
@QueryCondition(condition = SqlOperator.EQ)
|
||||
private Integer pid;
|
||||
|
||||
@ApiModelProperty("属性名称")
|
||||
@QueryCondition(condition = SqlOperator.LIKE)
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty("图标")
|
||||
private String icon;
|
||||
|
||||
@ApiModelProperty("删除标记,1:已删除,0:正常")
|
||||
private Short delFlag;
|
||||
|
||||
@ApiModelProperty("辅助删除key")
|
||||
private Integer delKey;
|
||||
|
||||
@ApiModelProperty("创建时间")
|
||||
private Date createTime;
|
||||
|
||||
@ApiModelProperty("更新时间")
|
||||
private Date updateTime;
|
||||
|
||||
@ApiModelProperty("编码长度")
|
||||
private Integer codeLength;
|
||||
|
||||
@ApiModelProperty("层级")
|
||||
private Integer level;
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.codvision.auth.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.codvision.webcore.bean.BasicEntity;
|
||||
import java.io.Serializable;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 系统应用
|
||||
* </p>
|
||||
*
|
||||
* @author lingee
|
||||
* @since 2024-04-29
|
||||
*/
|
||||
@Data
|
||||
@TableName("tbl_sys_app")
|
||||
@ApiModel(value = "SysApp", description = "系统应用")
|
||||
public class SysApp extends BasicEntity {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty("应用名称")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty("基础地址")
|
||||
private String entry;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
package com.codvision.auth.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 系统菜单
|
||||
* </p>
|
||||
*
|
||||
* @author lingee
|
||||
* @since 2023-11-09
|
||||
*/
|
||||
@Data
|
||||
@TableName("tbl_sys_menu")
|
||||
@ApiModel(value = "SysMenu", description = "系统菜单")
|
||||
public class SysMenu implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty("ID")
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Integer id;
|
||||
|
||||
@ApiModelProperty("菜单名称")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty("菜单父id")
|
||||
private Integer pid;
|
||||
|
||||
@ApiModelProperty("菜单权限标识")
|
||||
private String permission;
|
||||
|
||||
@ApiModelProperty("前端路由标识路径")
|
||||
private String url;
|
||||
|
||||
@ApiModelProperty("类型")
|
||||
private Short type;
|
||||
|
||||
@ApiModelProperty("排序值")
|
||||
private Short sortOrder;
|
||||
|
||||
@ApiModelProperty("创建时间")
|
||||
private Date createTime;
|
||||
|
||||
@ApiModelProperty("更新时间")
|
||||
private Date updateTime;
|
||||
|
||||
@TableLogic
|
||||
@ApiModelProperty("删除标记,1:已删除,0:正常")
|
||||
private Short delFlag;
|
||||
|
||||
@ApiModelProperty("逻辑删除辅助字段")
|
||||
private Integer delKey;
|
||||
|
||||
@ApiModelProperty("菜单图标")
|
||||
private String icon;
|
||||
|
||||
@ApiModelProperty("是否隐藏")
|
||||
private Boolean isHidden;
|
||||
|
||||
@ApiModelProperty("组件地址")
|
||||
private String component;
|
||||
|
||||
@ApiModelProperty("布局是否可见")
|
||||
private Boolean layout;
|
||||
|
||||
@ApiModelProperty("跳转地址")
|
||||
private String redirect;
|
||||
|
||||
@ApiModelProperty("目标地址")
|
||||
private String target;
|
||||
|
||||
@ApiModelProperty("所属分类")
|
||||
private String category;
|
||||
|
||||
@ApiModelProperty("是否默认")
|
||||
private Boolean isDefault;
|
||||
|
||||
@ApiModelProperty("菜单路径")
|
||||
private String pathName;
|
||||
|
||||
@ApiModelProperty("是否可见")
|
||||
private Boolean enabled;
|
||||
|
||||
@ApiModelProperty("应用id")
|
||||
private Integer appId;
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
package com.codvision.auth.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 系统角色
|
||||
* </p>
|
||||
*
|
||||
* @author lingee
|
||||
* @since 2023-11-09
|
||||
*/
|
||||
@Data
|
||||
@TableName("tbl_sys_role")
|
||||
@ApiModel(value = "SysRole", description = "系统角色")
|
||||
public class SysRole implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty("ID")
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Integer id;
|
||||
|
||||
@ApiModelProperty("角色名称")
|
||||
private String roleName;
|
||||
|
||||
@ApiModelProperty("角色标识")
|
||||
private String roleCode;
|
||||
|
||||
@ApiModelProperty("角色描述")
|
||||
private String roleDesc;
|
||||
|
||||
@ApiModelProperty("数据权限类型")
|
||||
private Short dsType;
|
||||
|
||||
@ApiModelProperty("数据权限作用范围")
|
||||
private Short dsScope;
|
||||
|
||||
@ApiModelProperty("删除标记,1:已删除,0:正常")
|
||||
private Short delFlag;
|
||||
|
||||
@ApiModelProperty("逻辑删除辅助字段")
|
||||
private Short delKey;
|
||||
|
||||
@ApiModelProperty("创建时间")
|
||||
private Date createTime;
|
||||
|
||||
@ApiModelProperty("更新时间")
|
||||
private Date updateTime;
|
||||
|
||||
@ApiModelProperty("是否默认")
|
||||
private Short isDefault;
|
||||
|
||||
@ApiModelProperty("父角色id")
|
||||
private Integer pId;
|
||||
|
||||
@ApiModelProperty("角色等级")
|
||||
private Short level;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.codvision.auth.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 系统角色菜单权限
|
||||
* </p>
|
||||
*
|
||||
* @author lingee
|
||||
* @since 2023-11-09
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@TableName("tbl_sys_role_menu")
|
||||
@ApiModel(value = "SysRoleMenu", description = "系统角色菜单权限")
|
||||
public class SysRoleMenu implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty("角色id")
|
||||
private Integer roleId;
|
||||
|
||||
@ApiModelProperty("菜单id")
|
||||
private Integer menuId;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
package com.codvision.auth.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 系统用户
|
||||
* </p>
|
||||
*
|
||||
* @author lingee
|
||||
* @since 2023-11-09
|
||||
*/
|
||||
@Data
|
||||
@TableName("tbl_sys_user")
|
||||
@ApiModel(value = "SysUser", description = "系统用户")
|
||||
public class SysUser implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty("ID")
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Integer id;
|
||||
|
||||
@ApiModelProperty("用户登陆名")
|
||||
private String loginName;
|
||||
|
||||
@ApiModelProperty("登陆密码")
|
||||
private String password;
|
||||
|
||||
@ApiModelProperty("用户真实姓名")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty("用户联系方式")
|
||||
private String mobile;
|
||||
|
||||
@ApiModelProperty("拓展字段:昵称")
|
||||
private String nickname;
|
||||
|
||||
@ApiModelProperty("拓展字段:头像")
|
||||
private String avatarUrl;
|
||||
|
||||
@ApiModelProperty("拓展字段:邮箱")
|
||||
private String email;
|
||||
|
||||
@ApiModelProperty("浙政钉ID")
|
||||
private String zzdId;
|
||||
|
||||
@ApiModelProperty("微信服务号openID")
|
||||
private String wxMpOpenid;
|
||||
|
||||
@ApiModelProperty("删除标记,1:已删除,0:正常")
|
||||
private Short delFlag;
|
||||
|
||||
@ApiModelProperty("逻辑删除辅助字段")
|
||||
private Short delKey;
|
||||
|
||||
@ApiModelProperty("备注")
|
||||
private String remark;
|
||||
|
||||
@ApiModelProperty("创建时间")
|
||||
private Date createTime;
|
||||
|
||||
@ApiModelProperty("更新时间")
|
||||
private Date updateTime;
|
||||
|
||||
@ApiModelProperty("最近一次密码更新的时间")
|
||||
private Date pwdLastUpdatedTime;
|
||||
|
||||
@ApiModelProperty("普通钉钉userid")
|
||||
private String dingTalkUid;
|
||||
|
||||
@ApiModelProperty("微信unionId")
|
||||
private String wxUnionid;
|
||||
|
||||
@ApiModelProperty("微信小程序openID")
|
||||
private String wxMaOpenid;
|
||||
|
||||
@ApiModelProperty("三方同步来的用户唯一id")
|
||||
private String syncId;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package com.codvision.auth.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 系统用户角色
|
||||
* </p>
|
||||
*
|
||||
* @author lingee
|
||||
* @since 2023-11-09
|
||||
*/
|
||||
@Data
|
||||
@TableName("tbl_org_user_mapper")
|
||||
@ApiModel(value = "UserOrgRole", description = "系统用户角色")
|
||||
public class UserOrgRole implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty("用户UID")
|
||||
private Integer uid;
|
||||
|
||||
@ApiModelProperty("组织OID")
|
||||
private Integer oid;
|
||||
|
||||
@ApiModelProperty("角色ID")
|
||||
private Integer roleId;
|
||||
|
||||
@ApiModelProperty("是否开启")
|
||||
private Short flagEnabled;
|
||||
|
||||
@ApiModelProperty("排序字段")
|
||||
private Integer orderby;
|
||||
|
||||
@ApiModelProperty("角色编码")
|
||||
@TableField(exist = false)
|
||||
private String roleCode;
|
||||
|
||||
@ApiModelProperty("更新时间")
|
||||
private Date updateTime;
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.codvision.auth.entity.ding;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* @author zjm
|
||||
* @version V1.0
|
||||
* @Package com.codvision.serverboot.bean.ding
|
||||
* @date 2020/3/4 9:57
|
||||
* @Copyright © 2017-2020 杭州码全科技有限公司
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class DingConfig {
|
||||
public String url;
|
||||
public String jsticket;
|
||||
public String signature;
|
||||
public String nonceStr;
|
||||
public long timeStamp;
|
||||
public String corpId;
|
||||
public String appkey;
|
||||
public String agentId;
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.codvision.auth.entity.ding;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class DingEnv {
|
||||
private String dingAppKey;
|
||||
private String dingAppSecret;
|
||||
private String dingAgentId;
|
||||
private String dingCorpId;
|
||||
private String govDingAppKey;
|
||||
private String govDingAppSecret;
|
||||
private String govDingAgentId;
|
||||
private String govDingTelnetId;
|
||||
private String govDingCorpId;
|
||||
private String govDingApiUrlPrefix;
|
||||
private String govDingScanAppKey;
|
||||
private String govDingScanAppSecret;
|
||||
private String govDingScanRedirectUrl;
|
||||
private String govDingScanDomainUrl;
|
||||
private String govDingScanAppFlag;
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
package com.codvision.auth.entity.ding.gov;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.codvision.auth.entity.SysUser;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.*;
|
||||
|
||||
@Data
|
||||
@ToString
|
||||
@Builder
|
||||
@TableName("tbl_gov_ding_employee")
|
||||
@ApiModel(description = "tbl_gov_ding_employee--对表的描述")
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class GovDingEmployee {
|
||||
@ApiModelProperty("创建人")
|
||||
private String gmtCreate;
|
||||
|
||||
@ApiModelProperty("人员账号ID")
|
||||
private String employeeAccountId;
|
||||
|
||||
@ApiModelProperty("人员手机号")
|
||||
private String employeeMobile;
|
||||
|
||||
@ApiModelProperty("")
|
||||
private String gmtLoad;
|
||||
|
||||
@ApiModelProperty("人员任职信息")
|
||||
private String govEmployeePositions;
|
||||
|
||||
@ApiModelProperty("人员姓名")
|
||||
private String employeeName;
|
||||
|
||||
@ApiModelProperty("人员性别 Code")
|
||||
private String empGender;
|
||||
|
||||
@ApiModelProperty("头像")
|
||||
private String govEmpAvatar;
|
||||
|
||||
@ApiModelProperty("人员Code")
|
||||
@TableId(type = IdType.INPUT)
|
||||
private String employeeCode;
|
||||
|
||||
@ApiModelProperty("人员状态(A为有效,F为无效)")
|
||||
private String status;
|
||||
|
||||
@ApiModelProperty("部门code")
|
||||
private String organizationCode;
|
||||
|
||||
@ApiModelProperty("数据同步类型:专有钉钉,门户")
|
||||
private Integer syncType;
|
||||
|
||||
@ApiModelProperty("删除标记,1:已删除,0:正常")
|
||||
private Integer delFlag;
|
||||
|
||||
@ApiModelProperty("登陆名")
|
||||
private String loginName;
|
||||
|
||||
|
||||
@TableField(exist = false)
|
||||
private SysUser zzdBindUser;
|
||||
|
||||
@TableField(exist = false)
|
||||
private SysUser syncBindUser;
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
package com.codvision.auth.entity.ding.gov;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.codvision.auth.entity.Org;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@ToString
|
||||
@Builder
|
||||
@TableName("tbl_gov_ding_org")
|
||||
@ApiModel(description = "tbl_gov_ding_org--对表的描述")
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class GovDingOrg {
|
||||
|
||||
@ApiModelProperty("父组织名称")
|
||||
private String parentName;
|
||||
|
||||
@ApiModelProperty("创建时间")
|
||||
private String gmtCreate;
|
||||
|
||||
@ApiModelProperty("组织类型名称")
|
||||
private String typeName;
|
||||
|
||||
@ApiModelProperty("排序码")
|
||||
private Integer displayOrder;
|
||||
|
||||
@ApiModelProperty("")
|
||||
private String gmtLoad;
|
||||
|
||||
@ApiModelProperty("组织code的path")
|
||||
private String organizationCodePath;
|
||||
|
||||
@ApiModelProperty("显示名称")
|
||||
private String organizationName;
|
||||
|
||||
@ApiModelProperty("组织code")
|
||||
@TableId(type = IdType.INPUT)
|
||||
private String organizationCode;
|
||||
|
||||
@ApiModelProperty("排序level")
|
||||
private Integer displayLevel;
|
||||
|
||||
@ApiModelProperty("父组织Code")
|
||||
private String parentCode;
|
||||
|
||||
@ApiModelProperty("行政区划code")
|
||||
private String divisionCode;
|
||||
|
||||
@ApiModelProperty("组织状态")
|
||||
private String status;
|
||||
|
||||
@ApiModelProperty("组织类型Code")
|
||||
private String typeCode;
|
||||
|
||||
@ApiModelProperty("数据同步类型:专有钉钉,门户")
|
||||
private Integer syncType;
|
||||
|
||||
|
||||
@ApiModelProperty("删除标记,1:已删除,0:正常")
|
||||
private Integer delFlag;
|
||||
|
||||
@TableField(exist = false)
|
||||
private Org sysOrg;
|
||||
|
||||
@TableField(exist = false)
|
||||
private List<GovDingOrg> children = new ArrayList<>();
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.codvision.auth.entity.ding.gov;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author hxl
|
||||
*/
|
||||
@Data
|
||||
@ApiModel
|
||||
public class GovUserInfo {
|
||||
|
||||
@ApiModelProperty("账号id")
|
||||
private Long accountId;
|
||||
@ApiModelProperty("姓名")
|
||||
private String lastName;
|
||||
@ApiModelProperty("应用标识")
|
||||
private String clientId;
|
||||
@ApiModelProperty("账号类型标识")
|
||||
private String namespace;
|
||||
@ApiModelProperty("昵称")
|
||||
private String nickNameCn;
|
||||
@ApiModelProperty("员工在当前企业内的唯一标识(租户+用户唯一标识)")
|
||||
private String tenantUserId;
|
||||
@ApiModelProperty("登录账号")
|
||||
private String account;
|
||||
@ApiModelProperty("人员code")
|
||||
private String employeeCode;
|
||||
@ApiModelProperty("租户ID")
|
||||
private Long realmId;
|
||||
@ApiModelProperty("租户名称")
|
||||
private String realmName;
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.codvision.auth.entity.ding.gov.msg;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* @author hxl
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
public class DingLinkMsg {
|
||||
|
||||
private String msgtype = "link";
|
||||
private LinkMsg link;
|
||||
public DingLinkMsg(LinkMsg link) {
|
||||
this.link = link;
|
||||
}
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public static class LinkMsg {
|
||||
// 消息点击链接地址,当发送消息为小程序时支持小程序跳转链接
|
||||
private String messageUrl;
|
||||
// 图片地址
|
||||
private String picUrl;
|
||||
// 消息标题
|
||||
private String title;
|
||||
// 消息描述
|
||||
private String text;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.codvision.auth.entity.ding.gov.msg;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* @author hxl
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
public class DingMarkDownMsg {
|
||||
|
||||
private String msgtype = "markdown";
|
||||
private MarkDownMsg markdown;
|
||||
|
||||
public DingMarkDownMsg(MarkDownMsg markdown) {
|
||||
this.markdown = markdown;
|
||||
}
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public static class MarkDownMsg {
|
||||
// 标题
|
||||
private String title;
|
||||
// markdown的文本
|
||||
private String text;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.codvision.auth.entity.ding.gov.msg;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* @author hxl
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
public class DingTextMsg {
|
||||
|
||||
private String msgtype = "text";
|
||||
private TextMsg text;
|
||||
|
||||
public DingTextMsg(TextMsg text) {
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public static class TextMsg {
|
||||
// 消息内容
|
||||
private String content;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Copyright (c) 2023 codvision.com All Rights Reserved.
|
||||
*/
|
||||
|
||||
package com.codvision.auth.entity.dto;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 系统菜单查询条件
|
||||
*
|
||||
* @author lingee
|
||||
* @date 2023/11/15
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@ApiModel(value = "SysUserQueryDTO", description = "系统用户查询条件")
|
||||
public class SysMenuQueryDTO implements Serializable {
|
||||
private static final long serialVersionUID = -691547145814273825L;
|
||||
|
||||
@ApiModelProperty("菜单名称")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty("菜单类型")
|
||||
private Integer type;
|
||||
|
||||
@ApiModelProperty("是否api")
|
||||
private Boolean ignoreApi;
|
||||
|
||||
@ApiModelProperty("菜单路径")
|
||||
private String pathName;
|
||||
|
||||
@ApiModelProperty("菜单类型(多个逗号隔开)")
|
||||
private String category;
|
||||
|
||||
@ApiModelProperty("用户id")
|
||||
private Integer uid;
|
||||
|
||||
public SysMenuQueryDTO(String name,
|
||||
Integer type,
|
||||
Boolean ignoreApi,
|
||||
String pathName,
|
||||
String category) {
|
||||
this.name = name;
|
||||
this.type = type;
|
||||
this.ignoreApi = ignoreApi;
|
||||
this.pathName = pathName;
|
||||
this.category = category;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Copyright (c) 2023 codvision.com All Rights Reserved.
|
||||
*/
|
||||
|
||||
package com.codvision.auth.entity.dto;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 系统组织查询条件
|
||||
*
|
||||
* @author lingee
|
||||
* @date 2023/11/15
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@ApiModel(value = "SysOrgQueryDTO", description = "系统组织查询条件")
|
||||
public class SysOrgQueryDTO implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -7134981238879392528L;
|
||||
|
||||
@ApiModelProperty("路径")
|
||||
private String root;
|
||||
|
||||
@ApiModelProperty("类型")
|
||||
private String type;
|
||||
|
||||
@ApiModelProperty("关键字")
|
||||
private String keyword;
|
||||
|
||||
@ApiModelProperty("组织属性id")
|
||||
private Integer orgPropertyId;
|
||||
|
||||
@ApiModelProperty("最大level")
|
||||
private Integer maxLevel;
|
||||
|
||||
@ApiModelProperty("是否忽略wkt")
|
||||
private Boolean isIgnoreWkt;
|
||||
|
||||
@ApiModelProperty("是否查询子组织")
|
||||
private Boolean subQuery;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.codvision.auth.entity.dto;
|
||||
|
||||
import com.codvision.auth.entity.SysUser;
|
||||
import com.codvision.auth.entity.UserOrgRole;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author hxl
|
||||
*/
|
||||
@Data
|
||||
@ApiModel
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class SysUserDTO extends SysUser {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty("原密码")
|
||||
private String oldPwd;
|
||||
|
||||
@ApiModelProperty("新密码")
|
||||
private String newPwd;
|
||||
|
||||
@ApiModelProperty("用户组织角色列表")
|
||||
private List<UserOrgRole> userOrgRoles;
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
* Copyright (c) 2023 codvision.com All Rights Reserved.
|
||||
*/
|
||||
|
||||
package com.codvision.auth.entity.dto;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 系统用户查询条件
|
||||
*
|
||||
* @author lingee
|
||||
* @date 2023/11/14
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@ApiModel(value = "SysUserQueryDTO", description = "系统用户查询条件")
|
||||
public class SysUserQueryDTO implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -4164799777443833642L;
|
||||
|
||||
@ApiModelProperty("关键字")
|
||||
private String keyword;
|
||||
|
||||
@ApiModelProperty("组织id")
|
||||
private Integer oid;
|
||||
|
||||
@ApiModelProperty("角色id")
|
||||
private Integer roleId;
|
||||
|
||||
@ApiModelProperty("是否绑定zzdId:0否,1是")
|
||||
private Integer flagBindZzd;
|
||||
|
||||
@ApiModelProperty("应用code")
|
||||
private String appCode;
|
||||
|
||||
@ApiModelProperty("是否禁用flagForbidden:0否,1是")
|
||||
private Integer flagForbidden;
|
||||
|
||||
@ApiModelProperty("用户id列表")
|
||||
private List<Integer> uidList;
|
||||
|
||||
public SysUserQueryDTO(String keyword,
|
||||
Integer oid,
|
||||
Integer roleId,
|
||||
Integer flagBindZzd,
|
||||
String appCode,
|
||||
Integer flagForbidden) {
|
||||
this.keyword = keyword;
|
||||
this.oid = oid;
|
||||
this.roleId = roleId;
|
||||
this.flagBindZzd = flagBindZzd;
|
||||
this.appCode = appCode;
|
||||
this.flagForbidden = flagForbidden;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package com.codvision.auth.entity.excel;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import com.alibaba.excel.annotation.write.style.ColumnWidth;
|
||||
import com.alibaba.excel.annotation.write.style.ContentRowHeight;
|
||||
import com.codvision.auth.support.excel.PropertyDynamicSelect;
|
||||
import com.codvision.base.annotation.ExcelSelected;
|
||||
import com.codvision.base.entity.ExcelErrorRecord;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* @author hxl
|
||||
*/
|
||||
@Data
|
||||
@ColumnWidth(30)
|
||||
@ContentRowHeight(16)
|
||||
@ExcelIgnoreUnannotated
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class OrgExcel extends ExcelErrorRecord {
|
||||
|
||||
@ExcelProperty(value = "组织名称")
|
||||
private String name;
|
||||
|
||||
@ExcelProperty(value = "父级组织路径")
|
||||
private String parentOrgName;
|
||||
|
||||
@ExcelProperty(value = "属性")
|
||||
@ExcelSelected(sourceClass = PropertyDynamicSelect.class)
|
||||
@ApiModelProperty(value = "属性名称")
|
||||
private String orgPropertyName;
|
||||
|
||||
@ExcelSelected(source = {"行政区划", "部门"})
|
||||
@ExcelProperty(value = "组织类型")
|
||||
@ApiModelProperty("组织类型")
|
||||
private String type;
|
||||
|
||||
@ExcelProperty(value = "行政区划编码")
|
||||
@ApiModelProperty("行政区划编码")
|
||||
private String districtCode;
|
||||
}
|
||||
@@ -0,0 +1,127 @@
|
||||
package com.codvision.auth.entity.excel;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import com.alibaba.excel.annotation.write.style.ColumnWidth;
|
||||
import com.alibaba.excel.annotation.write.style.ContentRowHeight;
|
||||
import com.codvision.auth.support.excel.EducationDynamicSelect;
|
||||
import com.codvision.auth.support.excel.NationDynamicSelect;
|
||||
import com.codvision.auth.support.excel.NationalityDynamicSelect;
|
||||
import com.codvision.base.annotation.ExcelSelected;
|
||||
import com.codvision.base.entity.ExcelErrorRecord;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* @author KX
|
||||
* @date 2023/5/17 10:33
|
||||
*/
|
||||
@Data
|
||||
@ColumnWidth(30)
|
||||
@ContentRowHeight(16)
|
||||
@ExcelIgnoreUnannotated
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class PersonExcel extends ExcelErrorRecord {
|
||||
|
||||
@ExcelProperty("姓名")
|
||||
@ApiModelProperty("姓名")
|
||||
private String name;
|
||||
|
||||
@ExcelProperty("曾用名")
|
||||
@ApiModelProperty("曾用名")
|
||||
private String usedName;
|
||||
|
||||
@ExcelProperty("所属组织")
|
||||
@ApiModelProperty("所属组织")
|
||||
private String orgPath;
|
||||
|
||||
@ExcelSelected(source = {"未知的性别", "男性", "女性", "未说明的性别"})
|
||||
@ExcelProperty("性别")
|
||||
@ApiModelProperty("性别-字典(PERSON_SEX)")
|
||||
private String sex;
|
||||
|
||||
@ExcelProperty("年龄")
|
||||
@ApiModelProperty("年龄")
|
||||
private String age;
|
||||
|
||||
@ExcelProperty("联系电话")
|
||||
@ApiModelProperty("联系电话")
|
||||
private String phone;
|
||||
|
||||
@ExcelSelected(source = {"身份证", "居住证", "签证", "护照", "军人证", "港澳通行证"})
|
||||
@ExcelProperty("证件类型")
|
||||
@ApiModelProperty("证件类型-字典(ID_TYPE)")
|
||||
private String idType;
|
||||
|
||||
@ExcelProperty("证件号码")
|
||||
@ApiModelProperty("证件号码")
|
||||
private String idCard;
|
||||
|
||||
@ExcelSelected(source = {"户籍人口", "流动人口", "境外人口", "其他人口"})
|
||||
@ExcelProperty("人口类型")
|
||||
@ApiModelProperty("人口类型-字典(PERSON_TYPE)")
|
||||
private String personType;
|
||||
|
||||
|
||||
@ExcelSelected(sourceClass = NationDynamicSelect.class)
|
||||
@ExcelProperty("民族")
|
||||
@ApiModelProperty("民族-字典(NATION)")
|
||||
private String nation;
|
||||
|
||||
@ExcelSelected(sourceClass = EducationDynamicSelect.class)
|
||||
@ExcelProperty("文化程度")
|
||||
@ApiModelProperty("文化程度-字典(EDUCATION)")
|
||||
private String education;
|
||||
|
||||
@ExcelSelected(source = {"社区矫正人员", "吸毒人员", "严重精神障碍患者", "刑释人员", "重点关爱青少年人员", "残疾人员", "60岁以上老人", "救助对象"})
|
||||
@ExcelProperty("人员标签")
|
||||
@ApiModelProperty("人员标签(,逗号隔开)")
|
||||
private String personTags;
|
||||
|
||||
@ExcelProperty("籍贯")
|
||||
@ApiModelProperty("籍贯")
|
||||
private String nativePlace;
|
||||
|
||||
@ExcelSelected(sourceClass = NationalityDynamicSelect.class)
|
||||
@ExcelProperty("国籍")
|
||||
@ApiModelProperty("国籍-字典(NATIONALITY)")
|
||||
private String nationality;
|
||||
|
||||
@ExcelProperty("出生日期")
|
||||
@ApiModelProperty("出生日期")
|
||||
private String birthday;
|
||||
|
||||
@ExcelSelected(source = {"未婚", "已婚", "初婚", "再婚", "复婚", "丧偶", "离婚", "未说明的婚姻状况"})
|
||||
@ExcelProperty("婚姻状况")
|
||||
@ApiModelProperty("婚姻状况-字典(MARITAL_STATUS)")
|
||||
private String maritalStatus;
|
||||
|
||||
@ExcelSelected(source = {"中共党员", "中共预备党员", "共青团员", "民主党派", "群众", "其他"})
|
||||
@ExcelProperty("政治面貌")
|
||||
@ApiModelProperty("政治面貌-字典(POLITIC_FACE)")
|
||||
private String politicFace;
|
||||
|
||||
@ExcelSelected(source = {"未服兵役", "退出现役", "士兵预备役", "军官预备役", "服现役", "其他"})
|
||||
@ExcelProperty("兵役状况")
|
||||
@ApiModelProperty("兵役状况-字典(MILITARY_STATUS)")
|
||||
private String militaryStatus;
|
||||
|
||||
@ExcelSelected(source = {"无宗教信仰", "佛教", "喇嘛教", "道教", "天主教", "基督教", "东正教", "伊斯兰教", "其他"})
|
||||
@ExcelProperty("宗教信仰")
|
||||
@ApiModelProperty("宗教信仰-字典(RELIGIOUS)")
|
||||
private String religious;
|
||||
|
||||
@ExcelProperty("现住地详址")
|
||||
@ApiModelProperty("现住地详址")
|
||||
private String inhabitedAddress;
|
||||
|
||||
@ExcelProperty("户籍地详址")
|
||||
@ApiModelProperty("户籍地详址")
|
||||
private String residenceAddress;
|
||||
|
||||
@ExcelProperty("备注")
|
||||
@ApiModelProperty("备注")
|
||||
private String remark;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.codvision.auth.entity.excel;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import com.alibaba.excel.annotation.write.style.ColumnWidth;
|
||||
import com.alibaba.excel.annotation.write.style.ContentRowHeight;
|
||||
import com.codvision.base.entity.ExcelErrorRecord;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* @author hxl
|
||||
*/
|
||||
@Data
|
||||
@ColumnWidth(30)
|
||||
@ContentRowHeight(16)
|
||||
@ExcelIgnoreUnannotated
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class SysUserExcel extends ExcelErrorRecord {
|
||||
|
||||
private static final long serialVersionUID = -7737887016652071246L;
|
||||
|
||||
@ExcelProperty("姓名")
|
||||
private String name;
|
||||
|
||||
@ExcelProperty("联系方式")
|
||||
private String mobile;
|
||||
|
||||
@ExcelProperty("所属组织")
|
||||
private String orgName;
|
||||
|
||||
@ExcelProperty("所属角色")
|
||||
private String role;
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.codvision.auth.entity.vo;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author hxl
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
public class CustomCaptchaVO {
|
||||
|
||||
/**
|
||||
* 验证码图片 base64
|
||||
*/
|
||||
private String picBase64;
|
||||
/**
|
||||
* 验证码请求号
|
||||
*/
|
||||
private String reqNo;
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package com.codvision.auth.entity.vo;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.codvision.auth.entity.SysUser;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.*;
|
||||
|
||||
|
||||
/**
|
||||
* @Author huxb
|
||||
* @description:
|
||||
* @create 2023/3/23 14:17
|
||||
*/
|
||||
@Data
|
||||
@ToString
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class GovDingEmployeeVo {
|
||||
@ApiModelProperty("创建人")
|
||||
private String gmtCreate;
|
||||
|
||||
@ApiModelProperty("人员账号ID")
|
||||
private String employeeAccountId;
|
||||
|
||||
@ApiModelProperty("人员手机号")
|
||||
private String employeeMobile;
|
||||
|
||||
@ApiModelProperty("")
|
||||
private String gmtLoad;
|
||||
|
||||
@ApiModelProperty("人员任职信息")
|
||||
private String govEmployeePositions;
|
||||
|
||||
@ApiModelProperty("人员姓名")
|
||||
private String employeeName;
|
||||
|
||||
@ApiModelProperty("人员性别 Code")
|
||||
private String empGender;
|
||||
|
||||
@ApiModelProperty("头像")
|
||||
private String govEmpAvatar;
|
||||
|
||||
@ApiModelProperty("人员Code")
|
||||
@TableId(type = IdType.INPUT)
|
||||
private String employeeCode;
|
||||
|
||||
@ApiModelProperty("人员状态(A为有效,F为无效)")
|
||||
private String status;
|
||||
|
||||
@ApiModelProperty("部门code")
|
||||
private String organizationCode;
|
||||
|
||||
private SysUser sysUser;
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.codvision.auth.entity.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author hxl
|
||||
*/
|
||||
@Data
|
||||
public class GovResponseVO {
|
||||
private Boolean success;
|
||||
private Object data;
|
||||
private String bizErrorCode;
|
||||
private String responseCode;
|
||||
private String responseMessage;
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
package com.codvision.auth.entity.vo;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 组织属性表展示信息
|
||||
* </p>
|
||||
*
|
||||
* @author lingee
|
||||
* @since 2023-11-10
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@ApiModel(value = "OrgPropertyVO", description = "组织属性表展示信息")
|
||||
public class OrgPropertyVO implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty("主键id")
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Integer id;
|
||||
|
||||
@ApiModelProperty("上级id")
|
||||
private Integer pid;
|
||||
|
||||
@ApiModelProperty("属性名称")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty("图标")
|
||||
private String icon;
|
||||
|
||||
@ApiModelProperty("删除标记,1:已删除,0:正常")
|
||||
private Short delFlag;
|
||||
|
||||
@ApiModelProperty("辅助删除key")
|
||||
private Integer delKey;
|
||||
|
||||
@ApiModelProperty("创建时间")
|
||||
private Date createTime;
|
||||
|
||||
@ApiModelProperty("更新时间")
|
||||
private Date updateTime;
|
||||
|
||||
@ApiModelProperty("编码长度")
|
||||
private Integer codeLength;
|
||||
|
||||
@ApiModelProperty("层级")
|
||||
private Integer level;
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.codvision.auth.entity.vo;
|
||||
|
||||
import com.codvision.auth.entity.Org;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 组织信息展示信息
|
||||
* </p>
|
||||
*
|
||||
* @author lingee
|
||||
* @since 2023-11-10
|
||||
*/
|
||||
@Data
|
||||
@ApiModel(value = "OrgVO", description = "组织信息展示信息")
|
||||
public class OrgVO extends Org {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty(value = "属性名称")
|
||||
private String orgPropertyName;
|
||||
|
||||
@ApiModelProperty(value = "属性图标")
|
||||
private String orgPropertyIcon;
|
||||
|
||||
@ApiModelProperty(value = "行政区划编码长度")
|
||||
private Integer codeLength;
|
||||
|
||||
@ApiModelProperty(value = "子组织树")
|
||||
private List<OrgVO> children = new ArrayList<>();
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.codvision.auth.entity.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author hxl
|
||||
*/
|
||||
@Data
|
||||
public class QuickLoginVO {
|
||||
|
||||
private String resultCode;
|
||||
private String desc;
|
||||
private String serviceTime;
|
||||
private BodyContent data;
|
||||
|
||||
@Data
|
||||
public static class BodyContent {
|
||||
private String msisdn;
|
||||
private String securityPhone;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.codvision.auth.entity.vo;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.codvision.webcore.bean.BasicEntity;
|
||||
import java.io.Serializable;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 系统应用展示信息
|
||||
* </p>
|
||||
*
|
||||
* @author lingee
|
||||
* @since 2024-04-29
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@ApiModel(value = "SysAppVO", description = "系统应用展示信息")
|
||||
public class SysAppVO extends BasicEntity {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty("应用名称")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty("基础地址")
|
||||
private String entry;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
package com.codvision.auth.entity.vo;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
import com.codvision.auth.entity.SysApp;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 系统菜单展示信息
|
||||
* </p>
|
||||
*
|
||||
* @author lingee
|
||||
* @since 2023-11-09
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@ApiModel(value = "SysMenuVO", description = "系统菜单展示信息")
|
||||
public class SysMenuVO implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty("ID")
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Integer id;
|
||||
|
||||
@ApiModelProperty("菜单名称")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty("菜单父id")
|
||||
private Integer pid;
|
||||
|
||||
@ApiModelProperty("菜单权限标识")
|
||||
private String permission;
|
||||
|
||||
@ApiModelProperty("前端路由标识路径")
|
||||
private String url;
|
||||
|
||||
@ApiModelProperty("类型")
|
||||
private Short type;
|
||||
|
||||
@ApiModelProperty("排序值")
|
||||
private Short sortOrder;
|
||||
|
||||
@ApiModelProperty("创建时间")
|
||||
private Date createTime;
|
||||
|
||||
@ApiModelProperty("更新时间")
|
||||
private Date updateTime;
|
||||
|
||||
@ApiModelProperty("删除标记,1:已删除,0:正常")
|
||||
private Short delFlag;
|
||||
|
||||
@ApiModelProperty("逻辑删除辅助字段")
|
||||
private Integer delKey;
|
||||
|
||||
@ApiModelProperty("菜单图标")
|
||||
private String icon;
|
||||
|
||||
@ApiModelProperty("是否隐藏")
|
||||
private Boolean isHidden;
|
||||
|
||||
@ApiModelProperty("组件地址")
|
||||
private String component;
|
||||
|
||||
@ApiModelProperty("布局是否可见")
|
||||
private Boolean layout;
|
||||
|
||||
@ApiModelProperty("跳转地址")
|
||||
private String redirect;
|
||||
|
||||
@ApiModelProperty("目标地址")
|
||||
private String target;
|
||||
|
||||
@ApiModelProperty("所属分类")
|
||||
private String category;
|
||||
|
||||
@ApiModelProperty("是否默认")
|
||||
private Boolean isDefault;
|
||||
|
||||
@ApiModelProperty("菜单路径")
|
||||
private String pathName;
|
||||
|
||||
@ApiModelProperty("是否可见")
|
||||
private Boolean enabled;
|
||||
|
||||
@ApiModelProperty("应用id")
|
||||
private Integer appId;
|
||||
|
||||
@ApiModelProperty("系统应用")
|
||||
private SysAppVO sysApp;
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright (c) 2023 codvision.com All Rights Reserved.
|
||||
*/
|
||||
|
||||
package com.codvision.auth.entity.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 系统角色菜单权限展示信息
|
||||
* </p>
|
||||
*
|
||||
* @author lingee
|
||||
* @since 2023-11-09
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@ApiModel(value = "SysRoleMenuVO", description = "系统角色菜单权限展示信息")
|
||||
public class SysRoleMenuVO implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty("角色id")
|
||||
private Integer roleId;
|
||||
|
||||
@ApiModelProperty("菜单id")
|
||||
private Integer menuId;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright (c) 2023 codvision.com All Rights Reserved.
|
||||
*/
|
||||
|
||||
package com.codvision.auth.entity.vo;
|
||||
|
||||
import com.codvision.auth.entity.SysMenu;
|
||||
import com.codvision.auth.entity.SysRole;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 系统角色展示信息
|
||||
* </p>
|
||||
*
|
||||
* @author lingee
|
||||
* @since 2023-11-09
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@ApiModel(value = "SysRoleVO", description = "系统角色展示信息")
|
||||
public class SysRoleVO extends SysRole {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty("角色的菜单")
|
||||
private List<SysMenuVO> roleMenus;
|
||||
|
||||
@ApiModelProperty("角色的子角色")
|
||||
private List<SysRoleVO> child = new ArrayList<>();
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* Copyright (c) 2023 codvision.com All Rights Reserved.
|
||||
*/
|
||||
|
||||
package com.codvision.auth.entity.vo;
|
||||
|
||||
import com.codvision.auth.entity.SysUser;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 系统用户展示信息
|
||||
* </p>
|
||||
*
|
||||
* @author lingee
|
||||
* @since 2023-11-09
|
||||
*/
|
||||
@Data
|
||||
@ApiModel(value = "SysUserVO", description = "系统用户展示信息")
|
||||
public class SysUserVO extends SysUser {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private String token;
|
||||
|
||||
@ApiModelProperty("当前组织OID")
|
||||
private Integer activeOid;
|
||||
|
||||
@ApiModelProperty("当前组织父级OID")
|
||||
private Integer activePoid;
|
||||
|
||||
@ApiModelProperty("当前组织名称")
|
||||
private String activeOrgName;
|
||||
|
||||
@ApiModelProperty("当前组织路径")
|
||||
private String activeOrgPath;
|
||||
|
||||
@ApiModelProperty("当前角色ID")
|
||||
private Integer activeRoleId;
|
||||
|
||||
@ApiModelProperty("当前角色名称")
|
||||
private String activeRoleName;
|
||||
|
||||
@ApiModelProperty("当前角色编码")
|
||||
private String activeRoleCode;
|
||||
|
||||
@ApiModelProperty("关联信息(组织与角色)")
|
||||
private List<UserAssociatedInfoVO> associatedInfos;
|
||||
|
||||
@ApiModelProperty("是否已禁用")
|
||||
private Boolean isForbidden;
|
||||
|
||||
@ApiModelProperty(value = "状态:0未读,1已读")
|
||||
private Integer readStatus;
|
||||
|
||||
@ApiModelProperty(value = "通知消息是否撤回:0否,1是")
|
||||
private Integer flagDel;
|
||||
|
||||
@ApiModelProperty("组织角色")
|
||||
private UserOrgRoleVO activeOrgRole;
|
||||
|
||||
@ApiModelProperty("组织角色列表")
|
||||
private List<UserOrgRoleVO> orgRoles;
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright (c) 2023 codvision.com All Rights Reserved.
|
||||
*/
|
||||
|
||||
package com.codvision.auth.entity.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 系统角色展示信息
|
||||
* </p>
|
||||
*
|
||||
* @author lingee
|
||||
* @since 2023-11-09
|
||||
*/
|
||||
@Data
|
||||
public class UserAssociatedInfoVO {
|
||||
|
||||
private Integer oid;
|
||||
|
||||
private String orgName;
|
||||
private String orgPath;
|
||||
private Integer orgLevel;
|
||||
|
||||
private Integer roleId;
|
||||
private String roleName;
|
||||
private Integer roleLevel;
|
||||
private String roleCode;
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright (c) 2023 codvision.com All Rights Reserved.
|
||||
*/
|
||||
|
||||
package com.codvision.auth.entity.vo;
|
||||
|
||||
import com.codvision.auth.entity.Org;
|
||||
import com.codvision.auth.entity.UserOrgRole;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 组织用户关联信息展示信息
|
||||
* </p>
|
||||
*
|
||||
* @author lingee
|
||||
* @since 2023-11-10
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ApiModel(value = "UserOrgRoleVO", description = "组织用户关联信息展示信息")
|
||||
public class UserOrgRoleVO extends UserOrgRole {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty("组织信息")
|
||||
private Org org;
|
||||
|
||||
@ApiModelProperty("角色信息")
|
||||
private SysRoleVO role;
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.codvision.auth.enums;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* @author hxl
|
||||
*/
|
||||
@Getter
|
||||
public enum CaptchaEnum {
|
||||
CLOSED, SIMPLE, BLOCK_PUZZLE
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.codvision.auth.enums;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 登陆类型
|
||||
* @author hxl
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum LoginTypeEnum {
|
||||
|
||||
AUTO_LOGIN(0, "免登"),
|
||||
SCAN_LOGIN(1,"扫码登陆");
|
||||
|
||||
private Integer code;
|
||||
private String msg;
|
||||
|
||||
|
||||
public static boolean isExist(Integer code) {
|
||||
for (LoginTypeEnum loginTypeEnum : LoginTypeEnum.values()) {
|
||||
if (loginTypeEnum.getCode().equals(code)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Copyright (c) 2023 codvision.com All Rights Reserved.
|
||||
*/
|
||||
|
||||
package com.codvision.auth.enums;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 菜单类型
|
||||
*
|
||||
* @author lingee
|
||||
* @date 2023/11/15
|
||||
*/
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
public enum MenuCategory {
|
||||
|
||||
API("4");
|
||||
|
||||
private final String category;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
/*
|
||||
* Copyright (c) 2023 codvision.com All Rights Reserved.
|
||||
*/
|
||||
|
||||
package com.codvision.auth.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.codvision.auth.entity.ding.gov.GovDingEmployee;
|
||||
|
||||
/**
|
||||
* 专有钉钉人员数据层
|
||||
*
|
||||
* @author lingee
|
||||
* @date 2023/11/29
|
||||
*/
|
||||
public interface GovDingEmployeeMapper extends BaseMapper<GovDingEmployee> {
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
package com.codvision.auth.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.codvision.auth.entity.Org;
|
||||
import com.codvision.auth.entity.dto.SysOrgQueryDTO;
|
||||
import com.codvision.auth.entity.vo.OrgVO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 组织信息 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author lingee
|
||||
* @since 2023-11-10
|
||||
*/
|
||||
public interface OrgMapper extends BaseMapper<Org> {
|
||||
|
||||
/**
|
||||
* 根据oid查询组织
|
||||
*
|
||||
* @param oid 组织ID
|
||||
* @return 组织信息
|
||||
*/
|
||||
OrgVO getByOid(@Param("oid") Integer oid);
|
||||
|
||||
/**
|
||||
* 根绝查询条件获取组织分页列表
|
||||
*
|
||||
* @param page 分页条件
|
||||
* @param queryDTO 查询条件
|
||||
* @return 分页结果
|
||||
*/
|
||||
List<OrgVO> findAll(IPage page, @Param("queryDTO") SysOrgQueryDTO queryDTO);
|
||||
|
||||
/**
|
||||
* 根据路径查询组织
|
||||
*
|
||||
* @param name 路径
|
||||
* @return 组织信息
|
||||
*/
|
||||
OrgVO getByNameWithOutPoid(@Param("name") String name);
|
||||
|
||||
/**
|
||||
* 根据组织名称和父级组织poid查询
|
||||
*
|
||||
* @param name 路径
|
||||
* @param poid 父组织id
|
||||
* @return 组织信息l
|
||||
*/
|
||||
OrgVO getByNameAndPoid(@Param("name") String name, @Param("poid") Integer poid);
|
||||
|
||||
/**
|
||||
* 根据组织path查询组织
|
||||
* @param path 组织path
|
||||
* @return Org
|
||||
*/
|
||||
OrgVO getOrgByPath(String path);
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.codvision.auth.mapper;
|
||||
|
||||
import com.codvision.auth.entity.OrgProperty;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 组织属性表 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author lingee
|
||||
* @since 2023-11-10
|
||||
*/
|
||||
public interface OrgPropertyMapper extends BaseMapper<OrgProperty> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.codvision.auth.mapper;
|
||||
|
||||
import com.codvision.auth.entity.SysApp;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 系统应用 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author lingee
|
||||
* @since 2024-04-29
|
||||
*/
|
||||
public interface SysAppMapper extends BaseMapper<SysApp> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.codvision.auth.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.codvision.auth.entity.SysMenu;
|
||||
import com.codvision.auth.entity.dto.SysMenuQueryDTO;
|
||||
import com.codvision.auth.entity.vo.SysMenuVO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 系统菜单 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author lingee
|
||||
* @since 2023-11-09
|
||||
*/
|
||||
public interface SysMenuMapper extends BaseMapper<SysMenu> {
|
||||
|
||||
/**
|
||||
* 查询角色对应的菜单权限
|
||||
*
|
||||
* @param roleId 角色id
|
||||
* @return 菜单权限
|
||||
*/
|
||||
List<SysMenuVO> getMenuList(@Param("roleId") Integer roleId);
|
||||
|
||||
/**
|
||||
* 获取用户菜单权限
|
||||
* @param queryDTO
|
||||
* @return
|
||||
*/
|
||||
List<SysMenuVO> getUserMenuList(@Param("queryDTO") SysMenuQueryDTO queryDTO);
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.codvision.auth.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.codvision.auth.entity.SysRole;
|
||||
import com.codvision.auth.entity.vo.SysRoleVO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 系统角色 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author lingee
|
||||
* @since 2023-11-09
|
||||
*/
|
||||
public interface SysRoleMapper extends BaseMapper<SysRole> {
|
||||
|
||||
/**
|
||||
* 根据角色id获取角色详情
|
||||
*
|
||||
* @param roleId 角色id
|
||||
* @return 角色详情
|
||||
*/
|
||||
SysRoleVO getRoleDetail(@Param("roleId") Integer roleId);
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.codvision.auth.mapper;
|
||||
|
||||
import com.codvision.auth.entity.SysRoleMenu;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 系统角色菜单权限 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author lingee
|
||||
* @since 2023-11-09
|
||||
*/
|
||||
public interface SysRoleMenuMapper extends BaseMapper<SysRoleMenu> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package com.codvision.auth.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.codvision.auth.entity.SysUser;
|
||||
import com.codvision.auth.entity.dto.SysUserQueryDTO;
|
||||
import com.codvision.auth.entity.vo.SysUserVO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 系统用户 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author lingee
|
||||
* @since 2023-11-09
|
||||
*/
|
||||
public interface SysUserMapper extends BaseMapper<SysUser> {
|
||||
|
||||
/**
|
||||
* 根据查询条件分页查询系统用户
|
||||
*
|
||||
* @param queryDTO 查询条件
|
||||
* @return 分页查询结果
|
||||
*/
|
||||
List<SysUserVO> findAll(IPage page, @Param("queryDTO") SysUserQueryDTO queryDTO);
|
||||
|
||||
|
||||
/**
|
||||
* 根据查询条件查询系统用户列表
|
||||
* @param paraMap 查询条件
|
||||
* @return 列表
|
||||
*/
|
||||
List<SysUserVO> listUsers(@Param("query") Map<String, Object> paraMap);
|
||||
|
||||
/**
|
||||
* 判断某个角色是否有用户正在使用
|
||||
*
|
||||
* @param roleId 角色ID
|
||||
* @return 数量
|
||||
*/
|
||||
int checkUserRole(@Param("roleId") Integer roleId);
|
||||
|
||||
|
||||
/**
|
||||
* 判断某个组织是否有用户正在使用
|
||||
*
|
||||
* @param oid 组织OID
|
||||
* @return 数量
|
||||
*/
|
||||
int checkUserOrg(@Param("oid") Integer oid);
|
||||
|
||||
|
||||
/**
|
||||
* 判断某个角色下面的子角色是否有用户正在使用
|
||||
*
|
||||
* @param roleId 角色ID
|
||||
* @return 数量
|
||||
*/
|
||||
int checkUserRoleByPid(@Param("roleId") Integer roleId);
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package com.codvision.auth.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.codvision.auth.entity.UserOrgRole;
|
||||
import com.codvision.auth.entity.vo.UserAssociatedInfoVO;
|
||||
import com.codvision.auth.entity.vo.UserOrgRoleVO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 组织用户关联信息 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author lingee
|
||||
* @since 2023-11-10
|
||||
*/
|
||||
public interface UserOrgRoleMapper extends BaseMapper<UserOrgRole> {
|
||||
|
||||
|
||||
/**
|
||||
* 获取用户最近的组织角色
|
||||
*
|
||||
* @param uid 用户id
|
||||
* @return 组织角色信息
|
||||
*/
|
||||
UserOrgRole getLatestInfo(@Param("uid") Integer uid);
|
||||
|
||||
/**
|
||||
* 获取用户最近的组织角色详情
|
||||
*
|
||||
* @param uid 用户id
|
||||
* @return 组织角色信息
|
||||
*/
|
||||
UserOrgRoleVO getLatestInfoDetail(@Param("uid") Integer uid);
|
||||
|
||||
/**
|
||||
* 获取用户组织角色列表
|
||||
*
|
||||
* @param uid 用户id
|
||||
* @return 组织角色列表
|
||||
*/
|
||||
List<UserOrgRoleVO> getUserOrgRoleList(@Param("uid") Integer uid);
|
||||
|
||||
/**
|
||||
* 获取用户关联信息
|
||||
*
|
||||
* @param uid 用户id
|
||||
* @return 用户关联信息列表
|
||||
*/
|
||||
List<UserAssociatedInfoVO> getAssociatedInfos(@Param("uid") Integer uid);
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
* Copyright (c) 2023 codvision.com All Rights Reserved.
|
||||
*/
|
||||
|
||||
package com.codvision.auth.service;
|
||||
|
||||
import com.codvision.auth.entity.vo.CustomCaptchaVO;
|
||||
|
||||
/**
|
||||
* 验证码业务接口
|
||||
*
|
||||
* @author lingee
|
||||
* @date 2023/11/29
|
||||
*/
|
||||
public interface ICustomCaptchaService {
|
||||
|
||||
/**
|
||||
* 获取图形验证码
|
||||
*
|
||||
* @return 验证码
|
||||
*/
|
||||
CustomCaptchaVO getPicCaptcha();
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Copyright (c) 2023 codvision.com All Rights Reserved.
|
||||
*/
|
||||
|
||||
package com.codvision.auth.service;
|
||||
|
||||
/**
|
||||
* 钉钉用户模块接口
|
||||
*
|
||||
* @author lingee
|
||||
* @since 2024/4/11
|
||||
*/
|
||||
public interface IDingUserService {
|
||||
|
||||
/**
|
||||
* 同步部门
|
||||
*/
|
||||
void syncDepartment();
|
||||
|
||||
/**
|
||||
* 同步用户
|
||||
*/
|
||||
void syncUser(String roleCode);
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
/*
|
||||
* Copyright (c) 2023 codvision.com All Rights Reserved.
|
||||
*/
|
||||
|
||||
package com.codvision.auth.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.codvision.auth.entity.ding.gov.GovDingEmployee;
|
||||
|
||||
/**
|
||||
* 专有钉钉 业务接口
|
||||
*
|
||||
* @author lingee
|
||||
* @date 2023/11/29
|
||||
*/
|
||||
public interface IGovDingEmployeeService extends IService<GovDingEmployee> {
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package com.codvision.auth.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.codvision.auth.entity.OrgProperty;
|
||||
import com.codvision.auth.entity.vo.OrgPropertyVO;
|
||||
import com.codvision.webcore.service.IBaseService;
|
||||
import com.codvision.webcore.bean.QueryPage;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 组织属性表 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author lingee
|
||||
* @since 2023-11-10
|
||||
*/
|
||||
public interface IOrgPropertyService extends IBaseService<OrgProperty, OrgPropertyVO> {
|
||||
|
||||
/**
|
||||
* 获取组织属性表详情
|
||||
*
|
||||
* @param id
|
||||
* @return 组织属性表
|
||||
*/
|
||||
OrgPropertyVO getDetail(Long id);
|
||||
|
||||
/**
|
||||
* 分页查询组织属性表
|
||||
*
|
||||
* @param queryPage 分页参数
|
||||
* @return 分页结果
|
||||
*/
|
||||
IPage<OrgPropertyVO> getPageResult(QueryPage<OrgProperty> queryPage);
|
||||
|
||||
/**
|
||||
* 根据条件查询组织属性表
|
||||
*
|
||||
* @param queryBean 查询条件
|
||||
* @return 组织属性表列表
|
||||
*/
|
||||
List<OrgPropertyVO> listAll(OrgProperty queryBean);
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
package com.codvision.auth.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.codvision.auth.entity.Org;
|
||||
import com.codvision.auth.entity.OrgProperty;
|
||||
import com.codvision.auth.entity.dto.SysOrgQueryDTO;
|
||||
import com.codvision.auth.entity.excel.OrgExcel;
|
||||
import com.codvision.auth.entity.vo.OrgVO;
|
||||
import com.codvision.webcore.bean.QueryPage;
|
||||
import com.codvision.webcore.service.IBaseService;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 组织信息 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author lingee
|
||||
* @since 2023-11-10
|
||||
*/
|
||||
public interface IOrgService extends IBaseService<Org, OrgVO> {
|
||||
|
||||
/**
|
||||
* 获取组织信息详情
|
||||
*
|
||||
* @param oid
|
||||
* @return 组织信息
|
||||
*/
|
||||
OrgVO getDetail(Integer oid);
|
||||
|
||||
/**
|
||||
* 获取默认组织(默认第一个组织)
|
||||
*
|
||||
* @return 组织信息
|
||||
*/
|
||||
Org getDefaultOrg();
|
||||
|
||||
/**
|
||||
* 获取组织信息分页列表
|
||||
*
|
||||
* @param queryPage 分页条件
|
||||
* @param queryDTO 查询条件
|
||||
* @return 分页结果
|
||||
*/
|
||||
IPage<OrgVO> findAll(QueryPage<Org> queryPage, SysOrgQueryDTO queryDTO);
|
||||
|
||||
/**
|
||||
* 添加组织
|
||||
*
|
||||
* @param org 组织信息
|
||||
* @return
|
||||
*/
|
||||
OrgVO addOrg(Org org);
|
||||
|
||||
/**
|
||||
* 更新组织
|
||||
*
|
||||
* @param org 组织信息
|
||||
* @return
|
||||
*/
|
||||
OrgVO updateOrg(Org org);
|
||||
|
||||
/**
|
||||
* 逻辑删除组织
|
||||
*
|
||||
* @param oid 组织id
|
||||
*/
|
||||
void logicDel(Integer oid);
|
||||
|
||||
/**
|
||||
* 获取组织树
|
||||
*
|
||||
* @param root 根id
|
||||
* @return 组织
|
||||
*/
|
||||
OrgVO getTree(Integer root);
|
||||
|
||||
/**
|
||||
* 导入组织数据
|
||||
*
|
||||
* @param file 文件
|
||||
* @return 导入结果
|
||||
*/
|
||||
String excelImport(MultipartFile file);
|
||||
|
||||
/**
|
||||
* excel保存
|
||||
*
|
||||
* @param cachedDataList 缓存数据列表
|
||||
* @param orgList 组织列表
|
||||
* @param orgPropertyList 组织属性列表
|
||||
*/
|
||||
void excelSave(List<OrgExcel> cachedDataList, List<OrgVO> orgList, List<OrgProperty> orgPropertyList);
|
||||
|
||||
void excelExport(SysOrgQueryDTO queryBean);
|
||||
|
||||
/**
|
||||
* 查询所有组织列表
|
||||
*
|
||||
* @param queryDTO 查询条件
|
||||
* @return 组织列表
|
||||
*/
|
||||
List<OrgVO> findAll(SysOrgQueryDTO queryDTO);
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.codvision.auth.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.codvision.auth.entity.SysApp;
|
||||
import com.codvision.auth.entity.vo.SysAppVO;
|
||||
import com.codvision.webcore.service.IBaseService;
|
||||
import com.codvision.webcore.bean.QueryPage;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 系统应用 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author lingee
|
||||
* @since 2024-04-29
|
||||
*/
|
||||
public interface ISysAppService extends IBaseService<SysApp, SysAppVO> {
|
||||
|
||||
/**
|
||||
* 获取系统应用详情
|
||||
*
|
||||
* @param id
|
||||
* @return 系统应用
|
||||
*/
|
||||
SysAppVO getDetail(Serializable id);
|
||||
|
||||
/**
|
||||
* 分页查询系统应用
|
||||
*
|
||||
* @param queryPage 分页参数
|
||||
* @return 分页结果
|
||||
*/
|
||||
IPage<SysAppVO> getPageResult(QueryPage<SysApp> queryPage);
|
||||
|
||||
/**
|
||||
* 根据条件查询系统应用
|
||||
*
|
||||
* @param queryBean 查询条件
|
||||
* @return 系统应用列表
|
||||
*/
|
||||
List<SysAppVO> listAll(SysApp queryBean);
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
package com.codvision.auth.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.codvision.auth.entity.SysMenu;
|
||||
import com.codvision.auth.entity.dto.SysMenuQueryDTO;
|
||||
import com.codvision.auth.entity.vo.SysMenuVO;
|
||||
import com.codvision.webcore.bean.QueryPage;
|
||||
import com.codvision.webcore.service.IBaseService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 系统菜单 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author lingee
|
||||
* @since 2023-11-09
|
||||
*/
|
||||
public interface ISysMenuService extends IBaseService<SysMenu, SysMenuVO> {
|
||||
|
||||
/**
|
||||
* 获取系统菜单详情
|
||||
*
|
||||
* @param id
|
||||
* @return 系统菜单
|
||||
*/
|
||||
SysMenuVO getDetail(Long id);
|
||||
|
||||
/**
|
||||
* 根据条件查询系统菜单
|
||||
*
|
||||
* @param queryBean 查询条件
|
||||
* @return 系统菜单列表
|
||||
*/
|
||||
List<SysMenuVO> listAll(SysMenu queryBean);
|
||||
|
||||
/**
|
||||
* 根据查询条件查询菜单分页列表
|
||||
*
|
||||
* @param queryPage 分页条件
|
||||
* @param queryDTO 查询条件
|
||||
* @return 分页结果
|
||||
*/
|
||||
IPage<SysMenuVO> findAll(QueryPage<SysMenu> queryPage, SysMenuQueryDTO queryDTO);
|
||||
|
||||
/**
|
||||
* 添加系统菜单
|
||||
*
|
||||
* @param sysMenu 系统菜单
|
||||
*/
|
||||
void addSysMenu(SysMenu sysMenu);
|
||||
|
||||
/**
|
||||
* 更新系统菜单
|
||||
*
|
||||
* @param sysMenu 系统菜单
|
||||
*/
|
||||
void updateSysMenu(SysMenu sysMenu);
|
||||
|
||||
/**
|
||||
* 获取用户菜单权限
|
||||
*
|
||||
* @param queryDTO 查询条件
|
||||
* @return 菜单权限
|
||||
*/
|
||||
List<SysMenuVO> getUserMenuList(SysMenuQueryDTO queryDTO);
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package com.codvision.auth.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.codvision.auth.entity.SysRoleMenu;
|
||||
import com.codvision.auth.entity.vo.SysRoleMenuVO;
|
||||
import com.codvision.webcore.service.IBaseService;
|
||||
import com.codvision.webcore.bean.QueryPage;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 系统角色菜单权限 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author lingee
|
||||
* @since 2023-11-09
|
||||
*/
|
||||
public interface ISysRoleMenuService extends IBaseService<SysRoleMenu, SysRoleMenuVO> {
|
||||
|
||||
/**
|
||||
* 获取系统角色菜单权限详情
|
||||
*
|
||||
* @param id
|
||||
* @return 系统角色菜单权限
|
||||
*/
|
||||
SysRoleMenuVO getDetail(Long id);
|
||||
|
||||
/**
|
||||
* 分页查询系统角色菜单权限
|
||||
*
|
||||
* @param queryPage 分页参数
|
||||
* @return 分页结果
|
||||
*/
|
||||
IPage<SysRoleMenuVO> getPageResult(QueryPage<SysRoleMenu> queryPage);
|
||||
|
||||
/**
|
||||
* 根据条件查询系统角色菜单权限
|
||||
*
|
||||
* @param queryBean 查询条件
|
||||
* @return 系统角色菜单权限列表
|
||||
*/
|
||||
List<SysRoleMenuVO> listAll(SysRoleMenu queryBean);
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
package com.codvision.auth.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.codvision.auth.entity.SysRole;
|
||||
import com.codvision.auth.entity.vo.SysRoleVO;
|
||||
import com.codvision.webcore.bean.QueryPage;
|
||||
import com.codvision.webcore.service.IBaseService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 系统角色 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author lingee
|
||||
* @since 2023-11-09
|
||||
*/
|
||||
public interface ISysRoleService extends IBaseService<SysRole, SysRoleVO> {
|
||||
|
||||
/**
|
||||
* 获取系统角色详情
|
||||
*
|
||||
* @param id
|
||||
* @return 系统角色
|
||||
*/
|
||||
SysRoleVO getDetail(Integer id);
|
||||
|
||||
/**
|
||||
* 分页查询系统角色
|
||||
*
|
||||
* @param queryPage 分页参数
|
||||
* @return 分页结果
|
||||
*/
|
||||
IPage<SysRoleVO> getPageResult(QueryPage<SysRole> queryPage);
|
||||
|
||||
/**
|
||||
* 根据条件查询系统角色
|
||||
*
|
||||
* @param queryBean 查询条件
|
||||
* @return 系统角色列表
|
||||
*/
|
||||
List<SysRoleVO> listAll(SysRole queryBean);
|
||||
|
||||
/**
|
||||
* 获取默认角色
|
||||
*
|
||||
* @return 角色信息
|
||||
*/
|
||||
SysRole getDefaultRole();
|
||||
|
||||
/**
|
||||
* 逻辑删除角色
|
||||
*
|
||||
* @param id id
|
||||
*/
|
||||
void logicDel(Integer id);
|
||||
|
||||
/**
|
||||
* 设置角色菜单
|
||||
*
|
||||
* @param roleId 角色id
|
||||
* @param menuIdList 菜单id列表
|
||||
*/
|
||||
void setRoleMenu(Integer roleId, List<Integer> menuIdList);
|
||||
}
|
||||
@@ -0,0 +1,169 @@
|
||||
package com.codvision.auth.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.codvision.auth.entity.SysRole;
|
||||
import com.codvision.auth.entity.SysUser;
|
||||
import com.codvision.auth.entity.UserOrgRole;
|
||||
import com.codvision.auth.entity.dto.SysUserDTO;
|
||||
import com.codvision.auth.entity.dto.SysUserQueryDTO;
|
||||
import com.codvision.auth.entity.excel.SysUserExcel;
|
||||
import com.codvision.auth.entity.vo.OrgVO;
|
||||
import com.codvision.auth.entity.vo.SysUserVO;
|
||||
import com.codvision.webcore.bean.QueryPage;
|
||||
import com.codvision.webcore.service.IBaseService;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 系统用户 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author lingee
|
||||
* @since 2023-11-09
|
||||
*/
|
||||
public interface ISysUserService extends IBaseService<SysUser, SysUserVO> {
|
||||
|
||||
/**
|
||||
* 获取系统用户详情
|
||||
*
|
||||
* @param id
|
||||
* @return 系统用户
|
||||
*/
|
||||
SysUserVO getDetail(Integer id);
|
||||
|
||||
/**
|
||||
* 批量重置密码
|
||||
*
|
||||
* @param userIds
|
||||
*/
|
||||
void batchResetPwd(List<Integer> userIds);
|
||||
|
||||
/**
|
||||
* 切换用户所属组织及对应角色
|
||||
*
|
||||
* @param userOrgRole 用户组织权限
|
||||
* @param sysUserVO 系统用户信息
|
||||
*/
|
||||
void activeOrgRole(UserOrgRole userOrgRole, SysUserVO sysUserVO);
|
||||
|
||||
/**
|
||||
* 根据登录名获取系统用户
|
||||
*
|
||||
* @param loginName 登录名
|
||||
* @return 系统用户
|
||||
*/
|
||||
SysUserVO getDetailByLoginName(String loginName);
|
||||
|
||||
/**
|
||||
* 检查密码是否更新
|
||||
*
|
||||
* @param username 用户名
|
||||
* @return true or false
|
||||
*/
|
||||
boolean isRenewPwd(String username);
|
||||
|
||||
/**
|
||||
* 一键登录
|
||||
*
|
||||
* @param token token
|
||||
* @param userInformation 用户信息
|
||||
* @return 登录结果
|
||||
*/
|
||||
String quickLogin(String token, String userInformation);
|
||||
|
||||
/**
|
||||
* 根据手机号登录
|
||||
*
|
||||
* @param mobile 手机号
|
||||
*/
|
||||
void loginByMobile(String mobile);
|
||||
|
||||
/**
|
||||
* 新增系统用户
|
||||
*
|
||||
* @param sysUserDTO 系统用户
|
||||
* @return
|
||||
*/
|
||||
Integer addSysUser(SysUserDTO sysUserDTO);
|
||||
|
||||
/**
|
||||
* 根据用户id获取用户详情
|
||||
*
|
||||
* @param uid 用户Id
|
||||
* @return 用户详情
|
||||
*/
|
||||
SysUserVO getDetailByUid(Integer uid);
|
||||
|
||||
/**
|
||||
* 分页查询系统用户列表
|
||||
*
|
||||
* @param queryPage 分页参数
|
||||
* @param queryDTO 查询参数
|
||||
* @return 分页结果
|
||||
*/
|
||||
IPage<SysUserVO> findAll(QueryPage<SysUser> queryPage, SysUserQueryDTO queryDTO);
|
||||
|
||||
/**
|
||||
* 更新系统用户
|
||||
*
|
||||
* @param sysUserDTO 系统用户信息
|
||||
*/
|
||||
void updateUser(SysUserDTO sysUserDTO);
|
||||
|
||||
/**
|
||||
* 导入用户信息
|
||||
*
|
||||
* @param file 用户信息文件
|
||||
* @return 导入结果
|
||||
*/
|
||||
String excelImport(MultipartFile file);
|
||||
|
||||
/**
|
||||
* excel保存
|
||||
*
|
||||
* @param cachedDataList 缓存数据列表
|
||||
* @param orgList 组织列表
|
||||
* @param sysRoleList 角色列表
|
||||
*/
|
||||
void excelSave(List<SysUserExcel> cachedDataList, List<OrgVO> orgList, List<SysRole> sysRoleList);
|
||||
|
||||
/**
|
||||
* excel导出
|
||||
*
|
||||
* @param queryDTO 查询条件
|
||||
*/
|
||||
void excelExport(SysUserQueryDTO queryDTO);
|
||||
|
||||
/**
|
||||
* 根据钉钉用户id获取用户信息
|
||||
*
|
||||
* @param dingTalkUid 钉钉用户id
|
||||
* @return 用户信息
|
||||
*/
|
||||
SysUserVO getByDingTalkUid(String dingTalkUid);
|
||||
|
||||
/**
|
||||
* 根据浙政钉id获取用户信息
|
||||
*
|
||||
* @param zzdId 浙政钉id
|
||||
* @return 用户信息
|
||||
*/
|
||||
SysUserVO getByZzdId(String zzdId);
|
||||
|
||||
/**
|
||||
* 获取用户列表
|
||||
* @param params 查询参数
|
||||
* @return 用户列表
|
||||
*/
|
||||
List<SysUserVO> listUsers(Map<String, Object> params);
|
||||
|
||||
/**
|
||||
* 批量获取用户信息
|
||||
* @param uidList 用户ID
|
||||
* @return 用户信息
|
||||
*/
|
||||
List<SysUserVO> getListByIds(List<Integer> uidList);
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package com.codvision.auth.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.codvision.auth.entity.UserOrgRole;
|
||||
import com.codvision.auth.entity.vo.UserOrgRoleVO;
|
||||
import com.codvision.webcore.bean.QueryPage;
|
||||
import com.codvision.webcore.service.IBaseService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 组织用户关联信息 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author lingee
|
||||
* @since 2023-11-10
|
||||
*/
|
||||
public interface IUserOrgRoleService extends IBaseService<UserOrgRole, UserOrgRoleVO> {
|
||||
|
||||
/**
|
||||
* 获取组织用户关联信息详情
|
||||
*
|
||||
* @param id
|
||||
* @return 组织用户关联信息
|
||||
*/
|
||||
UserOrgRoleVO getDetail(Long id);
|
||||
|
||||
/**
|
||||
* 分页查询组织用户关联信息
|
||||
*
|
||||
* @param queryPage 分页参数
|
||||
* @return 分页结果
|
||||
*/
|
||||
IPage<UserOrgRoleVO> getPageResult(QueryPage<UserOrgRole> queryPage);
|
||||
|
||||
/**
|
||||
* 根据条件查询组织用户关联信息
|
||||
*
|
||||
* @param queryBean 查询条件
|
||||
* @return 组织用户关联信息列表
|
||||
*/
|
||||
List<UserOrgRoleVO> listAll(UserOrgRole queryBean);
|
||||
|
||||
/**
|
||||
* 根据用户id、组织id、角色id获取组织用户关联信息
|
||||
*
|
||||
* @param uid 用户id
|
||||
* @param oid 组织id
|
||||
* @param roleId 角色id
|
||||
* @return 组织用户关联信息
|
||||
*/
|
||||
UserOrgRole getUserOrgRole(Integer uid, Integer oid, Integer roleId);
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.codvision.auth.service.impl;
|
||||
|
||||
import cn.hutool.captcha.CaptchaUtil;
|
||||
import cn.hutool.captcha.CircleCaptcha;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import com.codvision.auth.entity.vo.CustomCaptchaVO;
|
||||
import com.codvision.auth.service.ICustomCaptchaService;
|
||||
import com.codvision.cachecore.utils.RedisUtil;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static com.codvision.auth.support.CacheContants.CUSTOM_CAPTCHA_CODE;
|
||||
|
||||
|
||||
/**
|
||||
* @author hxl
|
||||
*/
|
||||
@Service
|
||||
public class CustomCaptchaServiceImpl implements ICustomCaptchaService {
|
||||
|
||||
@Override
|
||||
public CustomCaptchaVO getPicCaptcha() {
|
||||
String reqNo = IdUtil.fastSimpleUUID();
|
||||
CircleCaptcha circleCaptcha = CaptchaUtil.createCircleCaptcha(100, 38, 4, 8);
|
||||
// 将请求号作为key,验证码的值作为value放到redis用于校验,5分钟有效期
|
||||
RedisUtil.set(CUSTOM_CAPTCHA_CODE + reqNo, circleCaptcha.getCode(), 5, TimeUnit.MINUTES);
|
||||
return CustomCaptchaVO.builder().picBase64(circleCaptcha.getImageBase64Data()).reqNo(reqNo).build();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,215 @@
|
||||
/*
|
||||
* Copyright (c) 2023 codvision.com All Rights Reserved.
|
||||
*/
|
||||
|
||||
package com.codvision.auth.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.json.JSONArray;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.codvision.auth.entity.*;
|
||||
import com.codvision.auth.mapper.OrgPropertyMapper;
|
||||
import com.codvision.auth.mapper.SysRoleMapper;
|
||||
import com.codvision.auth.mapper.SysUserMapper;
|
||||
import com.codvision.auth.mapper.UserOrgRoleMapper;
|
||||
import com.codvision.auth.service.IDingUserService;
|
||||
import com.codvision.auth.service.IOrgService;
|
||||
import com.codvision.auth.support.DingHelper;
|
||||
import com.codvision.base.service.ISysConfigService;
|
||||
import com.codvision.commoncore.exception.BusinessException;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 钉钉用户业务实现
|
||||
*
|
||||
* @author lingee
|
||||
* @since 2024/4/11
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public class DingUserServiceImpl implements IDingUserService {
|
||||
|
||||
@Resource
|
||||
private IOrgService orgService;
|
||||
|
||||
@Resource
|
||||
private OrgPropertyMapper orgPropertyMapper;
|
||||
|
||||
@Resource
|
||||
private SysUserMapper sysUserMapper;
|
||||
|
||||
@Resource
|
||||
private UserOrgRoleMapper userOrgRoleMapper;
|
||||
|
||||
@Resource
|
||||
private SysRoleMapper sysRoleMapper;
|
||||
|
||||
@Resource
|
||||
private DingHelper dingHelper;
|
||||
|
||||
@Resource
|
||||
private BCryptPasswordEncoder bCryptEncode;
|
||||
|
||||
@Resource
|
||||
private ISysConfigService configService;
|
||||
|
||||
@Override
|
||||
public void syncDepartment() {
|
||||
log.info("开始同步钉钉组织架构");
|
||||
try {
|
||||
syncDept(1, 2);
|
||||
} catch (Exception e) {
|
||||
log.error("同步钉钉组织架构失败", e);
|
||||
throw new BusinessException("同步钉钉组织架构失败:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void syncUser(String roleCode) {
|
||||
List<Org> orgList = orgService.list();
|
||||
if (CollUtil.isEmpty(orgList)) {
|
||||
throw new BusinessException("组织信息为空,请先同步组织");
|
||||
}
|
||||
orgService.list().forEach(
|
||||
org -> {
|
||||
try {
|
||||
log.info("======>>>>>>组织名称:" + org.getName());
|
||||
syncDepartUser(Long.parseLong(org.getRefOid()), roleCode);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
public void syncDepartUser(long deptId, String roleCode) throws Exception {
|
||||
// 用户绑定角色编码不存在创建角色
|
||||
if (StringUtils.isBlank(roleCode)) {
|
||||
throw new BusinessException("角色编码不能为空");
|
||||
}
|
||||
SysRole sysRole = sysRoleMapper.selectOne(Wrappers.<SysRole>lambdaQuery().eq(SysRole::getRoleCode, roleCode));
|
||||
if (ObjectUtil.isEmpty(sysRole)) {
|
||||
sysRole = new SysRole();
|
||||
sysRole.setRoleName("默认角色");
|
||||
sysRole.setRoleDesc("默认角色");
|
||||
sysRole.setRoleCode(roleCode);
|
||||
sysRole.setLevel((short) 1);
|
||||
sysRole.setCreateTime(new Date());
|
||||
sysRole.setUpdateTime(new Date());
|
||||
sysRoleMapper.insert(sysRole);
|
||||
}
|
||||
|
||||
JSONObject departmentUser = dingHelper.getDepartmentUserList(deptId, 0);
|
||||
JSONObject result = departmentUser.getJSONObject("result");
|
||||
boolean flag;
|
||||
while (true) {
|
||||
flag = result.getBool("has_more");
|
||||
Long nextCursor = result.getLong("next_cursor");
|
||||
JSONArray list = result.getJSONArray("list");
|
||||
for (JSONObject entries : JSONUtil.toList(list, JSONObject.class)) {
|
||||
log.info("用户信息:" + entries.toString());
|
||||
String jobNumber = entries.getStr("job_number");
|
||||
String userid = entries.getStr("userid");
|
||||
String name = entries.getStr("name");
|
||||
|
||||
log.info("工号:" + entries.getStr("job_number")); // 工号
|
||||
log.info("用户id:" + entries.getStr("userid")); // ding_talk_uid
|
||||
log.info("用户名称:" + entries.getStr("name")); // 姓名
|
||||
SysUser sysUser = sysUserMapper.selectOne(Wrappers.<SysUser>lambdaQuery().eq(SysUser::getDingTalkUid, userid).last("limit 1"));
|
||||
if (sysUser == null) {
|
||||
sysUser = new SysUser();
|
||||
sysUser.setDingTalkUid(userid);
|
||||
if (StringUtils.isBlank(jobNumber)) {
|
||||
sysUser.setLoginName("未知工号_" + name);
|
||||
} else {
|
||||
sysUser.setLoginName(jobNumber + "_" + name);
|
||||
}
|
||||
sysUser.setName(name);
|
||||
sysUser.setAvatarUrl(entries.getStr("avatar"));
|
||||
sysUser.setPassword(bCryptEncode.encode(configService.getValueByKey("GLOBAL_DEFAULT_PWD")));
|
||||
sysUserMapper.insert(sysUser);
|
||||
sysUser = sysUserMapper.selectOne(Wrappers.<SysUser>lambdaQuery().eq(SysUser::getDingTalkUid, userid).last("limit 1"));
|
||||
JSONArray deptIdList = entries.getJSONArray("dept_id_list");
|
||||
for (String userDeptId : JSONUtil.toList(deptIdList, String.class)) {
|
||||
Org orgByRefOid = orgService.getOne(Wrappers.<Org>lambdaQuery().eq(Org::getRefOid, userDeptId));
|
||||
UserOrgRole userOrgRole = new UserOrgRole();
|
||||
userOrgRole.setRoleId(sysRole.getId());
|
||||
userOrgRole.setRoleCode(sysRole.getRoleCode());
|
||||
userOrgRole.setUid(sysUser.getId());
|
||||
userOrgRole.setOid(orgByRefOid.getOid());
|
||||
userOrgRole.setFlagEnabled((short)1);
|
||||
UserOrgRole userOrgRole1 = userOrgRoleMapper.selectOne(Wrappers.<UserOrgRole>lambdaQuery().eq(UserOrgRole::getUid, userOrgRole.getUid())
|
||||
.eq(UserOrgRole::getOid, userOrgRole.getOid()).eq(UserOrgRole::getRoleId, userOrgRole.getRoleId()));
|
||||
if (userOrgRole1 == null) {
|
||||
userOrgRoleMapper.insert(userOrgRole);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// 更新用户信息,删除组织角色关系
|
||||
sysUser.setDingTalkUid(userid);
|
||||
sysUser.setName(name);
|
||||
sysUser.setAvatarUrl(entries.getStr("avatar"));
|
||||
sysUserMapper.updateById(sysUser);
|
||||
}
|
||||
}
|
||||
if (!flag) {
|
||||
break;
|
||||
}
|
||||
departmentUser = dingHelper.getDepartmentUserList(deptId, nextCursor);
|
||||
result = departmentUser.getJSONObject("result");
|
||||
}
|
||||
}
|
||||
|
||||
private void syncDept(long parentDeptId, int level) throws Exception {
|
||||
Org parentOrg = orgService.getOne(Wrappers.<Org>lambdaQuery().eq(Org::getRefOid, parentDeptId + ""));
|
||||
JSONObject departmentList = dingHelper.getDepartmentList(parentDeptId);
|
||||
JSONArray result = departmentList.getJSONArray("result");
|
||||
for (int i = 0; i < result.size(); i++) {
|
||||
JSONObject jsonObject = result.getJSONObject(i);
|
||||
// 添加或更新组织信息
|
||||
log.info("部门名称:" + jsonObject.getStr("name"));
|
||||
log.info("部门id:" + jsonObject.getLong("dept_id"));
|
||||
log.info("部门级别:" + level);
|
||||
String departmentName = jsonObject.getStr("name");
|
||||
Long deptId = jsonObject.getLong("dept_id");
|
||||
Org org = orgService.getOne(Wrappers.<Org>lambdaQuery().eq(Org::getRefOid, deptId + ""));
|
||||
if (org == null) {
|
||||
org = new Org();
|
||||
org.setName(departmentName);
|
||||
org.setFullname(departmentName);
|
||||
org.setType(1);
|
||||
org.setRefOid(deptId + "");
|
||||
org.setLevel((short) level);
|
||||
org.setPoid(parentOrg.getOid());
|
||||
// 根据组织属性表中数据以及组织级别添加的对应id
|
||||
org.setOrgPropertyId(orgPropertyMapper.selectOne(Wrappers.<OrgProperty>lambdaQuery()
|
||||
.eq(OrgProperty::getLevel, level).orderByDesc(OrgProperty::getId).last("limit 1")).getId());
|
||||
orgService.addOrg(org);
|
||||
log.info(org.toString());
|
||||
} else {
|
||||
org.setName(departmentName);
|
||||
org.setFullname(departmentName);
|
||||
org.setType(1);
|
||||
org.setRefOid(deptId + "");
|
||||
org.setLevel((short) level);
|
||||
org.setPoid(parentOrg.getOid());
|
||||
org.setOrgPropertyId(level + 14);
|
||||
orgService.updateOrg(org);
|
||||
}
|
||||
// 递归查询下级部门
|
||||
syncDept(deptId, level + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.codvision.auth.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.codvision.auth.entity.ding.gov.GovDingEmployee;
|
||||
import com.codvision.auth.mapper.GovDingEmployeeMapper;
|
||||
import com.codvision.auth.service.IGovDingEmployeeService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
public class GovDingEmployeeServiceImpl extends ServiceImpl<GovDingEmployeeMapper, GovDingEmployee> implements IGovDingEmployeeService {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
package com.codvision.auth.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.codvision.auth.entity.Org;
|
||||
import com.codvision.auth.entity.OrgProperty;
|
||||
import com.codvision.auth.entity.vo.OrgPropertyVO;
|
||||
import com.codvision.auth.mapper.OrgMapper;
|
||||
import com.codvision.auth.mapper.OrgPropertyMapper;
|
||||
import com.codvision.auth.service.IOrgPropertyService;
|
||||
import com.codvision.commoncore.exception.BusinessException;
|
||||
import com.codvision.webcore.bean.QueryPage;
|
||||
import com.codvision.webcore.service.impl.BaseServiceImpl;
|
||||
import com.codvision.webcore.util.PageUtil;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 组织属性表 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author lingee
|
||||
* @since 2023-11-10
|
||||
*/
|
||||
@Service
|
||||
public class OrgPropertyServiceImpl extends BaseServiceImpl<OrgPropertyMapper, OrgProperty, OrgPropertyVO> implements IOrgPropertyService {
|
||||
|
||||
@Resource
|
||||
private OrgMapper orgMapper;
|
||||
|
||||
@Override
|
||||
public OrgPropertyVO getDetail(Long id) {
|
||||
OrgPropertyVO vo = new OrgPropertyVO();
|
||||
OrgProperty po = this.getById(id);
|
||||
if (null != po) {
|
||||
BeanUtil.copyProperties(po, vo);
|
||||
}
|
||||
return vo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPage<OrgPropertyVO> getPageResult(QueryPage<OrgProperty> queryPage) {
|
||||
QueryWrapper<OrgProperty> queryWrapper = queryPage.getWrapper();
|
||||
IPage<OrgPropertyVO> pageResult = this.getBasePage(queryPage.getPage(), queryWrapper);
|
||||
return pageResult;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<OrgPropertyVO> listAll(OrgProperty queryBean) {
|
||||
QueryWrapper<OrgProperty> wrapper = PageUtil.initWrapper(queryBean);
|
||||
List<OrgProperty> list = this.list(wrapper);
|
||||
return BeanUtil.copyToList(list, OrgPropertyVO.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean save(OrgProperty orgProperty) {
|
||||
Assert.notNull(orgProperty, "组织属性表不能为空");
|
||||
if (orgProperty.getPid() != 0) {
|
||||
OrgProperty parentOrgProperty = getBaseMapper()
|
||||
.selectOne(Wrappers.<OrgProperty>lambdaQuery().eq(OrgProperty::getId, orgProperty.getPid()));
|
||||
Assert.notNull(parentOrgProperty, "父级组织属性表不存在");
|
||||
orgProperty.setLevel(parentOrgProperty.getLevel() + 1);
|
||||
} else {
|
||||
orgProperty.setLevel(1);
|
||||
}
|
||||
getBaseMapper().insert(orgProperty);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateById(OrgProperty orgProperty) {
|
||||
Assert.notNull(orgProperty, "组织属性表不能为空");
|
||||
Assert.notNull(orgProperty.getId(), "组织属性表id不能为空");
|
||||
if (orgProperty.getPid() != 0) {
|
||||
OrgProperty parentOrgProperty = getBaseMapper()
|
||||
.selectOne(Wrappers.<OrgProperty>lambdaQuery().eq(OrgProperty::getId, orgProperty.getPid()));
|
||||
Assert.notNull(parentOrgProperty, "父级组织属性表不存在");
|
||||
orgProperty.setLevel(parentOrgProperty.getLevel() + 1);
|
||||
} else {
|
||||
orgProperty.setLevel(1);
|
||||
}
|
||||
getBaseMapper().updateById(orgProperty);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removeById(Serializable id) {
|
||||
OrgProperty orgProperty = getById(id);
|
||||
Assert.notNull(orgProperty, "组织属性表不存在");
|
||||
|
||||
// 判断是否存在下级,如果有下级不可进行删除
|
||||
if (this.count(Wrappers.<OrgProperty>lambdaQuery().eq(OrgProperty::getPid, id)) > 0) {
|
||||
throw new BusinessException("存在下级属性,不可删除");
|
||||
}
|
||||
// 判断是否绑定组织,如果有绑定组织不可删除
|
||||
if (orgMapper.selectCount(Wrappers.<Org>lambdaQuery().eq(Org::getOrgPropertyId, id)) > 0) {
|
||||
throw new BusinessException("属性绑定组织,不可删除");
|
||||
}
|
||||
|
||||
getBaseMapper().deleteById(id);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,347 @@
|
||||
package com.codvision.auth.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.extra.spring.SpringUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.alibaba.excel.EasyExcel;
|
||||
import com.alibaba.excel.context.AnalysisContext;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.codvision.auth.entity.Org;
|
||||
import com.codvision.auth.entity.OrgProperty;
|
||||
import com.codvision.auth.entity.dto.SysOrgQueryDTO;
|
||||
import com.codvision.auth.entity.excel.OrgExcel;
|
||||
import com.codvision.auth.entity.vo.OrgVO;
|
||||
import com.codvision.auth.mapper.OrgMapper;
|
||||
import com.codvision.auth.mapper.SysUserMapper;
|
||||
import com.codvision.auth.service.IOrgPropertyService;
|
||||
import com.codvision.auth.service.IOrgService;
|
||||
import com.codvision.base.config.excel.AbstractExportClass;
|
||||
import com.codvision.base.config.excel.ExcelDataReadListener;
|
||||
import com.codvision.base.entity.ExcelCheck;
|
||||
import com.codvision.base.entity.ExcelErrorRecord;
|
||||
import com.codvision.base.enums.DelFlag;
|
||||
import com.codvision.commoncore.exception.BusinessException;
|
||||
import com.codvision.webcore.bean.QueryPage;
|
||||
import com.codvision.webcore.service.impl.BaseServiceImpl;
|
||||
import com.codvision.webcore.util.PageUtil;
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.collect.Lists;
|
||||
import lombok.SneakyThrows;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.codvision.base.support.BaseConst.SLASH_SYMBOL;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 组织信息 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author lingee
|
||||
* @since 2023-11-10
|
||||
*/
|
||||
@Service
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public class OrgServiceImpl extends BaseServiceImpl<OrgMapper, Org, OrgVO> implements IOrgService {
|
||||
|
||||
@Resource
|
||||
private SysUserMapper sysUserMapper;
|
||||
|
||||
@Resource
|
||||
private IOrgPropertyService orgPropertyService;
|
||||
|
||||
@Override
|
||||
public OrgVO getDetail(Integer oid) {
|
||||
return getBaseMapper().getByOid(oid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Org getDefaultOrg() {
|
||||
return this.getOne(Wrappers.<Org>lambdaQuery().orderByAsc(Org::getOid).last("limit 1"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPage<OrgVO> findAll(QueryPage<Org> queryPage, SysOrgQueryDTO queryDTO) {
|
||||
IPage<Org> page = queryPage.getPage();
|
||||
List<OrgVO> voList = this.getBaseMapper().findAll(page, queryDTO);
|
||||
return PageUtil.convertPage(page, voList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public OrgVO addOrg(Org org) {
|
||||
isExist(org);
|
||||
if (org.getType() == 2 && org.getLevel() > 1) {
|
||||
org.setDistrictOid(getDistrictOid(org.getPoid()));
|
||||
}
|
||||
this.save(org);
|
||||
return getDetail(org.getOid());
|
||||
}
|
||||
|
||||
@Override
|
||||
public OrgVO updateOrg(Org org) {
|
||||
Org existOrg = getDetail(org.getOid());
|
||||
Preconditions.checkArgument(ObjectUtil.isNotEmpty(existOrg), 30001);
|
||||
|
||||
if (!Objects.equals(org.getPoid(), existOrg.getPoid())) {
|
||||
isExist(org);
|
||||
} else if (!Objects.equals(org.getName(), existOrg.getName())) {
|
||||
Org checkOrg = getBaseMapper().getByNameAndPoid(org.getName(), org.getPoid());
|
||||
Preconditions.checkArgument(checkOrg == null, "组织已存在");
|
||||
}
|
||||
|
||||
this.updateById(org);
|
||||
return getDetail(org.getOid());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void logicDel(Integer oid) {
|
||||
Org org = this.getById(oid);
|
||||
Preconditions.checkArgument(org != null, 30001);
|
||||
|
||||
// 判断当前组织是否已有账号在使用
|
||||
int count = sysUserMapper.checkUserOrg(oid);
|
||||
Preconditions.checkArgument(count <= 0, "已有账号正在使用该组织,暂无法删除");
|
||||
|
||||
this.update(Wrappers.<Org>lambdaUpdate().setSql("del_flag = 1, del_key = oid")
|
||||
.eq(Org::getDelFlag, DelFlag.NO_DELETED.getFlag()).like(Org::getOidPath, "/" + oid + "/"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public OrgVO getTree(Integer root) {
|
||||
SysOrgQueryDTO queryDTO = new SysOrgQueryDTO();
|
||||
if (root != null) {
|
||||
queryDTO.setRoot(String.valueOf(root));
|
||||
queryDTO.setSubQuery(true);
|
||||
}
|
||||
|
||||
List<OrgVO> orgList = this.getBaseMapper().findAll(null, queryDTO);
|
||||
if (CollectionUtils.isEmpty(orgList)) {
|
||||
return new OrgVO();
|
||||
}
|
||||
if (root == null) {
|
||||
return orgList.stream().filter(m -> m.getPoid() == null)
|
||||
.peek(m -> m.getChildren().addAll(sort(getChildren(m, orgList)))).iterator().next();
|
||||
}
|
||||
|
||||
return orgList.stream().filter(m -> root.equals(m.getOid()))
|
||||
.peek(m -> m.getChildren().addAll(sort(getChildren(m, orgList)))).iterator().next();
|
||||
}
|
||||
|
||||
@Override
|
||||
@SneakyThrows
|
||||
public String excelImport(MultipartFile file) {
|
||||
Map<String, Object> paraMap = new HashMap<>(16);
|
||||
paraMap.put("isIgnoreWkt", true);
|
||||
|
||||
SysOrgQueryDTO queryDTO = new SysOrgQueryDTO();
|
||||
queryDTO.setIsIgnoreWkt(true);
|
||||
List<OrgVO> orgList = getBaseMapper().findAll(null, queryDTO);
|
||||
List<OrgProperty> orgPropertyList = orgPropertyService.list();
|
||||
|
||||
String reqNo = IdUtil.fastSimpleUUID();
|
||||
IOrgService service = SpringUtil.getBean(IOrgService.class);
|
||||
ExcelDataReadListener<OrgExcel> listener = new ExcelDataReadListener<OrgExcel>(cachedDataList -> service.excelSave(cachedDataList, orgList, orgPropertyList)) {
|
||||
@Override
|
||||
protected void validator(OrgExcel orgExcel, ExcelCheck<OrgExcel> check, AnalysisContext context) {
|
||||
checkOne(reqNo, orgExcel, check, context.readRowHolder().getRowIndex(), orgList, orgPropertyList);
|
||||
}
|
||||
};
|
||||
EasyExcel.read(file.getInputStream(), OrgExcel.class, listener).sheet().doRead();
|
||||
if (listener.isHeadAbnormal()) {
|
||||
throw new BusinessException("文件格式错误,请检查导入模板");
|
||||
}
|
||||
|
||||
return listener.existErrorData() ? reqNo : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void excelSave(List<OrgExcel> cachedDataList, List<OrgVO> orgList, List<OrgProperty> orgPropertyList) {
|
||||
if (CollectionUtils.isNotEmpty(cachedDataList)) {
|
||||
List<Org> orgs = new ArrayList<>();
|
||||
for (OrgExcel orgExcel : cachedDataList) {
|
||||
Org org = new Org();
|
||||
org.setType("行政区划".equals(orgExcel.getType()) ? 1 : 2);
|
||||
org.setName(orgExcel.getName());
|
||||
org.setDistrictCode(orgExcel.getDistrictCode());
|
||||
Optional<OrgProperty> propertyOptional = orgPropertyList.stream().filter(orgProperty -> orgExcel.getOrgPropertyName().equals(orgProperty.getName())).findFirst();
|
||||
propertyOptional.ifPresent(orgProperty -> org.setOrgPropertyId(orgProperty.getId()));
|
||||
Optional<OrgVO> optional = orgList.stream().filter(o -> orgExcel.getParentOrgName().equals(o.getPath())).findFirst();
|
||||
optional.ifPresent(o -> org.setPoid(o.getOid()));
|
||||
Optional<OrgVO> isExist = orgList.stream().filter(o -> o.getName().equals(orgExcel.getName()) && o.getPoid().equals(org.getPoid())).findFirst();
|
||||
if (!isExist.isPresent()) {
|
||||
orgs.add(org);
|
||||
}
|
||||
}
|
||||
if (CollectionUtil.isNotEmpty(orgs)) {
|
||||
this.saveBatch(orgs);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void excelExport(SysOrgQueryDTO queryBean) {
|
||||
new AbstractExportClass<OrgExcel, Org>() {
|
||||
@Override
|
||||
protected List<OrgExcel> getList(QueryPage<Org> queryPage, Object queryBean) {
|
||||
List<OrgExcel> list = new ArrayList<>();
|
||||
List<OrgVO> orgList = getBaseMapper().findAll(queryPage.getPage(), (SysOrgQueryDTO) queryBean);
|
||||
List<OrgProperty> orgPropertyList = orgPropertyService.list();
|
||||
if (CollectionUtils.isNotEmpty(orgList)) {
|
||||
for (Org org : orgList) {
|
||||
OrgExcel orgExcel = new OrgExcel();
|
||||
orgExcel.setName(org.getName());
|
||||
Optional<OrgProperty> propertyOptional = orgPropertyList.stream().filter(orgProperty -> org.getOrgPropertyId().equals(orgProperty.getId())).findFirst();
|
||||
propertyOptional.ifPresent(orgProperty -> orgExcel.setOrgPropertyName(orgProperty.getName()));
|
||||
orgExcel.setType(org.getType().equals(1) ? "行政区划" : "部门");
|
||||
orgExcel.setDistrictCode(org.getDistrictCode());
|
||||
if (org.getPoid() != null) {
|
||||
Org parentOrg = getBaseMapper().selectById(org.getPoid());
|
||||
if (parentOrg != null) {
|
||||
orgExcel.setParentOrgName(parentOrg.getPath());
|
||||
}
|
||||
}
|
||||
list.add(orgExcel);
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
}.excelUser("组织信息表", queryBean, OrgExcel.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<OrgVO> findAll(SysOrgQueryDTO queryDTO) {
|
||||
return this.getBaseMapper().findAll(null, queryDTO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 递归获取上级行政区划类型组织oid
|
||||
*
|
||||
* @param oid 组织id
|
||||
* @return Integer
|
||||
*/
|
||||
private Integer getDistrictOid(Integer oid) {
|
||||
if (oid == null) {
|
||||
return null;
|
||||
}
|
||||
OrgVO orgVO = getDetail(oid);
|
||||
if (orgVO.getType() == 1) {
|
||||
return orgVO.getOid();
|
||||
}
|
||||
return getDistrictOid(orgVO.getPoid());
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断组织是否存在
|
||||
*
|
||||
* @param o 组织信息
|
||||
*/
|
||||
private void isExist(Org o) {
|
||||
OrgVO org;
|
||||
if (o.getPoid() == null) {
|
||||
org = getBaseMapper().getByNameWithOutPoid(o.getName());
|
||||
} else {
|
||||
org = getBaseMapper().getByNameAndPoid(o.getName(), o.getPoid());
|
||||
}
|
||||
|
||||
if (org != null) {
|
||||
throw new BusinessException("组织已存在");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取子组织列表
|
||||
*
|
||||
* @param parentOrg 父组织
|
||||
* @param orgList 组织列表
|
||||
* @return 子组织列表
|
||||
*/
|
||||
private List<OrgVO> getChildren(OrgVO parentOrg, List<OrgVO> orgList) {
|
||||
return orgList.stream()
|
||||
.filter(cur -> cur.getPoid() != null && Objects.equals(cur.getPoid(), parentOrg.getOid()))
|
||||
.peek(m -> m.getChildren().addAll(sort(getChildren(m, orgList)))).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 组织列表排序
|
||||
*
|
||||
* @param orgList 组织列表
|
||||
* @return 排序后的组织列表
|
||||
*/
|
||||
private List<OrgVO> sort(List<OrgVO> orgList) {
|
||||
if (CollectionUtils.isEmpty(orgList)) {
|
||||
return Lists.newArrayList();
|
||||
}
|
||||
|
||||
orgList.sort(Comparator.comparing(OrgVO::getOrderby));
|
||||
return orgList;
|
||||
}
|
||||
|
||||
|
||||
private void checkOne(String reqNo,
|
||||
OrgExcel orgExcel,
|
||||
ExcelCheck<OrgExcel> check,
|
||||
Integer rowIndex,
|
||||
List<OrgVO> orgList,
|
||||
List<OrgProperty> orgPropertyList) {
|
||||
Map<String, Object> fieldsErrorMap = new HashMap<>(16);
|
||||
if (StringUtils.isBlank(orgExcel.getName())) {
|
||||
fieldsErrorMap.put("name", "组织名称必填");
|
||||
}
|
||||
if (StringUtils.isBlank(orgExcel.getType())) {
|
||||
fieldsErrorMap.put("type", "组织类型必填");
|
||||
}
|
||||
|
||||
String parentOrgName = orgExcel.getParentOrgName();
|
||||
if (StringUtils.isBlank(parentOrgName)) {
|
||||
fieldsErrorMap.put("parentOrgName", "父级组织路径必填");
|
||||
} else {
|
||||
if (!(parentOrgName.startsWith(SLASH_SYMBOL) && parentOrgName.endsWith(SLASH_SYMBOL))) {
|
||||
fieldsErrorMap.put("parentOrgName", "格式错误");
|
||||
} else {
|
||||
Optional<OrgVO> optional = orgList.stream().filter(o -> orgExcel.getParentOrgName().equals(o.getPath())).findFirst();
|
||||
|
||||
if (!optional.isPresent()) {
|
||||
fieldsErrorMap.put("parentOrgName", "无法获取到父级组织的信息");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
String orgPropertyName = orgExcel.getOrgPropertyName();
|
||||
if (StringUtils.isBlank(orgPropertyName)) {
|
||||
fieldsErrorMap.put("orgPropertyName", "组织属性必填");
|
||||
} else {
|
||||
Optional<OrgProperty> optional = orgPropertyList.stream().filter(orgProperty -> orgExcel.getOrgPropertyName().equals(orgProperty.getName())).findFirst();
|
||||
if (!optional.isPresent()) {
|
||||
fieldsErrorMap.put("orgPropertyName", "无法获取到组织属性的信息");
|
||||
} else {
|
||||
OrgProperty property = new OrgProperty();
|
||||
optional.ifPresent(orgProperty -> property.setCodeLength(orgProperty.getCodeLength()));
|
||||
if (property.getCodeLength() != null && orgExcel.getDistrictCode().length() != property.getCodeLength()) {
|
||||
fieldsErrorMap.put("districtCode", "行政区划编码长度不正确");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (fieldsErrorMap.isEmpty()) {
|
||||
check.getCacheList().add(orgExcel);
|
||||
} else {
|
||||
ExcelErrorRecord record = new ExcelErrorRecord();
|
||||
record.setReqNo(reqNo);
|
||||
record.setRowIndex(rowIndex);
|
||||
record.setOriginalJsonValue(JSONUtil.toJsonStr(orgExcel));
|
||||
record.setErrorMsgJson(JSONUtil.toJsonStr(fieldsErrorMap));
|
||||
record.setTargetObject(orgExcel.getClass().getName());
|
||||
check.getErrorList().add(record);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
package com.codvision.auth.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.codvision.auth.entity.SysApp;
|
||||
import com.codvision.auth.entity.SysMenu;
|
||||
import com.codvision.auth.entity.vo.SysAppVO;
|
||||
import com.codvision.auth.mapper.SysAppMapper;
|
||||
import com.codvision.auth.mapper.SysMenuMapper;
|
||||
import com.codvision.auth.service.ISysAppService;
|
||||
import com.codvision.commoncore.enums.TrueOrFalse;
|
||||
import com.codvision.commoncore.exception.BusinessException;
|
||||
import com.codvision.webcore.bean.QueryPage;
|
||||
import com.codvision.webcore.service.impl.BaseServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 系统应用 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author lingee
|
||||
* @since 2024-04-29
|
||||
*/
|
||||
@Service
|
||||
public class SysAppServiceImpl extends BaseServiceImpl<SysAppMapper, SysApp, SysAppVO> implements ISysAppService {
|
||||
|
||||
@Resource
|
||||
private SysMenuMapper sysMenuMapper;
|
||||
|
||||
@Override
|
||||
public SysAppVO getDetail(Serializable id) {
|
||||
SysAppVO vo = new SysAppVO();
|
||||
SysApp po = this.getById(id);
|
||||
if (null != po) {
|
||||
BeanUtil.copyProperties(po, vo);
|
||||
}
|
||||
return vo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPage<SysAppVO> getPageResult(QueryPage<SysApp> queryPage) {
|
||||
LambdaQueryWrapper<SysApp> queryWrapper = Wrappers.lambdaQuery();
|
||||
SysApp queryBean = queryPage.getCondition();
|
||||
// 根据queryBean拼接查询条件
|
||||
if (null != queryBean) {
|
||||
queryWrapper.like(StrUtil.isNotBlank(queryBean.getName()), SysApp::getName, queryBean.getName());
|
||||
}
|
||||
queryWrapper.orderByDesc(SysApp::getId);
|
||||
IPage<SysAppVO> pageResult = this.getBasePage(queryPage.getPage(), queryWrapper);
|
||||
return pageResult;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SysAppVO> listAll(SysApp queryBean) {
|
||||
LambdaQueryWrapper<SysApp> queryWrapper = Wrappers.lambdaQuery();
|
||||
// 根据queryBean拼接查询条件
|
||||
if (null != queryBean) {
|
||||
|
||||
}
|
||||
List<SysApp> list = this.list(queryWrapper);
|
||||
return BeanUtil.copyToList(list, SysAppVO.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean save(SysApp sysApp) {
|
||||
Assert.notNull(sysApp, "系统应用不能为空");
|
||||
getBaseMapper().insert(sysApp);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateById(SysApp sysApp) {
|
||||
Assert.notNull(sysApp, "系统应用不能为空");
|
||||
Assert.notNull(sysApp.getId(), "系统应用id不能为空");
|
||||
getBaseMapper().updateById(sysApp);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removeById(Serializable id) {
|
||||
SysApp sysApp = getById(id);
|
||||
Assert.notNull(sysApp, "系统应用不存在");
|
||||
if (sysMenuMapper.selectCount(Wrappers.<SysMenu>lambdaQuery().eq(SysMenu::getAppId, id)
|
||||
.eq(SysMenu::getDelFlag, TrueOrFalse.FALSE.getIntVal())) > 0) {
|
||||
throw new BusinessException("当前应用已关联菜单,无法删除");
|
||||
}
|
||||
getBaseMapper().deleteById(id);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
package com.codvision.auth.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.codvision.auth.entity.SysMenu;
|
||||
import com.codvision.auth.entity.dto.SysMenuQueryDTO;
|
||||
import com.codvision.auth.entity.vo.SysMenuVO;
|
||||
import com.codvision.auth.enums.MenuCategory;
|
||||
import com.codvision.auth.mapper.SysMenuMapper;
|
||||
import com.codvision.auth.service.ISysMenuService;
|
||||
import com.codvision.base.enums.DelFlag;
|
||||
import com.codvision.webcore.bean.QueryPage;
|
||||
import com.codvision.webcore.service.impl.BaseServiceImpl;
|
||||
import com.codvision.webcore.util.PageUtil;
|
||||
import com.google.common.base.Preconditions;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 系统菜单 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author lingee
|
||||
* @since 2023-11-09
|
||||
*/
|
||||
@Service
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public class SysMenuServiceImpl extends BaseServiceImpl<SysMenuMapper, SysMenu, SysMenuVO> implements ISysMenuService {
|
||||
|
||||
@Override
|
||||
public SysMenuVO getDetail(Long id) {
|
||||
SysMenuVO vo = new SysMenuVO();
|
||||
SysMenu po = this.getById(id);
|
||||
if (null != po) {
|
||||
BeanUtil.copyProperties(po, vo);
|
||||
}
|
||||
return vo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SysMenuVO> listAll(SysMenu queryBean) {
|
||||
QueryWrapper<SysMenu> wrapper = PageUtil.initWrapper(queryBean);
|
||||
List<SysMenu> list = this.list(wrapper);
|
||||
return BeanUtil.copyToList(list, SysMenuVO.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPage<SysMenuVO> findAll(QueryPage<SysMenu> queryPage, SysMenuQueryDTO queryDTO) {
|
||||
LambdaQueryWrapper<SysMenu> queryWrapper = Wrappers.lambdaQuery();
|
||||
if (ObjectUtil.isNotEmpty(queryDTO)) {
|
||||
queryWrapper.like(StrUtil.isNotBlank(queryDTO.getName()), SysMenu::getName, queryDTO.getName())
|
||||
.eq(ObjectUtil.isNotEmpty(queryDTO.getType()), SysMenu::getType, queryDTO.getType())
|
||||
.like(StrUtil.isNotBlank(queryDTO.getPathName()), SysMenu::getPathName, queryDTO.getPathName());
|
||||
if (ObjectUtil.isNotEmpty(queryDTO.getIgnoreApi())) {
|
||||
queryWrapper.ne(queryDTO.getIgnoreApi(), SysMenu::getCategory, MenuCategory.API.getCategory());
|
||||
}
|
||||
if (StrUtil.isNotBlank(queryDTO.getCategory())) {
|
||||
Object[] categories = queryDTO.getCategory().split(",");
|
||||
queryWrapper.in(SysMenu::getCategory, categories);
|
||||
}
|
||||
}
|
||||
queryWrapper.eq(SysMenu::getDelFlag, DelFlag.NO_DELETED.getFlag()).orderByAsc(SysMenu::getSortOrder);
|
||||
IPage<SysMenuVO> page = this.getBasePage(queryPage.getPage(), queryWrapper);
|
||||
return page;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addSysMenu(SysMenu sysMenu) {
|
||||
isExistMenuPathName(sysMenu.getPathName());
|
||||
if (ObjectUtil.isEmpty(sysMenu.getPid())) {
|
||||
sysMenu.setPid(0);
|
||||
}
|
||||
this.save(sysMenu);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateSysMenu(SysMenu sysMenu) {
|
||||
SysMenu checkMenu = this.getById(sysMenu.getId());
|
||||
Preconditions.checkArgument(ObjectUtil.isNotEmpty(checkMenu), 30001);
|
||||
|
||||
if (!sysMenu.getPathName().equals(checkMenu.getPathName())) {
|
||||
isExistMenuPathName(sysMenu.getPathName());
|
||||
}
|
||||
|
||||
this.updateById(sysMenu);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SysMenuVO> getUserMenuList(SysMenuQueryDTO queryDTO) {
|
||||
return this.getBaseMapper().getUserMenuList(queryDTO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 菜单路径是否存在
|
||||
*
|
||||
* @param pathName 菜单路径
|
||||
*/
|
||||
private void isExistMenuPathName(String pathName) {
|
||||
SysMenu menu = this.getOne(Wrappers.<SysMenu>lambdaQuery().eq(SysMenu::getPathName, pathName));
|
||||
Preconditions.checkArgument(ObjectUtil.isEmpty(menu), "权限路径名称已存在!");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
package com.codvision.auth.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.codvision.auth.entity.SysRoleMenu;
|
||||
import com.codvision.auth.entity.vo.SysRoleMenuVO;
|
||||
import com.codvision.auth.mapper.SysRoleMenuMapper;
|
||||
import com.codvision.auth.service.ISysRoleMenuService;
|
||||
import com.codvision.webcore.bean.QueryPage;
|
||||
import com.codvision.webcore.service.impl.BaseServiceImpl;
|
||||
import com.codvision.webcore.util.PageUtil;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 系统角色菜单权限 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author lingee
|
||||
* @since 2023-11-09
|
||||
*/
|
||||
@Service
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public class SysRoleMenuServiceImpl extends BaseServiceImpl<SysRoleMenuMapper, SysRoleMenu, SysRoleMenuVO> implements ISysRoleMenuService {
|
||||
|
||||
@Override
|
||||
public SysRoleMenuVO getDetail(Long id) {
|
||||
SysRoleMenuVO vo = new SysRoleMenuVO();
|
||||
SysRoleMenu po = this.getById(id);
|
||||
if (null != po) {
|
||||
BeanUtil.copyProperties(po, vo);
|
||||
}
|
||||
return vo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPage<SysRoleMenuVO> getPageResult(QueryPage<SysRoleMenu> queryPage) {
|
||||
QueryWrapper<SysRoleMenu> queryWrapper = queryPage.getWrapper();
|
||||
IPage<SysRoleMenuVO> pageResult = this.getBasePage(queryPage.getPage(), queryWrapper);
|
||||
return pageResult;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SysRoleMenuVO> listAll(SysRoleMenu queryBean) {
|
||||
QueryWrapper<SysRoleMenu> wrapper = PageUtil.initWrapper(queryBean);
|
||||
List<SysRoleMenu> list = this.list(wrapper);
|
||||
return BeanUtil.copyToList(list, SysRoleMenuVO.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean save(SysRoleMenu sysRoleMenu) {
|
||||
Assert.notNull(sysRoleMenu, "系统角色菜单权限不能为空");
|
||||
getBaseMapper().insert(sysRoleMenu);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateById(SysRoleMenu sysRoleMenu) {
|
||||
Assert.notNull(sysRoleMenu, "系统角色菜单权限不能为空");
|
||||
getBaseMapper().updateById(sysRoleMenu);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removeById(Serializable id) {
|
||||
SysRoleMenu sysRoleMenu = getById(id);
|
||||
Assert.notNull(sysRoleMenu, "系统角色菜单权限不存在");
|
||||
getBaseMapper().deleteById(id);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,176 @@
|
||||
package com.codvision.auth.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.codvision.auth.entity.SysMenu;
|
||||
import com.codvision.auth.entity.SysRole;
|
||||
import com.codvision.auth.entity.SysRoleMenu;
|
||||
import com.codvision.auth.entity.vo.SysRoleVO;
|
||||
import com.codvision.auth.mapper.SysMenuMapper;
|
||||
import com.codvision.auth.mapper.SysRoleMapper;
|
||||
import com.codvision.auth.mapper.SysUserMapper;
|
||||
import com.codvision.auth.service.ISysRoleMenuService;
|
||||
import com.codvision.auth.service.ISysRoleService;
|
||||
import com.codvision.auth.support.AuthConst;
|
||||
import com.codvision.webcore.bean.QueryPage;
|
||||
import com.codvision.webcore.service.impl.BaseServiceImpl;
|
||||
import com.codvision.webcore.util.PageUtil;
|
||||
import com.google.common.base.Preconditions;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 系统角色 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author lingee
|
||||
* @since 2023-11-09
|
||||
*/
|
||||
@Service
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public class SysRoleServiceImpl extends BaseServiceImpl<SysRoleMapper, SysRole, SysRoleVO> implements ISysRoleService {
|
||||
|
||||
@Resource
|
||||
private SysMenuMapper sysMenuMapper;
|
||||
|
||||
@Resource
|
||||
private ISysRoleMenuService sysRoleMenuService;
|
||||
|
||||
@Resource
|
||||
private SysUserMapper sysUserMapper;
|
||||
|
||||
@Override
|
||||
public SysRoleVO getDetail(Integer id) {
|
||||
SysRoleVO vo = new SysRoleVO();
|
||||
SysRole po = this.getById(id);
|
||||
if (null != po) {
|
||||
BeanUtil.copyProperties(po, vo);
|
||||
}
|
||||
vo.setRoleMenus(sysMenuMapper.getMenuList(id));
|
||||
return vo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPage<SysRoleVO> getPageResult(QueryPage<SysRole> queryPage) {
|
||||
LambdaQueryWrapper<SysRole> queryWrapper = Wrappers.lambdaQuery();
|
||||
SysRole queryBean = queryPage.getCondition();
|
||||
if (ObjectUtil.isNotEmpty(queryBean)) {
|
||||
if (ObjectUtil.isNotEmpty(queryBean.getId())) {
|
||||
List<Integer> roleIds = this.list(Wrappers.<SysRole>lambdaQuery()
|
||||
.eq(SysRole::getPId, queryBean.getId()).select(SysRole::getId))
|
||||
.stream().map(SysRole::getId).collect(Collectors.toList());
|
||||
if (CollectionUtil.isEmpty(roleIds)) {
|
||||
roleIds = new ArrayList<>();
|
||||
}
|
||||
roleIds.add(queryBean.getId());
|
||||
queryWrapper.in(SysRole::getId, roleIds);
|
||||
}
|
||||
}
|
||||
IPage<SysRole> pageResult = this.page(queryPage.getPage(), queryWrapper);
|
||||
List<SysRole> list = pageResult.getRecords();
|
||||
List<SysRoleVO> voList = new ArrayList<>();
|
||||
if (CollectionUtil.isNotEmpty(list)) {
|
||||
list.forEach(sysRole -> {
|
||||
SysRoleVO vo = new SysRoleVO();
|
||||
BeanUtil.copyProperties(sysRole, vo);
|
||||
vo.setRoleMenus(sysMenuMapper.getMenuList(sysRole.getId()));
|
||||
voList.add(vo);
|
||||
});
|
||||
}
|
||||
return PageUtil.convertPage(pageResult, voList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SysRoleVO> listAll(SysRole queryBean) {
|
||||
LambdaQueryWrapper<SysRole> wrapper = Wrappers.lambdaQuery();
|
||||
List<SysRole> list = this.list(wrapper.orderByDesc(SysRole::getId));
|
||||
return BeanUtil.copyToList(list, SysRoleVO.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SysRole getDefaultRole() {
|
||||
return this.getOne(Wrappers.<SysRole>lambdaQuery().eq(SysRole::getIsDefault, AuthConst.DEFAULT_ROLE_FLAG));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void logicDel(Integer id) {
|
||||
SysRole sysRole = this.getById(id);
|
||||
Preconditions.checkArgument(sysRole != null, 30001);
|
||||
Preconditions.checkArgument(sysRole.getIsDefault() != 1, "默认角色无法删除");
|
||||
|
||||
// 判断当前角色是否已有账号在使用
|
||||
int roleCount = sysUserMapper.checkUserRole(id);
|
||||
int pRoleCount = sysUserMapper.checkUserRoleByPid(id);
|
||||
Preconditions.checkArgument(roleCount <= 0 && pRoleCount <= 0, "已有账号正在使用该角色,暂无法删除");
|
||||
|
||||
this.update(Wrappers.<SysRole>lambdaUpdate().setSql("del_flag = 1, del_key = id").eq(SysRole::getId, id));
|
||||
this.update(Wrappers.<SysRole>lambdaUpdate().setSql("del_flag = 1, del_key = id").eq(SysRole::getPId, id));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRoleMenu(Integer roleId, List<Integer> menuIdList) {
|
||||
sysRoleMenuService.remove(Wrappers.<SysRoleMenu>lambdaQuery().eq(SysRoleMenu::getRoleId, roleId));
|
||||
if (CollectionUtils.isNotEmpty(menuIdList)) {
|
||||
List<SysRoleMenu> sysRoleMenus = new ArrayList<>();
|
||||
for (Integer menuId : menuIdList) {
|
||||
sysRoleMenus.add(new SysRoleMenu(roleId, menuId));
|
||||
}
|
||||
sysRoleMenuService.saveBatch(sysRoleMenus);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean save(SysRole sysRole) {
|
||||
isExistRoleName(sysRole.getRoleName());
|
||||
getBaseMapper().insert(sysRole);
|
||||
|
||||
// 设置默认权限
|
||||
List<SysMenu> defaultList = sysMenuMapper.selectList(Wrappers.<SysMenu>lambdaQuery().eq(SysMenu::getIsDefault, true));
|
||||
if (CollectionUtils.isNotEmpty(defaultList)) {
|
||||
List<SysRoleMenu> sysRoleMenus = new ArrayList<>();
|
||||
for (SysMenu sysMenu : defaultList) {
|
||||
sysRoleMenus.add(new SysRoleMenu(sysRole.getId(), sysMenu.getId()));
|
||||
}
|
||||
sysRoleMenuService.saveBatch(sysRoleMenus);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateById(SysRole sysRole) {
|
||||
Assert.notNull(sysRole, "系统角色不能为空");
|
||||
Assert.notNull(sysRole.getId(), "系统角色id不能为空");
|
||||
|
||||
SysRole role = this.getById(sysRole.getId());
|
||||
Preconditions.checkArgument(ObjectUtil.isNotEmpty(role), 30001);
|
||||
if (StringUtils.isNotBlank(sysRole.getRoleName()) && !sysRole.getRoleName().equals(role.getRoleName())) {
|
||||
isExistRoleName(sysRole.getRoleName());
|
||||
}
|
||||
|
||||
getBaseMapper().updateById(sysRole);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断角色名称是否存在
|
||||
*
|
||||
* @param roleName 角色名称
|
||||
*/
|
||||
private void isExistRoleName(String roleName) {
|
||||
SysRole role = this.getOne(Wrappers.<SysRole>lambdaQuery().eq(SysRole::getRoleName, roleName));
|
||||
Preconditions.checkArgument(ObjectUtil.isEmpty(role), "角色名称已存在!");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,617 @@
|
||||
package com.codvision.auth.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.date.DatePattern;
|
||||
import cn.hutool.core.date.DateUnit;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.date.LocalDateTimeUtil;
|
||||
import cn.hutool.core.lang.Validator;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.crypto.asymmetric.SignAlgorithm;
|
||||
import cn.hutool.extra.spring.SpringUtil;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.alibaba.excel.EasyExcel;
|
||||
import com.alibaba.excel.context.AnalysisContext;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.codvision.auth.entity.Org;
|
||||
import com.codvision.auth.entity.SysRole;
|
||||
import com.codvision.auth.entity.SysUser;
|
||||
import com.codvision.auth.entity.UserOrgRole;
|
||||
import com.codvision.auth.entity.dto.SysOrgQueryDTO;
|
||||
import com.codvision.auth.entity.dto.SysUserDTO;
|
||||
import com.codvision.auth.entity.dto.SysUserQueryDTO;
|
||||
import com.codvision.auth.entity.excel.SysUserExcel;
|
||||
import com.codvision.auth.entity.vo.OrgVO;
|
||||
import com.codvision.auth.entity.vo.QuickLoginVO;
|
||||
import com.codvision.auth.entity.vo.SysUserVO;
|
||||
import com.codvision.auth.entity.vo.UserOrgRoleVO;
|
||||
import com.codvision.auth.mapper.OrgMapper;
|
||||
import com.codvision.auth.mapper.SysRoleMapper;
|
||||
import com.codvision.auth.mapper.SysUserMapper;
|
||||
import com.codvision.auth.mapper.UserOrgRoleMapper;
|
||||
import com.codvision.auth.service.IOrgService;
|
||||
import com.codvision.auth.service.ISysRoleService;
|
||||
import com.codvision.auth.service.ISysUserService;
|
||||
import com.codvision.auth.service.IUserOrgRoleService;
|
||||
import com.codvision.base.config.excel.AbstractExportClass;
|
||||
import com.codvision.base.config.excel.ExcelDataReadListener;
|
||||
import com.codvision.base.entity.ExcelCheck;
|
||||
import com.codvision.base.entity.ExcelErrorRecord;
|
||||
import com.codvision.base.entity.SysConfig;
|
||||
import com.codvision.base.service.ISysConfigService;
|
||||
import com.codvision.commoncore.exception.BusinessException;
|
||||
import com.codvision.commoncore.utils.*;
|
||||
import com.codvision.webcore.bean.QueryPage;
|
||||
import com.codvision.webcore.service.impl.BaseServiceImpl;
|
||||
import com.codvision.webcore.util.PageUtil;
|
||||
import com.google.common.base.Preconditions;
|
||||
import lombok.SneakyThrows;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.*;
|
||||
|
||||
import static com.codvision.auth.support.AuthConst.PWD_CHECK_FLAG;
|
||||
import static com.codvision.base.support.BaseConst.SLASH_SYMBOL;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 系统用户 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author lingee
|
||||
* @since 2023-11-09
|
||||
*/
|
||||
@Service
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public class SysUserServiceImpl extends BaseServiceImpl<SysUserMapper, SysUser, SysUserVO> implements ISysUserService {
|
||||
|
||||
@Resource
|
||||
private SysUserMapper sysUserMapper;
|
||||
|
||||
@Resource
|
||||
private ISysConfigService sysConfigService;
|
||||
|
||||
@Resource
|
||||
private BCryptPasswordEncoder bCryptEncode;
|
||||
|
||||
@Resource
|
||||
private IUserOrgRoleService userOrgRoleService;
|
||||
|
||||
@Resource
|
||||
private UserOrgRoleMapper userOrgRoleMapper;
|
||||
|
||||
@Resource
|
||||
private IOrgService orgService;
|
||||
|
||||
@Resource
|
||||
private ISysRoleService sysRoleService;
|
||||
|
||||
@Resource
|
||||
private SysRoleMapper sysRoleMapper;
|
||||
|
||||
@Resource
|
||||
private OrgMapper orgMapper;
|
||||
|
||||
@Override
|
||||
public SysUserVO getDetail(Integer id) {
|
||||
SysUserVO vo = new SysUserVO();
|
||||
SysUser po = this.getById(id);
|
||||
if (null != po) {
|
||||
BeanUtil.copyProperties(po, vo);
|
||||
}
|
||||
return initTarget(vo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void batchResetPwd(List<Integer> userIds) {
|
||||
SysConfig sysConfig = sysConfigService.getByKey("GLOBAL_DEFAULT_PWD");
|
||||
Preconditions.checkArgument(ObjectUtil.isNotEmpty(sysConfig) && StrUtil.isNotBlank(sysConfig.getV()),
|
||||
"请于系统配置界面内设置全局默认密码!");
|
||||
|
||||
String pwd = bCryptEncode.encode(sysConfig.getV());
|
||||
List<SysUser> sysUserList = new ArrayList<>();
|
||||
for (Integer uid : userIds) {
|
||||
SysUser sysUser = new SysUser();
|
||||
sysUser.setId(uid);
|
||||
sysUser.setPassword(pwd);
|
||||
sysUserList.add(sysUser);
|
||||
}
|
||||
this.updateBatchById(sysUserList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void activeOrgRole(UserOrgRole userOrgRole, SysUserVO sysUserVO) {
|
||||
UserOrgRole isExist = userOrgRoleService.getUserOrgRole(userOrgRole.getUid(), userOrgRole.getOid(), userOrgRole.getRoleId());
|
||||
Preconditions.checkArgument(isExist != null, "切换用户组织角色失败,请重试");
|
||||
initCurrentActiveUserInfo(sysUserVO, userOrgRole.getOid(), userOrgRole.getRoleId());
|
||||
|
||||
UserOrgRole updateBean = new UserOrgRole();
|
||||
updateBean.setUpdateTime(new Date());
|
||||
userOrgRoleService.update(updateBean, Wrappers.<UserOrgRole>lambdaUpdate()
|
||||
.eq(UserOrgRole::getUid, userOrgRole.getUid())
|
||||
.eq(UserOrgRole::getOid, userOrgRole.getOid())
|
||||
.eq(UserOrgRole::getRoleId, userOrgRole.getRoleId()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public SysUserVO getDetailByLoginName(String loginName) {
|
||||
SysUserVO vo = getByLoginName(loginName);
|
||||
if (ObjectUtil.isEmpty(vo)) {
|
||||
return null;
|
||||
}
|
||||
return initTarget(vo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRenewPwd(String username) {
|
||||
// 系统用户密码定期更新提醒开关(ON:启用 OFF:关闭)
|
||||
SysConfig config = sysConfigService.getByKey("PWD_UPDATE_REMIND_SWITCH");
|
||||
if (config != null && PWD_CHECK_FLAG.equals(config.getV())) {
|
||||
SysConfig dayConfig = sysConfigService.getByKey("PWD_UPDATE_REMIND_INTERVAL_DAYS");
|
||||
if (dayConfig != null) {
|
||||
int intervalDays;
|
||||
try {
|
||||
intervalDays = Integer.parseInt(dayConfig.getV());
|
||||
} catch (NumberFormatException e) {
|
||||
// 非数据类型(含空值),间隔天数默认设置为30天
|
||||
intervalDays = 30;
|
||||
}
|
||||
|
||||
SysUser sysUser = this.getOne(Wrappers.<SysUser>lambdaQuery().eq(SysUser::getLoginName, username));
|
||||
if (sysUser != null) {
|
||||
Date pwdLastUpdatedTime = sysUser.getPwdLastUpdatedTime();
|
||||
if (ObjectUtil.isNotEmpty(pwdLastUpdatedTime)) {
|
||||
return DateUtil.between(pwdLastUpdatedTime, new Date(), DateUnit.DAY) >= intervalDays;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String quickLogin(String token, String userInformation) {
|
||||
List<SysConfig> configs = sysConfigService.getListByKeys(Arrays.asList("QUICK_LOGIN_PRIVATE_KEY",
|
||||
"QUICK_LOGIN_PUBLIC_KEY", "QUICK_LOGIN_APP_ID", "QUICK_LOGIN_APP_KEY", "QUICK_LOGIN_URL"));
|
||||
Preconditions.checkArgument(!(CollectionUtils.isEmpty(configs) || configs.size() < 5), "请核查相关配置信息");
|
||||
|
||||
Map<String, String> configMap = new HashMap<>(16);
|
||||
for (SysConfig config : configs) {
|
||||
Preconditions.checkArgument(StringUtils.isNotBlank(config.getV()), "请核查相关配置信息");
|
||||
configMap.put(config.getK(), config.getV());
|
||||
}
|
||||
|
||||
String version = "1.0";
|
||||
String timestamp = LocalDateTimeUtil.format(LocalDateTimeUtil.now(), DatePattern.PURE_DATETIME_MS_PATTERN);
|
||||
String traceId = UUID.randomUUID().toString();
|
||||
JSONObject params = new JSONObject();
|
||||
params.put("userInformation", userInformation);
|
||||
params.put("token", token);
|
||||
String data = configMap.get("QUICK_LOGIN_APP_ID") + traceId + timestamp + token + version;
|
||||
LySign lySign = LySign.of(SignAlgorithm.SHA256withRSA, configMap.get("QUICK_LOGIN_PRIVATE_KEY"), configMap.get("QUICK_LOGIN_PUBLIC_KEY"), false);
|
||||
params.put("sign", lySign.sign(data));
|
||||
Map<String, String> headers = new HashMap<>();
|
||||
headers.put("interfaceVersion", version);
|
||||
headers.put("appId", configMap.get("QUICK_LOGIN_APP_ID"));
|
||||
headers.put("traceId", traceId);
|
||||
headers.put("timestamp", timestamp);
|
||||
headers.put("businessType", "8");
|
||||
String response = HttpClientUtils.doPost(configMap.get("QUICK_LOGIN_URL"), headers, params.toString());
|
||||
|
||||
QuickLoginVO quickLoginVO = JSONUtil.toBean(response, QuickLoginVO.class);
|
||||
if (!"103000".equals(quickLoginVO.getResultCode())) {
|
||||
throw new BusinessException(quickLoginVO.getDesc());
|
||||
}
|
||||
|
||||
String appKey = configMap.get("QUICK_LOGIN_APP_KEY");
|
||||
if (appKey.length() > 16) {
|
||||
appKey = appKey.substring(0, 16);
|
||||
} else {
|
||||
appKey = StringUtils.rightPad(appKey, 16, "0");
|
||||
}
|
||||
|
||||
AesUtil aes = new AesUtil(appKey);
|
||||
return new String(aes.decryptBase64(quickLoginVO.getData().getMsisdn()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loginByMobile(String mobile) {
|
||||
SysUserVO userVO = this.getByLoginName(mobile);
|
||||
if (userVO == null) {
|
||||
SysUser sysUser = new SysUser();
|
||||
sysUser.setLoginName(mobile);
|
||||
sysUser.setName(mobile);
|
||||
sysUser.setMobile(mobile);
|
||||
this.save(sysUser);
|
||||
|
||||
UserOrgRole userOrgRole = new UserOrgRole();
|
||||
userOrgRole.setUid(sysUser.getId());
|
||||
|
||||
Org defaultOrg = orgService.getDefaultOrg();
|
||||
Preconditions.checkArgument(defaultOrg != null, "暂无任何组织信息");
|
||||
userOrgRole.setOid(defaultOrg.getOid());
|
||||
|
||||
SysRole defaultRole = sysRoleService.getDefaultRole();
|
||||
Preconditions.checkArgument(defaultRole != null, "暂无默认角色");
|
||||
userOrgRole.setRoleId(defaultRole.getId());
|
||||
userOrgRoleMapper.insert(userOrgRole);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer addSysUser(SysUserDTO sysUserDTO) {
|
||||
// 获取明文密码
|
||||
String password = DecPwdUtil.decryptAes(sysUserDTO.getPassword());
|
||||
// 弱密码过滤
|
||||
boolean isNotWeak = CheckPwdUtil.checkPasswordRule(sysUserDTO.getLoginName(), password);
|
||||
if (!isNotWeak) {
|
||||
throw new BusinessException(30001, "密码必须包括大小写字母、数字和特殊符号,长度8-15位且不能与用户名相同!");
|
||||
}
|
||||
// 检查登陆名是否已存在
|
||||
SysUser checkUser = this.getByLoginName(sysUserDTO.getLoginName());
|
||||
Preconditions.checkArgument(checkUser == null, "用户名已存在!");
|
||||
|
||||
SysUser sysUser = new SysUser();
|
||||
BeanUtils.copyProperties(sysUserDTO, sysUser);
|
||||
// 采用BCrypt算法加密存储入库
|
||||
sysUser.setPassword(bCryptEncode.encode(password));
|
||||
this.save(sysUser);
|
||||
|
||||
// 设置用户与组织、角色的关系
|
||||
if (CollectionUtil.isNotEmpty(sysUserDTO.getUserOrgRoles())) {
|
||||
for (UserOrgRole userOrgRole : sysUserDTO.getUserOrgRoles()) {
|
||||
Preconditions.checkArgument(!(null == userOrgRole.getRoleId() || null == userOrgRole.getOid()), 30002);
|
||||
userOrgRole.setUid(sysUser.getId());
|
||||
userOrgRoleMapper.insert(userOrgRole);
|
||||
}
|
||||
}
|
||||
return sysUser.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SysUserVO getDetailByUid(Integer uid) {
|
||||
SysUserVO vo = getDetail(uid);
|
||||
|
||||
UserOrgRoleVO activeOrgRole = userOrgRoleMapper.getLatestInfoDetail(uid);
|
||||
if (ObjectUtil.isNotEmpty(activeOrgRole)) {
|
||||
activeOrgRole.setRole(sysRoleService.getDetail(activeOrgRole.getRoleId()));
|
||||
vo.setActiveOrgRole(activeOrgRole);
|
||||
vo.setActiveOid(activeOrgRole.getOid());
|
||||
vo.setActiveRoleId(activeOrgRole.getRoleId());
|
||||
vo.setActiveRoleCode(activeOrgRole.getRoleCode());
|
||||
}
|
||||
|
||||
List<UserOrgRoleVO> userOrgRoles = userOrgRoleMapper.getUserOrgRoleList(uid);
|
||||
if (CollectionUtil.isNotEmpty(userOrgRoles)) {
|
||||
userOrgRoles.forEach(userOrgRole -> {
|
||||
userOrgRole.setRole(sysRoleService.getDetail(userOrgRole.getRoleId()));
|
||||
});
|
||||
vo.setOrgRoles(userOrgRoles);
|
||||
}
|
||||
return vo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPage<SysUserVO> findAll(QueryPage<SysUser> queryPage, SysUserQueryDTO queryDTO) {
|
||||
IPage<SysUser> page = queryPage.getPage();
|
||||
List<SysUserVO> sysUserList = sysUserMapper.findAll(page, queryDTO);
|
||||
sysUserList.forEach(sysUserVO -> sysUserVO.setAssociatedInfos(userOrgRoleMapper.getAssociatedInfos(sysUserVO.getId())));
|
||||
return PageUtil.convertPage(page, sysUserList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SysUserVO> listUsers(Map<String, Object> params) {
|
||||
List<SysUserVO> sysUserList = sysUserMapper.listUsers(params);
|
||||
if (CollectionUtils.isNotEmpty(sysUserList)) {
|
||||
sysUserList.forEach(sysUserVO -> sysUserVO.setAssociatedInfos(userOrgRoleMapper.getAssociatedInfos(sysUserVO.getId())));
|
||||
|
||||
}
|
||||
return sysUserList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateUser(SysUserDTO sysUserDTO) {
|
||||
SysUser checkSysUser = this.getById(sysUserDTO.getId());
|
||||
if (ObjectUtil.isEmpty(checkSysUser)) {
|
||||
throw new BusinessException(30001);
|
||||
}
|
||||
|
||||
if (StringUtils.isNotBlank(sysUserDTO.getLoginName()) && !sysUserDTO.getLoginName().equals(checkSysUser.getLoginName())) {
|
||||
SysUser sysUser = getByLoginName(sysUserDTO.getLoginName());
|
||||
Preconditions.checkArgument(sysUser == null, "用户名已存在!");
|
||||
}
|
||||
|
||||
SysUser sysUser = new SysUser();
|
||||
BeanUtils.copyProperties(sysUserDTO, sysUser);
|
||||
|
||||
// 判断是否修改密码
|
||||
if (checkModifyPwd(sysUserDTO, sysUser)) {
|
||||
sysUser.setPwdLastUpdatedTime(new Date());
|
||||
}
|
||||
// 更新用户信息
|
||||
this.updateById(sysUser);
|
||||
|
||||
// 是否修改组织与角色
|
||||
if (CollectionUtils.isNotEmpty(sysUserDTO.getUserOrgRoles())) {
|
||||
userOrgRoleMapper.delete(Wrappers.<UserOrgRole>lambdaQuery().eq(UserOrgRole::getUid, sysUser.getId()));
|
||||
for (UserOrgRole userOrgRole : sysUserDTO.getUserOrgRoles()) {
|
||||
Preconditions.checkArgument(!((null == userOrgRole.getRoleId() && null == userOrgRole.getRoleCode())
|
||||
|| null == userOrgRole.getOid()), 30002);
|
||||
userOrgRole.setUid(sysUser.getId());
|
||||
if (StringUtils.isNotBlank(userOrgRole.getRoleCode())) {
|
||||
SysRole sysRole = sysRoleMapper.selectOne(Wrappers.<SysRole>lambdaQuery()
|
||||
.eq(SysRole::getRoleCode, userOrgRole.getRoleCode()).last("limit 1"));
|
||||
Preconditions.checkArgument(sysRole != null, 30001);
|
||||
userOrgRole.setRoleId(sysRole.getId());
|
||||
}
|
||||
userOrgRoleMapper.insert(userOrgRole);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SneakyThrows
|
||||
public String excelImport(MultipartFile file) {
|
||||
// 优先获取组织和角色信息列表,避免数据校验或操作时需要频繁的进行数据库操作
|
||||
Map<String, Object> paraMap = new HashMap<>(16);
|
||||
SysOrgQueryDTO queryDTO = new SysOrgQueryDTO();
|
||||
queryDTO.setIsIgnoreWkt(true);
|
||||
List<OrgVO> orgList = orgMapper.findAll(null, queryDTO);
|
||||
Preconditions.checkArgument(CollectionUtils.isNotEmpty(orgList), "暂无任何组织信息,请至组织管理添加组织信息");
|
||||
List<SysRole> sysRoleList = sysRoleService.list();
|
||||
Preconditions.checkArgument(CollectionUtils.isNotEmpty(sysRoleList), "暂无任何角色信息,请至角色管理添加角色信息");
|
||||
|
||||
String reqNo = IdUtil.fastSimpleUUID();
|
||||
ISysUserService service = SpringUtil.getBean(ISysUserService.class);
|
||||
ExcelDataReadListener<SysUserExcel> listener = new ExcelDataReadListener<SysUserExcel>(cachedDataList -> service.excelSave(cachedDataList, orgList, sysRoleList)) {
|
||||
@Override
|
||||
protected void validator(SysUserExcel sysUserExcel, ExcelCheck<SysUserExcel> check, AnalysisContext context) {
|
||||
checkOne(reqNo, sysUserExcel, check, context.readRowHolder().getRowIndex(), orgList, sysRoleList);
|
||||
}
|
||||
};
|
||||
EasyExcel.read(file.getInputStream(), SysUserExcel.class, listener).sheet().doRead();
|
||||
if (listener.isHeadAbnormal()) {
|
||||
throw new BusinessException("文件格式错误,请检查导入模板");
|
||||
}
|
||||
|
||||
return listener.existErrorData() ? reqNo : null;
|
||||
}
|
||||
|
||||
|
||||
private void checkOne(String reqNo, SysUserExcel sysUserExcel, ExcelCheck<SysUserExcel> check, Integer rowIndex, List<OrgVO> orgList, List<SysRole> sysRoleList) {
|
||||
Map<String, Object> fieldsErrorMap = new HashMap<>(16);
|
||||
if (StringUtils.isBlank(sysUserExcel.getName())) {
|
||||
fieldsErrorMap.put("name", "姓名必填");
|
||||
}
|
||||
if (StringUtils.isBlank(sysUserExcel.getMobile())) {
|
||||
fieldsErrorMap.put("mobile", "联系方式必填");
|
||||
} else {
|
||||
if (!Validator.isMobile(sysUserExcel.getMobile())) {
|
||||
fieldsErrorMap.put("mobile", "联系方式格式错误");
|
||||
}
|
||||
}
|
||||
|
||||
String orgName = sysUserExcel.getOrgName();
|
||||
if (StringUtils.isBlank(orgName)) {
|
||||
fieldsErrorMap.put("orgName", "组织名称必填");
|
||||
} else {
|
||||
if (!(orgName.startsWith(SLASH_SYMBOL) && orgName.endsWith(SLASH_SYMBOL))) {
|
||||
fieldsErrorMap.put("orgName", "格式错误");
|
||||
} else {
|
||||
Optional<OrgVO> optional = orgList.stream().filter(org -> orgName.equals(org.getPath())).findFirst();
|
||||
if (!optional.isPresent()) {
|
||||
fieldsErrorMap.put("orgName", "系统内无相关组织信息");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (StringUtils.isBlank(sysUserExcel.getRole())) {
|
||||
fieldsErrorMap.put("role", "角色名称必填");
|
||||
} else {
|
||||
Optional<SysRole> optional = sysRoleList.stream().filter(role -> sysUserExcel.getRole().equals(role.getRoleName())).findFirst();
|
||||
if (!optional.isPresent()) {
|
||||
fieldsErrorMap.put("role", "系统内无相关角色信息");
|
||||
}
|
||||
}
|
||||
|
||||
if (fieldsErrorMap.isEmpty()) {
|
||||
check.getCacheList().add(sysUserExcel);
|
||||
} else {
|
||||
ExcelErrorRecord record = new ExcelErrorRecord();
|
||||
record.setReqNo(reqNo);
|
||||
record.setRowIndex(rowIndex);
|
||||
record.setOriginalJsonValue(JSONUtil.toJsonStr(sysUserExcel));
|
||||
record.setErrorMsgJson(JSONUtil.toJsonStr(fieldsErrorMap));
|
||||
record.setTargetObject(sysUserExcel.getClass().getName());
|
||||
check.getErrorList().add(record);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void excelSave(List<SysUserExcel> cachedDataList, List<OrgVO> orgList, List<SysRole> sysRoleList) {
|
||||
if (CollectionUtils.isNotEmpty(cachedDataList)) {
|
||||
List<UserOrgRole> userOrgRoles = new ArrayList<>();
|
||||
for (SysUserExcel sysUserExcel : cachedDataList) {
|
||||
SysUser sysUser = this.getOne(Wrappers.<SysUser>lambdaQuery().eq(SysUser::getMobile, sysUserExcel.getMobile()));
|
||||
if (sysUser == null) {
|
||||
sysUser = new SysUser();
|
||||
sysUser.setLoginName(sysUserExcel.getMobile());
|
||||
sysUser.setPassword(bCryptEncode.encode(sysUserExcel.getMobile()));
|
||||
sysUser.setMobile(sysUserExcel.getMobile());
|
||||
sysUser.setName(sysUserExcel.getName());
|
||||
this.save(sysUser);
|
||||
|
||||
// 添加用户、组织与角色的关联关系
|
||||
UserOrgRole userOrgRole = new UserOrgRole();
|
||||
userOrgRole.setUid(sysUser.getId());
|
||||
Optional<OrgVO> orgOptional = orgList.stream().filter(org -> sysUserExcel.getOrgName().equals(org.getPath())).findFirst();
|
||||
orgOptional.ifPresent(org -> userOrgRole.setOid(org.getOid()));
|
||||
Optional<SysRole> roleOptional = sysRoleList.stream().filter(role -> sysUserExcel.getRole().equals(role.getRoleName())).findFirst();
|
||||
roleOptional.ifPresent(role -> userOrgRole.setRoleId(role.getId()));
|
||||
userOrgRoles.add(userOrgRole);
|
||||
}
|
||||
}
|
||||
if (CollectionUtil.isNotEmpty(userOrgRoles)) {
|
||||
userOrgRoleService.saveBatch(userOrgRoles);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void excelExport(SysUserQueryDTO queryDTO) {
|
||||
new AbstractExportClass<SysUserExcel, SysUser>() {
|
||||
@Override
|
||||
protected List<SysUserExcel> getList(QueryPage<SysUser> queryPage, Object queryBean) {
|
||||
List<SysUserExcel> excelList = new ArrayList<>();
|
||||
List<SysUserVO> sysUserVOList = getBaseMapper().findAll(null, (SysUserQueryDTO) queryBean);
|
||||
if (CollectionUtils.isNotEmpty(sysUserVOList)) {
|
||||
for (SysUserVO sysUserVO : sysUserVOList) {
|
||||
SysUserExcel sysUserExcel = new SysUserExcel();
|
||||
sysUserExcel.setName(sysUserVO.getName());
|
||||
sysUserExcel.setMobile(sysUserVO.getMobile());
|
||||
sysUserExcel.setOrgName(sysUserVO.getActiveOrgPath());
|
||||
sysUserExcel.setRole(sysUserVO.getActiveRoleName());
|
||||
excelList.add(sysUserExcel);
|
||||
}
|
||||
}
|
||||
return excelList;
|
||||
}
|
||||
}.excelUser("用户信息表", queryDTO, SysUserExcel.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SysUserVO getByDingTalkUid(String dingTalkUid) {
|
||||
SysUser po = this.getOne(Wrappers.<SysUser>lambdaQuery().eq(SysUser::getDingTalkUid, dingTalkUid).last("limit 1"));
|
||||
SysUserVO vo = new SysUserVO();
|
||||
if (ObjectUtil.isEmpty(po)) {
|
||||
return null;
|
||||
}
|
||||
BeanUtil.copyProperties(po, vo);
|
||||
vo.setAssociatedInfos(userOrgRoleMapper.getAssociatedInfos(vo.getId()));
|
||||
return initTarget(vo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SysUserVO getByZzdId(String zzdId) {
|
||||
SysUser po = this.getOne(Wrappers.<SysUser>lambdaQuery().eq(SysUser::getZzdId, zzdId).last("limit 1"));
|
||||
SysUserVO vo = new SysUserVO();
|
||||
if (ObjectUtil.isEmpty(po)) {
|
||||
return null;
|
||||
}
|
||||
BeanUtil.copyProperties(po, vo);
|
||||
vo.setAssociatedInfos(userOrgRoleMapper.getAssociatedInfos(vo.getId()));
|
||||
return initTarget(vo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据登录名获取用户信息
|
||||
*
|
||||
* @param loginName 登录名
|
||||
* @return 用户信息
|
||||
*/
|
||||
private SysUserVO getByLoginName(String loginName) {
|
||||
SysUser po = this.getOne(Wrappers.<SysUser>lambdaQuery().eq(SysUser::getLoginName, loginName));
|
||||
SysUserVO vo = new SysUserVO();
|
||||
if (ObjectUtil.isEmpty(po)) {
|
||||
return null;
|
||||
}
|
||||
BeanUtil.copyProperties(po, vo);
|
||||
vo.setAssociatedInfos(userOrgRoleMapper.getAssociatedInfos(vo.getId()));
|
||||
return vo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断是否修改密码
|
||||
*
|
||||
* @param sysUserDTO 输入用户信息
|
||||
* @param sysUser 已有用户信息
|
||||
*/
|
||||
private boolean checkModifyPwd(SysUserDTO sysUserDTO, SysUser sysUser) {
|
||||
if (StringUtils.isNotBlank(sysUserDTO.getOldPwd()) && StringUtils.isNotBlank(sysUserDTO.getNewPwd())) {
|
||||
SysUser checkUser = this.getById(sysUserDTO.getId());
|
||||
Preconditions.checkArgument(checkUser != null, 30001);
|
||||
|
||||
// 获取明文密码
|
||||
String oldPwd = DecPwdUtil.decryptAes(sysUserDTO.getOldPwd());
|
||||
Preconditions.checkArgument(bCryptEncode.matches(oldPwd, checkUser.getPassword()), "旧密码验证失败!");
|
||||
// 设置新密码
|
||||
String newPwd = DecPwdUtil.decryptAes(sysUserDTO.getNewPwd());
|
||||
// 弱密码过滤
|
||||
boolean isNotWeak = CheckPwdUtil.checkPasswordRule(checkUser.getLoginName(), newPwd);
|
||||
if (!isNotWeak) {
|
||||
throw new BusinessException(30001, "密码必须包括大小写字母、数字和特殊符号,长度8-15位且不能与用户名相同!");
|
||||
}
|
||||
sysUser.setPassword(bCryptEncode.encode(newPwd));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private SysUserVO initTarget(SysUserVO sysUserVO) {
|
||||
if (ObjectUtil.isEmpty(sysUserVO)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
UserOrgRole userOrgRole = userOrgRoleMapper.getLatestInfo(sysUserVO.getId());
|
||||
if (ObjectUtil.isEmpty(userOrgRole)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
initCurrentActiveUserInfo(sysUserVO, userOrgRole.getOid(), userOrgRole.getRoleId());
|
||||
return sysUserVO;
|
||||
}
|
||||
|
||||
private void initCurrentActiveUserInfo(SysUserVO sysUserVO, Integer oid, Integer roleId) {
|
||||
if (oid == null || roleId == null || sysUserVO == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Org org = orgService.getById(oid);
|
||||
Preconditions.checkArgument(org != null, "获取组织信息失败!");
|
||||
sysUserVO.setActiveOrgName(org.getName());
|
||||
sysUserVO.setActiveOid(org.getOid());
|
||||
sysUserVO.setActivePoid(org.getPoid());
|
||||
sysUserVO.setActiveOrgPath(org.getPath());
|
||||
|
||||
SysRole sysRole = sysRoleService.getById(roleId);
|
||||
Preconditions.checkArgument(sysRole != null, "获取角色信息失败!");
|
||||
sysUserVO.setActiveRoleId(sysRole.getId());
|
||||
sysUserVO.setActiveRoleName(sysRole.getRoleName());
|
||||
sysUserVO.setActiveRoleCode(sysRole.getRoleCode());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SysUserVO> getListByIds(List<Integer> uidList) {
|
||||
List<SysUserVO> sysUserVOS = new ArrayList<>();
|
||||
List<SysUser> sysUsers = getBaseMapper().selectBatchIds(uidList);
|
||||
for (SysUser sysUser : sysUsers) {
|
||||
SysUserVO sysUserVO = new SysUserVO();
|
||||
BeanUtil.copyProperties(sysUser, sysUserVO);
|
||||
UserOrgRoleVO activeOrgRole = userOrgRoleMapper.getLatestInfoDetail(sysUser.getId());
|
||||
if (activeOrgRole != null) {
|
||||
sysUserVO.setActiveOrgRole(activeOrgRole);
|
||||
}
|
||||
|
||||
List<UserOrgRoleVO> userOrgRoleList = userOrgRoleMapper.getUserOrgRoleList(sysUser.getId());
|
||||
if (CollectionUtils.isNotEmpty(userOrgRoleList)) {
|
||||
sysUserVO.setOrgRoles(userOrgRoleList);
|
||||
}
|
||||
|
||||
sysUserVOS.add(sysUserVO);
|
||||
}
|
||||
|
||||
return sysUserVOS;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
package com.codvision.auth.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.codvision.auth.entity.UserOrgRole;
|
||||
import com.codvision.auth.entity.vo.UserOrgRoleVO;
|
||||
import com.codvision.auth.mapper.UserOrgRoleMapper;
|
||||
import com.codvision.auth.service.IUserOrgRoleService;
|
||||
import com.codvision.webcore.bean.QueryPage;
|
||||
import com.codvision.webcore.service.impl.BaseServiceImpl;
|
||||
import com.codvision.webcore.util.PageUtil;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 组织用户关联信息 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author lingee
|
||||
* @since 2023-11-10
|
||||
*/
|
||||
@Service
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public class UserOrgRoleServiceImpl extends BaseServiceImpl<UserOrgRoleMapper, UserOrgRole, UserOrgRoleVO>
|
||||
implements IUserOrgRoleService {
|
||||
|
||||
@Override
|
||||
public UserOrgRoleVO getDetail(Long id) {
|
||||
UserOrgRoleVO vo = new UserOrgRoleVO();
|
||||
UserOrgRole po = this.getById(id);
|
||||
if (null != po) {
|
||||
BeanUtil.copyProperties(po, vo);
|
||||
}
|
||||
return vo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPage<UserOrgRoleVO> getPageResult(QueryPage<UserOrgRole> queryPage) {
|
||||
QueryWrapper<UserOrgRole> queryWrapper = queryPage.getWrapper();
|
||||
IPage<UserOrgRoleVO> pageResult = this.getBasePage(queryPage.getPage(), queryWrapper);
|
||||
return pageResult;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UserOrgRoleVO> listAll(UserOrgRole queryBean) {
|
||||
QueryWrapper<UserOrgRole> wrapper = PageUtil.initWrapper(queryBean);
|
||||
List<UserOrgRole> list = this.list(wrapper);
|
||||
return BeanUtil.copyToList(list, UserOrgRoleVO.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserOrgRole getUserOrgRole(Integer uid, Integer oid, Integer roleId) {
|
||||
return this.getOne(Wrappers.<UserOrgRole>lambdaQuery().eq(UserOrgRole::getUid, uid)
|
||||
.eq(UserOrgRole::getOid, oid).eq(UserOrgRole::getRoleId, roleId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean save(UserOrgRole orgUserMapper) {
|
||||
Assert.notNull(orgUserMapper, "组织用户关联信息不能为空");
|
||||
getBaseMapper().insert(orgUserMapper);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateById(UserOrgRole orgUserMapper) {
|
||||
Assert.notNull(orgUserMapper, "组织用户关联信息不能为空");
|
||||
getBaseMapper().updateById(orgUserMapper);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removeById(Serializable id) {
|
||||
UserOrgRole orgUserMapper = getById(id);
|
||||
Assert.notNull(orgUserMapper, "组织用户关联信息不存在");
|
||||
getBaseMapper().deleteById(id);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,193 @@
|
||||
package com.codvision.auth.service.third;
|
||||
|
||||
import com.codvision.auth.entity.ding.DingConfig;
|
||||
import com.codvision.auth.entity.ding.DingEnv;
|
||||
import com.codvision.base.service.ISysConfigService;
|
||||
import com.codvision.cachecore.utils.RedisUtil;
|
||||
import com.codvision.commoncore.exception.BusinessException;
|
||||
import com.dingtalk.api.DefaultDingTalkClient;
|
||||
import com.dingtalk.api.DingTalkClient;
|
||||
import com.dingtalk.api.request.*;
|
||||
import com.dingtalk.api.response.*;
|
||||
import com.taobao.api.ApiException;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.annotation.Resource;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.Formatter;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static com.codvision.auth.support.CacheContants.DING_TALK_JSAPI_TICKET;
|
||||
import static com.codvision.auth.support.CacheContants.DING_TALK_TOKEN;
|
||||
|
||||
|
||||
/**
|
||||
* 普通钉钉服务
|
||||
*
|
||||
* @author hxl
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class DingTalkService {
|
||||
|
||||
@Resource
|
||||
private ISysConfigService configService;
|
||||
|
||||
private static DingEnv dingEnv;
|
||||
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
dingEnv = DingEnv.builder().dingAppKey(configService.getValueByKey("DING_APP_KEY")).dingAppSecret(configService.getValueByKey("DING_APP_SECRET"))
|
||||
.dingAgentId(configService.getValueByKey("DING_AGENT_ID")).dingCorpId(configService.getValueByKey("DING_CORP_ID")).build();
|
||||
}
|
||||
|
||||
public String getAccessToken() throws ApiException {
|
||||
String dingTalkToken = RedisUtil.get(DING_TALK_TOKEN);
|
||||
if (StringUtils.isNotBlank(dingTalkToken)) {
|
||||
return dingTalkToken;
|
||||
}
|
||||
|
||||
DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/gettoken");
|
||||
OapiGettokenRequest request = new OapiGettokenRequest();
|
||||
request.setAppkey(dingEnv.getDingAppKey());
|
||||
request.setAppsecret(dingEnv.getDingAppSecret());
|
||||
request.setHttpMethod("GET");
|
||||
OapiGettokenResponse rsp = client.execute(request);
|
||||
if (rsp.getErrcode() != 0) {
|
||||
log.error("The errMsg is 【{}】", rsp.getErrmsg());
|
||||
throw new BusinessException(rsp.getErrmsg());
|
||||
}
|
||||
|
||||
dingTalkToken = rsp.getAccessToken();
|
||||
// access_token的有效期为7200秒(2小时),有效期内重复获取会返回相同结果并自动续期,过期后获取会返回新的access_token。
|
||||
// 防止临界过期问题,缓存失效时间比实际过期时间设置的偏低
|
||||
RedisUtil.set(DING_TALK_TOKEN, dingTalkToken, 119, TimeUnit.MINUTES);
|
||||
return dingTalkToken;
|
||||
}
|
||||
|
||||
public String getJsapiTicket() throws ApiException {
|
||||
String dingTalkJsapiTicket = RedisUtil.get(DING_TALK_JSAPI_TICKET);
|
||||
if (StringUtils.isNotBlank(dingTalkJsapiTicket)) {
|
||||
return dingTalkJsapiTicket;
|
||||
}
|
||||
|
||||
DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/get_jsapi_ticket");
|
||||
OapiGetJsapiTicketRequest req = new OapiGetJsapiTicketRequest();
|
||||
req.setHttpMethod("GET");
|
||||
OapiGetJsapiTicketResponse rsp = client.execute(req, getAccessToken());
|
||||
if (rsp.getErrcode() != 0) {
|
||||
log.error("The errMsg is 【{}】", rsp.getErrmsg());
|
||||
throw new BusinessException(rsp.getErrmsg());
|
||||
}
|
||||
|
||||
dingTalkJsapiTicket = rsp.getTicket();
|
||||
RedisUtil.set(DING_TALK_JSAPI_TICKET, dingTalkJsapiTicket, 2, TimeUnit.HOURS);
|
||||
return dingTalkJsapiTicket;
|
||||
}
|
||||
|
||||
|
||||
public DingConfig getConfig(String url) {
|
||||
DingConfig config;
|
||||
try {
|
||||
config = DingConfig.builder().url(url).jsticket(getJsapiTicket()).nonceStr(UUID.randomUUID().toString()).timeStamp(System.currentTimeMillis() / 1000)
|
||||
.corpId(dingEnv.getDingCorpId()).agentId(dingEnv.getDingAgentId()).appkey(dingEnv.getDingAppKey()).build();
|
||||
config.setSignature(getSign(config.getJsticket(), config.getNonceStr(), config.getTimeStamp(), url));
|
||||
} catch (ApiException e) {
|
||||
return new DingConfig();
|
||||
}
|
||||
|
||||
return config;
|
||||
}
|
||||
|
||||
private String getSign(String jsTicket, String nonceStr, Long timeStamp, String url) {
|
||||
String plainTex = "jsapi_ticket=" + jsTicket + "&noncestr=" + nonceStr + "×tamp=" + timeStamp + "&url=" + url;
|
||||
try {
|
||||
MessageDigest crypt = MessageDigest.getInstance("SHA-1");
|
||||
crypt.reset();
|
||||
crypt.update(plainTex.getBytes(StandardCharsets.UTF_8));
|
||||
return byteToHex(crypt.digest());
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
private String byteToHex(byte[] hash) {
|
||||
Formatter formatter = new Formatter();
|
||||
for (byte b : hash) {
|
||||
formatter.format("%02x", b);
|
||||
}
|
||||
String result = formatter.toString();
|
||||
formatter.close();
|
||||
return result;
|
||||
}
|
||||
|
||||
public OapiV2UserGetResponse getUserInfo(String code) throws ApiException {
|
||||
String accessToken = getAccessToken();
|
||||
String userId = getUerIdByAccessTokenAndCode(accessToken, code);
|
||||
OapiV2UserGetResponse rsp = getUerDetailByAccessTokenAndUserId(accessToken, userId);
|
||||
if (rsp.getErrcode() != 0) {
|
||||
log.error("The errMsg is 【{}】", rsp.getErrmsg());
|
||||
throw new BusinessException(rsp.getErrmsg());
|
||||
}
|
||||
return rsp;
|
||||
}
|
||||
|
||||
public String getUerIdByAccessTokenAndCode(String accessToken, String code) throws ApiException {
|
||||
DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/v2/user/getuserinfo");
|
||||
OapiV2UserGetuserinfoRequest req = new OapiV2UserGetuserinfoRequest();
|
||||
req.setCode(code);
|
||||
OapiV2UserGetuserinfoResponse rsp = client.execute(req, accessToken);
|
||||
if (0 != rsp.getErrcode()) {
|
||||
log.error("The errMsg is 【{}】", rsp.getErrmsg());
|
||||
throw new BusinessException(rsp.getErrmsg());
|
||||
}
|
||||
return rsp.getResult().getUserid();
|
||||
}
|
||||
|
||||
public OapiV2UserGetResponse getUerDetailByAccessTokenAndUserId(String accessToken, String userId) throws ApiException {
|
||||
DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/v2/user/get");
|
||||
OapiV2UserGetRequest req = new OapiV2UserGetRequest();
|
||||
req.setUserid(userId);
|
||||
req.setLanguage("zh_CN");
|
||||
return client.execute(req, accessToken);
|
||||
}
|
||||
|
||||
public OapiV2UserGetResponse getUserInfoByScan(String tmpAuthCode) throws ApiException {
|
||||
String accessToken = getAccessToken();
|
||||
DefaultDingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/sns/getuserinfo_bycode");
|
||||
OapiSnsGetuserinfoBycodeRequest req = new OapiSnsGetuserinfoBycodeRequest();
|
||||
req.setTmpAuthCode(tmpAuthCode);
|
||||
OapiSnsGetuserinfoBycodeResponse byCodeResponse = client.execute(req, dingEnv.getDingAppKey(), dingEnv.getDingAppSecret());
|
||||
if (byCodeResponse.getErrcode() != 0) {
|
||||
log.error("The errMsg is 【{}】", byCodeResponse.getErrmsg());
|
||||
throw new BusinessException(byCodeResponse.getErrmsg());
|
||||
}
|
||||
|
||||
String unionid = byCodeResponse.getUserInfo().getUnionid();
|
||||
DingTalkClient clientDingTalkClient = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/user/getbyunionid");
|
||||
OapiUserGetbyunionidRequest reqGetByUnionidRequest = new OapiUserGetbyunionidRequest();
|
||||
reqGetByUnionidRequest.setUnionid(unionid);
|
||||
OapiUserGetbyunionidResponse oapiUserGetbyunionidResponse = clientDingTalkClient.execute(reqGetByUnionidRequest, accessToken);
|
||||
if (oapiUserGetbyunionidResponse.getErrcode() != 0) {
|
||||
log.error("The errMsg is 【{}】", oapiUserGetbyunionidResponse.getErrmsg());
|
||||
throw new BusinessException(oapiUserGetbyunionidResponse.getErrmsg());
|
||||
}
|
||||
OapiV2UserGetResponse rspGetResponse = getUerDetailByAccessTokenAndUserId(accessToken, oapiUserGetbyunionidResponse.getResult().getUserid());
|
||||
if (rspGetResponse.getErrcode() != 0) {
|
||||
log.error("The errMsg is 【{}】", rspGetResponse.getErrmsg());
|
||||
throw new BusinessException(rspGetResponse.getErrmsg());
|
||||
}
|
||||
|
||||
return rspGetResponse;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,228 @@
|
||||
package com.codvision.auth.service.third;
|
||||
|
||||
import cn.hutool.core.lang.UUID;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.alibaba.xxpt.gateway.shared.api.request.*;
|
||||
import com.alibaba.xxpt.gateway.shared.api.response.*;
|
||||
import com.alibaba.xxpt.gateway.shared.client.http.ExecutableClient;
|
||||
import com.alibaba.xxpt.gateway.shared.client.http.IntelligentGetClient;
|
||||
import com.alibaba.xxpt.gateway.shared.client.http.IntelligentPostClient;
|
||||
import com.alibaba.xxpt.gateway.shared.client.http.api.OapiSpResultContent;
|
||||
import com.codvision.auth.entity.ding.DingEnv;
|
||||
import com.codvision.auth.entity.ding.gov.GovUserInfo;
|
||||
import com.codvision.auth.entity.ding.gov.msg.DingLinkMsg;
|
||||
import com.codvision.auth.entity.ding.gov.msg.DingMarkDownMsg;
|
||||
import com.codvision.auth.entity.ding.gov.msg.DingTextMsg;
|
||||
import com.codvision.auth.entity.vo.GovResponseVO;
|
||||
import com.codvision.base.service.ISysConfigService;
|
||||
import com.codvision.cachecore.utils.RedisUtil;
|
||||
import com.codvision.commoncore.exception.BusinessException;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.annotation.Resource;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static com.codvision.auth.support.CacheContants.*;
|
||||
|
||||
|
||||
/**
|
||||
* 专有钉钉(浙政钉)服务
|
||||
*
|
||||
* @author hxl
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class GovDingService {
|
||||
|
||||
@Resource
|
||||
private ISysConfigService configService;
|
||||
|
||||
private static DingEnv ENV;
|
||||
|
||||
private static ExecutableClient EXECUTABLE_CLIENT;
|
||||
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
ENV = DingEnv.builder()
|
||||
.govDingAppKey(configService.getValueByKey("GOV_DING_APP_KEY")).govDingAppSecret(configService.getValueByKey("GOV_DING_APP_SECRET"))
|
||||
.govDingTelnetId(configService.getValueByKey("GOV_DING_TELNET_ID")).govDingCorpId(configService.getValueByKey("GOV_DING_CORP_ID"))
|
||||
.govDingApiUrlPrefix(configService.getValueByKey("GOV_DING_API_URL_PREFIX")).govDingScanDomainUrl(configService.getValueByKey("GOV_DING_SCAN_DOMAIN_URL"))
|
||||
.govDingScanAppKey(configService.getValueByKey("GOV_DING_SCAN_APP_KEY")).govDingScanAppSecret(configService.getValueByKey("GOV_DING_SCAN_APP_SECRET"))
|
||||
.govDingScanRedirectUrl(configService.getValueByKey("GOV_DING_SCAN_REDIRECT_URL")).govDingScanAppFlag(configService.getValueByKey("GOV_DING_SCAN_APP_FLAG"))
|
||||
.build();
|
||||
|
||||
EXECUTABLE_CLIENT = ExecutableClient.getInstance();
|
||||
EXECUTABLE_CLIENT.setProtocal("https");
|
||||
EXECUTABLE_CLIENT.setDomainName(ENV.getGovDingApiUrlPrefix());
|
||||
EXECUTABLE_CLIENT.setAccessKey(ENV.getGovDingAppKey());
|
||||
EXECUTABLE_CLIENT.setSecretKey(ENV.getGovDingAppSecret());
|
||||
EXECUTABLE_CLIENT.init();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取access_token
|
||||
*
|
||||
* @return access_token
|
||||
*/
|
||||
public String getAccessToken() {
|
||||
return getAccessToken(ENV.getGovDingAppKey(), ENV.getGovDingAppSecret(), GOV_DING_TOKEN);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取access_token(扫码)
|
||||
*
|
||||
* @return access_token
|
||||
*/
|
||||
public String getScanAccessToken() {
|
||||
return getAccessToken(ENV.getGovDingScanAppKey(), ENV.getGovDingScanAppSecret(), GOV_DING_SCAN_TOKEN);
|
||||
}
|
||||
|
||||
private String getAccessToken(String appKey, String appSecret, String cacheKey) {
|
||||
String accessToken = RedisUtil.get(cacheKey);
|
||||
if (StringUtils.isNotBlank(accessToken)) {
|
||||
return accessToken;
|
||||
}
|
||||
|
||||
IntelligentGetClient intelligentGetClient = EXECUTABLE_CLIENT.newIntelligentGetClient("/gettoken.json");
|
||||
OapiGettokenJsonRequest oapiGettokenJsonRequest = new OapiGettokenJsonRequest();
|
||||
oapiGettokenJsonRequest.setAppkey(appKey);
|
||||
oapiGettokenJsonRequest.setAppsecret(appSecret);
|
||||
OapiGettokenJsonResponse rsp = intelligentGetClient.get(oapiGettokenJsonRequest);
|
||||
OapiSpResultContent content = rsp.getContent();
|
||||
if (!content.getSuccess()) {
|
||||
throw new BusinessException(content.getResponseMessage());
|
||||
}
|
||||
|
||||
accessToken = (String) JSONUtil.parseObj(content.getData()).get("accessToken");
|
||||
// access_token有效期为7200秒,有效期内重复获取返回相同结果并⾃动续期。防止临界过期问题,缓存失效时间比实际过期时间设置的偏低
|
||||
RedisUtil.set(GOV_DING_TOKEN, accessToken, 119, TimeUnit.MINUTES);
|
||||
return accessToken;
|
||||
}
|
||||
|
||||
/**
|
||||
* JSAPI鉴权
|
||||
*
|
||||
* @return 鉴权ticket
|
||||
*/
|
||||
public String getTicket() {
|
||||
String ticketAccessToken = RedisUtil.get(GOV_DING_TICKET_TOKEN);
|
||||
if (StringUtils.isNotBlank(ticketAccessToken)) {
|
||||
return ticketAccessToken;
|
||||
}
|
||||
|
||||
IntelligentGetClient intelligentGetClient = EXECUTABLE_CLIENT.newIntelligentGetClient("/get_jsapi_token.json");
|
||||
OapiGetJsapiTokenJsonRequest oapiGetJsapiTokenJsonRequest = new OapiGetJsapiTokenJsonRequest();
|
||||
oapiGetJsapiTokenJsonRequest.setAccessToken(getAccessToken());
|
||||
OapiGetJsapiTokenJsonResponse rsp = intelligentGetClient.get(oapiGetJsapiTokenJsonRequest);
|
||||
OapiSpResultContent content = rsp.getContent();
|
||||
if (!content.getSuccess()) {
|
||||
throw new BusinessException(content.getResponseMessage());
|
||||
}
|
||||
|
||||
ticketAccessToken = (String) JSONUtil.parseObj(content.getData()).get("accessToken");
|
||||
// JsApi获取access_token,access_token有效期为7200秒,有效期内重复获取返回相同结果,不会自动续期
|
||||
RedisUtil.set(GOV_DING_TICKET_TOKEN, ticketAccessToken, 2, TimeUnit.HOURS);
|
||||
return ticketAccessToken;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取授权用户的个人信息(扫码)
|
||||
*
|
||||
* @param code 临时授权码
|
||||
*/
|
||||
public GovUserInfo getUserInfoByScan(String code) {
|
||||
IntelligentGetClient intelligentGetClient = EXECUTABLE_CLIENT.newIntelligentGetClient("/rpc/oauth2/getuserinfo_bycode.json");
|
||||
OapiRpcOauth2GetuserinfoBycodeJsonRequest oapiRpcOauth2GetuserinfoBycodeJsonRequest = new OapiRpcOauth2GetuserinfoBycodeJsonRequest();
|
||||
oapiRpcOauth2GetuserinfoBycodeJsonRequest.setCode(code);
|
||||
oapiRpcOauth2GetuserinfoBycodeJsonRequest.setAccess_token(getScanAccessToken());
|
||||
OapiRpcOauth2GetuserinfoBycodeJsonResponse rsp = intelligentGetClient.get(oapiRpcOauth2GetuserinfoBycodeJsonRequest);
|
||||
GovResponseVO response = throwExceptionIfNecessary(rsp.getContent());
|
||||
return JSONUtil.toBean(JSONUtil.toJsonStr(response.getData()), GovUserInfo.class);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取授权用户的个人信息(免登)
|
||||
*
|
||||
* @param authCode 临时授权码
|
||||
*/
|
||||
public GovUserInfo getUserInfo(String authCode) {
|
||||
IntelligentPostClient intelligentPostClient = EXECUTABLE_CLIENT.newIntelligentPostClient("/rpc/oauth2/dingtalk_app_user.json");
|
||||
OapiRpcOauth2DingtalkAppUserJsonRequest oapiRpcOauth2DingtalkAppUserJsonRequest = new OapiRpcOauth2DingtalkAppUserJsonRequest();
|
||||
oapiRpcOauth2DingtalkAppUserJsonRequest.setAccess_token(getAccessToken());
|
||||
oapiRpcOauth2DingtalkAppUserJsonRequest.setAuth_code(authCode);
|
||||
OapiRpcOauth2DingtalkAppUserJsonResponse rsp = intelligentPostClient.post(oapiRpcOauth2DingtalkAppUserJsonRequest);
|
||||
GovResponseVO response = throwExceptionIfNecessary(rsp.getContent());
|
||||
return JSONUtil.toBean(JSONUtil.toJsonStr(response.getData()), GovUserInfo.class);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 工作通知消息
|
||||
*
|
||||
* @param receiverIds 接收人用户ID(accountId)
|
||||
* @param msg 消息内容 json格式
|
||||
*/
|
||||
public void workNotification(String receiverIds, String msg) {
|
||||
IntelligentGetClient intelligentGetClient = EXECUTABLE_CLIENT.newIntelligentGetClient("/message/workNotification");
|
||||
OapiMessageWorkNotificationRequest oapiMessageWorkNotificationRequest = new OapiMessageWorkNotificationRequest();
|
||||
//接收人用户ID,多个人时使用半角逗号分隔
|
||||
oapiMessageWorkNotificationRequest.setReceiverIds(receiverIds);
|
||||
oapiMessageWorkNotificationRequest.setTenantId(ENV.getGovDingTelnetId());
|
||||
oapiMessageWorkNotificationRequest.setBizMsgId(UUID.fastUUID().toString());
|
||||
oapiMessageWorkNotificationRequest.setMsg(msg);
|
||||
OapiMessageWorkNotificationResponse rsp = intelligentGetClient.get(oapiMessageWorkNotificationRequest);
|
||||
if (StringUtils.isBlank(rsp.getContent())) {
|
||||
throw new BusinessException(rsp.getErrorMsg());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 文本消息(工作通知消息)
|
||||
*
|
||||
* @param receiverIds 接收人用户ID(accountId)
|
||||
* @param content 消息内容
|
||||
*/
|
||||
public void sendTextMsg(String receiverIds, String content) {
|
||||
workNotification(receiverIds, JSONUtil.toJsonStr(new DingTextMsg(new DingTextMsg.TextMsg(content))));
|
||||
}
|
||||
|
||||
/**
|
||||
* 链接消息(工作通知消息)
|
||||
*
|
||||
* @param receiverIds 接收人用户ID(accountId)
|
||||
* @param title 消息标题
|
||||
* @param text 消息描述
|
||||
* @param messageUrl 消息点击链接地址,当发送消息为小程序时支持小程序跳转链接
|
||||
* @param picUrl 图片地址
|
||||
*/
|
||||
public void sendLinkMsg(String receiverIds, String title, String text, String messageUrl, String picUrl) {
|
||||
workNotification(receiverIds, JSONUtil.toJsonStr(new DingLinkMsg(new DingLinkMsg.LinkMsg(messageUrl, picUrl, title, text))));
|
||||
}
|
||||
|
||||
/**
|
||||
* MarkDown消息(工作通知消息)
|
||||
*
|
||||
* @param receiverIds 接收人用户ID(accountId)
|
||||
* @param title 标题
|
||||
* @param text markdown的文本
|
||||
*/
|
||||
public void sendMarkDownMsg(String receiverIds, String title, String text) {
|
||||
workNotification(receiverIds, JSONUtil.toJsonStr(new DingMarkDownMsg(new DingMarkDownMsg.MarkDownMsg(title, text))));
|
||||
}
|
||||
|
||||
|
||||
private GovResponseVO throwExceptionIfNecessary(String rspContent) {
|
||||
GovResponseVO response = JSONUtil.toBean(JSONUtil.toJsonStr(rspContent), GovResponseVO.class);
|
||||
if (!response.getSuccess()) {
|
||||
throw new BusinessException(response.getResponseMessage());
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
package com.codvision.auth.service.third;
|
||||
|
||||
import cn.hutool.crypto.SecureUtil;
|
||||
import cn.hutool.crypto.asymmetric.Sign;
|
||||
import cn.hutool.crypto.asymmetric.SignAlgorithm;
|
||||
import cn.hutool.http.HttpRequest;
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.codvision.base.service.ISysConfigService;
|
||||
import com.codvision.commoncore.exception.BusinessException;
|
||||
import com.codvision.commoncore.utils.DateUtil;
|
||||
import com.codvision.commoncore.utils.Md5Utils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Base64;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 浙里办服务
|
||||
*
|
||||
* @author codvision
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class ZlbService {
|
||||
|
||||
@Resource
|
||||
private ISysConfigService configService;
|
||||
|
||||
private static final String URL_PREFIX = "https://hzapi.citybrain.hangzhou.gov.cn";
|
||||
private static final String TICKET_VALIDATION = "https://appapi.zjzwfw.gov.cn/sso/servlet/simpleauth?method=ticketValidation&";
|
||||
private static final String GET_USER_INFO = "https://appapi.zjzwfw.gov.cn/sso/servlet/simpleauth?method=getUserInfo&";
|
||||
|
||||
private static String ZLB_SERVICE_CODE;
|
||||
private static String ZLB_SERVICE_PWD;
|
||||
private static String ZLB_KEY;
|
||||
private static String ZLB_SYSTEM_ID;
|
||||
private static String ZLB_APP_ID;
|
||||
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
ZLB_KEY = configService.getValueByKey("ZLB_KEY");
|
||||
ZLB_SYSTEM_ID = configService.getValueByKey("ZLB_SYSTEM_ID");
|
||||
ZLB_APP_ID = configService.getValueByKey("ZLB_APP_ID");
|
||||
ZLB_SERVICE_CODE = configService.getValueByKey("ZLB_SERVICE_CODE");
|
||||
ZLB_SERVICE_PWD = configService.getValueByKey("ZLB_SERVICE_PWD");
|
||||
}
|
||||
|
||||
public String ticketValidation(String st) {
|
||||
Map<String, Object> paraMap = new HashMap<>(16);
|
||||
paraMap.put("servicecode", ZLB_SERVICE_CODE);
|
||||
String time = DateUtil.toString(DateUtil.toDate(DateUtil.getNowDateTime()));
|
||||
paraMap.put("time", time);
|
||||
paraMap.put("sign", Md5Utils.getMd5(ZLB_SERVICE_CODE + ZLB_SERVICE_PWD + time));
|
||||
paraMap.put("st", st);
|
||||
paraMap.put("datatype", "json");
|
||||
String result = HttpUtil.post(TICKET_VALIDATION, paraMap);
|
||||
JSONObject stResult = new JSONObject(result);
|
||||
if (!"0".equals(stResult.getStr("result"))) {
|
||||
throw new BusinessException("票据认证失败");
|
||||
}
|
||||
|
||||
return stResult.getStr("token");
|
||||
}
|
||||
|
||||
public JSONObject getUserInfo(String st) {
|
||||
Map<String, Object> paraMap = new HashMap<>(16);
|
||||
paraMap.put("servicecode", ZLB_SERVICE_CODE);
|
||||
String time = DateUtil.toString(DateUtil.toDate(DateUtil.getNowDateTime()));
|
||||
paraMap.put("time", time);
|
||||
paraMap.put("sign", Md5Utils.getMd5(ZLB_SERVICE_CODE + ZLB_SERVICE_PWD + time));
|
||||
paraMap.put("token", ticketValidation(st));
|
||||
paraMap.put("datatype", "json");
|
||||
String result = HttpUtil.post(GET_USER_INFO, paraMap);
|
||||
return new JSONObject(result);
|
||||
}
|
||||
|
||||
public JSONObject getZlbLoginJson(String uri, JSONObject data) {
|
||||
JSONObject caller = new JSONObject();
|
||||
caller.set("appId", ZLB_APP_ID);
|
||||
caller.set("systemId", ZLB_SYSTEM_ID);
|
||||
caller.set("data", JSONUtil.toJsonStr(data));
|
||||
String timestamp = DateUtil.getNowDateTime();
|
||||
caller.set("timestamp", timestamp);
|
||||
String sign = "appId=" + ZLB_APP_ID + "&data=" + JSONUtil.toJsonStr(data) + "&systemId=" + ZLB_SYSTEM_ID + "×tamp=" + timestamp;
|
||||
// 签名算法和私钥
|
||||
Sign sign2 = SecureUtil.sign(SignAlgorithm.SHA256withRSA, ZLB_KEY, null);
|
||||
byte[] sign1 = sign2.sign(sign.getBytes());
|
||||
Base64.Encoder encoder = Base64.getEncoder();
|
||||
sign = encoder.encodeToString(sign1);
|
||||
caller.set("sign", sign);
|
||||
String body = HttpRequest.post(URL_PREFIX + uri).body(JSONUtil.toJsonStr(caller)).execute().body();
|
||||
return new JSONObject(body).getJSONObject("result");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.codvision.auth.support;
|
||||
|
||||
|
||||
/**
|
||||
* 常量类
|
||||
*
|
||||
* @author codvision
|
||||
*/
|
||||
public final class AuthConst {
|
||||
|
||||
/**
|
||||
* 登录错误次数 5
|
||||
*/
|
||||
public static final Integer USER_LOCK_LIMIT = 5;
|
||||
/**
|
||||
* 锁定标志
|
||||
*/
|
||||
public static final String LOCK = "LOCK";
|
||||
/**
|
||||
* 密码定期更新标志
|
||||
*/
|
||||
public static final String PWD_CHECK_FLAG = "ON";
|
||||
/**
|
||||
* 短信
|
||||
*/
|
||||
public static final String SMS_OK = "OK";
|
||||
public static final String SMS_PRODUCT = "Dysmsapi";
|
||||
public static final String SMS_DOMAIN = "dysmsapi.aliyuncs.com";
|
||||
public static String SMS_ACCESS_KEY_ID = "";
|
||||
public static String SMS_ACCESS_KEY_SECRET = "";
|
||||
/**
|
||||
* 默认角色标识
|
||||
*/
|
||||
public static final Short DEFAULT_ROLE_FLAG = 1;
|
||||
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user