first commit
This commit is contained in:
23
qingyun-admin/Dockerfile
Normal file
23
qingyun-admin/Dockerfile
Normal file
@@ -0,0 +1,23 @@
|
||||
FROM anapsix/alpine-java:8_server-jre_unlimited
|
||||
|
||||
MAINTAINER jianlu
|
||||
|
||||
RUN mkdir -p /ruoyi/server/logs \
|
||||
/ruoyi/server/temp \
|
||||
/ruoyi/skywalking/agent
|
||||
|
||||
WORKDIR /ruoyi/server
|
||||
|
||||
ENV SERVER_PORT=8080
|
||||
|
||||
EXPOSE ${SERVER_PORT}
|
||||
|
||||
ADD ./target/ruoyi-admin.jar ./app.jar
|
||||
|
||||
ENTRYPOINT ["java", \
|
||||
"-Djava.security.egd=file:/dev/./urandom", \
|
||||
"-Dserver.port=${SERVER_PORT}", \
|
||||
# 应用名称 如果想区分集群节点监控 改成不同的名称即可
|
||||
# "-Dskywalking.agent.service_name=ruoyi-server", \
|
||||
# "-javaagent:/ruoyi/skywalking/agent/skywalking-agent.jar", \
|
||||
"-jar", "app.jar"]
|
||||
157
qingyun-admin/pom.xml
Normal file
157
qingyun-admin/pom.xml
Normal file
@@ -0,0 +1,157 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<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>
|
||||
<artifactId>qingyun-plus</artifactId>
|
||||
<groupId>com.qingyun</groupId>
|
||||
<version>4.7.0</version>
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<packaging>jar</packaging>
|
||||
<artifactId>qingyun-admin</artifactId>
|
||||
|
||||
<description>
|
||||
web服务入口
|
||||
</description>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<!-- spring-boot-devtools -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-devtools</artifactId>
|
||||
<optional>true</optional> <!-- 表示依赖不会传递 -->
|
||||
</dependency>
|
||||
|
||||
<!-- Mysql驱动包 -->
|
||||
<dependency>
|
||||
<groupId>com.mysql</groupId>
|
||||
<artifactId>mysql-connector-j</artifactId>
|
||||
</dependency>
|
||||
<!-- Oracle -->
|
||||
<dependency>
|
||||
<groupId>com.oracle.database.jdbc</groupId>
|
||||
<artifactId>ojdbc8</artifactId>
|
||||
</dependency>
|
||||
<!-- PostgreSql -->
|
||||
<dependency>
|
||||
<groupId>org.postgresql</groupId>
|
||||
<artifactId>postgresql</artifactId>
|
||||
</dependency>
|
||||
<!-- SqlServer -->
|
||||
<dependency>
|
||||
<groupId>com.microsoft.sqlserver</groupId>
|
||||
<artifactId>mssql-jdbc</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- <!– 核心模块–>-->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>com.qingyun</groupId>-->
|
||||
<!-- <artifactId>qingyun-framework</artifactId>-->
|
||||
<!-- </dependency>-->
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>com.qingyun</groupId>
|
||||
<artifactId>qingyun-system</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.qingyun</groupId>
|
||||
<artifactId>qingyun-oss</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.qingyun</groupId>
|
||||
<artifactId>qingyun-core-config</artifactId>
|
||||
</dependency>
|
||||
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>com.qingyun</groupId>
|
||||
<artifactId>qingyun-data-permission</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.qingyun</groupId>
|
||||
<artifactId>qingyun-idempotent</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.qingyun</groupId>
|
||||
<artifactId>qingyun-mybatisplus</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.qingyun</groupId>
|
||||
<artifactId>qingyun-redis</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.qingyun</groupId>
|
||||
<artifactId>qingyun-security</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.qingyun</groupId>
|
||||
<artifactId>qingyun-service</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.qingyun</groupId>
|
||||
<artifactId>qingyun-swagger</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<finalName>${project.artifactId}</finalName>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<version>${spring-boot.version}</version>
|
||||
<configuration>
|
||||
<fork>true</fork> <!-- 如果没有该配置,devtools不会生效 -->
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>repackage</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-war-plugin</artifactId>
|
||||
<version>3.2.2</version>
|
||||
<configuration>
|
||||
<failOnMissingWebXml>false</failOnMissingWebXml>
|
||||
<warName>${project.artifactId}</warName>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-resources-plugin</artifactId>
|
||||
<version>2.6</version>
|
||||
<configuration>
|
||||
<encoding>UTF-8</encoding>
|
||||
<nonFilteredFileExtensions>
|
||||
<nonFilteredFileExtension>xls</nonFilteredFileExtension>
|
||||
<nonFilteredFileExtension>xlsx</nonFilteredFileExtension>
|
||||
</nonFilteredFileExtensions>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.qingyun;
|
||||
|
||||
import com.qingyun.framework.encrypt.annotation.EnableSecurity;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.context.metrics.buffering.BufferingApplicationStartup;
|
||||
import org.springframework.context.annotation.EnableAspectJAutoProxy;
|
||||
import org.springframework.scheduling.annotation.EnableAsync;
|
||||
|
||||
/**
|
||||
* 启动程序
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@EnableAsync
|
||||
@EnableSecurity
|
||||
@SpringBootApplication
|
||||
public class QingYunApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.setProperty("spring.devtools.restart.enabled", "false");
|
||||
SpringApplication application = new SpringApplication(QingYunApplication.class);
|
||||
application.setApplicationStartup(new BufferingApplicationStartup(2048));
|
||||
application.run(args);
|
||||
System.out.println("(♥◠‿◠)ノ゙ QingYun-Vue-Plus启动成功 ლ(´ڡ`ლ)゙");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.qingyun;
|
||||
|
||||
import org.springframework.boot.builder.SpringApplicationBuilder;
|
||||
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
|
||||
|
||||
/**
|
||||
* web容器中进行部署
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
public class QingYunServletInitializer extends SpringBootServletInitializer {
|
||||
|
||||
@Override
|
||||
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
|
||||
return application.sources(QingYunApplication.class);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package com.qingyun.config;
|
||||
|
||||
import cn.dev33.satoken.dao.SaTokenDao;
|
||||
import cn.dev33.satoken.interceptor.SaInterceptor;
|
||||
import cn.dev33.satoken.jwt.StpLogicJwtForSimple;
|
||||
import cn.dev33.satoken.router.SaRouter;
|
||||
import cn.dev33.satoken.stp.StpInterface;
|
||||
import cn.dev33.satoken.stp.StpLogic;
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import com.qingyun.common.utils.spring.SpringUtils;
|
||||
import com.qingyun.security.satoken.config.properties.SecurityProperties;
|
||||
import com.qingyun.security.satoken.handler.AllUrlHandler;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* sa-token 配置
|
||||
*
|
||||
* @author jianlu
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
@Configuration
|
||||
public class SaTokenConfig implements WebMvcConfigurer {
|
||||
|
||||
private final SecurityProperties securityProperties;
|
||||
|
||||
/**
|
||||
* 注册sa-token的拦截器
|
||||
*/
|
||||
@Override
|
||||
public void addInterceptors(InterceptorRegistry registry) {
|
||||
// 注册路由拦截器,自定义验证规则
|
||||
registry.addInterceptor(new SaInterceptor(handler -> {
|
||||
AllUrlHandler allUrlHandler = SpringUtils.getBean(AllUrlHandler.class);
|
||||
// 登录验证
|
||||
SaRouter.match(allUrlHandler.getUrls())
|
||||
.check(() -> StpUtil.checkLogin());
|
||||
}))
|
||||
.addPathPatterns("/**")
|
||||
// 排除不需要拦截的路径
|
||||
.excludePathPatterns(securityProperties.getExcludes());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,168 @@
|
||||
package com.qingyun.exception;
|
||||
|
||||
import cn.dev33.satoken.exception.NotLoginException;
|
||||
import cn.dev33.satoken.exception.NotPermissionException;
|
||||
import cn.dev33.satoken.exception.NotRoleException;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.http.HttpStatus;
|
||||
import com.qingyun.common.core.domain.R;
|
||||
import com.qingyun.common.exception.DemoModeException;
|
||||
import com.qingyun.common.exception.ServiceException;
|
||||
import com.qingyun.common.utils.StreamUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.mybatis.spring.MyBatisSystemException;
|
||||
import org.springframework.context.support.DefaultMessageSourceResolvable;
|
||||
import org.springframework.dao.DuplicateKeyException;
|
||||
import org.springframework.validation.BindException;
|
||||
import org.springframework.web.HttpRequestMethodNotSupportedException;
|
||||
import org.springframework.web.bind.MethodArgumentNotValidException;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.validation.ConstraintViolation;
|
||||
import javax.validation.ConstraintViolationException;
|
||||
|
||||
/**
|
||||
* 全局异常处理器
|
||||
*
|
||||
* @author jianlu
|
||||
*/
|
||||
@Slf4j
|
||||
@RestControllerAdvice
|
||||
public class GlobalExceptionHandler {
|
||||
|
||||
/**
|
||||
* 权限码异常
|
||||
*/
|
||||
@ExceptionHandler(NotPermissionException.class)
|
||||
public R<Void> handleNotPermissionException(NotPermissionException e, HttpServletRequest request) {
|
||||
String requestURI = request.getRequestURI();
|
||||
log.error("请求地址'{}',权限码校验失败'{}'", requestURI, e.getMessage());
|
||||
return R.fail(HttpStatus.HTTP_FORBIDDEN, "没有访问权限,请联系管理员授权");
|
||||
}
|
||||
|
||||
/**
|
||||
* 角色权限异常
|
||||
*/
|
||||
@ExceptionHandler(NotRoleException.class)
|
||||
public R<Void> handleNotRoleException(NotRoleException e, HttpServletRequest request) {
|
||||
String requestURI = request.getRequestURI();
|
||||
log.error("请求地址'{}',角色权限校验失败'{}'", requestURI, e.getMessage());
|
||||
return R.fail(HttpStatus.HTTP_FORBIDDEN, "没有访问权限,请联系管理员授权");
|
||||
}
|
||||
|
||||
/**
|
||||
* 认证失败
|
||||
*/
|
||||
@ExceptionHandler(NotLoginException.class)
|
||||
public R<Void> handleNotLoginException(NotLoginException e, HttpServletRequest request) {
|
||||
String requestURI = request.getRequestURI();
|
||||
log.error("请求地址'{}',认证失败'{}',无法访问系统资源", requestURI, e.getMessage());
|
||||
return R.fail(HttpStatus.HTTP_UNAUTHORIZED, "认证失败,无法访问系统资源");
|
||||
}
|
||||
|
||||
/**
|
||||
* 请求方式不支持
|
||||
*/
|
||||
@ExceptionHandler(HttpRequestMethodNotSupportedException.class)
|
||||
public R<Void> handleHttpRequestMethodNotSupported(HttpRequestMethodNotSupportedException e,
|
||||
HttpServletRequest request) {
|
||||
String requestURI = request.getRequestURI();
|
||||
log.error("请求地址'{}',不支持'{}'请求", requestURI, e.getMethod());
|
||||
return R.fail(e.getMessage());
|
||||
}
|
||||
|
||||
/**
|
||||
* 主键或UNIQUE索引,数据重复异常
|
||||
*/
|
||||
@ExceptionHandler(DuplicateKeyException.class)
|
||||
public R<Void> handleDuplicateKeyException(DuplicateKeyException e, HttpServletRequest request) {
|
||||
String requestURI = request.getRequestURI();
|
||||
log.error("请求地址'{}',数据库中已存在记录'{}'", requestURI, e.getMessage());
|
||||
return R.fail("数据库中已存在该记录,请联系管理员确认");
|
||||
}
|
||||
|
||||
/**
|
||||
* Mybatis系统异常 通用处理
|
||||
*/
|
||||
@ExceptionHandler(MyBatisSystemException.class)
|
||||
public R<Void> handleCannotFindDataSourceException(MyBatisSystemException e, HttpServletRequest request) {
|
||||
String requestURI = request.getRequestURI();
|
||||
String message = e.getMessage();
|
||||
if (message.contains("CannotFindDataSourceException")) {
|
||||
log.error("请求地址'{}', 未找到数据源", requestURI);
|
||||
return R.fail("未找到数据源,请联系管理员确认");
|
||||
}
|
||||
log.error("请求地址'{}', Mybatis系统异常", requestURI, e);
|
||||
return R.fail(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* 业务异常
|
||||
*/
|
||||
@ExceptionHandler(ServiceException.class)
|
||||
public R<Void> handleServiceException(ServiceException e, HttpServletRequest request) {
|
||||
log.error(e.getMessage(), e);
|
||||
Integer code = e.getCode();
|
||||
return ObjectUtil.isNotNull(code) ? R.fail(code, e.getMessage()) : R.fail(e.getMessage());
|
||||
}
|
||||
|
||||
/**
|
||||
* 拦截未知的运行时异常
|
||||
*/
|
||||
@ExceptionHandler(RuntimeException.class)
|
||||
public R<Void> handleRuntimeException(RuntimeException e, HttpServletRequest request) {
|
||||
String requestURI = request.getRequestURI();
|
||||
log.error("请求地址'{}',发生未知异常.", requestURI, e);
|
||||
return R.fail(e.getMessage());
|
||||
}
|
||||
|
||||
/**
|
||||
* 系统异常
|
||||
*/
|
||||
@ExceptionHandler(Exception.class)
|
||||
public R<Void> handleException(Exception e, HttpServletRequest request) {
|
||||
String requestURI = request.getRequestURI();
|
||||
log.error("请求地址'{}',发生系统异常.", requestURI, e);
|
||||
return R.fail(e.getMessage());
|
||||
}
|
||||
|
||||
/**
|
||||
* 自定义验证异常
|
||||
*/
|
||||
@ExceptionHandler(BindException.class)
|
||||
public R<Void> handleBindException(BindException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
String message = StreamUtils.join(e.getAllErrors(), DefaultMessageSourceResolvable::getDefaultMessage, ", ");
|
||||
return R.fail(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* 自定义验证异常
|
||||
*/
|
||||
@ExceptionHandler(ConstraintViolationException.class)
|
||||
public R<Void> constraintViolationException(ConstraintViolationException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
String message = StreamUtils.join(e.getConstraintViolations(), ConstraintViolation::getMessage, ", ");
|
||||
return R.fail(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* 自定义验证异常
|
||||
*/
|
||||
@ExceptionHandler(MethodArgumentNotValidException.class)
|
||||
public R<Void> handleMethodArgumentNotValidException(MethodArgumentNotValidException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
String message = e.getBindingResult().getFieldError().getDefaultMessage();
|
||||
return R.fail(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* 演示模式异常
|
||||
*/
|
||||
@ExceptionHandler(DemoModeException.class)
|
||||
public R<Void> handleDemoModeException(DemoModeException e) {
|
||||
return R.fail("演示模式,不允许操作");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
package com.qingyun.web.controller.api;
|
||||
|
||||
|
||||
import com.qingyun.common.core.domain.R;
|
||||
import com.qingyun.common.core.domain.entity.SysUser;
|
||||
import com.qingyun.common.core.domain.model.LoginUser;
|
||||
import com.qingyun.common.helper.LoginHelper;
|
||||
import com.qingyun.system.service.ISysUserService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 用户模块
|
||||
*
|
||||
* @author PC
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/api/user")
|
||||
@RequiredArgsConstructor
|
||||
public class ApiUserController {
|
||||
|
||||
private final ISysUserService userService;
|
||||
|
||||
// private final DtService dtService;
|
||||
|
||||
/**
|
||||
* 获取用户信息
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/getInfo")
|
||||
public R<Map<String, Object>> getInfo() {
|
||||
LoginUser loginUser = LoginHelper.getLoginUser();
|
||||
SysUser user = userService.selectUserById(loginUser.getUserId());
|
||||
Map<String, Object> ajax = new HashMap<>();
|
||||
ajax.put("user", user);
|
||||
ajax.put("roles", loginUser.getRolePermission());
|
||||
ajax.put("permissions", loginUser.getMenuPermission());
|
||||
return R.ok(ajax);
|
||||
}
|
||||
|
||||
// @GetMapping("sign")
|
||||
// public R<Map<String, Object>> sign(String url) throws Exception {
|
||||
// DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/get_jsapi_ticket");
|
||||
// OapiGetJsapiTicketRequest req = new OapiGetJsapiTicketRequest();
|
||||
// req.setHttpMethod("GET");
|
||||
// OapiGetJsapiTicketResponse rsp = client.execute(req, dtService.getDtConfigStorage().getAccessToken());
|
||||
// JSONObject json = JSON.parseObject(rsp.getBody());
|
||||
// long time = System.currentTimeMillis();
|
||||
// String sign = DdConfigSign.sign(json.getString("ticket"), "abcdefg", time, url);
|
||||
// Map<String, Object> map = new HashMap<>();
|
||||
// map.put("agentId", String.valueOf(dtService.getDtConfigStorage().getAgentId()));
|
||||
// map.put("corpId", dtService.getDtConfigStorage().getCorpId());
|
||||
// map.put("timeStamp", String.valueOf(time));
|
||||
// map.put("nonceStr", "abcdefg");
|
||||
// map.put("signature", sign);
|
||||
// return R.ok(map);
|
||||
// }
|
||||
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
package com.qingyun.web.controller.api;
|
||||
|
||||
import java.net.URL;
|
||||
import java.net.URLDecoder;
|
||||
import java.security.MessageDigest;
|
||||
import java.util.Formatter;
|
||||
|
||||
/**
|
||||
* 计算dd.config的签名参数
|
||||
**/
|
||||
public class DdConfigSign {
|
||||
|
||||
/**
|
||||
* 计算dd.config的签名参数
|
||||
*
|
||||
* @param jsticket 通过微应用appKey获取的jsticket
|
||||
* @param nonceStr 自定义固定字符串
|
||||
* @param timeStamp 当前时间戳
|
||||
* @param url 调用dd.config的当前页面URL
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public static String sign(String jsticket, String nonceStr, long timeStamp, String url) throws Exception {
|
||||
String plain = "jsapi_ticket=" + jsticket + "&noncestr=" + nonceStr + "×tamp=" + String.valueOf(timeStamp)
|
||||
+ "&url=" + decodeUrl(url);
|
||||
try {
|
||||
MessageDigest sha1 = MessageDigest.getInstance("SHA-256");
|
||||
sha1.reset();
|
||||
sha1.update(plain.getBytes("UTF-8"));
|
||||
return byteToHex(sha1.digest());
|
||||
} catch (Exception e) {
|
||||
throw new Exception(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
// 字节数组转化成十六进制字符串
|
||||
private static String byteToHex(final byte[] hash) {
|
||||
Formatter formatter = new Formatter();
|
||||
for (byte b : hash) {
|
||||
formatter.format("%02x", b);
|
||||
}
|
||||
String result = formatter.toString();
|
||||
formatter.close();
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 因为ios端上传递的url是encode过的,android是原始的url。开发者使用的也是原始url,
|
||||
* 所以需要把参数进行一般urlDecode
|
||||
*
|
||||
* @param url
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
private static String decodeUrl(String url) throws Exception {
|
||||
URL urler = new URL(url);
|
||||
StringBuilder urlBuffer = new StringBuilder();
|
||||
urlBuffer.append(urler.getProtocol());
|
||||
urlBuffer.append(":");
|
||||
if (urler.getAuthority() != null && urler.getAuthority().length() > 0) {
|
||||
urlBuffer.append("//");
|
||||
urlBuffer.append(urler.getAuthority());
|
||||
}
|
||||
if (urler.getPath() != null) {
|
||||
urlBuffer.append(urler.getPath());
|
||||
}
|
||||
if (urler.getQuery() != null) {
|
||||
urlBuffer.append('?');
|
||||
urlBuffer.append(URLDecoder.decode(urler.getQuery(), "utf-8"));
|
||||
}
|
||||
return urlBuffer.toString();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.qingyun.web.controller.api.contract;
|
||||
|
||||
import com.qingyun.common.core.domain.R;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import com.qingyun.common.core.controller.BaseController;
|
||||
import com.qingyun.service.domain.vo.ContractCompareResultVo;
|
||||
import com.qingyun.service.service.IContractCompareResultService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 合同对比结果
|
||||
*
|
||||
* @author jianlu
|
||||
* @date 2025-07-11
|
||||
*/
|
||||
@Validated
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/api/compareResult")
|
||||
public class ContractCompareResultController extends BaseController {
|
||||
|
||||
private final IContractCompareResultService contractCompareResultService;
|
||||
|
||||
/**
|
||||
* 查询对比结果列表
|
||||
*
|
||||
* @param taskId 任务ID
|
||||
*/
|
||||
@GetMapping("/list/{taskId}")
|
||||
public R<List<ContractCompareResultVo>> list(@PathVariable("taskId") Long taskId) {
|
||||
return R.ok(contractCompareResultService.queryList(taskId));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,196 @@
|
||||
package com.qingyun.web.controller.api.contract;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.qingyun.common.exception.ServiceException;
|
||||
import com.qingyun.common.helper.LoginHelper;
|
||||
import com.qingyun.common.utils.MapstructUtils;
|
||||
import com.qingyun.service.compare.factory.FileComparisonStrategyFactory;
|
||||
import com.qingyun.service.compare.strategy.FileComparisonStrategy;
|
||||
import com.qingyun.service.domain.ContractCompareResult;
|
||||
import com.qingyun.service.domain.ContractCompareTask;
|
||||
import com.qingyun.service.domain.ContractReviewResult;
|
||||
import com.qingyun.service.mapper.ContractCompareTaskMapper;
|
||||
import com.qingyun.service.service.IContractCompareResultService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.ibatis.session.SqlSession;
|
||||
import org.apache.ibatis.session.SqlSessionFactory;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import com.qingyun.idempotent.annotation.RepeatSubmit;
|
||||
import com.qingyun.common.annotation.Log;
|
||||
import com.qingyun.common.core.controller.BaseController;
|
||||
import com.qingyun.common.core.domain.PageQuery;
|
||||
import com.qingyun.common.core.domain.R;
|
||||
import com.qingyun.common.core.validate.AddGroup;
|
||||
import com.qingyun.common.core.validate.EditGroup;
|
||||
import com.qingyun.common.enums.BusinessType;
|
||||
import com.qingyun.service.domain.vo.ContractCompareTaskVo;
|
||||
import com.qingyun.service.domain.bo.ContractCompareTaskBo;
|
||||
import com.qingyun.service.service.IContractCompareTaskService;
|
||||
import com.qingyun.mybatisplus.page.TableDataInfo;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
/**
|
||||
* 合同对比任务管理
|
||||
*
|
||||
* @author jianlu
|
||||
* @date 2025-07-11
|
||||
*/
|
||||
@Slf4j
|
||||
@Validated
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/api/service/compareTask")
|
||||
public class ContractCompareTaskController extends BaseController {
|
||||
|
||||
private final IContractCompareTaskService contractCompareTaskService;
|
||||
|
||||
private final IContractCompareResultService contractCompareResultService;
|
||||
|
||||
private final SqlSessionFactory sqlSessionFactory;
|
||||
|
||||
private final FileComparisonStrategyFactory strategyFactory;
|
||||
|
||||
|
||||
/**
|
||||
* 查询对比任务列表 "service:compareTask:list"
|
||||
* @param contractName 合同名称 模糊查询
|
||||
*/
|
||||
@SaCheckPermission("service:compareTask:list")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo<ContractCompareTaskVo> list(String contractName, PageQuery pageQuery) {
|
||||
return contractCompareTaskService.queryPageList(contractName, pageQuery);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取对比任务详细信息 "service:compareTask:query"
|
||||
*
|
||||
* @param taskId 主键
|
||||
*/
|
||||
@SaCheckPermission("service:compareTask:query")
|
||||
@GetMapping("/{taskId}")
|
||||
public R<ContractCompareTaskVo> getInfo(@NotNull(message = "主键不能为空")
|
||||
@PathVariable Long taskId) {
|
||||
return R.ok(contractCompareTaskService.queryById(taskId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建对比任务 "service:compareTask:add"
|
||||
*/
|
||||
@SaCheckPermission("service:compareTask:add")
|
||||
//@RepeatSubmit(interval = 60000, message = "请勿重复提交")
|
||||
@PostMapping("/create")
|
||||
public R<Long> add(@Validated(AddGroup.class) @RequestBody ContractCompareTaskBo bo) {
|
||||
ContractCompareTask add = MapstructUtils.convert(bo, ContractCompareTask.class);
|
||||
if (add == null) {
|
||||
return R.fail("创建任务失败");
|
||||
}
|
||||
add.setStatus(1);
|
||||
add.setUserId(LoginHelper.getUserId());
|
||||
add.setDeptId(LoginHelper.getDeptId());
|
||||
add.setCreateTime(new Date());
|
||||
add.setCreateBy(LoginHelper.getUsername());
|
||||
FileComparisonStrategy strategy = strategyFactory.getStrategy(add);
|
||||
try (SqlSession sqlSession = sqlSessionFactory.openSession()) {
|
||||
ContractCompareTaskMapper mapper = sqlSession.getMapper(ContractCompareTaskMapper.class);
|
||||
// 提取内容
|
||||
strategy.extractContent(add);
|
||||
mapper.insert(add);
|
||||
sqlSession.commit();
|
||||
} catch (Exception e) {
|
||||
log.error("创建任务失败", e);
|
||||
throw new ServiceException("创建任务失败");
|
||||
}
|
||||
// 异步执行 比对任务
|
||||
contractCompareTaskService.executeTask(strategy, add);
|
||||
return R.ok(add.getTaskId());
|
||||
}
|
||||
|
||||
/**
|
||||
* 执行对比任务 "service:compareTask:execute"
|
||||
* @param taskId 任务ID
|
||||
*/
|
||||
@SaCheckPermission("service:compareTask:execute")
|
||||
@GetMapping("/execute/{taskId}")
|
||||
public R<Integer> execute(@NotNull(message = "任务ID不能为空") @PathVariable("taskId") Long taskId) {
|
||||
ContractCompareTask contractCompareTask = contractCompareTaskService.getBaseMapper().selectById(taskId);
|
||||
if (contractCompareTask == null) {
|
||||
throw new ServiceException("任务不存在");
|
||||
}
|
||||
contractCompareTask.setStatus(2);
|
||||
contractCompareTaskService.getBaseMapper().updateById(contractCompareTask);
|
||||
|
||||
contractCompareResultService.getBaseMapper().delete(Wrappers.lambdaQuery(ContractCompareResult.class)
|
||||
.eq(ContractCompareResult::getTaskId, taskId)
|
||||
);
|
||||
FileComparisonStrategy strategy = strategyFactory.getStrategy(contractCompareTask);
|
||||
// 异步执行
|
||||
contractCompareTaskService.executeTask(strategy, contractCompareTask);
|
||||
return R.ok(2);
|
||||
}
|
||||
|
||||
/**
|
||||
* 重试 "contract:compare:task:retry"
|
||||
*/
|
||||
@SaCheckPermission("contract:compare:task:retry")
|
||||
@GetMapping("/retry/{taskId}")
|
||||
public R<Integer> retry(@NotNull(message = "任务ID不能为空") @PathVariable("taskId") Long taskId) {
|
||||
ContractCompareTask contractCompareTask = contractCompareTaskService.getBaseMapper().selectById(taskId);
|
||||
if (contractCompareTask == null) {
|
||||
throw new ServiceException("任务不存在");
|
||||
}
|
||||
contractCompareResultService.getBaseMapper().delete(Wrappers.lambdaQuery(ContractCompareResult.class)
|
||||
.eq(ContractCompareResult::getTaskId, taskId)
|
||||
);
|
||||
contractCompareTask.setStatus(2);
|
||||
contractCompareTaskService.getBaseMapper().updateById(contractCompareTask);
|
||||
FileComparisonStrategy strategy = strategyFactory.getStrategy(contractCompareTask);
|
||||
// 异步执行
|
||||
contractCompareTaskService.executeTask(strategy, contractCompareTask);
|
||||
return R.ok("重试成功", 2);
|
||||
}
|
||||
|
||||
/**
|
||||
* 轮询对比任务结果 "contract:compareTask:status"
|
||||
*/
|
||||
@SaCheckPermission("contract:compareTask:status")
|
||||
@GetMapping("/status/{taskId}")
|
||||
public R<Integer> queryStatus(@NotNull(message = "任务ID不能为空") @PathVariable("taskId") Long taskId) {
|
||||
ContractCompareTask contractCompareTask = contractCompareTaskService.getBaseMapper().selectById(taskId);
|
||||
if (contractCompareTask == null) {
|
||||
throw new ServiceException("任务不存在");
|
||||
}
|
||||
return R.ok(contractCompareTask.getStatus());
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改对比任务 "service:compareTask:edit"
|
||||
*/
|
||||
@SaCheckPermission("service:compareTask:edit")
|
||||
@Log(title = "对比任务", businessType = BusinessType.UPDATE)
|
||||
@RepeatSubmit()
|
||||
@PostMapping("/update")
|
||||
public R<Void> edit(@Validated(EditGroup.class) @RequestBody ContractCompareTaskBo bo) {
|
||||
return toAjax(contractCompareTaskService.updateByBo(bo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除对比任务 "service:compareTask:remove"
|
||||
*
|
||||
* @param taskIds 主键串
|
||||
*/
|
||||
@SaCheckPermission("service:compareTask:remove")
|
||||
@Log(title = "对比任务", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{taskIds}")
|
||||
public R<Void> remove(@NotNull(message = "主键不能为空")
|
||||
@PathVariable Long[] taskIds) {
|
||||
return toAjax(contractCompareTaskService.deleteWithValidByIds(Arrays.asList(taskIds), Boolean.TRUE));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
package com.qingyun.web.controller.api.contract;
|
||||
|
||||
import com.qingyun.common.core.validate.EditGroup;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import com.qingyun.idempotent.annotation.RepeatSubmit;
|
||||
import com.qingyun.common.annotation.Log;
|
||||
import com.qingyun.common.core.controller.BaseController;
|
||||
import com.qingyun.common.core.domain.PageQuery;
|
||||
import com.qingyun.common.core.domain.R;
|
||||
import com.qingyun.common.core.validate.AddGroup;
|
||||
import com.qingyun.common.enums.BusinessType;
|
||||
import com.qingyun.service.domain.vo.ContractModelConfigVo;
|
||||
import com.qingyun.service.domain.bo.ContractModelConfigBo;
|
||||
import com.qingyun.service.service.IContractModelConfigService;
|
||||
import com.qingyun.mybatisplus.page.TableDataInfo;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* 合同模型配置
|
||||
*
|
||||
* @author jianlu
|
||||
* @date 2025-07-11
|
||||
*/
|
||||
@Validated
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/api/service/modelConfig")
|
||||
public class ContractModelConfigController extends BaseController {
|
||||
|
||||
private final IContractModelConfigService contractModelConfigService;
|
||||
|
||||
/**
|
||||
* 查询模型配置列表 "service:modelConfig:list"
|
||||
*/
|
||||
@SaCheckPermission("service:modelConfig:list")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo<ContractModelConfigVo> list(ContractModelConfigBo bo, PageQuery pageQuery) {
|
||||
return contractModelConfigService.queryPageList(bo, pageQuery);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取模型配置详细信息 "service:modelConfig:query"
|
||||
*
|
||||
* @param id 主键
|
||||
*/
|
||||
@SaCheckPermission("service:modelConfig:query")
|
||||
@GetMapping("/{id}")
|
||||
public R<ContractModelConfigVo> getInfo(@NotNull(message = "主键不能为空")
|
||||
@PathVariable String id) {
|
||||
return R.ok(contractModelConfigService.queryById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增模型配置 "service:modelConfig:add"
|
||||
*/
|
||||
@SaCheckPermission("service:modelConfig:add")
|
||||
@Log(title = "模型配置", businessType = BusinessType.INSERT)
|
||||
@RepeatSubmit()
|
||||
@PostMapping()
|
||||
public R<Void> add(@Validated(AddGroup.class) @RequestBody ContractModelConfigBo bo) {
|
||||
return toAjax(contractModelConfigService.insertByBo(bo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除模型配置 "service:modelConfig:remove"
|
||||
*/
|
||||
@SaCheckPermission("service:modelConfig:remove")
|
||||
@DeleteMapping("/{ids}")
|
||||
public R<Void> remove(@NotEmpty(message = "主键不能为空") @PathVariable Long[] ids) {
|
||||
if (Arrays.asList(ids).contains(1L)) {
|
||||
return R.fail("默认配置,不能删除");
|
||||
}
|
||||
return toAjax(contractModelConfigService.deleteWithValidByIds(ids, true));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改模型配置 "service:modelConfig:edit"
|
||||
* @param bo 模型配置业务对象
|
||||
* @return 操作结果
|
||||
*/
|
||||
@SaCheckPermission("service:modelConfig:edit")
|
||||
@PutMapping()
|
||||
public R<Void> edit(@Validated(EditGroup.class) @RequestBody ContractModelConfigBo bo) {
|
||||
return toAjax(contractModelConfigService.updateByBo(bo));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
package com.qingyun.web.controller.api.contract;
|
||||
|
||||
import com.qingyun.service.domain.ContractCompareTask;
|
||||
import com.qingyun.service.domain.ContractReviewTask;
|
||||
import com.qingyun.service.service.IContractCompareTaskService;
|
||||
import com.qingyun.service.service.IContractReviewTaskService;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.InputStream;
|
||||
import java.net.URL;
|
||||
|
||||
/**
|
||||
* pdf通用接口
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/api/pdf")
|
||||
@SuppressWarnings("all")
|
||||
@AllArgsConstructor
|
||||
public class ContractPDFCommonController {
|
||||
|
||||
private final IContractReviewTaskService contractReviewTaskService;
|
||||
|
||||
private final IContractCompareTaskService contractCompareTaskService;
|
||||
|
||||
/**
|
||||
* 根据任务id和任务类型获取pdf 文件流
|
||||
*
|
||||
* @param taskId 任务id
|
||||
* @param taskType 任务类型 1审查任务 2 比对任务-主版文件 3 比对任务-副版文件
|
||||
*/
|
||||
@GetMapping("/load/{taskId}")
|
||||
public void loadPDF(@PathVariable Long taskId, @RequestParam("taskType") Integer taskType,
|
||||
HttpServletResponse response) {
|
||||
// Return the PDF stream directly without returning a string
|
||||
String contractUrl = null;
|
||||
if (taskType == 1) {
|
||||
ContractReviewTask contractReviewTask = contractReviewTaskService.getBaseMapper().selectById(taskId);
|
||||
if (contractReviewTask == null) {
|
||||
throw new RuntimeException("任务不存在");
|
||||
}
|
||||
contractUrl = contractReviewTask.getContractUrl();
|
||||
} else if (taskType == 2) {
|
||||
// 主版pdf
|
||||
ContractCompareTask contractCompareTask = contractCompareTaskService.getBaseMapper().selectById(taskId);
|
||||
if (contractCompareTask == null) {
|
||||
throw new RuntimeException("任务不存在");
|
||||
}
|
||||
contractUrl = contractCompareTask.getFirstContractUrl();
|
||||
} else if (taskType == 3) {
|
||||
// 副版pdf
|
||||
ContractCompareTask contractCompareTask = contractCompareTaskService.getBaseMapper().selectById(taskId);
|
||||
if (contractCompareTask == null) {
|
||||
throw new RuntimeException("任务不存在");
|
||||
}
|
||||
contractUrl = contractCompareTask.getSecondContractUrl();
|
||||
} else {
|
||||
throw new RuntimeException("任务类型错误");
|
||||
}
|
||||
if (contractUrl == null) {
|
||||
throw new RuntimeException("任务不存在");
|
||||
}
|
||||
try (InputStream inputStream = new URL(contractUrl).openStream()) {
|
||||
response.setContentType("application/pdf");
|
||||
response.setHeader("Content-Disposition", "inline; filename=\"contract.pdf\"");
|
||||
byte[] buffer = new byte[4096];
|
||||
int bytesRead;
|
||||
while ((bytesRead = inputStream.read(buffer)) != -1) {
|
||||
response.getOutputStream().write(buffer, 0, bytesRead);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.qingyun.web.controller.api.contract;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import com.qingyun.common.core.controller.BaseController;
|
||||
import com.qingyun.common.core.domain.R;
|
||||
import com.qingyun.service.domain.vo.ContractReviewResultVo;
|
||||
import com.qingyun.service.service.IContractReviewResultService;
|
||||
|
||||
/**
|
||||
* 合同审查结果
|
||||
*
|
||||
* @author jianlu
|
||||
* @date 2025-07-11
|
||||
*/
|
||||
@Validated
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/api/service/reviewResult")
|
||||
public class ContractReviewResultController extends BaseController {
|
||||
|
||||
private final IContractReviewResultService contractReviewResultService;
|
||||
|
||||
/**
|
||||
* 查询审查结果列表 "service:reviewResult:list"
|
||||
*/
|
||||
@SaCheckPermission("service:reviewResult:list")
|
||||
@GetMapping("/list/{taskId}")
|
||||
public R<List<ContractReviewResultVo>> list(@PathVariable("taskId") Long taskId) {
|
||||
return R.ok(contractReviewResultService.queryList(taskId));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,308 @@
|
||||
package com.qingyun.web.controller.api.contract;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.qingyun.common.config.QingYunConfig;
|
||||
import com.qingyun.common.exception.ServiceException;
|
||||
import com.qingyun.common.helper.LoginHelper;
|
||||
import com.qingyun.common.utils.DateUtils;
|
||||
import com.qingyun.common.utils.MapstructUtils;
|
||||
import com.qingyun.service.compare.service.ReviewTaskService;
|
||||
import com.qingyun.service.domain.ContractReviewResult;
|
||||
import com.qingyun.service.domain.ContractReviewTask;
|
||||
import com.qingyun.service.domain.ContractRuleTemplate;
|
||||
import com.qingyun.service.mapper.ContractReviewTaskMapper;
|
||||
import com.qingyun.service.service.IContractRuleTemplateService;
|
||||
import com.qingyun.service.service.impl.ContractReviewResultServiceImpl;
|
||||
import com.qingyun.service.utils.PdfUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.ibatis.session.SqlSession;
|
||||
import org.apache.ibatis.session.SqlSessionFactory;
|
||||
import org.apache.pdfbox.Loader;
|
||||
import org.apache.pdfbox.pdmodel.PDDocument;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import com.qingyun.idempotent.annotation.RepeatSubmit;
|
||||
import com.qingyun.common.annotation.Log;
|
||||
import com.qingyun.common.core.controller.BaseController;
|
||||
import com.qingyun.common.core.domain.PageQuery;
|
||||
import com.qingyun.common.core.domain.R;
|
||||
import com.qingyun.common.core.validate.AddGroup;
|
||||
import com.qingyun.common.core.validate.EditGroup;
|
||||
import com.qingyun.common.enums.BusinessType;
|
||||
import com.qingyun.service.domain.vo.ContractReviewTaskVo;
|
||||
import com.qingyun.service.domain.bo.ContractReviewTaskBo;
|
||||
import com.qingyun.service.service.IContractReviewTaskService;
|
||||
import com.qingyun.mybatisplus.page.TableDataInfo;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* 合同审查任务
|
||||
*
|
||||
* @author jianlu
|
||||
* @date 2025-07-15
|
||||
*/
|
||||
@Slf4j
|
||||
@Validated
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/api/service/reviewTask")
|
||||
public class ContractReviewTaskController extends BaseController {
|
||||
|
||||
private final IContractReviewTaskService contractReviewTaskService;
|
||||
|
||||
private final IContractRuleTemplateService contractRuleTemplateService;
|
||||
|
||||
private final ReviewTaskService reviewTaskService;
|
||||
|
||||
private final SqlSessionFactory sqlSessionFactory;
|
||||
|
||||
private final PdfUtil pdfUtil;
|
||||
|
||||
private final ContractReviewResultServiceImpl contractReviewResultService;
|
||||
|
||||
/**
|
||||
* 查询审查任务列表 "service:reviewTask:list"
|
||||
*/
|
||||
@SaCheckPermission("service:reviewTask:list")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo<ContractReviewTaskVo> list(ContractReviewTaskBo bo, PageQuery pageQuery) {
|
||||
return contractReviewTaskService.queryPageList(bo, pageQuery);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取审查任务详细信息 "service:reviewTask:query"
|
||||
*
|
||||
* @param taskId 主键
|
||||
*/
|
||||
@SaCheckPermission("service:reviewTask:query")
|
||||
@GetMapping("/{taskId}")
|
||||
public R<ContractReviewTaskVo> getInfo(@NotNull(message = "主键不能为空")
|
||||
@PathVariable Long taskId) {
|
||||
return R.ok(contractReviewTaskService.queryById(taskId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增审查任务 "service:reviewTask:add"
|
||||
*/
|
||||
@SaCheckPermission("service:reviewTask:add")
|
||||
@Log(title = "审查任务", businessType = BusinessType.INSERT)
|
||||
//@RepeatSubmit(interval = 60000, message = "请稍候再试")
|
||||
@PostMapping("/create")
|
||||
public R<Integer> add(@Validated(AddGroup.class) @RequestBody ContractReviewTaskBo bo) {
|
||||
ContractReviewTask add = MapstructUtils.convert(bo, ContractReviewTask.class);
|
||||
if (add == null) {
|
||||
return R.fail("创建审查任务失败");
|
||||
}
|
||||
|
||||
ContractRuleTemplate contractRuleTemplate = contractRuleTemplateService.getBaseMapper().selectById(bo.getTemplateId());
|
||||
if (contractRuleTemplate == null) {
|
||||
return R.fail("配置规则模板不存在");
|
||||
}
|
||||
add.setReviewRule(contractRuleTemplate.getReviewRuleJson());
|
||||
add.setReviewElement(contractRuleTemplate.getReviewElementJson());
|
||||
|
||||
File pdfFile;
|
||||
File tempFile = null;
|
||||
try {
|
||||
// 临时文件
|
||||
tempFile = pdfUtil.downloadFile(add.getContractUrl(), add.getContractName());
|
||||
pdfFile = tempFile;
|
||||
String fileName = add.getContractName().toLowerCase();
|
||||
|
||||
// 判断文件类型
|
||||
//如果是word类型转换成pdf
|
||||
if (fileName.endsWith(".doc") || fileName.endsWith(".docx")) {
|
||||
pdfFile = pdfUtil.convertWordToPdf(tempFile);
|
||||
// 在用户上传的word文件路径目录下创建新的pdf格式文件路径
|
||||
String needUploadName = DateUtils.datePath() + "/" + IdUtil.fastUUID() + "/" +
|
||||
fileName.substring(0, fileName.lastIndexOf(".")) + ".pdf";
|
||||
String filePath = QingYunConfig.getUploadPath() + "/" + needUploadName;
|
||||
|
||||
// 确保目录存在
|
||||
File destFile = new File(filePath);
|
||||
destFile.getParentFile().mkdirs();
|
||||
|
||||
// 将转换后的PDF文件移动到目标位置
|
||||
File targetFile = new File(filePath);
|
||||
if (pdfFile.renameTo(targetFile)) {
|
||||
pdfFile = targetFile;
|
||||
} else {
|
||||
// 如果renameTo失败,尝试复制文件
|
||||
try (FileInputStream fis = new FileInputStream(pdfFile)) {
|
||||
Files.copy(pdfFile.toPath(), targetFile.toPath());
|
||||
pdfFile = targetFile;
|
||||
}
|
||||
}
|
||||
// 更新合同URL为新的PDF文件路径
|
||||
add.setContractUrl("/profile/upload/" + needUploadName);
|
||||
}
|
||||
|
||||
// 处理PDF文件
|
||||
PDDocument firstDocument = Loader.loadPDF(pdfFile);
|
||||
if (firstDocument == null) {
|
||||
throw new ServiceException("解析PDF文件失败");
|
||||
}
|
||||
add.setPageNum(firstDocument.getNumberOfPages());
|
||||
if (firstDocument.getNumberOfPages() > 0) {
|
||||
add.setWidth(firstDocument.getPage(0).getMediaBox().getWidth());
|
||||
add.setHeight(firstDocument.getPage(0).getMediaBox().getHeight());
|
||||
}
|
||||
firstDocument.close();
|
||||
} catch (ServiceException e) {
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
throw new ServiceException("解析文件失败");
|
||||
} finally {
|
||||
try {
|
||||
if (tempFile != null && tempFile.exists()) {
|
||||
Files.deleteIfExists(tempFile.toPath());
|
||||
}
|
||||
} catch (IOException e) {
|
||||
log.error("删除文件失败", e);
|
||||
}
|
||||
}
|
||||
|
||||
add.setUserId(LoginHelper.getUserId());
|
||||
add.setDeptId(LoginHelper.getDeptId());
|
||||
add.setStatus(2); // 获取原文中
|
||||
add.setCreateBy(LoginHelper.getUsername());
|
||||
add.setCreateTime(new Date());
|
||||
|
||||
try (SqlSession sqlSession = sqlSessionFactory.openSession()) {
|
||||
ContractReviewTaskMapper mapper = sqlSession.getMapper(ContractReviewTaskMapper.class);
|
||||
mapper.insert(add);
|
||||
sqlSession.commit(); // 手动提交事务
|
||||
} catch (Exception e) {
|
||||
return R.fail("创建审查任务失败");
|
||||
}
|
||||
// 异步执行解析合同文档中
|
||||
contractReviewTaskService.execute(add, null);
|
||||
return R.ok("创建成功", 2);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 执行审查任务 "service:reviewTask:execute"
|
||||
*/
|
||||
@SaCheckPermission("service:reviewTask:execute")
|
||||
//@RepeatSubmit(interval = 60000, message = "任务正在执行中")
|
||||
@GetMapping("/execute/{taskId}")
|
||||
public R<Integer> execute(@PathVariable Long taskId) {
|
||||
BaseMapper<ContractReviewTask> baseMapper = contractReviewTaskService.getBaseMapper();
|
||||
ContractReviewTask contractReviewTask = baseMapper.selectById(taskId);
|
||||
if (contractReviewTask == null) {
|
||||
return R.fail("任务不存在");
|
||||
}
|
||||
if (contractReviewTask.getStatus() == 2) {
|
||||
return R.fail("任务正在执行中", 2);
|
||||
}
|
||||
// if (contractReviewTask.getStatus() != 0) {
|
||||
// return R.fail("任务还未准备好", contractReviewTask.getStatus());
|
||||
// }
|
||||
if (contractReviewTask.getTemplateId() == null && StringUtils.isBlank(contractReviewTask.getReviewRule())) {
|
||||
return R.fail("请先配置审查规则");
|
||||
}
|
||||
contractReviewTask.setStatus(2);
|
||||
try (SqlSession sqlSession = sqlSessionFactory.openSession()) {
|
||||
ContractReviewTaskMapper mapper = sqlSession.getMapper(ContractReviewTaskMapper.class);
|
||||
mapper.updateById(contractReviewTask);
|
||||
sqlSession.commit(); // 手动提交事务
|
||||
} catch (Exception e) {
|
||||
return R.fail("重试失败");
|
||||
}
|
||||
|
||||
// 删除审查结果
|
||||
contractReviewResultService.getBaseMapper().delete(Wrappers.<ContractReviewResult>lambdaQuery().eq(ContractReviewResult::getTaskId, taskId));
|
||||
|
||||
// 异步执行审查逻辑
|
||||
contractReviewTaskService.execute(contractReviewTask, contractReviewTask.getModelId());
|
||||
return R.ok(2);
|
||||
}
|
||||
|
||||
/**
|
||||
* 重试 "service:reviewTask:retry"
|
||||
* @param taskId 任务ID
|
||||
*/
|
||||
@SaCheckPermission("service:reviewTask:retry")
|
||||
@GetMapping("/retry/{taskId}")
|
||||
public R<Integer> retry(@PathVariable("taskId") Long taskId) {
|
||||
BaseMapper<ContractReviewTask> baseMapper = contractReviewTaskService.getBaseMapper();
|
||||
ContractReviewTask contractReviewTask = baseMapper.selectById(taskId);
|
||||
if (contractReviewTask == null) {
|
||||
return R.fail("任务不存在");
|
||||
}
|
||||
Integer status = contractReviewTask.getStatus();
|
||||
if (status == 1) {
|
||||
// 重试解析pdf页面
|
||||
reviewTaskService.parsePdf(contractReviewTask);
|
||||
return R.ok("重试成功", 1);
|
||||
} else {
|
||||
try (SqlSession sqlSession = sqlSessionFactory.openSession()) {
|
||||
contractReviewTask.setStatus(2);
|
||||
ContractReviewTaskMapper mapper = sqlSession.getMapper(ContractReviewTaskMapper.class);
|
||||
mapper.updateById(contractReviewTask);
|
||||
sqlSession.commit(); // 手动提交事务
|
||||
} catch (Exception e) {
|
||||
return R.fail("重试失败");
|
||||
}
|
||||
// 删除审查结果
|
||||
contractReviewResultService.getBaseMapper().delete(Wrappers.<ContractReviewResult>lambdaQuery().eq(ContractReviewResult::getTaskId, taskId));
|
||||
// 重新执行任务
|
||||
contractReviewTaskService.execute(contractReviewTask, contractReviewTask.getModelId());
|
||||
return R.ok("重试成功", 2);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取审查任务状态 "service:reviewTask:status"
|
||||
*/
|
||||
@SaCheckPermission("service:reviewTask:status")
|
||||
@GetMapping("/status/{taskId}")
|
||||
public R<Integer> status(@PathVariable("taskId") Long taskId) {
|
||||
BaseMapper<ContractReviewTask> baseMapper = contractReviewTaskService.getBaseMapper();
|
||||
ContractReviewTask contractReviewTask = baseMapper.selectById(taskId);
|
||||
if (contractReviewTask == null) {
|
||||
return R.fail("任务不存在");
|
||||
}
|
||||
return R.ok(contractReviewTask.getStatus());
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改审查任务 "service:reviewTask:edit"
|
||||
*/
|
||||
@SaCheckPermission("service:reviewTask:edit")
|
||||
@Log(title = "审查任务", businessType = BusinessType.UPDATE)
|
||||
@RepeatSubmit()
|
||||
@PostMapping("/update")
|
||||
public R<Void> edit(@Validated(EditGroup.class) @RequestBody ContractReviewTaskBo bo) {
|
||||
return toAjax(contractReviewTaskService.updateByBo(bo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除审查任务 "service:reviewTask:remove"
|
||||
*
|
||||
* @param taskIds 主键串
|
||||
*/
|
||||
@SaCheckPermission("service:reviewTask:remove")
|
||||
@Log(title = "审查任务", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{taskIds}")
|
||||
public R<Void> remove(@NotEmpty(message = "主键不能为空")
|
||||
@PathVariable Long[] taskIds) {
|
||||
return toAjax(contractReviewTaskService.deleteWithValidByIds(Arrays.asList(taskIds), Boolean.TRUE));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
package com.qingyun.web.controller.api.contract;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import com.qingyun.idempotent.annotation.RepeatSubmit;
|
||||
import com.qingyun.common.annotation.Log;
|
||||
import com.qingyun.common.core.controller.BaseController;
|
||||
import com.qingyun.common.core.domain.PageQuery;
|
||||
import com.qingyun.common.core.domain.R;
|
||||
import com.qingyun.common.core.validate.AddGroup;
|
||||
import com.qingyun.common.core.validate.EditGroup;
|
||||
import com.qingyun.common.enums.BusinessType;
|
||||
import com.qingyun.service.domain.vo.ContractRuleTemplateVo;
|
||||
import com.qingyun.service.domain.bo.ContractRuleTemplateBo;
|
||||
import com.qingyun.service.service.IContractRuleTemplateService;
|
||||
import com.qingyun.mybatisplus.page.TableDataInfo;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
/**
|
||||
* 规则要素模板
|
||||
*
|
||||
* @author jianlu
|
||||
* @date 2025-07-11
|
||||
*/
|
||||
@Validated
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/service/ruleTemplate")
|
||||
public class ContractRuleTemplateController extends BaseController {
|
||||
|
||||
private final IContractRuleTemplateService contractRuleTemplateService;
|
||||
|
||||
/**
|
||||
* 查询规则要素模板列表 "service:ruleTemplate:list"
|
||||
*/
|
||||
@SaCheckPermission("service:ruleTemplate:list")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo<ContractRuleTemplateVo> list(ContractRuleTemplateBo bo, PageQuery pageQuery) {
|
||||
return contractRuleTemplateService.queryPageList(bo, pageQuery);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取规则要素模板详细信息 "service:ruleTemplate:query"
|
||||
*
|
||||
* @param id 主键
|
||||
*/
|
||||
@SaCheckPermission("service:ruleTemplate:query")
|
||||
@GetMapping("/{id}")
|
||||
public R<ContractRuleTemplateVo> getInfo(@NotNull(message = "主键不能为空")
|
||||
@PathVariable String id) {
|
||||
return R.ok(contractRuleTemplateService.queryById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增规则要素模板 "service:ruleTemplate:add"
|
||||
*/
|
||||
@SaCheckPermission("service:ruleTemplate:add")
|
||||
@Log(title = "规则要素模板", businessType = BusinessType.INSERT)
|
||||
@RepeatSubmit()
|
||||
@PostMapping()
|
||||
public R<Void> add(@Validated(AddGroup.class) @RequestBody ContractRuleTemplateBo bo) {
|
||||
return toAjax(contractRuleTemplateService.insertByBo(bo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改规则要素模板 "service:ruleTemplate:edit"
|
||||
*/
|
||||
@SaCheckPermission("service:ruleTemplate:edit")
|
||||
@Log(title = "规则要素模板", businessType = BusinessType.UPDATE)
|
||||
@RepeatSubmit()
|
||||
@PutMapping()
|
||||
public R<Void> edit(@Validated(EditGroup.class) @RequestBody ContractRuleTemplateBo bo) {
|
||||
return toAjax(contractRuleTemplateService.updateByBo(bo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除规则要素模板 "service:ruleTemplate:remove"
|
||||
*
|
||||
* @param ids 主键串
|
||||
*/
|
||||
@SaCheckPermission("service:ruleTemplate:remove")
|
||||
@Log(title = "规则要素模板", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
public R<Void> remove(@NotEmpty(message = "主键不能为空")
|
||||
@PathVariable String[] ids) {
|
||||
return toAjax(contractRuleTemplateService.deleteWithValidByIds(Arrays.asList(ids), Boolean.TRUE));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,168 @@
|
||||
package com.qingyun.web.controller.monitor;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.qingyun.common.constant.CacheConstants;
|
||||
import com.qingyun.common.constant.CacheNames;
|
||||
import com.qingyun.common.core.domain.R;
|
||||
import com.qingyun.common.utils.JsonUtils;
|
||||
import com.qingyun.common.utils.StringUtils;
|
||||
import com.qingyun.common.utils.redis.CacheUtils;
|
||||
import com.qingyun.common.utils.redis.RedisUtils;
|
||||
import com.qingyun.system.domain.SysCache;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.redisson.spring.data.connection.RedissonConnectionFactory;
|
||||
import org.springframework.data.redis.connection.RedisConnection;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 缓存监控
|
||||
*
|
||||
* @author jianlu
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/monitor/cache")
|
||||
public class CacheController {
|
||||
|
||||
private final RedissonConnectionFactory connectionFactory;
|
||||
|
||||
private final static List<SysCache> CACHES = new ArrayList<>();
|
||||
|
||||
static {
|
||||
CACHES.add(new SysCache(CacheConstants.ONLINE_TOKEN_KEY, "在线用户"));
|
||||
CACHES.add(new SysCache(CacheNames.SYS_CONFIG, "配置信息"));
|
||||
CACHES.add(new SysCache(CacheNames.SYS_DICT, "数据字典"));
|
||||
CACHES.add(new SysCache(CacheConstants.CAPTCHA_CODE_KEY, "验证码"));
|
||||
CACHES.add(new SysCache(CacheConstants.REPEAT_SUBMIT_KEY, "防重提交"));
|
||||
CACHES.add(new SysCache(CacheConstants.RATE_LIMIT_KEY, "限流处理"));
|
||||
CACHES.add(new SysCache(CacheNames.SYS_OSS_CONFIG, "OSS配置"));
|
||||
CACHES.add(new SysCache(CacheConstants.PWD_ERR_CNT_KEY, "密码错误次数"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取缓存监控列表
|
||||
*/
|
||||
@SaCheckPermission("monitor:cache:list")
|
||||
@GetMapping()
|
||||
public R<Map<String, Object>> getInfo() throws Exception {
|
||||
RedisConnection connection = connectionFactory.getConnection();
|
||||
Properties info = connection.info();
|
||||
Properties commandStats = connection.info("commandstats");
|
||||
Long dbSize = connection.dbSize();
|
||||
|
||||
Map<String, Object> result = new HashMap<>(3);
|
||||
result.put("info", info);
|
||||
result.put("dbSize", dbSize);
|
||||
|
||||
List<Map<String, String>> pieList = new ArrayList<>();
|
||||
if (commandStats != null) {
|
||||
commandStats.stringPropertyNames().forEach(key -> {
|
||||
Map<String, String> data = new HashMap<>(2);
|
||||
String property = commandStats.getProperty(key);
|
||||
data.put("name", StringUtils.removeStart(key, "cmdstat_"));
|
||||
data.put("value", StringUtils.substringBetween(property, "calls=", ",usec"));
|
||||
pieList.add(data);
|
||||
});
|
||||
}
|
||||
result.put("commandStats", pieList);
|
||||
return R.ok(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取缓存监控缓存名列表
|
||||
*/
|
||||
@SaCheckPermission("monitor:cache:list")
|
||||
@GetMapping("/getNames")
|
||||
public R<List<SysCache>> cache() {
|
||||
return R.ok(CACHES);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取缓存监控Key列表
|
||||
*
|
||||
* @param cacheName 缓存名
|
||||
*/
|
||||
@SaCheckPermission("monitor:cache:list")
|
||||
@GetMapping("/getKeys/{cacheName}")
|
||||
public R<Collection<String>> getCacheKeys(@PathVariable String cacheName) {
|
||||
Collection<String> cacheKeys = new HashSet<>(0);
|
||||
if (isCacheNames(cacheName)) {
|
||||
Set<Object> keys = CacheUtils.keys(cacheName);
|
||||
if (CollUtil.isNotEmpty(keys)) {
|
||||
cacheKeys = keys.stream().map(Object::toString).collect(Collectors.toList());
|
||||
}
|
||||
} else {
|
||||
cacheKeys = RedisUtils.keys(cacheName + "*");
|
||||
}
|
||||
return R.ok(cacheKeys);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取缓存监控缓存值详情
|
||||
*
|
||||
* @param cacheName 缓存名
|
||||
* @param cacheKey 缓存key
|
||||
*/
|
||||
@SaCheckPermission("monitor:cache:list")
|
||||
@GetMapping("/getValue/{cacheName}/{cacheKey}")
|
||||
public R<SysCache> getCacheValue(@PathVariable String cacheName, @PathVariable String cacheKey) {
|
||||
Object cacheValue;
|
||||
if (isCacheNames(cacheName)) {
|
||||
cacheValue = CacheUtils.get(cacheName, cacheKey);
|
||||
} else {
|
||||
cacheValue = RedisUtils.getCacheObject(cacheKey);
|
||||
}
|
||||
SysCache sysCache = new SysCache(cacheName, cacheKey, JsonUtils.toJsonString(cacheValue));
|
||||
return R.ok(sysCache);
|
||||
}
|
||||
|
||||
/**
|
||||
* 清理缓存监控缓存名
|
||||
*
|
||||
* @param cacheName 缓存名
|
||||
*/
|
||||
@SaCheckPermission("monitor:cache:list")
|
||||
@DeleteMapping("/clearCacheName/{cacheName}")
|
||||
public R<Void> clearCacheName(@PathVariable String cacheName) {
|
||||
if (isCacheNames(cacheName)) {
|
||||
CacheUtils.clear(cacheName);
|
||||
} else {
|
||||
RedisUtils.deleteKeys(cacheName + "*");
|
||||
}
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 清理缓存监控Key
|
||||
*
|
||||
* @param cacheKey key名
|
||||
*/
|
||||
@SaCheckPermission("monitor:cache:list")
|
||||
@DeleteMapping("/clearCacheKey/{cacheName}/{cacheKey}")
|
||||
public R<Void> clearCacheKey(@PathVariable String cacheName, @PathVariable String cacheKey) {
|
||||
if (isCacheNames(cacheName)) {
|
||||
CacheUtils.evict(cacheName, cacheKey);
|
||||
} else {
|
||||
RedisUtils.deleteObject(cacheKey);
|
||||
}
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 清理全部缓存监控
|
||||
*/
|
||||
@SaCheckPermission("monitor:cache:list")
|
||||
@DeleteMapping("/clearCacheAll")
|
||||
public R<Void> clearCacheAll() {
|
||||
RedisUtils.deleteKeys("*");
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
private boolean isCacheNames(String cacheName) {
|
||||
return !StringUtils.contains(cacheName, ":");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
package com.qingyun.web.controller.monitor;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import com.qingyun.common.annotation.Log;
|
||||
import com.qingyun.common.constant.CacheConstants;
|
||||
import com.qingyun.common.core.controller.BaseController;
|
||||
import com.qingyun.common.core.domain.PageQuery;
|
||||
import com.qingyun.common.core.domain.R;
|
||||
import com.qingyun.mybatisplus.page.TableDataInfo;
|
||||
import com.qingyun.common.enums.BusinessType;
|
||||
import com.qingyun.common.utils.poi.ExcelUtil;
|
||||
import com.qingyun.common.utils.redis.RedisUtils;
|
||||
import com.qingyun.system.domain.SysLogininfor;
|
||||
import com.qingyun.system.service.ISysLogininforService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 系统访问记录
|
||||
*
|
||||
* @author jianlu
|
||||
*/
|
||||
@Validated
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/monitor/logininfor")
|
||||
public class SysLogininforController extends BaseController {
|
||||
|
||||
private final ISysLogininforService logininforService;
|
||||
|
||||
/**
|
||||
* 获取系统访问记录列表
|
||||
*/
|
||||
@SaCheckPermission("monitor:logininfor:list")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo<SysLogininfor> list(SysLogininfor logininfor, PageQuery pageQuery) {
|
||||
return logininforService.selectPageLogininforList(logininfor, pageQuery);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出系统访问记录列表
|
||||
*/
|
||||
@Log(title = "登录日志", businessType = BusinessType.EXPORT)
|
||||
@SaCheckPermission("monitor:logininfor:export")
|
||||
@PostMapping("/export")
|
||||
public void export(SysLogininfor logininfor, HttpServletResponse response) {
|
||||
List<SysLogininfor> list = logininforService.selectLogininforList(logininfor);
|
||||
ExcelUtil.exportExcel(list, "登录日志", SysLogininfor.class, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除登录日志
|
||||
* @param infoIds 日志ids
|
||||
*/
|
||||
@SaCheckPermission("monitor:logininfor:remove")
|
||||
@Log(title = "登录日志", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{infoIds}")
|
||||
public R<Void> remove(@PathVariable Long[] infoIds) {
|
||||
return toAjax(logininforService.deleteLogininforByIds(infoIds));
|
||||
}
|
||||
|
||||
/**
|
||||
* 清理系统访问记录
|
||||
*/
|
||||
@SaCheckPermission("monitor:logininfor:remove")
|
||||
@Log(title = "登录日志", businessType = BusinessType.CLEAN)
|
||||
@DeleteMapping("/clean")
|
||||
public R<Void> clean() {
|
||||
logininforService.cleanLogininfor();
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@SaCheckPermission("monitor:logininfor:unlock")
|
||||
@Log(title = "账户解锁", businessType = BusinessType.OTHER)
|
||||
@GetMapping("/unlock/{userName}")
|
||||
public R<Void> unlock(@PathVariable("userName") String userName) {
|
||||
String loginName = CacheConstants.PWD_ERR_CNT_KEY + userName;
|
||||
if (RedisUtils.hasKey(loginName)) {
|
||||
RedisUtils.deleteObject(loginName);
|
||||
}
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
package com.qingyun.web.controller.monitor;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import com.qingyun.common.annotation.Log;
|
||||
import com.qingyun.common.core.controller.BaseController;
|
||||
import com.qingyun.common.core.domain.PageQuery;
|
||||
import com.qingyun.common.core.domain.R;
|
||||
import com.qingyun.mybatisplus.page.TableDataInfo;
|
||||
import com.qingyun.common.enums.BusinessType;
|
||||
import com.qingyun.common.utils.poi.ExcelUtil;
|
||||
import com.qingyun.system.domain.SysOperLog;
|
||||
import com.qingyun.system.service.ISysOperLogService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 操作日志记录
|
||||
*
|
||||
* @author jianlu
|
||||
*/
|
||||
@Validated
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/monitor/operlog")
|
||||
public class SysOperlogController extends BaseController {
|
||||
|
||||
private final ISysOperLogService operLogService;
|
||||
|
||||
/**
|
||||
* 获取操作日志记录列表
|
||||
*/
|
||||
@SaCheckPermission("monitor:operlog:list")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo<SysOperLog> list(SysOperLog operLog, PageQuery pageQuery) {
|
||||
return operLogService.selectPageOperLogList(operLog, pageQuery);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出操作日志记录列表
|
||||
*/
|
||||
@Log(title = "操作日志", businessType = BusinessType.EXPORT)
|
||||
@SaCheckPermission("monitor:operlog:export")
|
||||
@PostMapping("/export")
|
||||
public void export(SysOperLog operLog, HttpServletResponse response) {
|
||||
List<SysOperLog> list = operLogService.selectOperLogList(operLog);
|
||||
ExcelUtil.exportExcel(list, "操作日志", SysOperLog.class, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除操作日志记录
|
||||
* @param operIds 日志ids
|
||||
*/
|
||||
@Log(title = "操作日志", businessType = BusinessType.DELETE)
|
||||
@SaCheckPermission("monitor:operlog:remove")
|
||||
@DeleteMapping("/{operIds}")
|
||||
public R<Void> remove(@PathVariable Long[] operIds) {
|
||||
return toAjax(operLogService.deleteOperLogByIds(operIds));
|
||||
}
|
||||
|
||||
/**
|
||||
* 清理操作日志记录
|
||||
*/
|
||||
@Log(title = "操作日志", businessType = BusinessType.CLEAN)
|
||||
@SaCheckPermission("monitor:operlog:remove")
|
||||
@DeleteMapping("/clean")
|
||||
public R<Void> clean() {
|
||||
operLogService.cleanOperLog();
|
||||
return R.ok();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
package com.qingyun.web.controller.monitor;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import cn.dev33.satoken.exception.NotLoginException;
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.qingyun.common.annotation.Log;
|
||||
import com.qingyun.common.constant.CacheConstants;
|
||||
import com.qingyun.common.core.controller.BaseController;
|
||||
import com.qingyun.common.core.domain.R;
|
||||
import com.qingyun.common.core.domain.dto.UserOnlineDTO;
|
||||
import com.qingyun.mybatisplus.page.TableDataInfo;
|
||||
import com.qingyun.common.enums.BusinessType;
|
||||
import com.qingyun.common.utils.StreamUtils;
|
||||
import com.qingyun.common.utils.StringUtils;
|
||||
import com.qingyun.common.utils.redis.RedisUtils;
|
||||
import com.qingyun.system.domain.SysUserOnline;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 在线用户监控
|
||||
*
|
||||
* @author jianlu
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/monitor/online")
|
||||
public class SysUserOnlineController extends BaseController {
|
||||
|
||||
/**
|
||||
* 获取在线用户监控列表
|
||||
*
|
||||
* @param ipaddr IP地址
|
||||
* @param userName 用户名
|
||||
*/
|
||||
@SaCheckPermission("monitor:online:list")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo<SysUserOnline> list(String ipaddr, String userName) {
|
||||
// 获取所有未过期的 token
|
||||
List<String> keys = StpUtil.searchTokenValue("", 0, -1, false);
|
||||
List<UserOnlineDTO> userOnlineDTOList = new ArrayList<>();
|
||||
for (String key : keys) {
|
||||
String token = StringUtils.substringAfterLast(key, ":");
|
||||
// 如果已经过期则跳过
|
||||
if (StpUtil.stpLogic.getTokenActivityTimeoutByToken(token) < -1) {
|
||||
continue;
|
||||
}
|
||||
|
||||
userOnlineDTOList.add(RedisUtils.getCacheObject(CacheConstants.ONLINE_TOKEN_KEY + token));
|
||||
}
|
||||
if (StringUtils.isNotEmpty(ipaddr) && StringUtils.isNotEmpty(userName)) {
|
||||
userOnlineDTOList = StreamUtils.filter(userOnlineDTOList, userOnline ->
|
||||
StringUtils.equals(ipaddr, userOnline.getIpaddr()) &&
|
||||
StringUtils.equals(userName, userOnline.getUserName())
|
||||
);
|
||||
} else if (StringUtils.isNotEmpty(ipaddr)) {
|
||||
userOnlineDTOList = StreamUtils.filter(userOnlineDTOList, userOnline ->
|
||||
StringUtils.equals(ipaddr, userOnline.getIpaddr())
|
||||
);
|
||||
} else if (StringUtils.isNotEmpty(userName)) {
|
||||
userOnlineDTOList = StreamUtils.filter(userOnlineDTOList, userOnline ->
|
||||
StringUtils.equals(userName, userOnline.getUserName())
|
||||
);
|
||||
}
|
||||
Collections.reverse(userOnlineDTOList);
|
||||
userOnlineDTOList.removeAll(Collections.singleton(null));
|
||||
List<SysUserOnline> userOnlineList = BeanUtil.copyToList(userOnlineDTOList, SysUserOnline.class);
|
||||
return TableDataInfo.build(userOnlineList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 强退用户
|
||||
*
|
||||
* @param tokenId token值
|
||||
*/
|
||||
@SaCheckPermission("monitor:online:forceLogout")
|
||||
@Log(title = "在线用户", businessType = BusinessType.FORCE)
|
||||
@DeleteMapping("/{tokenId}")
|
||||
public R<Void> forceLogout(@PathVariable String tokenId) {
|
||||
try {
|
||||
StpUtil.kickoutByTokenValue(tokenId);
|
||||
} catch (NotLoginException ignored) {
|
||||
}
|
||||
return R.ok();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,136 @@
|
||||
package com.qingyun.web.controller.system;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import com.qingyun.common.annotation.Log;
|
||||
import com.qingyun.common.core.controller.BaseController;
|
||||
import com.qingyun.common.core.domain.PageQuery;
|
||||
import com.qingyun.common.core.domain.R;
|
||||
import com.qingyun.mybatisplus.page.TableDataInfo;
|
||||
import com.qingyun.common.enums.BusinessType;
|
||||
import com.qingyun.common.utils.poi.ExcelUtil;
|
||||
import com.qingyun.system.domain.SysConfig;
|
||||
import com.qingyun.system.service.ISysConfigService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 参数配置 信息操作处理
|
||||
*
|
||||
* @author jianlu
|
||||
*/
|
||||
@Validated
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/system/config")
|
||||
public class SysConfigController extends BaseController {
|
||||
|
||||
private final ISysConfigService configService;
|
||||
|
||||
/**
|
||||
* 获取参数配置列表
|
||||
*/
|
||||
@SaCheckPermission("system:config:list")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo<SysConfig> list(SysConfig config, PageQuery pageQuery) {
|
||||
return configService.selectPageConfigList(config, pageQuery);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出参数配置列表
|
||||
*/
|
||||
@Log(title = "参数管理", businessType = BusinessType.EXPORT)
|
||||
@SaCheckPermission("system:config:export")
|
||||
@PostMapping("/export")
|
||||
public void export(SysConfig config, HttpServletResponse response) {
|
||||
List<SysConfig> list = configService.selectConfigList(config);
|
||||
ExcelUtil.exportExcel(list, "参数数据", SysConfig.class, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据参数编号获取详细信息
|
||||
*
|
||||
* @param configId 参数ID
|
||||
*/
|
||||
@SaCheckPermission("system:config:query")
|
||||
@GetMapping(value = "/{configId}")
|
||||
public R<SysConfig> getInfo(@PathVariable Long configId) {
|
||||
return R.ok(configService.selectConfigById(configId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据参数键名查询参数值
|
||||
*
|
||||
* @param configKey 参数Key
|
||||
*/
|
||||
@GetMapping(value = "/configKey/{configKey}")
|
||||
public R<Void> getConfigKey(@PathVariable String configKey) {
|
||||
return R.ok(configService.selectConfigByKey(configKey));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增参数配置
|
||||
*/
|
||||
@SaCheckPermission("system:config:add")
|
||||
@Log(title = "参数管理", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public R<Void> add(@Validated @RequestBody SysConfig config) {
|
||||
if (!configService.checkConfigKeyUnique(config)) {
|
||||
return R.fail("新增参数'" + config.getConfigName() + "'失败,参数键名已存在");
|
||||
}
|
||||
configService.insertConfig(config);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改参数配置
|
||||
*/
|
||||
@SaCheckPermission("system:config:edit")
|
||||
@Log(title = "参数管理", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public R<Void> edit(@Validated @RequestBody SysConfig config) {
|
||||
if (!configService.checkConfigKeyUnique(config)) {
|
||||
return R.fail("修改参数'" + config.getConfigName() + "'失败,参数键名已存在");
|
||||
}
|
||||
configService.updateConfig(config);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据参数键名修改参数配置
|
||||
*/
|
||||
@SaCheckPermission("system:config:edit")
|
||||
@Log(title = "参数管理", businessType = BusinessType.UPDATE)
|
||||
@PutMapping("/updateByKey")
|
||||
public R<Void> updateByKey(@RequestBody SysConfig config) {
|
||||
configService.updateConfig(config);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除参数配置
|
||||
*
|
||||
* @param configIds 参数ID串
|
||||
*/
|
||||
@SaCheckPermission("system:config:remove")
|
||||
@Log(title = "参数管理", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{configIds}")
|
||||
public R<Void> remove(@PathVariable Long[] configIds) {
|
||||
configService.deleteConfigByIds(configIds);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 刷新参数缓存
|
||||
*/
|
||||
@SaCheckPermission("system:config:remove")
|
||||
@Log(title = "参数管理", businessType = BusinessType.CLEAN)
|
||||
@DeleteMapping("/refreshCache")
|
||||
public R<Void> refreshCache() {
|
||||
configService.resetConfigCache();
|
||||
return R.ok();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,119 @@
|
||||
package com.qingyun.web.controller.system;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import com.qingyun.common.annotation.Log;
|
||||
import com.qingyun.common.constant.UserConstants;
|
||||
import com.qingyun.common.core.controller.BaseController;
|
||||
import com.qingyun.common.core.domain.R;
|
||||
import com.qingyun.common.core.domain.entity.SysDept;
|
||||
import com.qingyun.common.enums.BusinessType;
|
||||
import com.qingyun.common.utils.StringUtils;
|
||||
import com.qingyun.system.service.ISysDeptService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 部门信息
|
||||
*
|
||||
* @author jianlu
|
||||
*/
|
||||
@Validated
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/system/dept")
|
||||
public class SysDeptController extends BaseController {
|
||||
|
||||
private final ISysDeptService deptService;
|
||||
|
||||
/**
|
||||
* 获取部门列表
|
||||
*/
|
||||
@SaCheckPermission("system:dept:list")
|
||||
@GetMapping("/list")
|
||||
public R<List<SysDept>> list(SysDept dept) {
|
||||
List<SysDept> depts = deptService.selectDeptList(dept);
|
||||
return R.ok(depts);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询部门列表(排除节点)
|
||||
*
|
||||
* @param deptId 部门ID
|
||||
*/
|
||||
@SaCheckPermission("system:dept:list")
|
||||
@GetMapping("/list/exclude/{deptId}")
|
||||
public R<List<SysDept>> excludeChild(@PathVariable(value = "deptId", required = false) Long deptId) {
|
||||
List<SysDept> depts = deptService.selectDeptList(new SysDept());
|
||||
depts.removeIf(d -> d.getDeptId().equals(deptId)
|
||||
|| StringUtils.splitList(d.getAncestors()).contains(Convert.toStr(deptId)));
|
||||
return R.ok(depts);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据部门编号获取详细信息
|
||||
*
|
||||
* @param deptId 部门ID
|
||||
*/
|
||||
@SaCheckPermission("system:dept:query")
|
||||
@GetMapping(value = "/{deptId}")
|
||||
public R<SysDept> getInfo(@PathVariable Long deptId) {
|
||||
deptService.checkDeptDataScope(deptId);
|
||||
return R.ok(deptService.selectDeptById(deptId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增部门
|
||||
*/
|
||||
@SaCheckPermission("system:dept:add")
|
||||
@Log(title = "部门管理", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public R<Void> add(@Validated @RequestBody SysDept dept) {
|
||||
if (!deptService.checkDeptNameUnique(dept)) {
|
||||
return R.fail("新增部门'" + dept.getDeptName() + "'失败,部门名称已存在");
|
||||
}
|
||||
return toAjax(deptService.insertDept(dept));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改部门
|
||||
*/
|
||||
@SaCheckPermission("system:dept:edit")
|
||||
@Log(title = "部门管理", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public R<Void> edit(@Validated @RequestBody SysDept dept) {
|
||||
Long deptId = dept.getDeptId();
|
||||
deptService.checkDeptDataScope(deptId);
|
||||
if (!deptService.checkDeptNameUnique(dept)) {
|
||||
return R.fail("修改部门'" + dept.getDeptName() + "'失败,部门名称已存在");
|
||||
} else if (dept.getParentId().equals(deptId)) {
|
||||
return R.fail("修改部门'" + dept.getDeptName() + "'失败,上级部门不能是自己");
|
||||
} else if (StringUtils.equals(UserConstants.DEPT_DISABLE, dept.getStatus())
|
||||
&& deptService.selectNormalChildrenDeptById(deptId) > 0) {
|
||||
return R.fail("该部门包含未停用的子部门!");
|
||||
}
|
||||
return toAjax(deptService.updateDept(dept));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除部门
|
||||
*
|
||||
* @param deptId 部门ID
|
||||
*/
|
||||
@SaCheckPermission("system:dept:remove")
|
||||
@Log(title = "部门管理", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{deptId}")
|
||||
public R<Void> remove(@PathVariable Long deptId) {
|
||||
if (deptService.hasChildByDeptId(deptId)) {
|
||||
return R.warn("存在下级部门,不允许删除");
|
||||
}
|
||||
if (deptService.checkDeptExistUser(deptId)) {
|
||||
return R.warn("部门存在用户,不允许删除");
|
||||
}
|
||||
deptService.checkDeptDataScope(deptId);
|
||||
return toAjax(deptService.deleteDeptById(deptId));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,117 @@
|
||||
package com.qingyun.web.controller.system;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.qingyun.common.annotation.Log;
|
||||
import com.qingyun.common.core.controller.BaseController;
|
||||
import com.qingyun.common.core.domain.PageQuery;
|
||||
import com.qingyun.common.core.domain.R;
|
||||
import com.qingyun.common.core.domain.entity.SysDictData;
|
||||
import com.qingyun.common.helper.LoginHelper;
|
||||
import com.qingyun.mybatisplus.page.TableDataInfo;
|
||||
import com.qingyun.common.enums.BusinessType;
|
||||
import com.qingyun.common.utils.poi.ExcelUtil;
|
||||
import com.qingyun.system.service.ISysDictDataService;
|
||||
import com.qingyun.system.service.ISysDictTypeService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 数据字典信息
|
||||
*
|
||||
* @author jianlu
|
||||
*/
|
||||
@Validated
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/system/dict/data")
|
||||
public class SysDictDataController extends BaseController {
|
||||
|
||||
private final ISysDictDataService dictDataService;
|
||||
private final ISysDictTypeService dictTypeService;
|
||||
|
||||
/**
|
||||
* 查询字典数据列表
|
||||
*/
|
||||
@SaCheckPermission("system:dict:list")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo<SysDictData> list(SysDictData dictData, PageQuery pageQuery) {
|
||||
return dictDataService.selectPageDictDataList(dictData, pageQuery);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出字典数据列表
|
||||
*/
|
||||
@Log(title = "字典数据", businessType = BusinessType.EXPORT)
|
||||
@SaCheckPermission("system:dict:export")
|
||||
@PostMapping("/export")
|
||||
public void export(SysDictData dictData, HttpServletResponse response) {
|
||||
List<SysDictData> list = dictDataService.selectDictDataList(dictData);
|
||||
ExcelUtil.exportExcel(list, "字典数据", SysDictData.class, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询字典数据详细
|
||||
*
|
||||
* @param dictCode 字典code
|
||||
*/
|
||||
@SaCheckPermission("system:dict:query")
|
||||
@GetMapping(value = "/{dictCode}")
|
||||
public R<SysDictData> getInfo(@PathVariable Long dictCode) {
|
||||
return R.ok(dictDataService.selectDictDataById(dictCode));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据字典类型查询字典数据信息
|
||||
*
|
||||
* @param dictType 字典类型
|
||||
*/
|
||||
@GetMapping(value = "/type/{dictType}")
|
||||
public R<List<SysDictData>> dictType(@PathVariable String dictType) {
|
||||
List<SysDictData> data = dictTypeService.selectDictDataByType(dictType);
|
||||
if (ObjectUtil.isNull(data)) {
|
||||
data = new ArrayList<>();
|
||||
}
|
||||
return R.ok(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增字典类型
|
||||
*/
|
||||
@SaCheckPermission("system:dict:add")
|
||||
@Log(title = "字典数据", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public R<Void> add(@Validated @RequestBody SysDictData dict) {
|
||||
dictDataService.insertDictData(dict);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改保存字典类型
|
||||
*/
|
||||
@SaCheckPermission("system:dict:edit")
|
||||
@Log(title = "字典数据", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public R<Void> edit(@Validated @RequestBody SysDictData dict) {
|
||||
dictDataService.updateDictData(dict);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除字典类型
|
||||
*
|
||||
* @param dictCodes 字典code串
|
||||
*/
|
||||
@SaCheckPermission("system:dict:remove")
|
||||
@Log(title = "字典类型", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{dictCodes}")
|
||||
public R<Void> remove(@PathVariable Long[] dictCodes) {
|
||||
dictDataService.deleteDictDataByIds(dictCodes);
|
||||
return R.ok();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,124 @@
|
||||
package com.qingyun.web.controller.system;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import com.qingyun.common.annotation.Log;
|
||||
import com.qingyun.common.core.controller.BaseController;
|
||||
import com.qingyun.common.core.domain.PageQuery;
|
||||
import com.qingyun.common.core.domain.R;
|
||||
import com.qingyun.common.core.domain.entity.SysDictType;
|
||||
import com.qingyun.mybatisplus.page.TableDataInfo;
|
||||
import com.qingyun.common.enums.BusinessType;
|
||||
import com.qingyun.common.utils.poi.ExcelUtil;
|
||||
import com.qingyun.system.service.ISysDictTypeService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 数据字典信息
|
||||
*
|
||||
* @author jianlu
|
||||
*/
|
||||
@Validated
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/system/dict/type")
|
||||
public class SysDictTypeController extends BaseController {
|
||||
|
||||
private final ISysDictTypeService dictTypeService;
|
||||
|
||||
/**
|
||||
* 查询字典类型列表
|
||||
*/
|
||||
@SaCheckPermission("system:dict:list")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo<SysDictType> list(SysDictType dictType, PageQuery pageQuery) {
|
||||
return dictTypeService.selectPageDictTypeList(dictType, pageQuery);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出字典类型列表
|
||||
*/
|
||||
@Log(title = "字典类型", businessType = BusinessType.EXPORT)
|
||||
@SaCheckPermission("system:dict:export")
|
||||
@PostMapping("/export")
|
||||
public void export(SysDictType dictType, HttpServletResponse response) {
|
||||
List<SysDictType> list = dictTypeService.selectDictTypeList(dictType);
|
||||
ExcelUtil.exportExcel(list, "字典类型", SysDictType.class, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询字典类型详细
|
||||
*
|
||||
* @param dictId 字典ID
|
||||
*/
|
||||
@SaCheckPermission("system:dict:query")
|
||||
@GetMapping(value = "/{dictId}")
|
||||
public R<SysDictType> getInfo(@PathVariable Long dictId) {
|
||||
return R.ok(dictTypeService.selectDictTypeById(dictId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增字典类型
|
||||
*/
|
||||
@SaCheckPermission("system:dict:add")
|
||||
@Log(title = "字典类型", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public R<Void> add(@Validated @RequestBody SysDictType dict) {
|
||||
if (!dictTypeService.checkDictTypeUnique(dict)) {
|
||||
return R.fail("新增字典'" + dict.getDictName() + "'失败,字典类型已存在");
|
||||
}
|
||||
dictTypeService.insertDictType(dict);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改字典类型
|
||||
*/
|
||||
@SaCheckPermission("system:dict:edit")
|
||||
@Log(title = "字典类型", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public R<Void> edit(@Validated @RequestBody SysDictType dict) {
|
||||
if (!dictTypeService.checkDictTypeUnique(dict)) {
|
||||
return R.fail("修改字典'" + dict.getDictName() + "'失败,字典类型已存在");
|
||||
}
|
||||
dictTypeService.updateDictType(dict);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除字典类型
|
||||
*
|
||||
* @param dictIds 字典ID串
|
||||
*/
|
||||
@SaCheckPermission("system:dict:remove")
|
||||
@Log(title = "字典类型", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{dictIds}")
|
||||
public R<Void> remove(@PathVariable Long[] dictIds) {
|
||||
dictTypeService.deleteDictTypeByIds(dictIds);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 刷新字典缓存
|
||||
*/
|
||||
@SaCheckPermission("system:dict:remove")
|
||||
@Log(title = "字典类型", businessType = BusinessType.CLEAN)
|
||||
@DeleteMapping("/refreshCache")
|
||||
public R<Void> refreshCache() {
|
||||
dictTypeService.resetDictCache();
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取字典选择框列表
|
||||
*/
|
||||
@GetMapping("/optionselect")
|
||||
public R<List<SysDictType>> optionselect() {
|
||||
List<SysDictType> dictTypes = dictTypeService.selectDictTypeAll();
|
||||
return R.ok(dictTypes);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.qingyun.web.controller.system;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaIgnore;
|
||||
import com.qingyun.common.config.QingYunConfig;
|
||||
import com.qingyun.common.utils.StringUtils;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* 首页
|
||||
*
|
||||
* @author jianlu
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
public class SysIndexController {
|
||||
|
||||
/**
|
||||
* 系统基础配置
|
||||
*/
|
||||
private final QingYunConfig ruoyiConfig;
|
||||
|
||||
/**
|
||||
* 访问首页,提示语
|
||||
*/
|
||||
@SaIgnore
|
||||
@GetMapping("/")
|
||||
public String index() {
|
||||
return StringUtils.format("欢迎使用{}后台管理系统,当前版本:v{},请通过前端地址访问。", ruoyiConfig.getName(), ruoyiConfig.getVersion());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,185 @@
|
||||
package com.qingyun.web.controller.system;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaIgnore;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.qingyun.common.constant.Constants;
|
||||
import com.qingyun.common.core.domain.R;
|
||||
import com.qingyun.common.core.domain.entity.SysMenu;
|
||||
import com.qingyun.common.core.domain.entity.SysUser;
|
||||
import com.qingyun.common.core.domain.model.EmailLoginBody;
|
||||
import com.qingyun.common.core.domain.model.LoginBody;
|
||||
import com.qingyun.common.core.domain.model.LoginUser;
|
||||
import com.qingyun.common.core.domain.model.SmsLoginBody;
|
||||
import com.qingyun.common.helper.LoginHelper;
|
||||
import com.qingyun.common.utils.MapstructUtils;
|
||||
import com.qingyun.common.utils.StreamUtils;
|
||||
import com.qingyun.common.utils.StringUtils;
|
||||
import com.qingyun.system.domain.bo.SysTenantBo;
|
||||
import com.qingyun.system.domain.vo.LoginTenantVo;
|
||||
import com.qingyun.system.domain.vo.RouterVo;
|
||||
import com.qingyun.system.domain.vo.SysTenantVo;
|
||||
import com.qingyun.system.domain.vo.TenantListVo;
|
||||
import com.qingyun.system.service.ISysMenuService;
|
||||
import com.qingyun.system.service.ISysTenantService;
|
||||
import com.qingyun.system.service.ISysUserService;
|
||||
import com.qingyun.system.service.SysLoginService;
|
||||
import com.qingyun.tenant.helper.TenantHelper;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import java.net.URL;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 登录验证
|
||||
*
|
||||
* @author jianlu
|
||||
*/
|
||||
@Validated
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
public class SysLoginController {
|
||||
|
||||
private final SysLoginService loginService;
|
||||
private final ISysMenuService menuService;
|
||||
private final ISysUserService userService;
|
||||
private final ISysTenantService tenantService;
|
||||
/**
|
||||
* 登录方法
|
||||
*
|
||||
* @param loginBody 登录信息
|
||||
* @return 结果
|
||||
*/
|
||||
@SaIgnore
|
||||
@PostMapping("/login")
|
||||
public R<Map<String, Object>> login(@Validated @RequestBody LoginBody loginBody) {
|
||||
Map<String, Object> ajax = new HashMap<>();
|
||||
// 生成令牌
|
||||
String token = loginService.login(loginBody.getTenantId(),loginBody.getUsername(), loginBody.getPassword(), loginBody.getCode(),
|
||||
loginBody.getUuid());
|
||||
ajax.put(Constants.TOKEN, token);
|
||||
return R.ok(ajax);
|
||||
}
|
||||
|
||||
/**
|
||||
* 短信登录
|
||||
*
|
||||
* @param smsLoginBody 登录信息
|
||||
* @return 结果
|
||||
*/
|
||||
@SaIgnore
|
||||
@PostMapping("/smsLogin")
|
||||
public R<Map<String, Object>> smsLogin(@Validated @RequestBody SmsLoginBody smsLoginBody) {
|
||||
Map<String, Object> ajax = new HashMap<>();
|
||||
// 生成令牌
|
||||
String token = loginService.smsLogin(smsLoginBody.getTenantId(),smsLoginBody.getPhonenumber(), smsLoginBody.getSmsCode());
|
||||
ajax.put(Constants.TOKEN, token);
|
||||
return R.ok(ajax);
|
||||
}
|
||||
|
||||
/**
|
||||
* 邮件登录
|
||||
*
|
||||
* @param body 登录信息
|
||||
* @return 结果
|
||||
*/
|
||||
@PostMapping("/emailLogin")
|
||||
public R<Map<String, Object>> emailLogin(@Validated @RequestBody EmailLoginBody body) {
|
||||
Map<String, Object> ajax = new HashMap<>();
|
||||
// 生成令牌
|
||||
String token = loginService.emailLogin(body.getTenantId(),body.getEmail(), body.getEmailCode());
|
||||
ajax.put(Constants.TOKEN, token);
|
||||
return R.ok(ajax);
|
||||
}
|
||||
|
||||
/**
|
||||
* 小程序登录(示例)
|
||||
*
|
||||
* @param xcxCode 小程序code
|
||||
* @return 结果
|
||||
*/
|
||||
@SaIgnore
|
||||
@PostMapping("/xcxLogin")
|
||||
public R<Map<String, Object>> xcxLogin(@NotBlank(message = "{xcx.code.not.blank}") String xcxCode) {
|
||||
Map<String, Object> ajax = new HashMap<>();
|
||||
// 生成令牌
|
||||
String token = loginService.xcxLogin(xcxCode);
|
||||
ajax.put(Constants.TOKEN, token);
|
||||
return R.ok(ajax);
|
||||
}
|
||||
|
||||
/**
|
||||
* 退出登录
|
||||
*/
|
||||
@SaIgnore
|
||||
@PostMapping("/logout")
|
||||
public R<Void> logout() {
|
||||
loginService.logout();
|
||||
return R.ok("退出成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户信息
|
||||
*
|
||||
* @return 用户信息
|
||||
*/
|
||||
@GetMapping("/system/user/getInfo")
|
||||
public R<Map<String, Object>> getInfo() {
|
||||
LoginUser loginUser = LoginHelper.getLoginUser();
|
||||
SysUser user = userService.selectUserById(loginUser.getUserId());
|
||||
Map<String, Object> ajax = new HashMap<>();
|
||||
ajax.put("user", user);
|
||||
ajax.put("roles", loginUser.getRolePermission());
|
||||
ajax.put("permissions", loginUser.getMenuPermission());
|
||||
return R.ok(ajax);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取路由信息
|
||||
*
|
||||
* @return 路由信息
|
||||
*/
|
||||
@GetMapping("/system/menu/getRouters")
|
||||
public R<List<RouterVo>> getRouters() {
|
||||
Long userId = LoginHelper.getUserId();
|
||||
List<SysMenu> menus = menuService.selectMenuTreeByUserId(userId);
|
||||
return R.ok(menuService.buildMenus(menus));
|
||||
}
|
||||
|
||||
/**
|
||||
* 登录页面租户下拉框
|
||||
*
|
||||
* @return 租户列表
|
||||
*/
|
||||
@SaIgnore
|
||||
@GetMapping("/tenant/list")
|
||||
public R<LoginTenantVo> tenantList(HttpServletRequest request) throws Exception {
|
||||
List<SysTenantVo> tenantList = tenantService.queryList(new SysTenantBo());
|
||||
List<TenantListVo> voList = MapstructUtils.convert(tenantList, TenantListVo.class);
|
||||
// 获取域名
|
||||
String host;
|
||||
String referer = request.getHeader("referer");
|
||||
if (StringUtils.isNotBlank(referer)) {
|
||||
// 这里从referer中取值是为了本地使用hosts添加虚拟域名,方便本地环境调试
|
||||
host = referer.split("//")[1].split("/")[0];
|
||||
} else {
|
||||
host = new URL(request.getRequestURL().toString()).getHost();
|
||||
}
|
||||
// 根据域名进行筛选
|
||||
List<TenantListVo> list = StreamUtils.filter(voList, vo ->
|
||||
StringUtils.equals(vo.getDomain(), host));
|
||||
// 返回对象
|
||||
LoginTenantVo vo = new LoginTenantVo();
|
||||
vo.setVoList(CollUtil.isNotEmpty(list) ? list : voList);
|
||||
vo.setTenantEnabled(TenantHelper.isEnable());
|
||||
return R.ok(vo);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,146 @@
|
||||
package com.qingyun.web.controller.system;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import cn.dev33.satoken.annotation.SaCheckRole;
|
||||
import cn.hutool.core.lang.tree.Tree;
|
||||
import com.qingyun.common.annotation.Log;
|
||||
import com.qingyun.common.constant.TenantConstants;
|
||||
import com.qingyun.common.constant.UserConstants;
|
||||
import com.qingyun.common.core.controller.BaseController;
|
||||
import com.qingyun.common.core.domain.R;
|
||||
import com.qingyun.common.core.domain.entity.SysMenu;
|
||||
import com.qingyun.common.enums.BusinessType;
|
||||
import com.qingyun.common.helper.LoginHelper;
|
||||
import com.qingyun.common.utils.StringUtils;
|
||||
import com.qingyun.system.service.ISysMenuService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 菜单信息
|
||||
*
|
||||
* @author jianlu
|
||||
*/
|
||||
@Validated
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/system/menu")
|
||||
public class SysMenuController extends BaseController {
|
||||
|
||||
private final ISysMenuService menuService;
|
||||
|
||||
/**
|
||||
* 获取菜单列表
|
||||
*/
|
||||
@SaCheckPermission("system:menu:list")
|
||||
@GetMapping("/list")
|
||||
public R<List<SysMenu>> list(SysMenu menu) {
|
||||
List<SysMenu> menus = menuService.selectMenuList(menu, getUserId());
|
||||
return R.ok(menus);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据菜单编号获取详细信息
|
||||
*
|
||||
* @param menuId 菜单ID
|
||||
*/
|
||||
@SaCheckPermission("system:menu:query")
|
||||
@GetMapping(value = "/{menuId}")
|
||||
public R<SysMenu> getInfo(@PathVariable Long menuId) {
|
||||
return R.ok(menuService.selectMenuById(menuId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取菜单下拉树列表
|
||||
*/
|
||||
@GetMapping("/treeselect")
|
||||
public R<List<Tree<Long>>> treeselect(SysMenu menu) {
|
||||
List<SysMenu> menus = menuService.selectMenuList(menu, getUserId());
|
||||
return R.ok(menuService.buildMenuTreeSelect(menus));
|
||||
}
|
||||
|
||||
/**
|
||||
* 加载对应角色菜单列表树
|
||||
*
|
||||
* @param roleId 角色ID
|
||||
*/
|
||||
@GetMapping(value = "/roleMenuTreeselect/{roleId}")
|
||||
public R<Map<String, Object>> roleMenuTreeselect(@PathVariable("roleId") Long roleId) {
|
||||
List<SysMenu> menus = menuService.selectMenuList(getUserId());
|
||||
Map<String, Object> ajax = new HashMap<>();
|
||||
ajax.put("checkedKeys", menuService.selectMenuListByRoleId(roleId));
|
||||
ajax.put("menus", menuService.buildMenuTreeSelect(menus));
|
||||
return R.ok(ajax);
|
||||
}
|
||||
|
||||
/**
|
||||
* 加载对应租户套餐菜单列表树
|
||||
*
|
||||
* @param packageId 租户套餐ID
|
||||
*/
|
||||
@SaCheckRole(TenantConstants.SUPER_ADMIN_ROLE_KEY)
|
||||
@SaCheckPermission("system:menu:query")
|
||||
@GetMapping(value = "/tenantPackageMenuTreeselect/{packageId}")
|
||||
public R<Map<String, Object>> tenantPackageMenuTreeselect(@PathVariable("packageId") Long packageId) {
|
||||
List<SysMenu> menus = menuService.selectMenuList(LoginHelper.getUserId());
|
||||
Map<String, Object> ajax = new HashMap<>();
|
||||
ajax.put("checkedKeys",menuService.selectMenuListByPackageId(packageId));
|
||||
ajax.put("menus",menuService.buildMenuTreeSelect(menus));
|
||||
return R.ok(ajax);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增菜单
|
||||
*/
|
||||
@SaCheckPermission("system:menu:add")
|
||||
@Log(title = "菜单管理", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public R<Void> add(@Validated @RequestBody SysMenu menu) {
|
||||
if (!menuService.checkMenuNameUnique(menu)) {
|
||||
return R.fail("新增菜单'" + menu.getMenuName() + "'失败,菜单名称已存在");
|
||||
} else if (UserConstants.YES_FRAME.equals(menu.getIsFrame()) && !StringUtils.ishttp(menu.getPath())) {
|
||||
return R.fail("新增菜单'" + menu.getMenuName() + "'失败,地址必须以http(s)://开头");
|
||||
}
|
||||
return toAjax(menuService.insertMenu(menu));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改菜单
|
||||
*/
|
||||
@SaCheckPermission("system:menu:edit")
|
||||
@Log(title = "菜单管理", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public R<Void> edit(@Validated @RequestBody SysMenu menu) {
|
||||
if (!menuService.checkMenuNameUnique(menu)) {
|
||||
return R.fail("修改菜单'" + menu.getMenuName() + "'失败,菜单名称已存在");
|
||||
} else if (UserConstants.YES_FRAME.equals(menu.getIsFrame()) && !StringUtils.ishttp(menu.getPath())) {
|
||||
return R.fail("修改菜单'" + menu.getMenuName() + "'失败,地址必须以http(s)://开头");
|
||||
} else if (menu.getMenuId().equals(menu.getParentId())) {
|
||||
return R.fail("修改菜单'" + menu.getMenuName() + "'失败,上级菜单不能选择自己");
|
||||
}
|
||||
return toAjax(menuService.updateMenu(menu));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除菜单
|
||||
*
|
||||
* @param menuId 菜单ID
|
||||
*/
|
||||
@SaCheckPermission("system:menu:remove")
|
||||
@Log(title = "菜单管理", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{menuId}")
|
||||
public R<Void> remove(@PathVariable("menuId") Long menuId) {
|
||||
if (menuService.hasChildByMenuId(menuId)) {
|
||||
return R.warn("存在子菜单,不允许删除");
|
||||
}
|
||||
if (menuService.checkMenuExistRole(menuId)) {
|
||||
return R.warn("菜单已分配,不允许删除");
|
||||
}
|
||||
return toAjax(menuService.deleteMenuById(menuId));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
package com.qingyun.web.controller.system;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import com.qingyun.common.annotation.Log;
|
||||
import com.qingyun.common.core.controller.BaseController;
|
||||
import com.qingyun.common.core.domain.PageQuery;
|
||||
import com.qingyun.common.core.domain.R;
|
||||
import com.qingyun.mybatisplus.page.TableDataInfo;
|
||||
import com.qingyun.common.enums.BusinessType;
|
||||
import com.qingyun.system.domain.SysNotice;
|
||||
import com.qingyun.system.service.ISysNoticeService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
/**
|
||||
* 公告 信息操作处理
|
||||
*
|
||||
* @author jianlu
|
||||
*/
|
||||
@Validated
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/system/notice")
|
||||
public class SysNoticeController extends BaseController {
|
||||
|
||||
private final ISysNoticeService noticeService;
|
||||
|
||||
/**
|
||||
* 获取通知公告列表
|
||||
*/
|
||||
@SaCheckPermission("system:notice:list")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo<SysNotice> list(SysNotice notice, PageQuery pageQuery) {
|
||||
return noticeService.selectPageNoticeList(notice, pageQuery);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据通知公告编号获取详细信息
|
||||
*
|
||||
* @param noticeId 公告ID
|
||||
*/
|
||||
@SaCheckPermission("system:notice:query")
|
||||
@GetMapping(value = "/{noticeId}")
|
||||
public R<SysNotice> getInfo(@PathVariable Long noticeId) {
|
||||
return R.ok(noticeService.selectNoticeById(noticeId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增通知公告
|
||||
*/
|
||||
@SaCheckPermission("system:notice:add")
|
||||
@Log(title = "通知公告", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public R<Void> add(@Validated @RequestBody SysNotice notice) {
|
||||
return toAjax(noticeService.insertNotice(notice));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改通知公告
|
||||
*/
|
||||
@SaCheckPermission("system:notice:edit")
|
||||
@Log(title = "通知公告", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public R<Void> edit(@Validated @RequestBody SysNotice notice) {
|
||||
return toAjax(noticeService.updateNotice(notice));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除通知公告
|
||||
*
|
||||
* @param noticeIds 公告ID串
|
||||
*/
|
||||
@SaCheckPermission("system:notice:remove")
|
||||
@Log(title = "通知公告", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{noticeIds}")
|
||||
public R<Void> remove(@PathVariable Long[] noticeIds) {
|
||||
return toAjax(noticeService.deleteNoticeByIds(noticeIds));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
package com.qingyun.web.controller.system;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import com.qingyun.common.annotation.Log;
|
||||
import com.qingyun.common.core.controller.BaseController;
|
||||
import com.qingyun.common.core.domain.PageQuery;
|
||||
import com.qingyun.common.core.domain.R;
|
||||
import com.qingyun.mybatisplus.page.TableDataInfo;
|
||||
import com.qingyun.common.core.validate.AddGroup;
|
||||
import com.qingyun.common.core.validate.EditGroup;
|
||||
import com.qingyun.common.core.validate.QueryGroup;
|
||||
import com.qingyun.common.enums.BusinessType;
|
||||
import com.qingyun.idempotent.annotation.RepeatSubmit;
|
||||
import com.qingyun.system.domain.bo.SysOssConfigBo;
|
||||
import com.qingyun.system.domain.vo.SysOssConfigVo;
|
||||
import com.qingyun.system.service.ISysOssConfigService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* 对象存储配置
|
||||
*
|
||||
* @author jianlu
|
||||
* @author 孤舟烟雨
|
||||
* @date 2021-08-13
|
||||
*/
|
||||
@Validated
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/system/oss/config")
|
||||
public class SysOssConfigController extends BaseController {
|
||||
|
||||
private final ISysOssConfigService iSysOssConfigService;
|
||||
|
||||
/**
|
||||
* 查询对象存储配置列表
|
||||
*/
|
||||
@SaCheckPermission("system:oss:list")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo<SysOssConfigVo> list(@Validated(QueryGroup.class) SysOssConfigBo bo, PageQuery pageQuery) {
|
||||
return iSysOssConfigService.queryPageList(bo, pageQuery);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取对象存储配置详细信息
|
||||
*
|
||||
* @param ossConfigId OSS配置ID
|
||||
*/
|
||||
@SaCheckPermission("system:oss:query")
|
||||
@GetMapping("/{ossConfigId}")
|
||||
public R<SysOssConfigVo> getInfo(@NotNull(message = "主键不能为空")
|
||||
@PathVariable Long ossConfigId) {
|
||||
return R.ok(iSysOssConfigService.queryById(ossConfigId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增对象存储配置
|
||||
*/
|
||||
@SaCheckPermission("system:oss:add")
|
||||
@Log(title = "对象存储配置", businessType = BusinessType.INSERT)
|
||||
@RepeatSubmit()
|
||||
@PostMapping()
|
||||
public R<Void> add(@Validated(AddGroup.class) @RequestBody SysOssConfigBo bo) {
|
||||
return toAjax(iSysOssConfigService.insertByBo(bo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改对象存储配置
|
||||
*/
|
||||
@SaCheckPermission("system:oss:edit")
|
||||
@Log(title = "对象存储配置", businessType = BusinessType.UPDATE)
|
||||
@RepeatSubmit()
|
||||
@PutMapping()
|
||||
public R<Void> edit(@Validated(EditGroup.class) @RequestBody SysOssConfigBo bo) {
|
||||
return toAjax(iSysOssConfigService.updateByBo(bo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除对象存储配置
|
||||
*
|
||||
* @param ossConfigIds OSS配置ID串
|
||||
*/
|
||||
@SaCheckPermission("system:oss:remove")
|
||||
@Log(title = "对象存储配置", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ossConfigIds}")
|
||||
public R<Void> remove(@NotEmpty(message = "主键不能为空")
|
||||
@PathVariable Long[] ossConfigIds) {
|
||||
return toAjax(iSysOssConfigService.deleteWithValidByIds(Arrays.asList(ossConfigIds), true));
|
||||
}
|
||||
|
||||
/**
|
||||
* 状态修改
|
||||
*/
|
||||
@SaCheckPermission("system:oss:edit")
|
||||
@Log(title = "对象存储状态修改", businessType = BusinessType.UPDATE)
|
||||
@PutMapping("/changeStatus")
|
||||
public R<Void> changeStatus(@RequestBody SysOssConfigBo bo) {
|
||||
return toAjax(iSysOssConfigService.updateOssConfigStatus(bo));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,137 @@
|
||||
package com.qingyun.web.controller.system;
|
||||
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.qingyun.common.annotation.Log;
|
||||
import com.qingyun.common.config.QingYunConfig;
|
||||
import com.qingyun.common.core.controller.BaseController;
|
||||
import com.qingyun.common.core.domain.PageQuery;
|
||||
import com.qingyun.common.core.domain.R;
|
||||
import com.qingyun.common.utils.file.FileUploadUtils;
|
||||
import com.qingyun.common.utils.file.MimeTypeUtils;
|
||||
import com.qingyun.idempotent.annotation.RepeatSubmit;
|
||||
import com.qingyun.mybatisplus.page.TableDataInfo;
|
||||
import com.qingyun.common.core.validate.QueryGroup;
|
||||
import com.qingyun.common.enums.BusinessType;
|
||||
import com.qingyun.system.domain.bo.SysOssBo;
|
||||
import com.qingyun.system.domain.vo.SysOssVo;
|
||||
import com.qingyun.system.service.ISysOssService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 文件上传 控制层
|
||||
*
|
||||
* @author jianlu
|
||||
*/
|
||||
@Validated
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/system/oss")
|
||||
public class SysOssController extends BaseController {
|
||||
|
||||
private final ISysOssService iSysOssService;
|
||||
|
||||
/**
|
||||
* 查询OSS对象存储列表
|
||||
*/
|
||||
@SaCheckPermission("system:oss:list")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo<SysOssVo> list(@Validated(QueryGroup.class) SysOssBo bo, PageQuery pageQuery) {
|
||||
return iSysOssService.queryPageList(bo, pageQuery);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询OSS对象基于id串
|
||||
*
|
||||
* @param ossIds OSS对象ID串
|
||||
*/
|
||||
@SaCheckPermission("system:oss:list")
|
||||
@GetMapping("/listByIds/{ossIds}")
|
||||
public R<List<SysOssVo>> listByIds(@NotEmpty(message = "主键不能为空")
|
||||
@PathVariable Long[] ossIds) {
|
||||
List<SysOssVo> list = iSysOssService.listByIds(Arrays.asList(ossIds));
|
||||
return R.ok(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传OSS对象存储
|
||||
*
|
||||
* @param file 文件
|
||||
*/
|
||||
@SaCheckPermission("system:oss:upload")
|
||||
@Log(title = "OSS对象存储", businessType = BusinessType.INSERT)
|
||||
@PostMapping(value = "/upload", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
|
||||
public R<Map<String, String>> upload(@RequestPart("file") MultipartFile file) {
|
||||
if (ObjectUtil.isNull(file)) {
|
||||
return R.fail("上传文件不能为空");
|
||||
}
|
||||
SysOssVo oss = iSysOssService.upload(file);
|
||||
Map<String, String> map = new HashMap<>(2);
|
||||
map.put("url", oss.getUrl());
|
||||
map.put("fileName", oss.getOriginalName());
|
||||
map.put("ossId", oss.getOssId().toString());
|
||||
return R.ok(map);
|
||||
}
|
||||
|
||||
/**
|
||||
* 本地上传文件存储
|
||||
* @param file 文件
|
||||
*/
|
||||
//@RepeatSubmit(interval = 500)
|
||||
@PostMapping("/uploadLocal")
|
||||
public R<Map<String, Object>> uploadLocal(@RequestPart("file") MultipartFile file){
|
||||
try {
|
||||
FileUploadUtils.assertAllowed(file, MimeTypeUtils.DEFAULT_ALLOWED_EXTENSION);
|
||||
// 上传文件路径
|
||||
String filePath = QingYunConfig.getUploadPath();
|
||||
// 上传并返回新文件名称
|
||||
String fileName = FileUploadUtils.upload(filePath, file);
|
||||
// String localPath = QingYunConfig.getProfile() + StringUtils.substringAfter(fileName, Constants.RESOURCE_PREFIX);
|
||||
String url = QingYunConfig.getProjectUrl() + fileName;
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("name", fileName);
|
||||
map.put("url", url);
|
||||
return R.ok(map);
|
||||
} catch (Exception e) {
|
||||
return R.fail(e.getMessage(), null);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 下载OSS对象
|
||||
*
|
||||
* @param ossId OSS对象ID
|
||||
*/
|
||||
@SaCheckPermission("system:oss:download")
|
||||
@GetMapping("/download/{ossId}")
|
||||
public void download(@PathVariable Long ossId, HttpServletResponse response) throws IOException {
|
||||
iSysOssService.download(ossId,response);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除OSS对象存储
|
||||
*
|
||||
* @param ossIds OSS对象ID串
|
||||
*/
|
||||
@SaCheckPermission("system:oss:remove")
|
||||
@Log(title = "OSS对象存储", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ossIds}")
|
||||
public R<Void> remove(@NotEmpty(message = "主键不能为空")
|
||||
@PathVariable Long[] ossIds) {
|
||||
return toAjax(iSysOssService.deleteWithValidByIds(Arrays.asList(ossIds), true));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,114 @@
|
||||
package com.qingyun.web.controller.system;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import com.qingyun.common.annotation.Log;
|
||||
import com.qingyun.common.core.controller.BaseController;
|
||||
import com.qingyun.common.core.domain.PageQuery;
|
||||
import com.qingyun.common.core.domain.R;
|
||||
import com.qingyun.mybatisplus.page.TableDataInfo;
|
||||
import com.qingyun.common.enums.BusinessType;
|
||||
import com.qingyun.common.utils.poi.ExcelUtil;
|
||||
import com.qingyun.system.domain.SysPost;
|
||||
import com.qingyun.system.service.ISysPostService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 岗位信息操作处理
|
||||
*
|
||||
* @author jianlu
|
||||
*/
|
||||
@Validated
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/system/post")
|
||||
public class SysPostController extends BaseController {
|
||||
|
||||
private final ISysPostService postService;
|
||||
|
||||
/**
|
||||
* 获取岗位列表
|
||||
*/
|
||||
@SaCheckPermission("system:post:list")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo<SysPost> list(SysPost post, PageQuery pageQuery) {
|
||||
return postService.selectPagePostList(post, pageQuery);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出岗位列表
|
||||
*/
|
||||
@Log(title = "岗位管理", businessType = BusinessType.EXPORT)
|
||||
@SaCheckPermission("system:post:export")
|
||||
@PostMapping("/export")
|
||||
public void export(SysPost post, HttpServletResponse response) {
|
||||
List<SysPost> list = postService.selectPostList(post);
|
||||
ExcelUtil.exportExcel(list, "岗位数据", SysPost.class, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据岗位编号获取详细信息
|
||||
*
|
||||
* @param postId 岗位ID
|
||||
*/
|
||||
@SaCheckPermission("system:post:query")
|
||||
@GetMapping(value = "/{postId}")
|
||||
public R<SysPost> getInfo(@PathVariable Long postId) {
|
||||
return R.ok(postService.selectPostById(postId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增岗位
|
||||
*/
|
||||
@SaCheckPermission("system:post:add")
|
||||
@Log(title = "岗位管理", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public R<Void> add(@Validated @RequestBody SysPost post) {
|
||||
if (!postService.checkPostNameUnique(post)) {
|
||||
return R.fail("新增岗位'" + post.getPostName() + "'失败,岗位名称已存在");
|
||||
} else if (!postService.checkPostCodeUnique(post)) {
|
||||
return R.fail("新增岗位'" + post.getPostName() + "'失败,岗位编码已存在");
|
||||
}
|
||||
return toAjax(postService.insertPost(post));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改岗位
|
||||
*/
|
||||
@SaCheckPermission("system:post:edit")
|
||||
@Log(title = "岗位管理", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public R<Void> edit(@Validated @RequestBody SysPost post) {
|
||||
if (!postService.checkPostNameUnique(post)) {
|
||||
return R.fail("修改岗位'" + post.getPostName() + "'失败,岗位名称已存在");
|
||||
} else if (!postService.checkPostCodeUnique(post)) {
|
||||
return R.fail("修改岗位'" + post.getPostName() + "'失败,岗位编码已存在");
|
||||
}
|
||||
return toAjax(postService.updatePost(post));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除岗位
|
||||
*
|
||||
* @param postIds 岗位ID串
|
||||
*/
|
||||
@SaCheckPermission("system:post:remove")
|
||||
@Log(title = "岗位管理", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{postIds}")
|
||||
public R<Void> remove(@PathVariable Long[] postIds) {
|
||||
return toAjax(postService.deletePostByIds(postIds));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取岗位选择框列表
|
||||
*/
|
||||
@GetMapping("/optionselect")
|
||||
public R<List<SysPost>> optionselect() {
|
||||
List<SysPost> posts = postService.selectPostAll();
|
||||
return R.ok(posts);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,126 @@
|
||||
package com.qingyun.web.controller.system;
|
||||
|
||||
import cn.dev33.satoken.secure.BCrypt;
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import com.qingyun.common.annotation.Log;
|
||||
import com.qingyun.common.constant.UserConstants;
|
||||
import com.qingyun.common.core.controller.BaseController;
|
||||
import com.qingyun.common.core.domain.R;
|
||||
import com.qingyun.common.core.domain.entity.SysUser;
|
||||
import com.qingyun.common.enums.BusinessType;
|
||||
import com.qingyun.common.helper.LoginHelper;
|
||||
import com.qingyun.common.utils.StringUtils;
|
||||
import com.qingyun.common.utils.file.MimeTypeUtils;
|
||||
import com.qingyun.system.domain.SysOss;
|
||||
import com.qingyun.system.domain.vo.SysOssVo;
|
||||
import com.qingyun.system.service.ISysOssService;
|
||||
import com.qingyun.system.service.ISysUserService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 个人信息 业务处理
|
||||
*
|
||||
* @author jianlu
|
||||
*/
|
||||
@Validated
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/system/user/profile")
|
||||
public class SysProfileController extends BaseController {
|
||||
|
||||
private final ISysUserService userService;
|
||||
private final ISysOssService iSysOssService;
|
||||
|
||||
/**
|
||||
* 个人信息
|
||||
*/
|
||||
@GetMapping
|
||||
public R<Map<String, Object>> profile() {
|
||||
SysUser user = userService.selectUserById(getUserId());
|
||||
Map<String, Object> ajax = new HashMap<>();
|
||||
ajax.put("user", user);
|
||||
ajax.put("roleGroup", userService.selectUserRoleGroup(user.getUserName()));
|
||||
ajax.put("postGroup", userService.selectUserPostGroup(user.getUserName()));
|
||||
return R.ok(ajax);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改用户
|
||||
*/
|
||||
@Log(title = "个人信息", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public R<Void> updateProfile(@RequestBody SysUser user) {
|
||||
if (StringUtils.isNotEmpty(user.getPhonenumber()) && !userService.checkPhoneUnique(user)) {
|
||||
return R.fail("修改用户'" + user.getUserName() + "'失败,手机号码已存在");
|
||||
}
|
||||
if (StringUtils.isNotEmpty(user.getEmail()) && !userService.checkEmailUnique(user)) {
|
||||
return R.fail("修改用户'" + user.getUserName() + "'失败,邮箱账号已存在");
|
||||
}
|
||||
user.setUserId(getUserId());
|
||||
user.setUserName(null);
|
||||
user.setPassword(null);
|
||||
user.setAvatar(null);
|
||||
user.setDeptId(null);
|
||||
if (userService.updateUserProfile(user) > 0) {
|
||||
return R.ok();
|
||||
}
|
||||
return R.fail("修改个人信息异常,请联系管理员");
|
||||
}
|
||||
|
||||
/**
|
||||
* 重置密码
|
||||
*
|
||||
* @param newPassword 旧密码
|
||||
* @param oldPassword 新密码
|
||||
*/
|
||||
@Log(title = "个人信息", businessType = BusinessType.UPDATE)
|
||||
@PutMapping("/updatePwd")
|
||||
public R<Void> updatePwd(String oldPassword, String newPassword) {
|
||||
SysUser user = userService.selectUserById(LoginHelper.getUserId());
|
||||
String userName = user.getUserName();
|
||||
String password = user.getPassword();
|
||||
if (!BCrypt.checkpw(oldPassword, password)) {
|
||||
return R.fail("修改密码失败,旧密码错误");
|
||||
}
|
||||
if (BCrypt.checkpw(newPassword, password)) {
|
||||
return R.fail("新密码不能与旧密码相同");
|
||||
}
|
||||
|
||||
if (userService.resetUserPwd(userName, BCrypt.hashpw(newPassword)) > 0) {
|
||||
return R.ok();
|
||||
}
|
||||
return R.fail("修改密码异常,请联系管理员");
|
||||
}
|
||||
|
||||
/**
|
||||
* 头像上传
|
||||
*
|
||||
* @param avatarfile 用户头像
|
||||
*/
|
||||
@Log(title = "用户头像", businessType = BusinessType.UPDATE)
|
||||
@PostMapping(value = "/avatar", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
|
||||
public R<Map<String, Object>> avatar(@RequestPart("avatarfile") MultipartFile avatarfile) {
|
||||
Map<String, Object> ajax = new HashMap<>();
|
||||
if (!avatarfile.isEmpty()) {
|
||||
String extension = FileUtil.extName(avatarfile.getOriginalFilename());
|
||||
if (!StringUtils.equalsAnyIgnoreCase(extension, MimeTypeUtils.IMAGE_EXTENSION)) {
|
||||
return R.fail("文件格式不正确,请上传" + Arrays.toString(MimeTypeUtils.IMAGE_EXTENSION) + "格式");
|
||||
}
|
||||
SysOssVo oss = iSysOssService.upload(avatarfile);
|
||||
String avatar = oss.getUrl();
|
||||
if (userService.updateUserAvatar(getUsername(), avatar)) {
|
||||
ajax.put("imgUrl", avatar);
|
||||
return R.ok(ajax);
|
||||
}
|
||||
}
|
||||
return R.fail("上传图片异常,请联系管理员");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.qingyun.web.controller.system;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaIgnore;
|
||||
import com.qingyun.common.core.controller.BaseController;
|
||||
import com.qingyun.common.core.domain.R;
|
||||
import com.qingyun.common.core.domain.model.RegisterBody;
|
||||
import com.qingyun.system.service.ISysConfigService;
|
||||
import com.qingyun.system.service.SysRegisterService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* 注册验证
|
||||
*
|
||||
* @author jianlu
|
||||
*/
|
||||
@Validated
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
public class SysRegisterController extends BaseController {
|
||||
|
||||
private final SysRegisterService registerService;
|
||||
private final ISysConfigService configService;
|
||||
|
||||
/**
|
||||
* 用户注册
|
||||
*/
|
||||
@SaIgnore
|
||||
@PostMapping("/register")
|
||||
public R<Void> register(@Validated @RequestBody RegisterBody user) {
|
||||
if (!("true".equals(configService.selectConfigByKey("sys.account.registerUser")))) {
|
||||
return R.fail("当前系统没有开启注册功能!");
|
||||
}
|
||||
registerService.register(user);
|
||||
return R.ok();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,227 @@
|
||||
package com.qingyun.web.controller.system;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import com.qingyun.common.annotation.Log;
|
||||
import com.qingyun.common.core.controller.BaseController;
|
||||
import com.qingyun.common.core.domain.PageQuery;
|
||||
import com.qingyun.common.core.domain.R;
|
||||
import com.qingyun.common.core.domain.entity.SysDept;
|
||||
import com.qingyun.common.core.domain.entity.SysRole;
|
||||
import com.qingyun.common.core.domain.entity.SysUser;
|
||||
import com.qingyun.mybatisplus.page.TableDataInfo;
|
||||
import com.qingyun.common.enums.BusinessType;
|
||||
import com.qingyun.common.utils.poi.ExcelUtil;
|
||||
import com.qingyun.system.domain.SysUserRole;
|
||||
import com.qingyun.system.service.ISysDeptService;
|
||||
import com.qingyun.system.service.ISysRoleService;
|
||||
import com.qingyun.system.service.ISysUserService;
|
||||
import com.qingyun.system.service.SysPermissionService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 角色信息
|
||||
*
|
||||
* @author jianlu
|
||||
*/
|
||||
@Validated
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/system/role")
|
||||
public class SysRoleController extends BaseController {
|
||||
|
||||
private final ISysRoleService roleService;
|
||||
private final ISysUserService userService;
|
||||
private final ISysDeptService deptService;
|
||||
private final SysPermissionService permissionService;
|
||||
|
||||
/**
|
||||
* 获取角色信息列表
|
||||
*/
|
||||
@SaCheckPermission("system:role:list")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo<SysRole> list(SysRole role, PageQuery pageQuery) {
|
||||
return roleService.selectPageRoleList(role, pageQuery);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出角色信息列表
|
||||
*/
|
||||
@Log(title = "角色管理", businessType = BusinessType.EXPORT)
|
||||
@SaCheckPermission("system:role:export")
|
||||
@PostMapping("/export")
|
||||
public void export(SysRole role, HttpServletResponse response) {
|
||||
List<SysRole> list = roleService.selectRoleList(role);
|
||||
ExcelUtil.exportExcel(list, "角色数据", SysRole.class, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据角色编号获取详细信息
|
||||
*
|
||||
* @param roleId 角色ID
|
||||
*/
|
||||
@SaCheckPermission("system:role:query")
|
||||
@GetMapping(value = "/{roleId}")
|
||||
public R<SysRole> getInfo(@PathVariable Long roleId) {
|
||||
roleService.checkRoleDataScope(roleId);
|
||||
return R.ok(roleService.selectRoleById(roleId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增角色
|
||||
*/
|
||||
@SaCheckPermission("system:role:add")
|
||||
@Log(title = "角色管理", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public R<Void> add(@Validated @RequestBody SysRole role) {
|
||||
if (!roleService.checkRoleNameUnique(role)) {
|
||||
return R.fail("新增角色'" + role.getRoleName() + "'失败,角色名称已存在");
|
||||
} else if (!roleService.checkRoleKeyUnique(role)) {
|
||||
return R.fail("新增角色'" + role.getRoleName() + "'失败,角色权限已存在");
|
||||
}
|
||||
return toAjax(roleService.insertRole(role));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改保存角色
|
||||
*/
|
||||
@SaCheckPermission("system:role:edit")
|
||||
@Log(title = "角色管理", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public R<Void> edit(@Validated @RequestBody SysRole role) {
|
||||
roleService.checkRoleAllowed(role);
|
||||
roleService.checkRoleDataScope(role.getRoleId());
|
||||
if (!roleService.checkRoleNameUnique(role)) {
|
||||
return R.fail("修改角色'" + role.getRoleName() + "'失败,角色名称已存在");
|
||||
} else if (!roleService.checkRoleKeyUnique(role)) {
|
||||
return R.fail("修改角色'" + role.getRoleName() + "'失败,角色权限已存在");
|
||||
}
|
||||
|
||||
if (roleService.updateRole(role) > 0) {
|
||||
roleService.cleanOnlineUserByRole(role.getRoleId());
|
||||
return R.ok();
|
||||
}
|
||||
return R.fail("修改角色'" + role.getRoleName() + "'失败,请联系管理员");
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改保存数据权限
|
||||
*/
|
||||
@SaCheckPermission("system:role:edit")
|
||||
@Log(title = "角色管理", businessType = BusinessType.UPDATE)
|
||||
@PutMapping("/dataScope")
|
||||
public R<Void> dataScope(@RequestBody SysRole role) {
|
||||
roleService.checkRoleAllowed(role);
|
||||
roleService.checkRoleDataScope(role.getRoleId());
|
||||
return toAjax(roleService.authDataScope(role));
|
||||
}
|
||||
|
||||
/**
|
||||
* 状态修改
|
||||
*/
|
||||
@SaCheckPermission("system:role:edit")
|
||||
@Log(title = "角色管理", businessType = BusinessType.UPDATE)
|
||||
@PutMapping("/changeStatus")
|
||||
public R<Void> changeStatus(@RequestBody SysRole role) {
|
||||
roleService.checkRoleAllowed(role);
|
||||
roleService.checkRoleDataScope(role.getRoleId());
|
||||
return toAjax(roleService.updateRoleStatus(role));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除角色
|
||||
*
|
||||
* @param roleIds 角色ID串
|
||||
*/
|
||||
@SaCheckPermission("system:role:remove")
|
||||
@Log(title = "角色管理", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{roleIds}")
|
||||
public R<Void> remove(@PathVariable Long[] roleIds) {
|
||||
return toAjax(roleService.deleteRoleByIds(roleIds));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取角色选择框列表
|
||||
*/
|
||||
@SaCheckPermission("system:role:query")
|
||||
@GetMapping("/optionselect")
|
||||
public R<List<SysRole>> optionselect() {
|
||||
return R.ok(roleService.selectRoleAll());
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询已分配用户角色列表
|
||||
*/
|
||||
@SaCheckPermission("system:role:list")
|
||||
@GetMapping("/authUser/allocatedList")
|
||||
public TableDataInfo<SysUser> allocatedList(SysUser user, PageQuery pageQuery) {
|
||||
return userService.selectAllocatedList(user, pageQuery);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询未分配用户角色列表
|
||||
*/
|
||||
@SaCheckPermission("system:role:list")
|
||||
@GetMapping("/authUser/unallocatedList")
|
||||
public TableDataInfo<SysUser> unallocatedList(SysUser user, PageQuery pageQuery) {
|
||||
return userService.selectUnallocatedList(user, pageQuery);
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消授权用户
|
||||
*/
|
||||
@SaCheckPermission("system:role:edit")
|
||||
@Log(title = "角色管理", businessType = BusinessType.GRANT)
|
||||
@PutMapping("/authUser/cancel")
|
||||
public R<Void> cancelAuthUser(@RequestBody SysUserRole userRole) {
|
||||
return toAjax(roleService.deleteAuthUser(userRole));
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量取消授权用户
|
||||
*
|
||||
* @param roleId 角色ID
|
||||
* @param userIds 用户ID串
|
||||
*/
|
||||
@SaCheckPermission("system:role:edit")
|
||||
@Log(title = "角色管理", businessType = BusinessType.GRANT)
|
||||
@PutMapping("/authUser/cancelAll")
|
||||
public R<Void> cancelAuthUserAll(Long roleId, Long[] userIds) {
|
||||
return toAjax(roleService.deleteAuthUsers(roleId, userIds));
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量选择用户授权
|
||||
*
|
||||
* @param roleId 角色ID
|
||||
* @param userIds 用户ID串
|
||||
*/
|
||||
@SaCheckPermission("system:role:edit")
|
||||
@Log(title = "角色管理", businessType = BusinessType.GRANT)
|
||||
@PutMapping("/authUser/selectAll")
|
||||
public R<Void> selectAuthUserAll(Long roleId, Long[] userIds) {
|
||||
roleService.checkRoleDataScope(roleId);
|
||||
return toAjax(roleService.insertAuthUsers(roleId, userIds));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取对应角色部门树列表
|
||||
*
|
||||
* @param roleId 角色ID
|
||||
*/
|
||||
@SaCheckPermission("system:role:list")
|
||||
@GetMapping(value = "/deptTree/{roleId}")
|
||||
public R<Map<String, Object>> roleDeptTreeselect(@PathVariable("roleId") Long roleId) {
|
||||
Map<String, Object> ajax = new HashMap<>();
|
||||
ajax.put("checkedKeys", deptService.selectDeptListByRoleId(roleId));
|
||||
ajax.put("depts", deptService.selectDeptTreeList(new SysDept()));
|
||||
return R.ok(ajax);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,177 @@
|
||||
package com.qingyun.web.controller.system;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import cn.dev33.satoken.annotation.SaCheckRole;
|
||||
import com.baomidou.lock.annotation.Lock4j;
|
||||
import com.qingyun.common.annotation.Log;
|
||||
import com.qingyun.common.constant.TenantConstants;
|
||||
import com.qingyun.common.core.controller.BaseController;
|
||||
import com.qingyun.common.core.domain.PageQuery;
|
||||
import com.qingyun.common.core.domain.R;
|
||||
import com.qingyun.mybatisplus.page.TableDataInfo;
|
||||
import com.qingyun.common.core.validate.AddGroup;
|
||||
import com.qingyun.common.core.validate.EditGroup;
|
||||
import com.qingyun.common.enums.BusinessType;
|
||||
import com.qingyun.common.utils.poi.ExcelUtil;
|
||||
import com.qingyun.idempotent.annotation.RepeatSubmit;
|
||||
import com.qingyun.system.domain.bo.SysTenantBo;
|
||||
import com.qingyun.system.domain.vo.SysTenantVo;
|
||||
import com.qingyun.system.service.ISysTenantService;
|
||||
import com.qingyun.tenant.helper.TenantHelper;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 租户管理
|
||||
*
|
||||
* @author Michelle.Chung
|
||||
*/
|
||||
@Validated
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/system/tenant")
|
||||
public class SysTenantController extends BaseController {
|
||||
|
||||
private final ISysTenantService tenantService;
|
||||
|
||||
/**
|
||||
* 查询租户列表
|
||||
*/
|
||||
@SaCheckRole(TenantConstants.SUPER_ADMIN_ROLE_KEY)
|
||||
@SaCheckPermission("system:tenant:list")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo<SysTenantVo> list(SysTenantBo bo, PageQuery pageQuery) {
|
||||
return tenantService.queryPageList(bo, pageQuery);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出租户列表
|
||||
*/
|
||||
@SaCheckRole(TenantConstants.SUPER_ADMIN_ROLE_KEY)
|
||||
@SaCheckPermission("system:tenant:export")
|
||||
@Log(title = "租户", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(SysTenantBo bo, HttpServletResponse response) {
|
||||
List<SysTenantVo> list = tenantService.queryList(bo);
|
||||
ExcelUtil.exportExcel(list, "租户", SysTenantVo.class, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取租户详细信息
|
||||
*
|
||||
* @param id 主键
|
||||
*/
|
||||
@SaCheckRole(TenantConstants.SUPER_ADMIN_ROLE_KEY)
|
||||
@SaCheckPermission("system:tenant:query")
|
||||
@GetMapping("/{id}")
|
||||
public R<SysTenantVo> getInfo(@NotNull(message = "主键不能为空")
|
||||
@PathVariable Long id) {
|
||||
return R.ok(tenantService.queryById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增租户
|
||||
*/
|
||||
@SaCheckRole(TenantConstants.SUPER_ADMIN_ROLE_KEY)
|
||||
@SaCheckPermission("system:tenant:add")
|
||||
@Log(title = "租户", businessType = BusinessType.INSERT)
|
||||
@Lock4j
|
||||
@RepeatSubmit()
|
||||
@PostMapping()
|
||||
public R<Void> add(@Validated(AddGroup.class) @RequestBody SysTenantBo bo) {
|
||||
if (!tenantService.checkCompanyNameUnique(bo)) {
|
||||
return R.fail("新增租户'" + bo.getCompanyName() + "'失败,企业名称已存在");
|
||||
}
|
||||
return toAjax(TenantHelper.ignore(() -> tenantService.insertByBo(bo)));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改租户
|
||||
*/
|
||||
@SaCheckRole(TenantConstants.SUPER_ADMIN_ROLE_KEY)
|
||||
@SaCheckPermission("system:tenant:edit")
|
||||
@Log(title = "租户", businessType = BusinessType.UPDATE)
|
||||
@RepeatSubmit()
|
||||
@PutMapping()
|
||||
public R<Void> edit(@Validated(EditGroup.class) @RequestBody SysTenantBo bo) {
|
||||
tenantService.checkTenantAllowed(bo.getTenantId());
|
||||
if (!tenantService.checkCompanyNameUnique(bo)) {
|
||||
return R.fail("修改租户'" + bo.getCompanyName() + "'失败,公司名称已存在");
|
||||
}
|
||||
return toAjax(tenantService.updateByBo(bo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 状态修改
|
||||
*/
|
||||
@SaCheckRole(TenantConstants.SUPER_ADMIN_ROLE_KEY)
|
||||
@SaCheckPermission("system:tenant:edit")
|
||||
@Log(title = "租户", businessType = BusinessType.UPDATE)
|
||||
@PutMapping("/changeStatus")
|
||||
public R<Void> changeStatus(@RequestBody SysTenantBo bo) {
|
||||
tenantService.checkTenantAllowed(bo.getTenantId());
|
||||
return toAjax(tenantService.updateTenantStatus(bo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除租户
|
||||
*
|
||||
* @param ids 主键串
|
||||
*/
|
||||
@SaCheckRole(TenantConstants.SUPER_ADMIN_ROLE_KEY)
|
||||
@SaCheckPermission("system:tenant:remove")
|
||||
@Log(title = "租户", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
public R<Void> remove(@NotEmpty(message = "主键不能为空")
|
||||
@PathVariable Long[] ids) {
|
||||
return toAjax(tenantService.deleteWithValidByIds(Arrays.asList(ids), true));
|
||||
}
|
||||
|
||||
/**
|
||||
* 动态切换租户
|
||||
*
|
||||
* @param tenantId 租户ID
|
||||
*/
|
||||
@SaCheckRole(TenantConstants.SUPER_ADMIN_ROLE_KEY)
|
||||
@GetMapping("/dynamic/{tenantId}")
|
||||
public R<Void> dynamicTenant(@NotBlank(message = "租户ID不能为空") @PathVariable String tenantId) {
|
||||
TenantHelper.setDynamic(tenantId);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 清除动态租户
|
||||
*/
|
||||
@SaCheckRole(TenantConstants.SUPER_ADMIN_ROLE_KEY)
|
||||
@GetMapping("/dynamic/clear")
|
||||
public R<Void> dynamicClear() {
|
||||
TenantHelper.clearDynamic();
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 同步租户套餐
|
||||
*
|
||||
* @param tenantId 租户id
|
||||
* @param packageId 套餐id
|
||||
*/
|
||||
@SaCheckRole(TenantConstants.SUPER_ADMIN_ROLE_KEY)
|
||||
@SaCheckPermission("system:tenant:edit")
|
||||
@Log(title = "租户", businessType = BusinessType.UPDATE)
|
||||
@GetMapping("/syncTenantPackage")
|
||||
public R<Void> syncTenantPackage(@NotBlank(message = "租户ID不能为空") String tenantId, @NotBlank(message = "套餐ID不能为空") String packageId) {
|
||||
return toAjax(TenantHelper.ignore(() -> tenantService.syncTenantPackage(tenantId, packageId)));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,135 @@
|
||||
package com.qingyun.web.controller.system;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import cn.dev33.satoken.annotation.SaCheckRole;
|
||||
import com.qingyun.common.annotation.Log;
|
||||
import com.qingyun.common.constant.TenantConstants;
|
||||
import com.qingyun.common.core.controller.BaseController;
|
||||
import com.qingyun.common.core.domain.PageQuery;
|
||||
import com.qingyun.common.core.domain.R;
|
||||
import com.qingyun.mybatisplus.page.TableDataInfo;
|
||||
import com.qingyun.common.core.validate.AddGroup;
|
||||
import com.qingyun.common.core.validate.EditGroup;
|
||||
import com.qingyun.common.enums.BusinessType;
|
||||
import com.qingyun.common.utils.poi.ExcelUtil;
|
||||
import com.qingyun.idempotent.annotation.RepeatSubmit;
|
||||
import com.qingyun.system.domain.bo.SysTenantPackageBo;
|
||||
import com.qingyun.system.domain.vo.SysTenantPackageVo;
|
||||
import com.qingyun.system.service.ISysTenantPackageService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 租户套餐管理
|
||||
*
|
||||
* @author Michelle.Chung
|
||||
*/
|
||||
@Validated
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/system/tenant/package")
|
||||
public class SysTenantPackageController extends BaseController {
|
||||
|
||||
private final ISysTenantPackageService tenantPackageService;
|
||||
|
||||
/**
|
||||
* 查询租户套餐列表
|
||||
*/
|
||||
@SaCheckRole(TenantConstants.SUPER_ADMIN_ROLE_KEY)
|
||||
@SaCheckPermission("system:tenantPackage:list")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo<SysTenantPackageVo> list(SysTenantPackageBo bo, PageQuery pageQuery) {
|
||||
return tenantPackageService.queryPageList(bo, pageQuery);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询租户套餐下拉选列表
|
||||
*/
|
||||
@SaCheckRole(TenantConstants.SUPER_ADMIN_ROLE_KEY)
|
||||
@SaCheckPermission("system:tenantPackage:list")
|
||||
@GetMapping("/selectList")
|
||||
public R<List<SysTenantPackageVo>> selectList() {
|
||||
return R.ok(tenantPackageService.selectList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出租户套餐列表
|
||||
*/
|
||||
@SaCheckRole(TenantConstants.SUPER_ADMIN_ROLE_KEY)
|
||||
@SaCheckPermission("system:tenantPackage:export")
|
||||
@Log(title = "租户套餐", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(SysTenantPackageBo bo, HttpServletResponse response) {
|
||||
List<SysTenantPackageVo> list = tenantPackageService.queryList(bo);
|
||||
ExcelUtil.exportExcel(list, "租户套餐", SysTenantPackageVo.class, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取租户套餐详细信息
|
||||
*
|
||||
* @param packageId 主键
|
||||
*/
|
||||
@SaCheckRole(TenantConstants.SUPER_ADMIN_ROLE_KEY)
|
||||
@SaCheckPermission("system:tenantPackage:query")
|
||||
@GetMapping("/{packageId}")
|
||||
public R<SysTenantPackageVo> getInfo(@NotNull(message = "主键不能为空")
|
||||
@PathVariable Long packageId) {
|
||||
return R.ok(tenantPackageService.queryById(packageId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增租户套餐
|
||||
*/
|
||||
@SaCheckRole(TenantConstants.SUPER_ADMIN_ROLE_KEY)
|
||||
@SaCheckPermission("system:tenantPackage:add")
|
||||
@Log(title = "租户套餐", businessType = BusinessType.INSERT)
|
||||
@RepeatSubmit()
|
||||
@PostMapping()
|
||||
public R<Void> add(@Validated(AddGroup.class) @RequestBody SysTenantPackageBo bo) {
|
||||
return toAjax(tenantPackageService.insertByBo(bo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改租户套餐
|
||||
*/
|
||||
@SaCheckRole(TenantConstants.SUPER_ADMIN_ROLE_KEY)
|
||||
@SaCheckPermission("system:tenantPackage:edit")
|
||||
@Log(title = "租户套餐", businessType = BusinessType.UPDATE)
|
||||
@RepeatSubmit()
|
||||
@PutMapping()
|
||||
public R<Void> edit(@Validated(EditGroup.class) @RequestBody SysTenantPackageBo bo) {
|
||||
return toAjax(tenantPackageService.updateByBo(bo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 状态修改
|
||||
*/
|
||||
@SaCheckRole(TenantConstants.SUPER_ADMIN_ROLE_KEY)
|
||||
@SaCheckPermission("system:tenantPackage:edit")
|
||||
@Log(title = "租户套餐", businessType = BusinessType.UPDATE)
|
||||
@PutMapping("/changeStatus")
|
||||
public R<Void> changeStatus(@RequestBody SysTenantPackageBo bo) {
|
||||
return toAjax(tenantPackageService.updatePackageStatus(bo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除租户套餐
|
||||
*
|
||||
* @param packageIds 主键串
|
||||
*/
|
||||
@SaCheckRole(TenantConstants.SUPER_ADMIN_ROLE_KEY)
|
||||
@SaCheckPermission("system:tenantPackage:remove")
|
||||
@Log(title = "租户套餐", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{packageIds}")
|
||||
public R<Void> remove(@NotEmpty(message = "主键不能为空")
|
||||
@PathVariable Long[] packageIds) {
|
||||
return toAjax(tenantPackageService.deleteWithValidByIds(Arrays.asList(packageIds), true));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,252 @@
|
||||
package com.qingyun.web.controller.system;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import cn.dev33.satoken.secure.BCrypt;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.lang.tree.Tree;
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.qingyun.common.annotation.Log;
|
||||
import com.qingyun.common.core.controller.BaseController;
|
||||
import com.qingyun.common.core.domain.PageQuery;
|
||||
import com.qingyun.common.core.domain.R;
|
||||
import com.qingyun.common.core.domain.entity.SysDept;
|
||||
import com.qingyun.common.core.domain.entity.SysRole;
|
||||
import com.qingyun.common.core.domain.entity.SysUser;
|
||||
import com.qingyun.mybatisplus.page.TableDataInfo;
|
||||
import com.qingyun.common.enums.BusinessType;
|
||||
import com.qingyun.common.excel.ExcelResult;
|
||||
import com.qingyun.common.helper.LoginHelper;
|
||||
import com.qingyun.common.utils.StreamUtils;
|
||||
import com.qingyun.common.utils.StringUtils;
|
||||
import com.qingyun.common.utils.poi.ExcelUtil;
|
||||
import com.qingyun.system.domain.vo.SysUserExportVo;
|
||||
import com.qingyun.system.domain.vo.SysUserImportVo;
|
||||
import com.qingyun.system.listener.SysUserImportListener;
|
||||
import com.qingyun.system.service.*;
|
||||
import com.qingyun.tenant.helper.TenantHelper;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 用户信息
|
||||
*
|
||||
* @author jianlu
|
||||
*/
|
||||
@Validated
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/system/user")
|
||||
public class SysUserController extends BaseController {
|
||||
|
||||
private final ISysUserService userService;
|
||||
private final ISysRoleService roleService;
|
||||
private final ISysPostService postService;
|
||||
private final ISysDeptService deptService;
|
||||
private final ISysTenantService tenantService;
|
||||
/**
|
||||
* 获取用户列表
|
||||
*/
|
||||
@SaCheckPermission("system:user:list")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo<SysUser> list(SysUser user, PageQuery pageQuery) {
|
||||
return userService.selectPageUserList(user, pageQuery);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出用户列表
|
||||
*/
|
||||
@Log(title = "用户管理", businessType = BusinessType.EXPORT)
|
||||
@SaCheckPermission("system:user:export")
|
||||
@PostMapping("/export")
|
||||
public void export(SysUser user, HttpServletResponse response) {
|
||||
List<SysUser> list = userService.selectUserList(user);
|
||||
List<SysUserExportVo> listVo = BeanUtil.copyToList(list, SysUserExportVo.class);
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
SysDept dept = list.get(i).getDept();
|
||||
SysUserExportVo vo = listVo.get(i);
|
||||
if (ObjectUtil.isNotEmpty(dept)) {
|
||||
vo.setDeptName(dept.getDeptName());
|
||||
vo.setLeader(dept.getLeader());
|
||||
}
|
||||
}
|
||||
ExcelUtil.exportExcel(listVo, "用户数据", SysUserExportVo.class, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导入数据
|
||||
*
|
||||
* @param file 导入文件
|
||||
* @param updateSupport 是否更新已存在数据
|
||||
*/
|
||||
@Log(title = "用户管理", businessType = BusinessType.IMPORT)
|
||||
@SaCheckPermission("system:user:import")
|
||||
@PostMapping(value = "/importData", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
|
||||
public R<Void> importData(@RequestPart("file") MultipartFile file, boolean updateSupport) throws Exception {
|
||||
ExcelResult<SysUserImportVo> result = ExcelUtil.importExcel(file.getInputStream(), SysUserImportVo.class, new SysUserImportListener(updateSupport));
|
||||
return R.ok(result.getAnalysis());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取导入模板
|
||||
*/
|
||||
@PostMapping("/importTemplate")
|
||||
public void importTemplate(HttpServletResponse response) {
|
||||
ExcelUtil.exportExcel(new ArrayList<>(), "用户数据", SysUserImportVo.class, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据用户编号获取详细信息
|
||||
*
|
||||
* @param userId 用户ID
|
||||
*/
|
||||
@SaCheckPermission("system:user:query")
|
||||
@GetMapping(value = {"/", "/{userId}"})
|
||||
public R<Map<String, Object>> getInfo(@PathVariable(value = "userId", required = false) Long userId) {
|
||||
userService.checkUserDataScope(userId);
|
||||
Map<String, Object> ajax = new HashMap<>();
|
||||
List<SysRole> roles = roleService.selectRoleAll();
|
||||
ajax.put("roles", LoginHelper.isSuperAdmin(userId) ? roles : StreamUtils.filter(roles, r -> !r.isAdmin()));
|
||||
ajax.put("posts", postService.selectPostAll());
|
||||
if (ObjectUtil.isNotNull(userId)) {
|
||||
SysUser sysUser = userService.selectUserById(userId);
|
||||
ajax.put("user", sysUser);
|
||||
ajax.put("postIds", postService.selectPostListByUserId(userId));
|
||||
ajax.put("roleIds", StreamUtils.toList(sysUser.getRoles(), SysRole::getRoleId));
|
||||
}
|
||||
return R.ok(ajax);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增用户
|
||||
*/
|
||||
@SaCheckPermission("system:user:add")
|
||||
@Log(title = "用户管理", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public R<Void> add(@Validated @RequestBody SysUser user) {
|
||||
if (TenantHelper.isEnable()) {
|
||||
if (!tenantService.checkAccountBalance(TenantHelper.getTenantId())) {
|
||||
return R.fail("当前租户下用户名额不足,请联系管理员");
|
||||
}
|
||||
}
|
||||
if (!userService.checkUserNameUnique(user)) {
|
||||
return R.fail("新增用户'" + user.getUserName() + "'失败,登录账号已存在");
|
||||
} else if (StringUtils.isNotEmpty(user.getPhonenumber()) && !userService.checkPhoneUnique(user)) {
|
||||
return R.fail("新增用户'" + user.getUserName() + "'失败,手机号码已存在");
|
||||
} else if (StringUtils.isNotEmpty(user.getEmail()) && !userService.checkEmailUnique(user)) {
|
||||
return R.fail("新增用户'" + user.getUserName() + "'失败,邮箱账号已存在");
|
||||
}
|
||||
|
||||
user.setPassword(BCrypt.hashpw(user.getPassword()));
|
||||
return toAjax(userService.insertUser(user));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改用户
|
||||
*/
|
||||
@SaCheckPermission("system:user:edit")
|
||||
@Log(title = "用户管理", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public R<Void> edit(@Validated @RequestBody SysUser user) {
|
||||
userService.checkUserAllowed(user);
|
||||
userService.checkUserDataScope(user.getUserId());
|
||||
if (!userService.checkUserNameUnique(user)) {
|
||||
return R.fail("修改用户'" + user.getUserName() + "'失败,登录账号已存在");
|
||||
} else if (StringUtils.isNotEmpty(user.getPhonenumber()) && !userService.checkPhoneUnique(user)) {
|
||||
return R.fail("修改用户'" + user.getUserName() + "'失败,手机号码已存在");
|
||||
} else if (StringUtils.isNotEmpty(user.getEmail()) && !userService.checkEmailUnique(user)) {
|
||||
return R.fail("修改用户'" + user.getUserName() + "'失败,邮箱账号已存在");
|
||||
}
|
||||
return toAjax(userService.updateUser(user));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除用户
|
||||
*
|
||||
* @param userIds 角色ID串
|
||||
*/
|
||||
@SaCheckPermission("system:user:remove")
|
||||
@Log(title = "用户管理", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{userIds}")
|
||||
public R<Void> remove(@PathVariable Long[] userIds) {
|
||||
if (ArrayUtil.contains(userIds, getUserId())) {
|
||||
return R.fail("当前用户不能删除");
|
||||
}
|
||||
return toAjax(userService.deleteUserByIds(userIds));
|
||||
}
|
||||
|
||||
/**
|
||||
* 重置密码
|
||||
*/
|
||||
@SaCheckPermission("system:user:resetPwd")
|
||||
@Log(title = "用户管理", businessType = BusinessType.UPDATE)
|
||||
@PutMapping("/resetPwd")
|
||||
public R<Void> resetPwd(@RequestBody SysUser user) {
|
||||
userService.checkUserAllowed(user);
|
||||
userService.checkUserDataScope(user.getUserId());
|
||||
user.setPassword(BCrypt.hashpw(user.getPassword()));
|
||||
return toAjax(userService.resetPwd(user));
|
||||
}
|
||||
|
||||
/**
|
||||
* 状态修改
|
||||
*/
|
||||
@SaCheckPermission("system:user:edit")
|
||||
@Log(title = "用户管理", businessType = BusinessType.UPDATE)
|
||||
@PutMapping("/changeStatus")
|
||||
public R<Void> changeStatus(@RequestBody SysUser user) {
|
||||
userService.checkUserAllowed(user);
|
||||
userService.checkUserDataScope(user.getUserId());
|
||||
return toAjax(userService.updateUserStatus(user));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据用户编号获取授权角色
|
||||
*
|
||||
* @param userId 用户ID
|
||||
*/
|
||||
@SaCheckPermission("system:user:query")
|
||||
@GetMapping("/authRole/{userId}")
|
||||
public R<Map<String, Object>> authRole(@PathVariable Long userId) {
|
||||
SysUser user = userService.selectUserById(userId);
|
||||
List<SysRole> roles = roleService.selectRolesByUserId(userId);
|
||||
Map<String, Object> ajax = new HashMap<>();
|
||||
ajax.put("user", user);
|
||||
ajax.put("roles", LoginHelper.isSuperAdmin(userId) ? roles : StreamUtils.filter(roles, r -> !r.isAdmin()));
|
||||
return R.ok(ajax);
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户授权角色
|
||||
*
|
||||
* @param userId 用户Id
|
||||
* @param roleIds 角色ID串
|
||||
*/
|
||||
@SaCheckPermission("system:user:edit")
|
||||
@Log(title = "用户管理", businessType = BusinessType.GRANT)
|
||||
@PutMapping("/authRole")
|
||||
public R<Void> insertAuthRole(Long userId, Long[] roleIds) {
|
||||
userService.checkUserDataScope(userId);
|
||||
userService.insertUserAuth(userId, roleIds);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取部门树列表
|
||||
*/
|
||||
@SaCheckPermission("system:user:list")
|
||||
@GetMapping("/deptTree")
|
||||
public R<List<Tree<Long>>> deptTree(SysDept dept) {
|
||||
return R.ok(deptService.selectDeptTreeList(dept));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
com.qingyun.common.captcha.CaptchaCacheServiceProvider
|
||||
155
qingyun-admin/src/main/resources/application-dev.yml
Normal file
155
qingyun-admin/src/main/resources/application-dev.yml
Normal file
@@ -0,0 +1,155 @@
|
||||
--- # 项目相关配置
|
||||
qingyun:
|
||||
# 项目根目录
|
||||
profile: ${root.directory}
|
||||
# projectUrl: http://192.168.3.16:8081
|
||||
projectUrl: http://localhost:8099
|
||||
--- # 监控中心配置
|
||||
spring.boot.admin.client:
|
||||
# 增加客户端开关
|
||||
enabled: false
|
||||
url: http://localhost:9090/admin
|
||||
instance:
|
||||
service-host-type: IP
|
||||
username: qingyun
|
||||
password: 123456
|
||||
|
||||
|
||||
|
||||
--- # 数据源配置
|
||||
spring:
|
||||
datasource:
|
||||
type: com.zaxxer.hikari.HikariDataSource
|
||||
# 动态数据源文档 https://www.kancloud.cn/tracy5546/dynamic-datasource/content
|
||||
dynamic:
|
||||
# 性能分析插件(有性能损耗 不建议生产环境使用)
|
||||
p6spy: true
|
||||
# 设置默认的数据源或者数据源组,默认值即为 master
|
||||
primary: master
|
||||
# 严格模式 匹配不到数据源则报错
|
||||
strict: true
|
||||
datasource:
|
||||
# 主库数据源
|
||||
master:
|
||||
type: ${spring.datasource.type}
|
||||
driverClassName: com.mysql.cj.jdbc.Driver
|
||||
# jdbc 所有参数配置参考 https://lionli.blog.csdn.net/article/details/122018562
|
||||
# rewriteBatchedStatements=true 批处理优化 大幅提升批量插入更新删除性能(对数据库有性能损耗 使用批量操作应考虑性能问题)
|
||||
url: jdbc:mysql://192.168.11.200:3306/qingyun_contract_review?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true
|
||||
username: qingyun_contract_review
|
||||
password: EjMx657CDY7hiw7x
|
||||
# 从库数据源
|
||||
slave:
|
||||
lazy: true
|
||||
type: ${spring.datasource.type}
|
||||
driverClassName: com.mysql.cj.jdbc.Driver
|
||||
url: jdbc:mysql://localhost:3306/ry-vue?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true
|
||||
username:
|
||||
password:
|
||||
hikari:
|
||||
# 最大连接池数量
|
||||
maxPoolSize: 20
|
||||
# 最小空闲线程数量
|
||||
minIdle: 10
|
||||
# 配置获取连接等待超时的时间
|
||||
connectionTimeout: 30000
|
||||
# 校验超时时间
|
||||
validationTimeout: 5000
|
||||
# 空闲连接存活最大时间,默认10分钟
|
||||
idleTimeout: 600000
|
||||
# 此属性控制池中连接的最长生命周期,值0表示无限生命周期,默认30分钟
|
||||
maxLifetime: 1800000
|
||||
# 连接测试query(配置检测连接是否有效)
|
||||
connectionTestQuery: SELECT 1
|
||||
# 多久检查一次连接的活性
|
||||
keepaliveTime: 30000
|
||||
|
||||
--- # redis 单机配置(单机与集群只能开启一个另一个需要注释掉)
|
||||
spring:
|
||||
redis:
|
||||
# 地址
|
||||
host: 192.168.11.200
|
||||
# 端口,默认为6379
|
||||
port: 6379
|
||||
# 数据库索引
|
||||
database: 0
|
||||
# 密码(如没有密码请注释掉)
|
||||
password: EjMx657CDY7hiw7x
|
||||
# 连接超时时间
|
||||
timeout: 10s
|
||||
# 是否开启ssl
|
||||
ssl: false
|
||||
|
||||
redisson:
|
||||
# redis key前缀
|
||||
keyPrefix:
|
||||
# 线程池数量
|
||||
threads: 4
|
||||
# Netty线程池数量
|
||||
nettyThreads: 8
|
||||
# 单节点配置
|
||||
singleServerConfig:
|
||||
# 客户端名称
|
||||
clientName: ${qingyun.name}
|
||||
# 最小空闲连接数
|
||||
connectionMinimumIdleSize: 8
|
||||
# 连接池大小
|
||||
connectionPoolSize: 32
|
||||
# 连接空闲超时,单位:毫秒
|
||||
idleConnectionTimeout: 10000
|
||||
# 命令等待超时,单位:毫秒
|
||||
timeout: 3000
|
||||
# 发布和订阅连接池大小
|
||||
subscriptionConnectionPoolSize: 50
|
||||
|
||||
springdoc:
|
||||
api-docs:
|
||||
# 是否开启接口文档
|
||||
enabled: true
|
||||
swagger-ui:
|
||||
path: /doc.html
|
||||
# 持久化认证数据
|
||||
persistAuthorization: true
|
||||
tags-sorter: alpha
|
||||
operations-sorter: alpha
|
||||
show-extensions: true
|
||||
#这里定义了两个分组,可定义多个,也可以不定义
|
||||
group-configs:
|
||||
- group: 1.演示模块
|
||||
packages-to-scan: com.qingyun.demo
|
||||
- group: 2.系统模块
|
||||
packages-to-scan: com.qingyun.web.system
|
||||
- group: 3.代码生成模块
|
||||
packages-to-scan: com.qingyun.generator
|
||||
- group: 4.合同业务管理
|
||||
packages-to-scan: com.qingyun.web.controller.api.contract
|
||||
|
||||
|
||||
# security配置
|
||||
security:
|
||||
# 排除路径
|
||||
excludes:
|
||||
# 静态资源
|
||||
- /*.html
|
||||
- /**/*.html
|
||||
- /**/*.css
|
||||
- /**/*.js
|
||||
# 公共路径
|
||||
- /favicon.ico
|
||||
- /error
|
||||
# swagger 文档配置
|
||||
- /*/api-docs
|
||||
- /*/api-docs/**
|
||||
# # actuator 监控配置
|
||||
# - /actuator
|
||||
# - /actuator/**
|
||||
# 验证码
|
||||
- /**/captcha/**
|
||||
- /system/oss/uploadLocal
|
||||
- /api/service/reviewTask/**
|
||||
- /api/pdf/**
|
||||
- /api/service/compareTask/**
|
||||
|
||||
# orc识别服务
|
||||
ocr:
|
||||
url: http://10.78.113.249:8080/layout-parsing
|
||||
138
qingyun-admin/src/main/resources/application-prod.yml
Normal file
138
qingyun-admin/src/main/resources/application-prod.yml
Normal file
@@ -0,0 +1,138 @@
|
||||
--- # 项目相关配置
|
||||
qingyun:
|
||||
profile: /opt/workspace/localUpload/carUpload
|
||||
projectUrl: http://localhost:8099
|
||||
# projectUrl:
|
||||
--- # 临时文件存储位置 避免临时文件被系统清理报错
|
||||
spring.servlet.multipart.location: /qingyun/server/temp
|
||||
|
||||
--- # 数据源配置
|
||||
spring:
|
||||
datasource:
|
||||
type: com.zaxxer.hikari.HikariDataSource
|
||||
# 动态数据源文档 https://www.kancloud.cn/tracy5546/dynamic-datasource/content
|
||||
dynamic:
|
||||
# 性能分析插件(有性能损耗 不建议生产环境使用)
|
||||
p6spy: false
|
||||
# 设置默认的数据源或者数据源组,默认值即为 master
|
||||
primary: master
|
||||
# 严格模式 匹配不到数据源则报错
|
||||
strict: true
|
||||
datasource:
|
||||
# 主库数据源
|
||||
master:
|
||||
type: ${spring.datasource.type}
|
||||
driverClassName: com.mysql.cj.jdbc.Driver
|
||||
# jdbc 所有参数配置参考 https://lionli.blog.csdn.net/article/details/122018562
|
||||
# rewriteBatchedStatements=true 批处理优化 大幅提升批量插入更新删除性能(对数据库有性能损耗 使用批量操作应考虑性能问题)
|
||||
url: jdbc:mysql://192.168.11.200:3306/qingyun_contract_review?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true
|
||||
username: qingyun_contract_review
|
||||
password: EjMx657CDY7hiw7x
|
||||
# 从库数据源
|
||||
slave:
|
||||
lazy: true
|
||||
type: ${spring.datasource.type}
|
||||
driverClassName: com.mysql.cj.jdbc.Driver
|
||||
url: jdbc:mysql://localhost:3306/ry-vue?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true
|
||||
username:
|
||||
password:
|
||||
hikari:
|
||||
# 最大连接池数量
|
||||
maxPoolSize: 20
|
||||
# 最小空闲线程数量
|
||||
minIdle: 10
|
||||
# 配置获取连接等待超时的时间
|
||||
connectionTimeout: 30000
|
||||
# 校验超时时间
|
||||
validationTimeout: 5000
|
||||
# 空闲连接存活最大时间,默认10分钟
|
||||
idleTimeout: 600000
|
||||
# 此属性控制池中连接的最长生命周期,值0表示无限生命周期,默认30分钟
|
||||
maxLifetime: 1800000
|
||||
# 连接测试query(配置检测连接是否有效)
|
||||
connectionTestQuery: SELECT 1
|
||||
# 多久检查一次连接的活性
|
||||
keepaliveTime: 30000
|
||||
|
||||
--- # redis 单机配置(单机与集群只能开启一个另一个需要注释掉)
|
||||
spring:
|
||||
redis:
|
||||
# 地址
|
||||
host: 192.168.11.200
|
||||
# 端口,默认为6379
|
||||
port: 6379
|
||||
# 数据库索引
|
||||
database: 0
|
||||
# 密码(如没有密码请注释掉)
|
||||
password: EjMx657CDY7hiw7x
|
||||
# 连接超时时间
|
||||
timeout: 10s
|
||||
# 是否开启ssl
|
||||
ssl: false
|
||||
|
||||
redisson:
|
||||
# redis key前缀
|
||||
keyPrefix:
|
||||
# 线程池数量
|
||||
threads: 16
|
||||
# Netty线程池数量
|
||||
nettyThreads: 32
|
||||
# 单节点配置
|
||||
singleServerConfig:
|
||||
# 客户端名称
|
||||
clientName: ${qingyun.name}
|
||||
# 最小空闲连接数
|
||||
connectionMinimumIdleSize: 32
|
||||
# 连接池大小
|
||||
connectionPoolSize: 64
|
||||
# 连接空闲超时,单位:毫秒
|
||||
idleConnectionTimeout: 10000
|
||||
# 命令等待超时,单位:毫秒
|
||||
timeout: 3000
|
||||
# 发布和订阅连接池大小
|
||||
subscriptionConnectionPoolSize: 50
|
||||
|
||||
springdoc:
|
||||
api-docs:
|
||||
# 是否开启接口文档
|
||||
enabled: false
|
||||
swagger-ui:
|
||||
path: /doc.html
|
||||
# 持久化认证数据
|
||||
persistAuthorization: true
|
||||
tags-sorter: alpha
|
||||
operations-sorter: alpha
|
||||
show-extensions: true
|
||||
#这里定义了两个分组,可定义多个,也可以不定义
|
||||
group-configs:
|
||||
- group: 1.演示模块
|
||||
packages-to-scan: com.qingyun.demo
|
||||
- group: 2.系统模块
|
||||
packages-to-scan: com.qingyun.web.system
|
||||
- group: 3.代码生成模块
|
||||
packages-to-scan: com.qingyun.generator
|
||||
- group: 4.合同业务管理
|
||||
packages-to-scan: com.qingyun.web.controller.api.contract
|
||||
|
||||
# security配置
|
||||
security:
|
||||
# 排除路径
|
||||
excludes:
|
||||
# 静态资源
|
||||
- /*.html
|
||||
- /**/*.html
|
||||
- /**/*.css
|
||||
- /**/*.js
|
||||
# 公共路径
|
||||
- /favicon.ico
|
||||
- /error
|
||||
# 验证码
|
||||
- /**/captcha/**
|
||||
- /system/oss/uploadLocal
|
||||
- /api/service/reviewTask/**
|
||||
- /api/pdf/**
|
||||
- /api/service/compareTask/**
|
||||
|
||||
# orc识别服务
|
||||
ocr:
|
||||
url: http://10.77.149.156:8188/layout-parsing
|
||||
255
qingyun-admin/src/main/resources/application.yml
Normal file
255
qingyun-admin/src/main/resources/application.yml
Normal file
@@ -0,0 +1,255 @@
|
||||
# 项目相关配置
|
||||
qingyun:
|
||||
# 名称
|
||||
name: QingYun-Vue-Plus
|
||||
# 版本
|
||||
version: ${qingyun-plus.version}
|
||||
# 版权年份
|
||||
copyrightYear: 2025
|
||||
# 获取ip地址开关
|
||||
addressEnabled: true
|
||||
# 缓存懒加载
|
||||
cacheLazy: false
|
||||
|
||||
captcha:
|
||||
# 页面 <参数设置> 可开启关闭 验证码校验
|
||||
# 验证码类型 math 数组计算 char 字符验证
|
||||
type: MATH
|
||||
# line 线段干扰 circle 圆圈干扰 shear 扭曲干扰
|
||||
category: CIRCLE
|
||||
# 数字验证码位数
|
||||
numberLength: 1
|
||||
# 字符验证码长度
|
||||
charLength: 4
|
||||
|
||||
encrypt:
|
||||
body:
|
||||
open: false
|
||||
aesKey: ABCDEFGHJKLMNOBQ
|
||||
showLog: true
|
||||
|
||||
# 开发环境配置
|
||||
server:
|
||||
# 服务器的HTTP端口,默认为8080
|
||||
port: 8099
|
||||
servlet:
|
||||
# 应用的访问路径
|
||||
context-path: /
|
||||
# undertow 配置
|
||||
undertow:
|
||||
# HTTP post内容的最大大小。当值为-1时,默认值为大小是无限的
|
||||
max-http-post-size: -1
|
||||
# 以下的配置会影响buffer,这些buffer会用于服务器连接的IO操作,有点类似netty的池化内存管理
|
||||
# 每块buffer的空间大小,越小的空间被利用越充分
|
||||
buffer-size: 512
|
||||
# 是否分配的直接内存
|
||||
direct-buffers: true
|
||||
threads:
|
||||
# 设置IO线程数, 它主要执行非阻塞的任务,它们会负责多个连接, 默认设置每个CPU核心一个线程
|
||||
io: 8
|
||||
# 阻塞任务线程池, 当执行类似servlet请求阻塞操作, undertow会从这个线程池中取得线程,它的值设置取决于系统的负载
|
||||
worker: 256
|
||||
|
||||
# 日志配置
|
||||
logging:
|
||||
level:
|
||||
com.qingyun: debug
|
||||
org.springframework: warn
|
||||
config: classpath:logback-plus.xml
|
||||
|
||||
# 用户配置
|
||||
user:
|
||||
password:
|
||||
# 密码最大错误次数
|
||||
maxRetryCount: 5
|
||||
# 密码锁定时间(默认10分钟)
|
||||
lockTime: 10
|
||||
|
||||
# Spring配置
|
||||
spring:
|
||||
application:
|
||||
name: ${qingyun.name}
|
||||
# 资源信息
|
||||
messages:
|
||||
# 国际化资源文件路径
|
||||
basename: i18n/messages
|
||||
profiles:
|
||||
active: ${profiles.active}
|
||||
# 文件上传
|
||||
servlet:
|
||||
multipart:
|
||||
# 单个文件大小
|
||||
max-file-size: 10MB
|
||||
# 设置总上传的文件大小
|
||||
max-request-size: 20MB
|
||||
# 服务模块
|
||||
devtools:
|
||||
restart:
|
||||
# 热部署开关
|
||||
enabled: true
|
||||
mvc:
|
||||
format:
|
||||
date-time: yyyy-MM-dd HH:mm:ss
|
||||
jackson:
|
||||
# 日期格式化
|
||||
date-format: yyyy-MM-dd HH:mm:ss
|
||||
serialization:
|
||||
# 格式化输出
|
||||
indent_output: false
|
||||
# 忽略无法转换的对象
|
||||
fail_on_empty_beans: false
|
||||
deserialization:
|
||||
# 允许对象忽略json中不存在的属性
|
||||
fail_on_unknown_properties: false
|
||||
|
||||
# Sa-Token配置
|
||||
sa-token:
|
||||
# token名称 (同时也是cookie名称)
|
||||
token-name: Authorization
|
||||
# token有效期 设为一天 (必定过期) 单位: 秒
|
||||
timeout: 86400
|
||||
# token临时有效期 (指定时间无操作就过期) 单位: 秒
|
||||
activity-timeout: 86400
|
||||
# 是否允许同一账号并发登录 (为true时允许一起登录, 为false时新登录挤掉旧登录)
|
||||
is-concurrent: true
|
||||
# 在多人登录同一账号时,是否共用一个token (为true时所有登录共用一个token, 为false时每次登录新建一个token)
|
||||
is-share: false
|
||||
# 是否尝试从header里读取token
|
||||
is-read-header: true
|
||||
# 是否尝试从cookie里读取token
|
||||
is-read-cookie: false
|
||||
# token前缀
|
||||
token-prefix: "Bearer"
|
||||
# jwt秘钥
|
||||
jwt-secret-key: abcdefghijklmnopqrstuvwxyzsss
|
||||
|
||||
# MyBatisPlus配置
|
||||
# https://baomidou.com/config/
|
||||
mybatis-plus:
|
||||
# 不支持多包, 如有需要可在注解配置 或 提升扫包等级
|
||||
# 例如 com.**.**.mapper
|
||||
mapperPackage: com.qingyun.**.mapper
|
||||
# 对应的 XML 文件位置
|
||||
mapperLocations: classpath*:mapper/**/*Mapper.xml
|
||||
# 实体扫描,多个package用逗号或者分号分隔
|
||||
typeAliasesPackage: com.qingyun.**.domain
|
||||
# 启动时是否检查 MyBatis XML 文件的存在,默认不检查
|
||||
checkConfigLocation: false
|
||||
configuration:
|
||||
# 自动驼峰命名规则(camel case)映射
|
||||
mapUnderscoreToCamelCase: true
|
||||
# MyBatis 自动映射策略
|
||||
# NONE:不启用 PARTIAL:只对非嵌套 resultMap 自动映射 FULL:对所有 resultMap 自动映射
|
||||
autoMappingBehavior: FULL
|
||||
# MyBatis 自动映射时未知列或未知属性处理策
|
||||
# NONE:不做处理 WARNING:打印相关警告 FAILING:抛出异常和详细信息
|
||||
autoMappingUnknownColumnBehavior: NONE
|
||||
# 更详细的日志输出 会有性能损耗 org.apache.ibatis.logging.stdout.StdOutImpl
|
||||
# 关闭日志记录 (可单纯使用 p6spy 分析) org.apache.ibatis.logging.nologging.NoLoggingImpl
|
||||
# 默认日志输出 org.apache.ibatis.logging.slf4j.Slf4jImpl
|
||||
logImpl: org.apache.ibatis.logging.nologging.NoLoggingImpl
|
||||
global-config:
|
||||
# 是否打印 Logo banner
|
||||
banner: true
|
||||
dbConfig:
|
||||
# 主键类型
|
||||
# AUTO 自增 NONE 空 INPUT 用户输入 ASSIGN_ID 雪花 ASSIGN_UUID 唯一 UUID
|
||||
idType: auto
|
||||
# 逻辑已删除值
|
||||
logicDeleteValue: 2
|
||||
# 逻辑未删除值
|
||||
logicNotDeleteValue: 0
|
||||
# 字段验证策略之 insert,在 insert 的时候的字段验证策略
|
||||
# IGNORED 忽略 NOT_NULL 非NULL NOT_EMPTY 非空 DEFAULT 默认 NEVER 不加入 SQL
|
||||
insertStrategy: NOT_NULL
|
||||
# 字段验证策略之 update,在 update 的时候的字段验证策略
|
||||
updateStrategy: NOT_NULL
|
||||
# 字段验证策略之 select,在 select 的时候的字段验证策略既 wrapper 根据内部 entity 生成的 where 条件
|
||||
where-strategy: NOT_NULL
|
||||
|
||||
# 数据加密
|
||||
mybatis-encryptor:
|
||||
# 是否开启加密
|
||||
enable: false
|
||||
# 默认加密算法
|
||||
algorithm: BASE64
|
||||
# 编码方式 BASE64/HEX。默认BASE64
|
||||
encode: BASE64
|
||||
# 安全秘钥 对称算法的秘钥 如:AES,SM4
|
||||
password:
|
||||
# 公私钥 非对称算法的公私钥 如:SM2,RSA
|
||||
publicKey:
|
||||
privateKey:
|
||||
|
||||
# Swagger配置
|
||||
swagger:
|
||||
info:
|
||||
# 标题
|
||||
title: '标题:${qingyun.name}后台管理系统_接口文档'
|
||||
# 描述
|
||||
description: '描述:用于管理集团旗下公司的人员信息,具体包括XXX,XXX模块...'
|
||||
# 版本
|
||||
version: '版本号: ${qingyun-plus.version}'
|
||||
# 作者信息
|
||||
contact:
|
||||
name: jianlu
|
||||
email: crazylionli@163.com
|
||||
url: http://www.qingyunclouds.com
|
||||
components:
|
||||
# 鉴权方式配置
|
||||
security-schemes:
|
||||
apiKey:
|
||||
type: APIKEY
|
||||
in: HEADER
|
||||
name: ${sa-token.token-name}
|
||||
|
||||
# 防止XSS攻击
|
||||
xss:
|
||||
# 过滤开关
|
||||
enabled: true
|
||||
# 排除链接(多个用逗号分隔)
|
||||
excludes: /system/notice
|
||||
# 匹配链接
|
||||
urlPatterns: /system/*,/monitor/*,/tool/*
|
||||
|
||||
# 全局线程池相关配置
|
||||
thread-pool:
|
||||
# 是否开启线程池
|
||||
enabled: true
|
||||
# 队列最大长度
|
||||
queueCapacity: 128
|
||||
# 线程池维护线程所允许的空闲时间
|
||||
keepAliveSeconds: 300
|
||||
|
||||
--- # 分布式锁 lock4j 全局配置
|
||||
lock4j:
|
||||
# 获取分布式锁超时时间,默认为 3000 毫秒
|
||||
acquire-timeout: 3000
|
||||
# 分布式锁的超时时间,默认为 30 秒
|
||||
expire: 30000
|
||||
|
||||
websocket:
|
||||
enable: true
|
||||
path: '/websocket'
|
||||
allowedOrigins: '*'
|
||||
|
||||
# 多租户配置
|
||||
tenant:
|
||||
# 是否开启
|
||||
enable: false
|
||||
# 排除表
|
||||
excludes:
|
||||
- sys_menu
|
||||
- sys_tenant
|
||||
- sys_tenant_package
|
||||
- sys_role_dept
|
||||
- sys_role_menu
|
||||
- sys_user_post
|
||||
- sys_user_role
|
||||
|
||||
|
||||
aj:
|
||||
captcha:
|
||||
water-mark: 倾云科技 # 图形验证码水印
|
||||
cache-type: redis
|
||||
type: BLOCKPUZZLE
|
||||
8
qingyun-admin/src/main/resources/banner.txt
Normal file
8
qingyun-admin/src/main/resources/banner.txt
Normal file
@@ -0,0 +1,8 @@
|
||||
Application Version: ${qingyun-plus.version}
|
||||
Spring Boot Version: ${spring-boot.version}
|
||||
__________ _____.___.__ ____ ____ __________.__
|
||||
\______ \__ __ ____\__ | |__| \ \ / /_ __ ____ \______ \ | __ __ ______
|
||||
| _/ | \/ _ \/ | | | ______ \ Y / | \_/ __ \ ______ | ___/ | | | \/ ___/
|
||||
| | \ | ( <_> )____ | | /_____/ \ /| | /\ ___/ /_____/ | | | |_| | /\___ \
|
||||
|____|_ /____/ \____// ______|__| \___/ |____/ \___ > |____| |____/____//____ >
|
||||
\/ \/ \/ \/
|
||||
BIN
qingyun-admin/src/main/resources/fonts/SimSun.ttf
Normal file
BIN
qingyun-admin/src/main/resources/fonts/SimSun.ttf
Normal file
Binary file not shown.
53
qingyun-admin/src/main/resources/i18n/messages.properties
Normal file
53
qingyun-admin/src/main/resources/i18n/messages.properties
Normal file
@@ -0,0 +1,53 @@
|
||||
#错误消息
|
||||
not.null=* 必须填写
|
||||
user.jcaptcha.error=验证码错误
|
||||
user.jcaptcha.expire=验证码已失效
|
||||
user.not.exists=对不起, 您的账号:{0} 不存在.
|
||||
user.password.not.match=用户不存在/密码错误
|
||||
user.password.retry.limit.count=密码输入错误{0}次
|
||||
user.password.retry.limit.exceed=密码输入错误{0}次,帐户锁定{1}分钟
|
||||
user.password.delete=对不起,您的账号:{0} 已被删除
|
||||
user.blocked=对不起,您的账号:{0} 已禁用,请联系管理员
|
||||
role.blocked=角色已封禁,请联系管理员
|
||||
user.logout.success=退出成功
|
||||
length.not.valid=长度必须在{min}到{max}个字符之间
|
||||
user.username.not.blank=用户名不能为空
|
||||
tenant.number.not.blank=租户编号不能为空
|
||||
user.username.not.valid=* 2到20个汉字、字母、数字或下划线组成,且必须以非数字开头
|
||||
user.username.length.valid=账户长度必须在{min}到{max}个字符之间
|
||||
user.password.not.blank=用户密码不能为空
|
||||
user.password.length.valid=用户密码长度必须在{min}到{max}个字符之间
|
||||
user.password.not.valid=* 5-50个字符
|
||||
user.email.not.valid=邮箱格式错误
|
||||
user.email.not.blank=邮箱不能为空
|
||||
user.phonenumber.not.blank=用户手机号不能为空
|
||||
user.mobile.phone.number.not.valid=手机号格式错误
|
||||
user.login.success=登录成功
|
||||
user.register.success=注册成功
|
||||
user.register.save.error=保存用户 {0} 失败,注册账号已存在
|
||||
user.register.error=注册失败,请联系系统管理人员
|
||||
user.notfound=请重新登录
|
||||
user.forcelogout=管理员强制退出,请重新登录
|
||||
user.unknown.error=未知错误,请重新登录
|
||||
##文件上传消息
|
||||
upload.exceed.maxSize=上传的文件大小超出限制的文件大小!<br/>允许的文件最大大小是:{0}MB!
|
||||
upload.filename.exceed.length=上传的文件名最长{0}个字符
|
||||
##权限
|
||||
no.permission=您没有数据的权限,请联系管理员添加权限 [{0}]
|
||||
no.create.permission=您没有创建数据的权限,请联系管理员添加权限 [{0}]
|
||||
no.update.permission=您没有修改数据的权限,请联系管理员添加权限 [{0}]
|
||||
no.delete.permission=您没有删除数据的权限,请联系管理员添加权限 [{0}]
|
||||
no.export.permission=您没有导出数据的权限,请联系管理员添加权限 [{0}]
|
||||
no.view.permission=您没有查看数据的权限,请联系管理员添加权限 [{0}]
|
||||
repeat.submit.message=不允许重复提交,请稍候再试
|
||||
rate.limiter.message=访问过于频繁,请稍候再试
|
||||
sms.code.not.blank=短信验证码不能为空
|
||||
sms.code.retry.limit.count=短信验证码输入错误{0}次
|
||||
sms.code.retry.limit.exceed=短信验证码输入错误{0}次,帐户锁定{1}分钟
|
||||
email.code.not.blank=邮箱验证码不能为空
|
||||
email.code.retry.limit.count=邮箱验证码输入错误{0}次
|
||||
email.code.retry.limit.exceed=邮箱验证码输入错误{0}次,帐户锁定{1}分钟
|
||||
xcx.code.not.blank=小程序code不能为空
|
||||
tenant.not.exists=对不起, 您的租户不存在,请联系管理员
|
||||
tenant.blocked=对不起,您的租户已禁用,请联系管理员
|
||||
tenant.expired=对不起,您的租户已过期,请联系管理员
|
||||
@@ -0,0 +1,53 @@
|
||||
#错误消息
|
||||
not.null=* Required fill in
|
||||
user.jcaptcha.error=Captcha error
|
||||
user.jcaptcha.expire=Captcha invalid
|
||||
user.not.exists=Sorry, your account: {0} does not exist
|
||||
user.password.not.match=User does not exist/Password error
|
||||
user.password.retry.limit.count=Password input error {0} times
|
||||
user.password.retry.limit.exceed=Password input error {0} times, account locked for {1} minutes
|
||||
user.password.delete=Sorry, your account:{0} has been deleted
|
||||
user.blocked=Sorry, your account: {0} has been disabled. Please contact the administrator
|
||||
role.blocked=Role disabled,please contact administrators
|
||||
user.logout.success=Exit successful
|
||||
tenant.number.not.blank=Tenant number cannot be empty
|
||||
length.not.valid=The length must be between {min} and {max} characters
|
||||
user.username.not.blank=Username cannot be blank
|
||||
user.username.not.valid=* 2 to 20 chinese characters, letters, numbers or underscores, and must start with a non number
|
||||
user.username.length.valid=Account length must be between {min} and {max} characters
|
||||
user.password.not.blank=Password cannot be empty
|
||||
user.password.length.valid=Password length must be between {min} and {max} characters
|
||||
user.password.not.valid=* 5-50 characters
|
||||
user.email.not.valid=Mailbox format error
|
||||
user.email.not.blank=Mailbox cannot be blank
|
||||
user.phonenumber.not.blank=Phone number cannot be blank
|
||||
user.mobile.phone.number.not.valid=Phone number format error
|
||||
user.login.success=Login successful
|
||||
user.register.success=Register successful
|
||||
user.register.save.error=Failed to save user {0}, The registered account already exists
|
||||
user.register.error=Register failed, please contact system administrator
|
||||
user.notfound=Please login again
|
||||
user.forcelogout=The administrator is forced to exit,please login again
|
||||
user.unknown.error=Unknown error, please login again
|
||||
##文件上传消息
|
||||
upload.exceed.maxSize=The uploaded file size exceeds the limit file size!<br/>the maximum allowed file size is:{0}MB!
|
||||
upload.filename.exceed.length=The maximum length of uploaded file name is {0} characters
|
||||
##权限
|
||||
no.permission=You do not have permission to the data,please contact your administrator to add permissions [{0}]
|
||||
no.create.permission=You do not have permission to create data,please contact your administrator to add permissions [{0}]
|
||||
no.update.permission=You do not have permission to modify data,please contact your administrator to add permissions [{0}]
|
||||
no.delete.permission=You do not have permission to delete data,please contact your administrator to add permissions [{0}]
|
||||
no.export.permission=You do not have permission to export data,please contact your administrator to add permissions [{0}]
|
||||
no.view.permission=You do not have permission to view data,please contact your administrator to add permissions [{0}]
|
||||
repeat.submit.message=Repeat submit is not allowed, please try again later
|
||||
rate.limiter.message=Visit too frequently, please try again later
|
||||
sms.code.not.blank=Sms code cannot be blank
|
||||
sms.code.retry.limit.count=Sms code input error {0} times
|
||||
sms.code.retry.limit.exceed=Sms code input error {0} times, account locked for {1} minutes
|
||||
email.code.not.blank=Email code cannot be blank
|
||||
email.code.retry.limit.count=Email code input error {0} times
|
||||
email.code.retry.limit.exceed=Email code input error {0} times, account locked for {1} minutes
|
||||
xcx.code.not.blank=Mini program code cannot be blank
|
||||
tenant.not.exists=Sorry, your tenant does not exist. Please contact the administrator
|
||||
tenant.blocked=Sorry, your tenant is disabled. Please contact the administrator
|
||||
tenant.expired=Sorry, your tenant has expired. Please contact the administrator.
|
||||
@@ -0,0 +1,53 @@
|
||||
#错误消息
|
||||
not.null=* 必须填写
|
||||
user.jcaptcha.error=验证码错误
|
||||
user.jcaptcha.expire=验证码已失效
|
||||
user.not.exists=对不起, 您的账号:{0} 不存在.
|
||||
user.password.not.match=用户不存在/密码错误
|
||||
user.password.retry.limit.count=密码输入错误{0}次
|
||||
user.password.retry.limit.exceed=密码输入错误{0}次,帐户锁定{1}分钟
|
||||
user.password.delete=对不起,您的账号:{0} 已被删除
|
||||
user.blocked=对不起,您的账号:{0} 已禁用,请联系管理员
|
||||
role.blocked=角色已封禁,请联系管理员
|
||||
user.logout.success=退出成功
|
||||
tenant.number.not.blank=租户编号不能为空
|
||||
length.not.valid=长度必须在{min}到{max}个字符之间
|
||||
user.username.not.blank=用户名不能为空
|
||||
user.username.not.valid=* 2到20个汉字、字母、数字或下划线组成,且必须以非数字开头
|
||||
user.username.length.valid=账户长度必须在{min}到{max}个字符之间
|
||||
user.password.not.blank=用户密码不能为空
|
||||
user.password.length.valid=用户密码长度必须在{min}到{max}个字符之间
|
||||
user.password.not.valid=* 5-50个字符
|
||||
user.email.not.valid=邮箱格式错误
|
||||
user.email.not.blank=邮箱不能为空
|
||||
user.phonenumber.not.blank=用户手机号不能为空
|
||||
user.mobile.phone.number.not.valid=手机号格式错误
|
||||
user.login.success=登录成功
|
||||
user.register.success=注册成功
|
||||
user.register.save.error=保存用户 {0} 失败,注册账号已存在
|
||||
user.register.error=注册失败,请联系系统管理人员
|
||||
user.notfound=请重新登录
|
||||
user.forcelogout=管理员强制退出,请重新登录
|
||||
user.unknown.error=未知错误,请重新登录
|
||||
##文件上传消息
|
||||
upload.exceed.maxSize=上传的文件大小超出限制的文件大小!<br/>允许的文件最大大小是:{0}MB!
|
||||
upload.filename.exceed.length=上传的文件名最长{0}个字符
|
||||
##权限
|
||||
no.permission=您没有数据的权限,请联系管理员添加权限 [{0}]
|
||||
no.create.permission=您没有创建数据的权限,请联系管理员添加权限 [{0}]
|
||||
no.update.permission=您没有修改数据的权限,请联系管理员添加权限 [{0}]
|
||||
no.delete.permission=您没有删除数据的权限,请联系管理员添加权限 [{0}]
|
||||
no.export.permission=您没有导出数据的权限,请联系管理员添加权限 [{0}]
|
||||
no.view.permission=您没有查看数据的权限,请联系管理员添加权限 [{0}]
|
||||
repeat.submit.message=不允许重复提交,请稍候再试
|
||||
rate.limiter.message=访问过于频繁,请稍候再试
|
||||
sms.code.not.blank=短信验证码不能为空
|
||||
sms.code.retry.limit.count=短信验证码输入错误{0}次
|
||||
sms.code.retry.limit.exceed=短信验证码输入错误{0}次,帐户锁定{1}分钟
|
||||
email.code.not.blank=邮箱验证码不能为空
|
||||
email.code.retry.limit.count=邮箱验证码输入错误{0}次
|
||||
email.code.retry.limit.exceed=邮箱验证码输入错误{0}次,帐户锁定{1}分钟
|
||||
xcx.code.not.blank=小程序code不能为空
|
||||
tenant.not.exists=对不起, 您的租户不存在,请联系管理员
|
||||
tenant.blocked=对不起,您的租户已禁用,请联系管理员
|
||||
tenant.expired=对不起,您的租户已过期,请联系管理员
|
||||
BIN
qingyun-admin/src/main/resources/ip2region.xdb
Normal file
BIN
qingyun-admin/src/main/resources/ip2region.xdb
Normal file
Binary file not shown.
129
qingyun-admin/src/main/resources/logback-plus.xml
Normal file
129
qingyun-admin/src/main/resources/logback-plus.xml
Normal file
@@ -0,0 +1,129 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration>
|
||||
<property name="log.path" value="./logs"/>
|
||||
<property name="console.log.pattern"
|
||||
value="%red(%d{yyyy-MM-dd HH:mm:ss}) %green([%thread]) %highlight(%-5level) %boldMagenta(%logger{36}%n) - %msg%n"/>
|
||||
<property name="log.pattern" value="%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n"/>
|
||||
|
||||
<!-- 控制台输出 -->
|
||||
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder>
|
||||
<pattern>${console.log.pattern}</pattern>
|
||||
<charset>utf-8</charset>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<!-- 控制台输出 -->
|
||||
<appender name="file_console" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<file>${log.path}/sys-console.log</file>
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<!-- 日志文件名格式 -->
|
||||
<fileNamePattern>${log.path}/sys-console.%d{yyyy-MM-dd}.log</fileNamePattern>
|
||||
<!-- 日志最大 1天 -->
|
||||
<maxHistory>1</maxHistory>
|
||||
</rollingPolicy>
|
||||
<encoder>
|
||||
<pattern>${log.pattern}</pattern>
|
||||
<charset>utf-8</charset>
|
||||
</encoder>
|
||||
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
|
||||
<!-- 过滤的级别 -->
|
||||
<level>INFO</level>
|
||||
</filter>
|
||||
</appender>
|
||||
|
||||
<!-- 系统日志输出 -->
|
||||
<appender name="file_info" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<file>${log.path}/sys-info.log</file>
|
||||
<!-- 循环政策:基于时间创建日志文件 -->
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<!-- 日志文件名格式 -->
|
||||
<fileNamePattern>${log.path}/sys-info.%d{yyyy-MM-dd}.log</fileNamePattern>
|
||||
<!-- 日志最大的历史 60天 -->
|
||||
<maxHistory>60</maxHistory>
|
||||
</rollingPolicy>
|
||||
<encoder>
|
||||
<pattern>${log.pattern}</pattern>
|
||||
</encoder>
|
||||
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||
<!-- 过滤的级别 -->
|
||||
<level>INFO</level>
|
||||
<!-- 匹配时的操作:接收(记录) -->
|
||||
<onMatch>ACCEPT</onMatch>
|
||||
<!-- 不匹配时的操作:拒绝(不记录) -->
|
||||
<onMismatch>DENY</onMismatch>
|
||||
</filter>
|
||||
</appender>
|
||||
|
||||
<appender name="file_error" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<file>${log.path}/sys-error.log</file>
|
||||
<!-- 循环政策:基于时间创建日志文件 -->
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<!-- 日志文件名格式 -->
|
||||
<fileNamePattern>${log.path}/sys-error.%d{yyyy-MM-dd}.log</fileNamePattern>
|
||||
<!-- 日志最大的历史 60天 -->
|
||||
<maxHistory>60</maxHistory>
|
||||
</rollingPolicy>
|
||||
<encoder>
|
||||
<pattern>${log.pattern}</pattern>
|
||||
</encoder>
|
||||
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||
<!-- 过滤的级别 -->
|
||||
<level>ERROR</level>
|
||||
<!-- 匹配时的操作:接收(记录) -->
|
||||
<onMatch>ACCEPT</onMatch>
|
||||
<!-- 不匹配时的操作:拒绝(不记录) -->
|
||||
<onMismatch>DENY</onMismatch>
|
||||
</filter>
|
||||
</appender>
|
||||
|
||||
<!-- info异步输出 -->
|
||||
<appender name="async_info" class="ch.qos.logback.classic.AsyncAppender">
|
||||
<!-- 不丢失日志.默认的,如果队列的80%已满,则会丢弃TRACT、DEBUG、INFO级别的日志 -->
|
||||
<discardingThreshold>0</discardingThreshold>
|
||||
<!-- 更改默认的队列的深度,该值会影响性能.默认值为256 -->
|
||||
<queueSize>512</queueSize>
|
||||
<!-- 添加附加的appender,最多只能添加一个 -->
|
||||
<appender-ref ref="file_info"/>
|
||||
</appender>
|
||||
|
||||
<!-- error异步输出 -->
|
||||
<appender name="async_error" class="ch.qos.logback.classic.AsyncAppender">
|
||||
<!-- 不丢失日志.默认的,如果队列的80%已满,则会丢弃TRACT、DEBUG、INFO级别的日志 -->
|
||||
<discardingThreshold>0</discardingThreshold>
|
||||
<!-- 更改默认的队列的深度,该值会影响性能.默认值为256 -->
|
||||
<queueSize>512</queueSize>
|
||||
<!-- 添加附加的appender,最多只能添加一个 -->
|
||||
<appender-ref ref="file_error"/>
|
||||
</appender>
|
||||
|
||||
<!-- 整合 skywalking 控制台输出 tid -->
|
||||
<!-- <appender name="console" class="ch.qos.logback.core.ConsoleAppender">-->
|
||||
<!-- <encoder class="ch.qos.logback.core.encoder.LayoutWrappingEncoder">-->
|
||||
<!-- <layout class="org.apache.skywalking.apm.toolkit.log.logback.v1.x.TraceIdPatternLogbackLayout">-->
|
||||
<!-- <pattern>[%tid] ${console.log.pattern}</pattern>-->
|
||||
<!-- </layout>-->
|
||||
<!-- <charset>utf-8</charset>-->
|
||||
<!-- </encoder>-->
|
||||
<!-- </appender>-->
|
||||
|
||||
<!-- 整合 skywalking 推送采集日志 -->
|
||||
<!-- <appender name="sky_log" class="org.apache.skywalking.apm.toolkit.log.logback.v1.x.log.GRPCLogClientAppender">-->
|
||||
<!-- <encoder class="ch.qos.logback.core.encoder.LayoutWrappingEncoder">-->
|
||||
<!-- <layout class="org.apache.skywalking.apm.toolkit.log.logback.v1.x.TraceIdPatternLogbackLayout">-->
|
||||
<!-- <pattern>[%tid] ${console.log.pattern}</pattern>-->
|
||||
<!-- </layout>-->
|
||||
<!-- <charset>utf-8</charset>-->
|
||||
<!-- </encoder>-->
|
||||
<!-- </appender>-->
|
||||
|
||||
<!--系统操作日志-->
|
||||
<root level="info">
|
||||
<appender-ref ref="console" />
|
||||
<appender-ref ref="async_info" />
|
||||
<appender-ref ref="async_error" />
|
||||
<appender-ref ref="file_console" />
|
||||
<!-- <appender-ref ref="sky_log"/>-->
|
||||
</root>
|
||||
|
||||
</configuration>
|
||||
25
qingyun-admin/src/main/resources/prompt/contractReview.txt
Normal file
25
qingyun-admin/src/main/resources/prompt/contractReview.txt
Normal file
@@ -0,0 +1,25 @@
|
||||
- 角色: 合同审查专家
|
||||
- 背景: 用户输入合同内容,需要根据审查规则细致的审查。用户希望明确指出合同中审查异常的具体内容,并要求提供详细的异常原因和修改建议。
|
||||
- 工作: 你是一个专业的合同审查助手,具备法律知识和合同条款分析能力。你的任务是根据用户提供的合同文本,按照合同审查规则进行逐条审查,识别合同中可能存在的问题或风险点,并输出结构化的审查结果。
|
||||
- 技能: 熟练掌握合同法及相关法律法规,具备专业的合同审核能力,能够准确识别合同条款的合规性、完整性、合理性,并根据审查规则进行客观审查。
|
||||
- Workflow:
|
||||
1. 仔细阅读用户的合同内容,理解合同的整体内容和条款。
|
||||
2. 根据内置的评分规则,对合同进行逐项评估,输出有问题的合同原文内容、原因和修改建议,修改意见可详细一些,无需输出扣分表编号。
|
||||
3. 确保异常项的判断准确无误。
|
||||
4. 将修改意见整理成输出要求的json形式,方便后续系统解析使用。
|
||||
5. 请求的数据是分页截取的,仅基于合同原文进行分析,不得编造、推测或补充合同中未提及的内容。
|
||||
6.合同内容为json字符串,格式为:[{"pageNum": 1, "context": "合同内容1"}, {"pageNum": 2, "context": "合同内容2"}, {"pageNum": 3, "context": "合同内容3"}]
|
||||
- 输出要求:
|
||||
1. 严格输出JSON格式示例如 [{"pageNum": 1,"contractContent": "原文内容","reviewBasis":"审查判断依据","riskTips":"审查异常风险提示", "riskLevel": 无风险 "modifyExample":"建议修改示例"}],
|
||||
JSON参数解释:pageNum为对应请求中的页码(pageNum)、contractContent表示原文内容、reviewBasis为审查判断依据、riskTips为审查异常风险提示、riskLevel为风险等级(无风险、低风险、中风险、高风险)、modifyExample为建议修改示例。
|
||||
2. 你不需要将输出结果渲染成markdown格式。
|
||||
3. 如果当前合同内容无法匹配到规则,就直接返回[],你不需要解释输出其它文字。
|
||||
4. 如果审查规则或合同内容为空,请直接返回[]。
|
||||
5. 输出的内容格式中,页码字段要与我请求的结构对应上,并且要求你严格去除返回的原文中带有HTML标签或markdown标签,请只保留文字。
|
||||
- 输出验证: 输出全部内容必须满足:(JSON.isArray(result) || result === "[]"),且JSON格式通过标准解析器校验。
|
||||
- 以下是请求的参数:
|
||||
- 审查规则:
|
||||
${rules}
|
||||
|
||||
- 合同内容:
|
||||
${context}
|
||||
25
qingyun-admin/src/main/resources/prompt/reviewElement.txt
Normal file
25
qingyun-admin/src/main/resources/prompt/reviewElement.txt
Normal file
@@ -0,0 +1,25 @@
|
||||
- 角色: 合同要素检查专家
|
||||
- 背景: 用户输入合同内容,需要根据检查要素细致的审查。用户希望明确指出合同中违规或不合适的内容,并要求提供详细的原因和修改建议。
|
||||
- 工作: 你是一个专业的合同要素检查助手,具备法律知识和合同条款分析能力。你的任务是根据用户提供的合同文本,按照合同要素规则进行逐条检查,识别合同中可能存在的问题,并输出结构化的检查结果。
|
||||
- 技能: 熟练掌握合同法及相关法律法规,具备专业的合同审核能力,能够准确识别合同条款的合规性、完整性、合理性,并根据规则进行客观检查。
|
||||
- Workflow:
|
||||
1. 仔细阅读用户的合同内容,理解合同的整体内容和条款。
|
||||
2. 根据内置的评分规则,对合同进行逐项评估,输出有问题的合同原文内容、原因和修改建议,修改意见可详细一些,无需输出扣分表编号。
|
||||
3. 确保异常项的判断准确无误。
|
||||
4. 将修改意见整理成输出要求的json形式,方便后续系统解析使用。
|
||||
5. 请求的数据是分页截取的,仅基于合同原文进行分析,不得编造、推测或补充合同中未提及的内容。
|
||||
6.合同内容为json字符串,格式为:[{"pageNum": 1, "context": "合同内容1"}, {"pageNum": 2, "context": "合同内容2"}, {"pageNum": 3, "context": "合同内容3"}]
|
||||
- 输出要求:
|
||||
1. 严格输出JSON格式如 [{"pageNum": 1, "contractContent": "原文内容","reviewBasis":"审查判断依据","riskTips":"审查异常风险提示", "riskLevel": 无风险 "modifyExample":"建议修改示例"}],
|
||||
JSON参数解释:pageNum为对应请求中的页码(pageNum)、contractContent表示原文内容、reviewBasis为审查判断依据、riskTips为审查异常风险提示、riskLevel为风险等级(无风险、低风险、中风险、高风险)、modifyExample为建议修改示例。
|
||||
2. 你不需要将输出结果渲染成markdown格式。
|
||||
3. 如果当前合同内容无法匹配到规则,就直接返回[],你不需要解释输出其它文字。
|
||||
4. 如果审查规则或合同内容为空,请直接返回[]。
|
||||
5. 输出的内容格式中,页码字段要与我请求的结构对应上,并且要求你严格去除返回的原文中带有HTML标签或markdown标签,请只保留文字。
|
||||
- 输出验证: 输出全部内容必须满足:(JSON.isArray(result) || result === "[]"),且JSON格式通过标准解析器校验。
|
||||
- 以下是请求的参数:
|
||||
- 审查规则:
|
||||
rules: = ${rules}
|
||||
|
||||
- 合同内容:
|
||||
context = ${context}
|
||||
28
qingyun-admin/src/main/resources/spy.properties
Normal file
28
qingyun-admin/src/main/resources/spy.properties
Normal file
@@ -0,0 +1,28 @@
|
||||
# p6spy 性能分析插件配置文件
|
||||
modulelist=com.baomidou.mybatisplus.extension.p6spy.MybatisPlusLogFactory,com.p6spy.engine.outage.P6OutageFactory
|
||||
# 自定义日志打印
|
||||
logMessageFormat=com.baomidou.mybatisplus.extension.p6spy.P6SpyLogger
|
||||
#日志输出到控制台
|
||||
appender=com.baomidou.mybatisplus.extension.p6spy.StdoutLogger
|
||||
# 使用日志系统记录 sql
|
||||
#appender=com.p6spy.engine.spy.appender.Slf4JLogger
|
||||
# 设置 p6spy driver 代理
|
||||
#deregisterdrivers=true
|
||||
# 取消JDBC URL前缀
|
||||
useprefix=true
|
||||
# 配置记录 Log 例外,可去掉的结果集有error,info,batch,debug,statement,commit,rollback,result,resultset.
|
||||
excludecategories=info,debug,result,commit,resultset
|
||||
# 日期格式
|
||||
dateformat=yyyy-MM-dd HH:mm:ss
|
||||
# SQL语句打印时间格式
|
||||
databaseDialectTimestampFormat=yyyy-MM-dd HH:mm:ss
|
||||
# 实际驱动可多个
|
||||
#driverlist=org.h2.Driver
|
||||
# 是否开启慢SQL记录
|
||||
outagedetection=true
|
||||
# 慢SQL记录标准 2 秒
|
||||
outagedetectioninterval=2
|
||||
# 是否过滤 Log
|
||||
filter=true
|
||||
# 过滤 Log 时所排除的 sql 关键字,以逗号分隔
|
||||
exclude=SELECT 1
|
||||
@@ -0,0 +1,91 @@
|
||||
package com.qingyun.service;
|
||||
|
||||
import cn.hutool.core.util.CharsetUtil;
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import com.agentsflex.core.llm.response.AiMessageResponse;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.qingyun.service.agent.LlmStrategy;
|
||||
import com.qingyun.service.agent.LlmStrategyFactory;
|
||||
import com.qingyun.service.agent.TemplateManager;
|
||||
import com.qingyun.service.domain.ContractReviewResult;
|
||||
import com.qingyun.service.domain.ContractReviewTask;
|
||||
import com.qingyun.service.mapper.ContractReviewTaskMapper;
|
||||
import com.qingyun.service.utils.MarkdownUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.util.Base64;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@SpringBootTest
|
||||
@RunWith(SpringRunner.class)
|
||||
public class TestAgentsFlex {
|
||||
|
||||
@Autowired
|
||||
private ContractReviewTaskMapper contractReviewTaskMapper;
|
||||
|
||||
@Test
|
||||
public void test() throws IOException {
|
||||
ContractReviewTask contractReviewTask = contractReviewTaskMapper.selectById(5);
|
||||
String reviewElement = contractReviewTask.getReviewElement();
|
||||
|
||||
// 获取所有页面内容, 数组索引为页码,从0开始
|
||||
List<String> pagesContent = JSONArray.parseArray(contractReviewTask.getContractContentMd(), String.class);
|
||||
|
||||
int totalPages = pagesContent.size();
|
||||
|
||||
String reviewPromptTemp = TemplateManager.getTemplate("classpath:prompt/reviewElement.txt");
|
||||
String rulePromptTemp = TemplateManager.getTemplate("classpath:prompt/contractReview.txt");
|
||||
|
||||
LlmStrategy strategy = LlmStrategyFactory.getStrategy(null);
|
||||
// 构建参数
|
||||
Map<String, String> reviewParams = new HashMap<>();
|
||||
reviewParams.put("rules", reviewElement);
|
||||
reviewParams.put("context", pagesContent.get(3));
|
||||
AiMessageResponse reviewResponse = null;
|
||||
if (StringUtils.isNotBlank(reviewElement)) {
|
||||
|
||||
reviewResponse = strategy.chat(reviewPromptTemp, reviewParams);
|
||||
System.out.println("reviewResponse: " + reviewResponse);
|
||||
String content = reviewResponse.getMessage().getContent();
|
||||
List<String> strings = MarkdownUtils.extractJsonBlocks(content);
|
||||
if (strings != null && !strings.isEmpty()) {
|
||||
List<ContractReviewResult> resultList = JSONArray.parseArray(strings.get(0), ContractReviewResult.class);
|
||||
resultList.forEach(result -> System.out.println(JSONObject.toJSONString(result)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testParsing() throws IOException {
|
||||
String filePath = "localhost:8080/profile/upload/2025/07/15/12645cd2-2f6b-4e8d-808d-fb95c1fbc23b.pdf";
|
||||
|
||||
File tempFile = File.createTempFile("contract_", ".pdf");
|
||||
long file = HttpUtil.downloadFile(filePath, tempFile);
|
||||
if (file <= 0) {
|
||||
throw new IOException("无法下载 PDF 文件");
|
||||
}
|
||||
|
||||
byte[] pageBytes = Files.readAllBytes(tempFile.toPath());
|
||||
String base64 = Base64.getEncoder().encodeToString(pageBytes);
|
||||
|
||||
// 删除临时文件
|
||||
Files.deleteIfExists(tempFile.toPath());
|
||||
|
||||
// 构造请求体
|
||||
Map<String, Object> requestBody = new HashMap<>();
|
||||
requestBody.put("file", base64);
|
||||
String result = HttpUtil.post("http://10.78.113.249:8080/layout-parsing", requestBody);
|
||||
JSONObject jsonObject = JSONObject.parseObject(result);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user