#init commit
This commit is contained in:
8
.idea/.gitignore
generated
vendored
Normal file
8
.idea/.gitignore
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
# 默认忽略的文件
|
||||||
|
/shelf/
|
||||||
|
/workspace.xml
|
||||||
|
# 基于编辑器的 HTTP 客户端请求
|
||||||
|
/httpRequests/
|
||||||
|
# Datasource local storage ignored files
|
||||||
|
/dataSources/
|
||||||
|
/dataSources.local.xml
|
||||||
35
template/.gitignore
vendored
Normal file
35
template/.gitignore
vendored
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
## java
|
||||||
|
bin/
|
||||||
|
classes/
|
||||||
|
|
||||||
|
|
||||||
|
## eclipse
|
||||||
|
.settings/
|
||||||
|
.classpath
|
||||||
|
.project
|
||||||
|
|
||||||
|
## idea
|
||||||
|
*.iml
|
||||||
|
.idea/*
|
||||||
|
!.idea/codeStyles/
|
||||||
|
!.idea/dataSources.xml
|
||||||
|
HELP.md
|
||||||
|
|
||||||
|
## vscode
|
||||||
|
.vscode/
|
||||||
|
.factorypath
|
||||||
|
|
||||||
|
## maven:
|
||||||
|
target/
|
||||||
|
test-output/
|
||||||
|
|
||||||
|
## system
|
||||||
|
.DS_Store
|
||||||
|
logs/
|
||||||
|
*.log
|
||||||
|
|
||||||
|
## vs
|
||||||
|
.vs
|
||||||
|
!modules/.gitkeep
|
||||||
|
.gitattributes
|
||||||
|
.toco/config.local.yml
|
||||||
1
template/.mvn/jvm.config
Normal file
1
template/.mvn/jvm.config
Normal file
@@ -0,0 +1 @@
|
|||||||
|
-Xmx1536m
|
||||||
BIN
template/.mvn/wrapper/maven-wrapper.jar
vendored
Normal file
BIN
template/.mvn/wrapper/maven-wrapper.jar
vendored
Normal file
Binary file not shown.
20
template/.mvn/wrapper/maven-wrapper.properties
vendored
Normal file
20
template/.mvn/wrapper/maven-wrapper.properties
vendored
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
# Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
# or more contributor license agreements. See the NOTICE file
|
||||||
|
# distributed with this work for additional information
|
||||||
|
# regarding copyright ownership. The ASF licenses this file
|
||||||
|
# to you under the Apache License, Version 2.0 (the
|
||||||
|
# "License"); you may not use this file except in compliance
|
||||||
|
# with the License. You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing,
|
||||||
|
# software distributed under the License is distributed on an
|
||||||
|
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
# KIND, either express or implied. See the License for the
|
||||||
|
# specific language governing permissions and limitations
|
||||||
|
# under the License.
|
||||||
|
distributionUrl=https://maven.aliyun.com/repository/public/org/apache/maven/apache-maven/3.8.8/apache-maven-3.8.8-bin.zip
|
||||||
|
distributionSha256Sum=2e181515ce8ae14b7a904c40bb4794831f5fd1d9641107a13b916af15af4001a
|
||||||
|
wrapperUrl=https://maven.aliyun.com/repository/public/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar
|
||||||
|
wrapperUrlSha256Sum=e63a53cfb9c4d291ebe3c2b0edacb7622bbc480326beaa5a0456e412f52f066a
|
||||||
8
template/.toco/README
Normal file
8
template/.toco/README
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
Directory Structure for Rules (.md files only):
|
||||||
|
|
||||||
|
global: Directory for storing common rules applicable to all agents
|
||||||
|
toco: Directory for storing Toco Agent-specific rules, used for overall control of the outer workflow
|
||||||
|
modeling: Directory for storing Modeling Agent-specific rules, used during the domain modeling phase
|
||||||
|
plan: Directory for storing Plan Agent-specific rules, used during the overall planning phase
|
||||||
|
design: Directory for storing Design Agent-specific rules, used for TOCO design element creation
|
||||||
|
coding: Directory for storing Coding Agent-specific rules, used during the coding phase
|
||||||
1
template/.toco/coding/README
Normal file
1
template/.toco/coding/README
Normal file
@@ -0,0 +1 @@
|
|||||||
|
The directory is used to store dedicated rules for Coding Agent, intended for the coding phase, and only supports .md files.
|
||||||
1
template/.toco/design/README
Normal file
1
template/.toco/design/README
Normal file
@@ -0,0 +1 @@
|
|||||||
|
The directory is used to store dedicated rules for Design Agent, intended for the coding phase, and only supports .md files.
|
||||||
1
template/.toco/global/README
Normal file
1
template/.toco/global/README
Normal file
@@ -0,0 +1 @@
|
|||||||
|
The directory is used to store common rules for all agents and only supports .md files.
|
||||||
1
template/.toco/modeling/README
Normal file
1
template/.toco/modeling/README
Normal file
@@ -0,0 +1 @@
|
|||||||
|
The directory is used to store dedicated rules for Modeling Agent, intended for the domain modeling phase, and only supports .md files.
|
||||||
1
template/.toco/plan/README
Normal file
1
template/.toco/plan/README
Normal file
@@ -0,0 +1 @@
|
|||||||
|
The directory is used to store dedicated rules for the Plan Agent, intended for the overall planning phase, and only supports .md files.
|
||||||
1
template/.toco/toco/README
Normal file
1
template/.toco/toco/README
Normal file
@@ -0,0 +1 @@
|
|||||||
|
The directory is used to store dedicated rules for the Toco Agent, intended for overall control of the outer workflow, and only supports .md files.
|
||||||
20
template/Dockerfile
Normal file
20
template/Dockerfile
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
FROM maven:3.8.8 AS builder
|
||||||
|
WORKDIR source
|
||||||
|
COPY ./ ./
|
||||||
|
ARG JAR_FILE=entrance/web/target/*.jar
|
||||||
|
RUN mvn clean package -Dmaven.test.skip=true
|
||||||
|
RUN cp ${JAR_FILE} app.jar
|
||||||
|
RUN java -Djarmode=layertools -jar ./app.jar extract
|
||||||
|
|
||||||
|
FROM openjdk:11.0.14
|
||||||
|
WORKDIR /application
|
||||||
|
RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
|
||||||
|
RUN echo 'Asia/Shanghai' >/etc/timezone
|
||||||
|
RUN sed -i 's/deb.debian.org/mirrors.aliyun.com/g' /etc/apt/sources.list
|
||||||
|
COPY --from=builder source/dependencies/ ./
|
||||||
|
COPY --from=builder source/snapshot-dependencies/ ./
|
||||||
|
COPY --from=builder source/spring-boot-loader/ ./
|
||||||
|
COPY --from=builder source/application/ ./
|
||||||
|
ENV JAVA_OPTS="-Xms512m -Xmx512m"
|
||||||
|
ENV MAIN_CLASS="org.springframework.boot.loader.JarLauncher"
|
||||||
|
ENTRYPOINT ["sh", "-c", "exec java ${JAVA_OPTS} -Djava.security.egd=file:dev/./urandom ${MAIN_CLASS}"]
|
||||||
20
template/LICENSE
Normal file
20
template/LICENSE
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
The MIT License (MIT)
|
||||||
|
|
||||||
|
Copyright (c) 2019 RuoYi-Vue-Plus
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
|
this software and associated documentation files (the "Software"), to deal in
|
||||||
|
the Software without restriction, including without limitation the rights to
|
||||||
|
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||||
|
the Software, and to permit persons to whom the Software is furnished to do so,
|
||||||
|
subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
|
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
5
template/common/README.md
Normal file
5
template/common/README.md
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
> 本模块存放公共组件
|
||||||
|
``` \-- *.utils(工具类; package)
|
||||||
|
\-- *.enums(公共枚举; package)
|
||||||
|
\-- *.constants(公共常量; package)
|
||||||
|
```
|
||||||
17
template/common/pom.xml
Normal file
17
template/common/pom.xml
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
<?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">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<parent>
|
||||||
|
<groupId>{{ .groupId }}</groupId>
|
||||||
|
<artifactId>{{ .artifactId }}</artifactId>
|
||||||
|
<version>${revision}</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<groupId>{{ .groupId }}</groupId>
|
||||||
|
<artifactId>{{ .artifactId }}-common</artifactId>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
|
||||||
|
</dependencies>
|
||||||
|
</project>
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
package {{ .package }}.common.config;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Configuration
|
||||||
|
@ConfigurationProperties(prefix = "rocketmq")
|
||||||
|
public class MqConfig {
|
||||||
|
private String nameServer;
|
||||||
|
private String topic;
|
||||||
|
private String consumerGroup;
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
package {{ .package }}.common.config;
|
||||||
|
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import jakarta.annotation.Resource;
|
||||||
|
import {{ .package }}.common.config.MqConfig;
|
||||||
|
import {{ .package }}.common.rocketmq.RocketMQService;
|
||||||
|
import {{ .package }}.common.rocketmq.RocketMQServiceImpl;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
public class RocketMqAutoConfiguration {
|
||||||
|
@Resource
|
||||||
|
private MqConfig mqConfig;
|
||||||
|
@Bean
|
||||||
|
RocketMQService createRocketMQService() {
|
||||||
|
RocketMQServiceImpl instance = new RocketMQServiceImpl(mqConfig.getNameServer());
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
> 本模块存放公共常量
|
||||||
|
``` \-- *Constant.java
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
> 本模块存放公共枚举
|
||||||
|
``` \-- *Enum.java
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
package {{ .package }}.common.mybatisplus;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.ddl.IDdl;
|
||||||
|
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
|
import javax.sql.DataSource;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class EmptyDdl implements IDdl {
|
||||||
|
public void execute() {
|
||||||
|
// 空实现
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void runScript(Consumer<DataSource> consumer) {}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> getSqlFiles() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,116 @@
|
|||||||
|
package {{ .package }}.common.redis;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Qualifier;
|
||||||
|
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import redis.clients.jedis.HostAndPort;
|
||||||
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||||
|
import redis.clients.jedis.JedisCluster;
|
||||||
|
import redis.clients.jedis.JedisPool;
|
||||||
|
import redis.clients.jedis.JedisPoolConfig;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
@EnableConfigurationProperties({RedisPoolProperties.class})
|
||||||
|
public class RedisPoolConfig {
|
||||||
|
@Autowired
|
||||||
|
private RedisPoolProperties redisPoolProperties;
|
||||||
|
@Value("${redis-config.pool.password:}")
|
||||||
|
private String password;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 连接池的基本配置
|
||||||
|
*
|
||||||
|
* @return JedisPoolConfig
|
||||||
|
*/
|
||||||
|
@Bean
|
||||||
|
@ConditionalOnProperty(prefix = "redis-config.pool",name = "hostAndPort")
|
||||||
|
public JedisPoolConfig initPoolConfig() {
|
||||||
|
JedisPoolConfig poolConfig = new JedisPoolConfig();
|
||||||
|
// 设置最大连接数,默认值为8.如果赋值为-1,则表示不限制;
|
||||||
|
poolConfig.setMaxTotal(redisPoolProperties.getMaxTotal());
|
||||||
|
// 最大空闲连接数
|
||||||
|
poolConfig.setMaxIdle(redisPoolProperties.getMaxIdle());
|
||||||
|
// 最小空闲连接数
|
||||||
|
poolConfig.setMinIdle(redisPoolProperties.getMinIdle());
|
||||||
|
// 获取Jedis连接的最大等待时间,单位毫秒,默认值为-1,表示永不超时。如果超过等待时间,则直接抛出JedisConnectionException
|
||||||
|
poolConfig.setMaxWaitMillis(redisPoolProperties.getMaxWaitMillis());
|
||||||
|
// 每次释放连接的最大数目
|
||||||
|
poolConfig.setNumTestsPerEvictionRun(redisPoolProperties.getNumTestsPerEvictionRun());
|
||||||
|
// 释放连接的扫描间隔(毫秒),如果为负数,则不运行逐出线程, 默认-1
|
||||||
|
poolConfig.setTimeBetweenEvictionRunsMillis(redisPoolProperties.getTimeBetweenEvictionRunsMillis());
|
||||||
|
// 连接最小空闲时间
|
||||||
|
poolConfig.setMinEvictableIdleTimeMillis(redisPoolProperties.getMinEvictableIdleTimeMillis());
|
||||||
|
// 连接空闲多久后释放, 当空闲时间>该值 且 空闲连接>最大空闲连接数 时直接释放
|
||||||
|
poolConfig.setSoftMinEvictableIdleTimeMillis(redisPoolProperties.getSoftMinEvictableIdleTimeMillis());
|
||||||
|
// 在获取Jedis连接时,自动检验连接是否可用
|
||||||
|
poolConfig.setTestOnBorrow(redisPoolProperties.isTestOnBorrow());
|
||||||
|
// 在将连接放回池中前,自动检验连接是否有效
|
||||||
|
poolConfig.setTestOnReturn(redisPoolProperties.isTestOnReturn());
|
||||||
|
// 自动测试池中的空闲连接是否都是可用连接
|
||||||
|
poolConfig.setTestWhileIdle(redisPoolProperties.isTestWhileIdle());
|
||||||
|
// 连接耗尽时是否阻塞, false报异常,ture阻塞直到超时, 默认true
|
||||||
|
poolConfig.setBlockWhenExhausted(redisPoolProperties.isBlockWhenExhausted());
|
||||||
|
// 是否启用pool的jmx管理功能, 默认true
|
||||||
|
poolConfig.setJmxEnabled(redisPoolProperties.isJmxEnabled());
|
||||||
|
// 是否启用后进先出, 默认true
|
||||||
|
poolConfig.setLifo(redisPoolProperties.isLifo());
|
||||||
|
// 每次逐出检查时 逐出的最大数目 如果为负数就是 : 1/abs(n), 默认3
|
||||||
|
poolConfig.setNumTestsPerEvictionRun(redisPoolProperties.getNumTestsPerEvictionRun());
|
||||||
|
poolConfig.setTestOnBorrow(false);
|
||||||
|
return poolConfig;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建JedisCluster客户端, 将redis客户端放到容器中; 连接redis集群
|
||||||
|
* Jedis 连接集群
|
||||||
|
*
|
||||||
|
* @return JedisCluster 使用完成后不需要手动释放连接,返回客户端, 使用完成后不需要手动释放连接, 客户端会自动释放连接
|
||||||
|
*/
|
||||||
|
// @Bean
|
||||||
|
// @Qualifier("JedisCluster")
|
||||||
|
// public JedisCluster getJedisCluster() {
|
||||||
|
// return new JedisCluster(getSet(), initPoolConfig());
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 单例版 需要手动获取jedis实例,用完后需要手动释放
|
||||||
|
*
|
||||||
|
* @return 返回redis连接池,
|
||||||
|
*/
|
||||||
|
@Bean
|
||||||
|
@ConditionalOnProperty(prefix = "redis-config.pool",name = "hostAndPort")
|
||||||
|
public JedisPool getRedisPool() {
|
||||||
|
String host = StrUtil.subBefore(redisPoolProperties.getHostAndPort(), ":", false);
|
||||||
|
int port = Integer.parseInt(StrUtil.subAfter(redisPoolProperties.getHostAndPort(), ":", false));
|
||||||
|
if(StrUtil.isNotEmpty(this.password)) {
|
||||||
|
return new JedisPool(initPoolConfig(),host,port ,1000, password);
|
||||||
|
}else{
|
||||||
|
return new JedisPool(initPoolConfig(),host,port);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取集群对象集合
|
||||||
|
*
|
||||||
|
* @return Set
|
||||||
|
*/
|
||||||
|
public Set<HostAndPort> getSet() {
|
||||||
|
String hostAndPortStr = redisPoolProperties.getHostAndPort();
|
||||||
|
String[] hostAndPortArrays = hostAndPortStr.trim().split(",");
|
||||||
|
Set<HostAndPort> hostAndPorts = new HashSet<>();
|
||||||
|
for (String hostAndPort : hostAndPortArrays) {
|
||||||
|
hostAndPorts.add(new HostAndPort(hostAndPort.split(":")[0], Integer.parseInt(hostAndPort.split(":")[1])));
|
||||||
|
}
|
||||||
|
return hostAndPorts;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,145 @@
|
|||||||
|
package {{ .package }}.common.redis;
|
||||||
|
|
||||||
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.context.annotation.PropertySource;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
@ConfigurationProperties(prefix = "redis-config.pool")
|
||||||
|
public class RedisPoolProperties {
|
||||||
|
private String hostAndPort;
|
||||||
|
private int maxTotal;
|
||||||
|
private int maxIdle;
|
||||||
|
private int minIdle;
|
||||||
|
private Long maxWaitMillis;
|
||||||
|
private Long timeBetweenEvictionRunsMillis;
|
||||||
|
private Long minEvictableIdleTimeMillis;
|
||||||
|
private Long softMinEvictableIdleTimeMillis;
|
||||||
|
private boolean testOnBorrow;
|
||||||
|
private boolean testOnReturn;
|
||||||
|
private boolean testWhileIdle;
|
||||||
|
private boolean blockWhenExhausted;
|
||||||
|
private boolean jmxEnabled;
|
||||||
|
private boolean lifo;
|
||||||
|
private int numTestsPerEvictionRun;
|
||||||
|
|
||||||
|
public String getHostAndPort() {
|
||||||
|
return hostAndPort;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setHostAndPort(String hostAndPort) {
|
||||||
|
this.hostAndPort = hostAndPort;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMaxTotal() {
|
||||||
|
return maxTotal;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMaxTotal(int maxTotal) {
|
||||||
|
this.maxTotal = maxTotal;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMaxIdle() {
|
||||||
|
return maxIdle;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMaxIdle(int maxIdle) {
|
||||||
|
this.maxIdle = maxIdle;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMinIdle() {
|
||||||
|
return minIdle;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMinIdle(int minIdle) {
|
||||||
|
this.minIdle = minIdle;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getMaxWaitMillis() {
|
||||||
|
return maxWaitMillis;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMaxWaitMillis(Long maxWaitMillis) {
|
||||||
|
this.maxWaitMillis = maxWaitMillis;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getTimeBetweenEvictionRunsMillis() {
|
||||||
|
return timeBetweenEvictionRunsMillis;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTimeBetweenEvictionRunsMillis(Long timeBetweenEvictionRunsMillis) {
|
||||||
|
this.timeBetweenEvictionRunsMillis = timeBetweenEvictionRunsMillis;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getMinEvictableIdleTimeMillis() {
|
||||||
|
return minEvictableIdleTimeMillis;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMinEvictableIdleTimeMillis(Long minEvictableIdleTimeMillis) {
|
||||||
|
this.minEvictableIdleTimeMillis = minEvictableIdleTimeMillis;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getSoftMinEvictableIdleTimeMillis() {
|
||||||
|
return softMinEvictableIdleTimeMillis;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSoftMinEvictableIdleTimeMillis(Long softMinEvictableIdleTimeMillis) {
|
||||||
|
this.softMinEvictableIdleTimeMillis = softMinEvictableIdleTimeMillis;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isTestOnBorrow() {
|
||||||
|
return testOnBorrow;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTestOnBorrow(boolean testOnBorrow) {
|
||||||
|
this.testOnBorrow = testOnBorrow;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isTestOnReturn() {
|
||||||
|
return testOnReturn;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTestOnReturn(boolean testOnReturn) {
|
||||||
|
this.testOnReturn = testOnReturn;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isTestWhileIdle() {
|
||||||
|
return testWhileIdle;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTestWhileIdle(boolean testWhileIdle) {
|
||||||
|
this.testWhileIdle = testWhileIdle;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isBlockWhenExhausted() {
|
||||||
|
return blockWhenExhausted;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBlockWhenExhausted(boolean blockWhenExhausted) {
|
||||||
|
this.blockWhenExhausted = blockWhenExhausted;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isJmxEnabled() {
|
||||||
|
return jmxEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setJmxEnabled(boolean jmxEnabled) {
|
||||||
|
this.jmxEnabled = jmxEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isLifo() {
|
||||||
|
return lifo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLifo(boolean lifo) {
|
||||||
|
this.lifo = lifo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getNumTestsPerEvictionRun() {
|
||||||
|
return numTestsPerEvictionRun;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNumTestsPerEvictionRun(int numTestsPerEvictionRun) {
|
||||||
|
this.numTestsPerEvictionRun = numTestsPerEvictionRun;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
package {{ .package }}.common.response;
|
||||||
|
|
||||||
|
import java.text.*;
|
||||||
|
import java.util.Calendar;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
public class MyDateFormat extends DateFormat {
|
||||||
|
private static final long serialVersionUID = -4580955831439573829L;
|
||||||
|
private static final String customDateFormat = "yyyy-MM-dd HH:mm:ss";
|
||||||
|
private DateFormat dateFormat;
|
||||||
|
private SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||||
|
|
||||||
|
public MyDateFormat(DateFormat dateFormat) {
|
||||||
|
this.calendar = Calendar.getInstance();
|
||||||
|
this.dateFormat = dateFormat;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition fieldPosition) {
|
||||||
|
return this.dateFormat.format(date, toAppendTo, fieldPosition);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date parse(String source, ParsePosition pos) {
|
||||||
|
Date date = null;
|
||||||
|
if (source.length() == "yyyy-MM-dd HH:mm:ss".length()) {
|
||||||
|
date = this.simpleDateFormat.parse(source, pos);
|
||||||
|
} else {
|
||||||
|
date = this.dateFormat.parse(source, pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
return date;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date parse(String source) throws ParseException {
|
||||||
|
Date date = null;
|
||||||
|
if (source.length() == "yyyy-MM-dd HH:mm:ss".length()) {
|
||||||
|
date = this.simpleDateFormat.parse(source);
|
||||||
|
} else {
|
||||||
|
date = this.dateFormat.parse(source);
|
||||||
|
}
|
||||||
|
|
||||||
|
return date;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object clone() {
|
||||||
|
Object format = this.dateFormat.clone();
|
||||||
|
return new MyDateFormat((DateFormat)format);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,118 @@
|
|||||||
|
package {{ .package }}.common.response;
|
||||||
|
|
||||||
|
import com.vs.common.util.rpc.pub.FailData;
|
||||||
|
import com.vs.ox.common.exception.ErrorCode;
|
||||||
|
import com.vs.ox.common.exception.IgnoredException;
|
||||||
|
import com.vs.ox.common.utils.ObjectMapperFactory;
|
||||||
|
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
|
import jakarta.validation.ConstraintViolation;
|
||||||
|
import jakarta.validation.ConstraintViolationException;
|
||||||
|
import jakarta.validation.Path;
|
||||||
|
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.springframework.beans.factory.InitializingBean;
|
||||||
|
import org.springframework.core.Ordered;
|
||||||
|
import org.springframework.http.MediaType;
|
||||||
|
import org.springframework.http.converter.HttpMessageConverter;
|
||||||
|
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
|
||||||
|
import org.springframework.http.server.ServletServerHttpResponse;
|
||||||
|
import org.springframework.web.servlet.ModelAndView;
|
||||||
|
import org.springframework.web.servlet.handler.AbstractHandlerExceptionResolver;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.PrintWriter;
|
||||||
|
import java.io.StringWriter;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
public class ResponseJsonExceptionResolver extends AbstractHandlerExceptionResolver
|
||||||
|
implements InitializingBean {
|
||||||
|
private HttpMessageConverter messageConverter;
|
||||||
|
|
||||||
|
public ResponseJsonExceptionResolver() {}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void afterPropertiesSet() throws Exception {
|
||||||
|
if (messageConverter == null) {
|
||||||
|
messageConverter =
|
||||||
|
new MappingJackson2HttpMessageConverter(
|
||||||
|
ObjectMapperFactory.getDefaultObjectMapper());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getErrorInfoFromException(Exception e) {
|
||||||
|
try {
|
||||||
|
StringWriter sw = new StringWriter();
|
||||||
|
PrintWriter pw = new PrintWriter(sw);
|
||||||
|
e.printStackTrace(pw);
|
||||||
|
return "\r\n" + sw.toString() + "\r\n";
|
||||||
|
} catch (Exception e2) {
|
||||||
|
return "bad getErrorInfoFromException";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected ModelAndView doResolveException(
|
||||||
|
HttpServletRequest request,
|
||||||
|
HttpServletResponse response,
|
||||||
|
Object handler,
|
||||||
|
Exception ex) {
|
||||||
|
/** web请求分页单独处理,应对antd框架 */
|
||||||
|
FailData failData = new FailData();
|
||||||
|
failData.setMessage(ex.getMessage());
|
||||||
|
if (ex instanceof IgnoredException) {
|
||||||
|
IgnoredException realEx = (IgnoredException) ex;
|
||||||
|
failData.setCode(realEx.getErrorCode());
|
||||||
|
failData.setData(realEx.getData());
|
||||||
|
log.error("execute {} failed with exception", request.getRequestURL(), ex);
|
||||||
|
} else if (ex instanceof ConstraintViolationException) {
|
||||||
|
failData.setCode(ErrorCode.WRONG_PARAMETER);
|
||||||
|
failData.setMessage(getMessage((ConstraintViolationException) ex));
|
||||||
|
} else if (ex instanceof ErrorCode) {
|
||||||
|
failData.setCode(((ErrorCode) ex).getErrorCode());
|
||||||
|
} else {
|
||||||
|
log.error("execute {} failed with exception", request.getRequestURL(), ex);
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
response.setCharacterEncoding("utf-8");
|
||||||
|
messageConverter.write(
|
||||||
|
failData, MediaType.APPLICATION_JSON, new ServletServerHttpResponse(response));
|
||||||
|
} catch (IOException e) {
|
||||||
|
logger.error(e.getMessage(), e);
|
||||||
|
}
|
||||||
|
return new ModelAndView();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getOrder() {
|
||||||
|
return Ordered.LOWEST_PRECEDENCE;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getMessage(ConstraintViolationException e) {
|
||||||
|
List<String> msgList = new ArrayList<>();
|
||||||
|
for (ConstraintViolation<?> constraintViolation : e.getConstraintViolations()) {
|
||||||
|
int i = 0;
|
||||||
|
StringBuilder param = new StringBuilder();
|
||||||
|
for (Iterator<Path.Node> iterator = constraintViolation.getPropertyPath().iterator();
|
||||||
|
iterator.hasNext();
|
||||||
|
i++) {
|
||||||
|
Path.Node node = iterator.next();
|
||||||
|
if (i == 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (!param.toString().isBlank()) {
|
||||||
|
param.append(".");
|
||||||
|
}
|
||||||
|
param.append(node.getName());
|
||||||
|
}
|
||||||
|
msgList.add("参数 [ " + param + " ] " + constraintViolation.getMessage());
|
||||||
|
}
|
||||||
|
return StringUtils.join(msgList.toArray(), ";");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,62 @@
|
|||||||
|
package {{ .package }}.common.response;
|
||||||
|
|
||||||
|
import com.vs.common.util.rpc.pub.SuccessData;
|
||||||
|
import com.vs.ox.common.utils.ObjectMapperFactory;
|
||||||
|
|
||||||
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.InitializingBean;
|
||||||
|
import org.springframework.core.MethodParameter;
|
||||||
|
import org.springframework.http.MediaType;
|
||||||
|
import org.springframework.http.converter.HttpMessageConverter;
|
||||||
|
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
|
||||||
|
import org.springframework.http.server.ServletServerHttpResponse;
|
||||||
|
import org.springframework.web.context.request.NativeWebRequest;
|
||||||
|
import org.springframework.web.method.support.HandlerMethodReturnValueHandler;
|
||||||
|
import org.springframework.web.method.support.ModelAndViewContainer;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
|
||||||
|
/** 处理 Controller 里的返回值,从 Object转为Json */
|
||||||
|
public class ResponseJsonMethodReturnValueHandler
|
||||||
|
implements HandlerMethodReturnValueHandler, InitializingBean {
|
||||||
|
private HttpMessageConverter messageConverter;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void afterPropertiesSet() {
|
||||||
|
if (messageConverter == null) {
|
||||||
|
messageConverter =
|
||||||
|
new MappingJackson2HttpMessageConverter(
|
||||||
|
ObjectMapperFactory.getDefaultObjectMapper());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean supportsReturnType(MethodParameter returnType) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handleReturnValue(
|
||||||
|
Object returnValue,
|
||||||
|
MethodParameter returnType,
|
||||||
|
ModelAndViewContainer mavContainer,
|
||||||
|
NativeWebRequest webRequest)
|
||||||
|
throws Exception {
|
||||||
|
mavContainer.setRequestHandled(true);
|
||||||
|
Object result = returnValue;
|
||||||
|
/** Web分页请求的返回按照antd框架要求的格式,不转为SuccessData */
|
||||||
|
result =
|
||||||
|
result == null
|
||||||
|
? new SuccessData(Collections.emptyMap())
|
||||||
|
: new SuccessData(returnValue);
|
||||||
|
ServletServerHttpResponse response =
|
||||||
|
new ServletServerHttpResponse(
|
||||||
|
webRequest.getNativeResponse(HttpServletResponse.class));
|
||||||
|
messageConverter.write(
|
||||||
|
result,
|
||||||
|
new MediaType(
|
||||||
|
MediaType.APPLICATION_JSON, Collections.singletonMap("charset", "utf-8")),
|
||||||
|
response);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,104 @@
|
|||||||
|
package {{ .package }}.common.response;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
|
||||||
|
import org.springframework.beans.BeansException;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.context.ApplicationContext;
|
||||||
|
import org.springframework.context.ApplicationContextAware;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.ComponentScan;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder;
|
||||||
|
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
|
||||||
|
import org.springframework.web.method.annotation.MapMethodProcessor;
|
||||||
|
import org.springframework.web.method.support.HandlerMethodReturnValueHandler;
|
||||||
|
import org.springframework.web.servlet.HandlerExceptionResolver;
|
||||||
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||||
|
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter;
|
||||||
|
import org.springframework.web.servlet.mvc.method.annotation.ViewNameMethodReturnValueHandler;
|
||||||
|
|
||||||
|
import java.text.DateFormat;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
@ComponentScan("com.vs.ox")
|
||||||
|
public class WebMvcConfiguration implements WebMvcConfigurer, ApplicationContextAware {
|
||||||
|
private RequestMappingHandlerAdapter requestMappingHandlerAdapter;
|
||||||
|
private ApplicationContext applicationContext;
|
||||||
|
|
||||||
|
// 删除 init 方法,在 setRequestMappingHandlerAdapter 中调用
|
||||||
|
private void init() {
|
||||||
|
List<HandlerMethodReturnValueHandler> returnValueHandlers =
|
||||||
|
this.requestMappingHandlerAdapter.getReturnValueHandlers();
|
||||||
|
if (returnValueHandlers == null) {
|
||||||
|
return; // 避免空指针异常
|
||||||
|
}
|
||||||
|
Iterator<HandlerMethodReturnValueHandler> iterator = returnValueHandlers.iterator();
|
||||||
|
List<HandlerMethodReturnValueHandler> newProcessors = new ArrayList<>();
|
||||||
|
while (iterator.hasNext()) {
|
||||||
|
HandlerMethodReturnValueHandler next = iterator.next();
|
||||||
|
// 为了能在controller中直接返回map,不被默认的MapMethodProcessor拦截
|
||||||
|
if (next instanceof MapMethodProcessor
|
||||||
|
||
|
||||||
|
// 为了能在controller中直接返回String,不被默认的ViewNameMethodReturnValueHandler拦截
|
||||||
|
next instanceof ViewNameMethodReturnValueHandler) {
|
||||||
|
continue;
|
||||||
|
} else {
|
||||||
|
newProcessors.add(next);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.requestMappingHandlerAdapter.setReturnValueHandlers(newProcessors);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 使用 configureHandlerExceptionResolvers 方法
|
||||||
|
@Override
|
||||||
|
public void configureHandlerExceptionResolvers(
|
||||||
|
List<HandlerExceptionResolver> exceptionResolvers) {
|
||||||
|
ResponseJsonExceptionResolver responseJsonExceptionResolver =
|
||||||
|
new ResponseJsonExceptionResolver();
|
||||||
|
try {
|
||||||
|
responseJsonExceptionResolver.afterPropertiesSet();
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
exceptionResolvers.add(responseJsonExceptionResolver);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 使用 addReturnValueHandlers 方法
|
||||||
|
@Override
|
||||||
|
public void addReturnValueHandlers(List<HandlerMethodReturnValueHandler> returnValueHandlers) {
|
||||||
|
ResponseJsonMethodReturnValueHandler responseJsonMethodReturnValueHandler =
|
||||||
|
new ResponseJsonMethodReturnValueHandler();
|
||||||
|
responseJsonMethodReturnValueHandler.afterPropertiesSet();
|
||||||
|
returnValueHandlers.add(responseJsonMethodReturnValueHandler);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
|
||||||
|
this.applicationContext = applicationContext;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Autowired private Jackson2ObjectMapperBuilder jackson2ObjectMapperBuilder;
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public MappingJackson2HttpMessageConverter mappingJackson2HttpMessageConverter() {
|
||||||
|
ObjectMapper mapper = jackson2ObjectMapperBuilder.build();
|
||||||
|
DateFormat dateFormat = mapper.getDateFormat();
|
||||||
|
mapper.setDateFormat(new MyDateFormat(dateFormat));
|
||||||
|
MappingJackson2HttpMessageConverter mappingJsonpHttpMessageConverter =
|
||||||
|
new MappingJackson2HttpMessageConverter(mapper);
|
||||||
|
return mappingJsonpHttpMessageConverter;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 删除 ServletContextListener,使用 ApplicationListener 或 BeanPostProcessor
|
||||||
|
// 或者直接注入 RequestMappingHandlerAdapter
|
||||||
|
@Autowired
|
||||||
|
public void setRequestMappingHandlerAdapter(
|
||||||
|
RequestMappingHandlerAdapter requestMappingHandlerAdapter) {
|
||||||
|
this.requestMappingHandlerAdapter = requestMappingHandlerAdapter;
|
||||||
|
init(); // 在这里调用 init 方法
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
package {{ .package }}.common.rocketmq;
|
||||||
|
|
||||||
|
import org.apache.rocketmq.client.consumer.DefaultMQPushConsumer;
|
||||||
|
|
||||||
|
public interface RocketMQService {
|
||||||
|
DefaultMQPushConsumer getConsumer(String consumerGroup);
|
||||||
|
}
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
package {{ .package }}.common.rocketmq;
|
||||||
|
|
||||||
|
import lombok.Synchronized;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.rocketmq.client.consumer.DefaultMQPushConsumer;
|
||||||
|
import org.apache.rocketmq.client.exception.MQClientException;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
public class RocketMQServiceImpl implements RocketMQService {
|
||||||
|
private String serverAddr = null;
|
||||||
|
|
||||||
|
public RocketMQServiceImpl(String serverAddr) {
|
||||||
|
this.serverAddr = serverAddr;
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, DefaultMQPushConsumer> consumerMap = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Synchronized
|
||||||
|
public DefaultMQPushConsumer getConsumer(String consumerGroup) {
|
||||||
|
DefaultMQPushConsumer defaultMQPushConsumer = consumerMap.get(consumerGroup);
|
||||||
|
if (defaultMQPushConsumer != null) {
|
||||||
|
return defaultMQPushConsumer;
|
||||||
|
}
|
||||||
|
DefaultMQPushConsumer instance = new DefaultMQPushConsumer(consumerGroup);
|
||||||
|
instance.setNamesrvAddr(this.serverAddr);
|
||||||
|
this.consumerMap.put(consumerGroup, instance);
|
||||||
|
return instance;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
> 本模块存放公共工具类
|
||||||
|
``` \-- *Util.java
|
||||||
|
```
|
||||||
1
template/modules/.gitkeep
Normal file
1
template/modules/.gitkeep
Normal file
@@ -0,0 +1 @@
|
|||||||
|
|
||||||
308
template/mvnw
vendored
Executable file
308
template/mvnw
vendored
Executable file
@@ -0,0 +1,308 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# ----------------------------------------------------------------------------
|
||||||
|
# Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
# or more contributor license agreements. See the NOTICE file
|
||||||
|
# distributed with this work for additional information
|
||||||
|
# regarding copyright ownership. The ASF licenses this file
|
||||||
|
# to you under the Apache License, Version 2.0 (the
|
||||||
|
# "License"); you may not use this file except in compliance
|
||||||
|
# with the License. You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing,
|
||||||
|
# software distributed under the License is distributed on an
|
||||||
|
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
# KIND, either express or implied. See the License for the
|
||||||
|
# specific language governing permissions and limitations
|
||||||
|
# under the License.
|
||||||
|
# ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
# ----------------------------------------------------------------------------
|
||||||
|
# Apache Maven Wrapper startup batch script, version 3.2.0
|
||||||
|
#
|
||||||
|
# Required ENV vars:
|
||||||
|
# ------------------
|
||||||
|
# JAVA_HOME - location of a JDK home dir
|
||||||
|
#
|
||||||
|
# Optional ENV vars
|
||||||
|
# -----------------
|
||||||
|
# MAVEN_OPTS - parameters passed to the Java VM when running Maven
|
||||||
|
# e.g. to debug Maven itself, use
|
||||||
|
# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
|
||||||
|
# MAVEN_SKIP_RC - flag to disable loading of mavenrc files
|
||||||
|
# ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
if [ -z "$MAVEN_SKIP_RC" ] ; then
|
||||||
|
|
||||||
|
if [ -f /usr/local/etc/mavenrc ] ; then
|
||||||
|
. /usr/local/etc/mavenrc
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -f /etc/mavenrc ] ; then
|
||||||
|
. /etc/mavenrc
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -f "$HOME/.mavenrc" ] ; then
|
||||||
|
. "$HOME/.mavenrc"
|
||||||
|
fi
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
|
# OS specific support. $var _must_ be set to either true or false.
|
||||||
|
cygwin=false;
|
||||||
|
darwin=false;
|
||||||
|
mingw=false
|
||||||
|
case "$(uname)" in
|
||||||
|
CYGWIN*) cygwin=true ;;
|
||||||
|
MINGW*) mingw=true;;
|
||||||
|
Darwin*) darwin=true
|
||||||
|
# Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home
|
||||||
|
# See https://developer.apple.com/library/mac/qa/qa1170/_index.html
|
||||||
|
if [ -z "$JAVA_HOME" ]; then
|
||||||
|
if [ -x "/usr/libexec/java_home" ]; then
|
||||||
|
JAVA_HOME="$(/usr/libexec/java_home)"; export JAVA_HOME
|
||||||
|
else
|
||||||
|
JAVA_HOME="/Library/Java/Home"; export JAVA_HOME
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
if [ -z "$JAVA_HOME" ] ; then
|
||||||
|
if [ -r /etc/gentoo-release ] ; then
|
||||||
|
JAVA_HOME=$(java-config --jre-home)
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# For Cygwin, ensure paths are in UNIX format before anything is touched
|
||||||
|
if $cygwin ; then
|
||||||
|
[ -n "$JAVA_HOME" ] &&
|
||||||
|
JAVA_HOME=$(cygpath --unix "$JAVA_HOME")
|
||||||
|
[ -n "$CLASSPATH" ] &&
|
||||||
|
CLASSPATH=$(cygpath --path --unix "$CLASSPATH")
|
||||||
|
fi
|
||||||
|
|
||||||
|
# For Mingw, ensure paths are in UNIX format before anything is touched
|
||||||
|
if $mingw ; then
|
||||||
|
[ -n "$JAVA_HOME" ] && [ -d "$JAVA_HOME" ] &&
|
||||||
|
JAVA_HOME="$(cd "$JAVA_HOME" || (echo "cannot cd into $JAVA_HOME."; exit 1); pwd)"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "$JAVA_HOME" ]; then
|
||||||
|
javaExecutable="$(which javac)"
|
||||||
|
if [ -n "$javaExecutable" ] && ! [ "$(expr "\"$javaExecutable\"" : '\([^ ]*\)')" = "no" ]; then
|
||||||
|
# readlink(1) is not available as standard on Solaris 10.
|
||||||
|
readLink=$(which readlink)
|
||||||
|
if [ ! "$(expr "$readLink" : '\([^ ]*\)')" = "no" ]; then
|
||||||
|
if $darwin ; then
|
||||||
|
javaHome="$(dirname "\"$javaExecutable\"")"
|
||||||
|
javaExecutable="$(cd "\"$javaHome\"" && pwd -P)/javac"
|
||||||
|
else
|
||||||
|
javaExecutable="$(readlink -f "\"$javaExecutable\"")"
|
||||||
|
fi
|
||||||
|
javaHome="$(dirname "\"$javaExecutable\"")"
|
||||||
|
javaHome=$(expr "$javaHome" : '\(.*\)/bin')
|
||||||
|
JAVA_HOME="$javaHome"
|
||||||
|
export JAVA_HOME
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "$JAVACMD" ] ; then
|
||||||
|
if [ -n "$JAVA_HOME" ] ; then
|
||||||
|
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||||
|
# IBM's JDK on AIX uses strange locations for the executables
|
||||||
|
JAVACMD="$JAVA_HOME/jre/sh/java"
|
||||||
|
else
|
||||||
|
JAVACMD="$JAVA_HOME/bin/java"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
JAVACMD="$(\unset -f command 2>/dev/null; \command -v java)"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -x "$JAVACMD" ] ; then
|
||||||
|
echo "Error: JAVA_HOME is not defined correctly." >&2
|
||||||
|
echo " We cannot execute $JAVACMD" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "$JAVA_HOME" ] ; then
|
||||||
|
echo "Warning: JAVA_HOME environment variable is not set."
|
||||||
|
fi
|
||||||
|
|
||||||
|
# traverses directory structure from process work directory to filesystem root
|
||||||
|
# first directory with .mvn subdirectory is considered project base directory
|
||||||
|
find_maven_basedir() {
|
||||||
|
if [ -z "$1" ]
|
||||||
|
then
|
||||||
|
echo "Path not specified to find_maven_basedir"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
basedir="$1"
|
||||||
|
wdir="$1"
|
||||||
|
while [ "$wdir" != '/' ] ; do
|
||||||
|
if [ -d "$wdir"/.mvn ] ; then
|
||||||
|
basedir=$wdir
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
# workaround for JBEAP-8937 (on Solaris 10/Sparc)
|
||||||
|
if [ -d "${wdir}" ]; then
|
||||||
|
wdir=$(cd "$wdir/.." || exit 1; pwd)
|
||||||
|
fi
|
||||||
|
# end of workaround
|
||||||
|
done
|
||||||
|
printf '%s' "$(cd "$basedir" || exit 1; pwd)"
|
||||||
|
}
|
||||||
|
|
||||||
|
# concatenates all lines of a file
|
||||||
|
concat_lines() {
|
||||||
|
if [ -f "$1" ]; then
|
||||||
|
# Remove \r in case we run on Windows within Git Bash
|
||||||
|
# and check out the repository with auto CRLF management
|
||||||
|
# enabled. Otherwise, we may read lines that are delimited with
|
||||||
|
# \r\n and produce $'-Xarg\r' rather than -Xarg due to word
|
||||||
|
# splitting rules.
|
||||||
|
tr -s '\r\n' ' ' < "$1"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
log() {
|
||||||
|
if [ "$MVNW_VERBOSE" = true ]; then
|
||||||
|
printf '%s\n' "$1"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
BASE_DIR=$(find_maven_basedir "$(dirname "$0")")
|
||||||
|
if [ -z "$BASE_DIR" ]; then
|
||||||
|
exit 1;
|
||||||
|
fi
|
||||||
|
|
||||||
|
MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"}; export MAVEN_PROJECTBASEDIR
|
||||||
|
log "$MAVEN_PROJECTBASEDIR"
|
||||||
|
|
||||||
|
##########################################################################################
|
||||||
|
# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
|
||||||
|
# This allows using the maven wrapper in projects that prohibit checking in binary data.
|
||||||
|
##########################################################################################
|
||||||
|
wrapperJarPath="$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar"
|
||||||
|
if [ -r "$wrapperJarPath" ]; then
|
||||||
|
log "Found $wrapperJarPath"
|
||||||
|
else
|
||||||
|
log "Couldn't find $wrapperJarPath, downloading it ..."
|
||||||
|
|
||||||
|
if [ -n "$MVNW_REPOURL" ]; then
|
||||||
|
wrapperUrl="$MVNW_REPOURL/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar"
|
||||||
|
else
|
||||||
|
wrapperUrl="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar"
|
||||||
|
fi
|
||||||
|
while IFS="=" read -r key value; do
|
||||||
|
# Remove '\r' from value to allow usage on windows as IFS does not consider '\r' as a separator ( considers space, tab, new line ('\n'), and custom '=' )
|
||||||
|
safeValue=$(echo "$value" | tr -d '\r')
|
||||||
|
case "$key" in (wrapperUrl) wrapperUrl="$safeValue"; break ;;
|
||||||
|
esac
|
||||||
|
done < "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.properties"
|
||||||
|
log "Downloading from: $wrapperUrl"
|
||||||
|
|
||||||
|
if $cygwin; then
|
||||||
|
wrapperJarPath=$(cygpath --path --windows "$wrapperJarPath")
|
||||||
|
fi
|
||||||
|
|
||||||
|
if command -v wget > /dev/null; then
|
||||||
|
log "Found wget ... using wget"
|
||||||
|
[ "$MVNW_VERBOSE" = true ] && QUIET="" || QUIET="--quiet"
|
||||||
|
if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then
|
||||||
|
wget $QUIET "$wrapperUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath"
|
||||||
|
else
|
||||||
|
wget $QUIET --http-user="$MVNW_USERNAME" --http-password="$MVNW_PASSWORD" "$wrapperUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath"
|
||||||
|
fi
|
||||||
|
elif command -v curl > /dev/null; then
|
||||||
|
log "Found curl ... using curl"
|
||||||
|
[ "$MVNW_VERBOSE" = true ] && QUIET="" || QUIET="--silent"
|
||||||
|
if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then
|
||||||
|
curl $QUIET -o "$wrapperJarPath" "$wrapperUrl" -f -L || rm -f "$wrapperJarPath"
|
||||||
|
else
|
||||||
|
curl $QUIET --user "$MVNW_USERNAME:$MVNW_PASSWORD" -o "$wrapperJarPath" "$wrapperUrl" -f -L || rm -f "$wrapperJarPath"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
log "Falling back to using Java to download"
|
||||||
|
javaSource="$MAVEN_PROJECTBASEDIR/.mvn/wrapper/MavenWrapperDownloader.java"
|
||||||
|
javaClass="$MAVEN_PROJECTBASEDIR/.mvn/wrapper/MavenWrapperDownloader.class"
|
||||||
|
# For Cygwin, switch paths to Windows format before running javac
|
||||||
|
if $cygwin; then
|
||||||
|
javaSource=$(cygpath --path --windows "$javaSource")
|
||||||
|
javaClass=$(cygpath --path --windows "$javaClass")
|
||||||
|
fi
|
||||||
|
if [ -e "$javaSource" ]; then
|
||||||
|
if [ ! -e "$javaClass" ]; then
|
||||||
|
log " - Compiling MavenWrapperDownloader.java ..."
|
||||||
|
("$JAVA_HOME/bin/javac" "$javaSource")
|
||||||
|
fi
|
||||||
|
if [ -e "$javaClass" ]; then
|
||||||
|
log " - Running MavenWrapperDownloader.java ..."
|
||||||
|
("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$wrapperUrl" "$wrapperJarPath") || rm -f "$wrapperJarPath"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
##########################################################################################
|
||||||
|
# End of extension
|
||||||
|
##########################################################################################
|
||||||
|
|
||||||
|
# If specified, validate the SHA-256 sum of the Maven wrapper jar file
|
||||||
|
wrapperSha256Sum=""
|
||||||
|
while IFS="=" read -r key value; do
|
||||||
|
case "$key" in (wrapperSha256Sum) wrapperSha256Sum=$value; break ;;
|
||||||
|
esac
|
||||||
|
done < "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.properties"
|
||||||
|
if [ -n "$wrapperSha256Sum" ]; then
|
||||||
|
wrapperSha256Result=false
|
||||||
|
if command -v sha256sum > /dev/null; then
|
||||||
|
if echo "$wrapperSha256Sum $wrapperJarPath" | sha256sum -c > /dev/null 2>&1; then
|
||||||
|
wrapperSha256Result=true
|
||||||
|
fi
|
||||||
|
elif command -v shasum > /dev/null; then
|
||||||
|
if echo "$wrapperSha256Sum $wrapperJarPath" | shasum -a 256 -c > /dev/null 2>&1; then
|
||||||
|
wrapperSha256Result=true
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "Checksum validation was requested but neither 'sha256sum' or 'shasum' are available."
|
||||||
|
echo "Please install either command, or disable validation by removing 'wrapperSha256Sum' from your maven-wrapper.properties."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if [ $wrapperSha256Result = false ]; then
|
||||||
|
echo "Error: Failed to validate Maven wrapper SHA-256, your Maven wrapper might be compromised." >&2
|
||||||
|
echo "Investigate or delete $wrapperJarPath to attempt a clean download." >&2
|
||||||
|
echo "If you updated your Maven version, you need to update the specified wrapperSha256Sum property." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS"
|
||||||
|
|
||||||
|
# For Cygwin, switch paths to Windows format before running java
|
||||||
|
if $cygwin; then
|
||||||
|
[ -n "$JAVA_HOME" ] &&
|
||||||
|
JAVA_HOME=$(cygpath --path --windows "$JAVA_HOME")
|
||||||
|
[ -n "$CLASSPATH" ] &&
|
||||||
|
CLASSPATH=$(cygpath --path --windows "$CLASSPATH")
|
||||||
|
[ -n "$MAVEN_PROJECTBASEDIR" ] &&
|
||||||
|
MAVEN_PROJECTBASEDIR=$(cygpath --path --windows "$MAVEN_PROJECTBASEDIR")
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Provide a "standardized" way to retrieve the CLI args that will
|
||||||
|
# work with both Windows and non-Windows executions.
|
||||||
|
MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $*"
|
||||||
|
export MAVEN_CMD_LINE_ARGS
|
||||||
|
|
||||||
|
WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
|
||||||
|
|
||||||
|
# shellcheck disable=SC2086 # safe args
|
||||||
|
exec "$JAVACMD" \
|
||||||
|
$MAVEN_OPTS \
|
||||||
|
$MAVEN_DEBUG_OPTS \
|
||||||
|
-classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \
|
||||||
|
"-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
|
||||||
|
${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@"
|
||||||
205
template/mvnw.cmd
vendored
Executable file
205
template/mvnw.cmd
vendored
Executable file
@@ -0,0 +1,205 @@
|
|||||||
|
@REM ----------------------------------------------------------------------------
|
||||||
|
@REM Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
@REM or more contributor license agreements. See the NOTICE file
|
||||||
|
@REM distributed with this work for additional information
|
||||||
|
@REM regarding copyright ownership. The ASF licenses this file
|
||||||
|
@REM to you under the Apache License, Version 2.0 (the
|
||||||
|
@REM "License"); you may not use this file except in compliance
|
||||||
|
@REM with the License. You may obtain a copy of the License at
|
||||||
|
@REM
|
||||||
|
@REM http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
@REM
|
||||||
|
@REM Unless required by applicable law or agreed to in writing,
|
||||||
|
@REM software distributed under the License is distributed on an
|
||||||
|
@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
@REM KIND, either express or implied. See the License for the
|
||||||
|
@REM specific language governing permissions and limitations
|
||||||
|
@REM under the License.
|
||||||
|
@REM ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
@REM ----------------------------------------------------------------------------
|
||||||
|
@REM Apache Maven Wrapper startup batch script, version 3.2.0
|
||||||
|
@REM
|
||||||
|
@REM Required ENV vars:
|
||||||
|
@REM JAVA_HOME - location of a JDK home dir
|
||||||
|
@REM
|
||||||
|
@REM Optional ENV vars
|
||||||
|
@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands
|
||||||
|
@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending
|
||||||
|
@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven
|
||||||
|
@REM e.g. to debug Maven itself, use
|
||||||
|
@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
|
||||||
|
@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files
|
||||||
|
@REM ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
|
||||||
|
@echo off
|
||||||
|
@REM set title of command window
|
||||||
|
title %0
|
||||||
|
@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on'
|
||||||
|
@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO%
|
||||||
|
|
||||||
|
@REM set %HOME% to equivalent of $HOME
|
||||||
|
if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")
|
||||||
|
|
||||||
|
@REM Execute a user defined script before this one
|
||||||
|
if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre
|
||||||
|
@REM check for pre script, once with legacy .bat ending and once with .cmd ending
|
||||||
|
if exist "%USERPROFILE%\mavenrc_pre.bat" call "%USERPROFILE%\mavenrc_pre.bat" %*
|
||||||
|
if exist "%USERPROFILE%\mavenrc_pre.cmd" call "%USERPROFILE%\mavenrc_pre.cmd" %*
|
||||||
|
:skipRcPre
|
||||||
|
|
||||||
|
@setlocal
|
||||||
|
|
||||||
|
set ERROR_CODE=0
|
||||||
|
|
||||||
|
@REM To isolate internal variables from possible post scripts, we use another setlocal
|
||||||
|
@setlocal
|
||||||
|
|
||||||
|
@REM ==== START VALIDATION ====
|
||||||
|
if not "%JAVA_HOME%" == "" goto OkJHome
|
||||||
|
|
||||||
|
echo.
|
||||||
|
echo Error: JAVA_HOME not found in your environment. >&2
|
||||||
|
echo Please set the JAVA_HOME variable in your environment to match the >&2
|
||||||
|
echo location of your Java installation. >&2
|
||||||
|
echo.
|
||||||
|
goto error
|
||||||
|
|
||||||
|
:OkJHome
|
||||||
|
if exist "%JAVA_HOME%\bin\java.exe" goto init
|
||||||
|
|
||||||
|
echo.
|
||||||
|
echo Error: JAVA_HOME is set to an invalid directory. >&2
|
||||||
|
echo JAVA_HOME = "%JAVA_HOME%" >&2
|
||||||
|
echo Please set the JAVA_HOME variable in your environment to match the >&2
|
||||||
|
echo location of your Java installation. >&2
|
||||||
|
echo.
|
||||||
|
goto error
|
||||||
|
|
||||||
|
@REM ==== END VALIDATION ====
|
||||||
|
|
||||||
|
:init
|
||||||
|
|
||||||
|
@REM Find the project base dir, i.e. the directory that contains the folder ".mvn".
|
||||||
|
@REM Fallback to current working directory if not found.
|
||||||
|
|
||||||
|
set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR%
|
||||||
|
IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir
|
||||||
|
|
||||||
|
set EXEC_DIR=%CD%
|
||||||
|
set WDIR=%EXEC_DIR%
|
||||||
|
:findBaseDir
|
||||||
|
IF EXIST "%WDIR%"\.mvn goto baseDirFound
|
||||||
|
cd ..
|
||||||
|
IF "%WDIR%"=="%CD%" goto baseDirNotFound
|
||||||
|
set WDIR=%CD%
|
||||||
|
goto findBaseDir
|
||||||
|
|
||||||
|
:baseDirFound
|
||||||
|
set MAVEN_PROJECTBASEDIR=%WDIR%
|
||||||
|
cd "%EXEC_DIR%"
|
||||||
|
goto endDetectBaseDir
|
||||||
|
|
||||||
|
:baseDirNotFound
|
||||||
|
set MAVEN_PROJECTBASEDIR=%EXEC_DIR%
|
||||||
|
cd "%EXEC_DIR%"
|
||||||
|
|
||||||
|
:endDetectBaseDir
|
||||||
|
|
||||||
|
IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig
|
||||||
|
|
||||||
|
@setlocal EnableExtensions EnableDelayedExpansion
|
||||||
|
for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a
|
||||||
|
@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS%
|
||||||
|
|
||||||
|
:endReadAdditionalConfig
|
||||||
|
|
||||||
|
SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
|
||||||
|
set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar"
|
||||||
|
set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
|
||||||
|
|
||||||
|
set WRAPPER_URL="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar"
|
||||||
|
|
||||||
|
FOR /F "usebackq tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO (
|
||||||
|
IF "%%A"=="wrapperUrl" SET WRAPPER_URL=%%B
|
||||||
|
)
|
||||||
|
|
||||||
|
@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
|
||||||
|
@REM This allows using the maven wrapper in projects that prohibit checking in binary data.
|
||||||
|
if exist %WRAPPER_JAR% (
|
||||||
|
if "%MVNW_VERBOSE%" == "true" (
|
||||||
|
echo Found %WRAPPER_JAR%
|
||||||
|
)
|
||||||
|
) else (
|
||||||
|
if not "%MVNW_REPOURL%" == "" (
|
||||||
|
SET WRAPPER_URL="%MVNW_REPOURL%/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar"
|
||||||
|
)
|
||||||
|
if "%MVNW_VERBOSE%" == "true" (
|
||||||
|
echo Couldn't find %WRAPPER_JAR%, downloading it ...
|
||||||
|
echo Downloading from: %WRAPPER_URL%
|
||||||
|
)
|
||||||
|
|
||||||
|
powershell -Command "&{"^
|
||||||
|
"$webclient = new-object System.Net.WebClient;"^
|
||||||
|
"if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^
|
||||||
|
"$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^
|
||||||
|
"}"^
|
||||||
|
"[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%WRAPPER_URL%', '%WRAPPER_JAR%')"^
|
||||||
|
"}"
|
||||||
|
if "%MVNW_VERBOSE%" == "true" (
|
||||||
|
echo Finished downloading %WRAPPER_JAR%
|
||||||
|
)
|
||||||
|
)
|
||||||
|
@REM End of extension
|
||||||
|
|
||||||
|
@REM If specified, validate the SHA-256 sum of the Maven wrapper jar file
|
||||||
|
SET WRAPPER_SHA_256_SUM=""
|
||||||
|
FOR /F "usebackq tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO (
|
||||||
|
IF "%%A"=="wrapperSha256Sum" SET WRAPPER_SHA_256_SUM=%%B
|
||||||
|
)
|
||||||
|
IF NOT %WRAPPER_SHA_256_SUM%=="" (
|
||||||
|
powershell -Command "&{"^
|
||||||
|
"$hash = (Get-FileHash \"%WRAPPER_JAR%\" -Algorithm SHA256).Hash.ToLower();"^
|
||||||
|
"If('%WRAPPER_SHA_256_SUM%' -ne $hash){"^
|
||||||
|
" Write-Output 'Error: Failed to validate Maven wrapper SHA-256, your Maven wrapper might be compromised.';"^
|
||||||
|
" Write-Output 'Investigate or delete %WRAPPER_JAR% to attempt a clean download.';"^
|
||||||
|
" Write-Output 'If you updated your Maven version, you need to update the specified wrapperSha256Sum property.';"^
|
||||||
|
" exit 1;"^
|
||||||
|
"}"^
|
||||||
|
"}"
|
||||||
|
if ERRORLEVEL 1 goto error
|
||||||
|
)
|
||||||
|
|
||||||
|
@REM Provide a "standardized" way to retrieve the CLI args that will
|
||||||
|
@REM work with both Windows and non-Windows executions.
|
||||||
|
set MAVEN_CMD_LINE_ARGS=%*
|
||||||
|
|
||||||
|
%MAVEN_JAVA_EXE% ^
|
||||||
|
%JVM_CONFIG_MAVEN_PROPS% ^
|
||||||
|
%MAVEN_OPTS% ^
|
||||||
|
%MAVEN_DEBUG_OPTS% ^
|
||||||
|
-classpath %WRAPPER_JAR% ^
|
||||||
|
"-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" ^
|
||||||
|
%WRAPPER_LAUNCHER% %MAVEN_CONFIG% %*
|
||||||
|
if ERRORLEVEL 1 goto error
|
||||||
|
goto end
|
||||||
|
|
||||||
|
:error
|
||||||
|
set ERROR_CODE=1
|
||||||
|
|
||||||
|
:end
|
||||||
|
@endlocal & set ERROR_CODE=%ERROR_CODE%
|
||||||
|
|
||||||
|
if not "%MAVEN_SKIP_RC%"=="" goto skipRcPost
|
||||||
|
@REM check for post script, once with legacy .bat ending and once with .cmd ending
|
||||||
|
if exist "%USERPROFILE%\mavenrc_post.bat" call "%USERPROFILE%\mavenrc_post.bat"
|
||||||
|
if exist "%USERPROFILE%\mavenrc_post.cmd" call "%USERPROFILE%\mavenrc_post.cmd"
|
||||||
|
:skipRcPost
|
||||||
|
|
||||||
|
@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on'
|
||||||
|
if "%MAVEN_BATCH_PAUSE%"=="on" pause
|
||||||
|
|
||||||
|
if "%MAVEN_TERMINATE_CMD%"=="on" exit %ERROR_CODE%
|
||||||
|
|
||||||
|
cmd /C exit /B %ERROR_CODE%
|
||||||
130
template/odin-web/.flattened-pom.xml
Normal file
130
template/odin-web/.flattened-pom.xml
Normal file
@@ -0,0 +1,130 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<parent>
|
||||||
|
<groupId>com.insigma_oracle</groupId>
|
||||||
|
<artifactId>insigma_oracle</artifactId>
|
||||||
|
<version>4.1.0-SNAPSHOT</version>
|
||||||
|
</parent>
|
||||||
|
<groupId>com.insigma_oracle</groupId>
|
||||||
|
<artifactId>odin-web</artifactId>
|
||||||
|
<version>4.1.0-SNAPSHOT</version>
|
||||||
|
<licenses>
|
||||||
|
<license>
|
||||||
|
<name>odin-base</name>
|
||||||
|
</license>
|
||||||
|
</licenses>
|
||||||
|
<properties>
|
||||||
|
<maven.compiler.target>17</maven.compiler.target>
|
||||||
|
<odin-est.version>2.0.0</odin-est.version>
|
||||||
|
<maven.compiler.source>17</maven.compiler.source>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
</properties>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.insigma</groupId>
|
||||||
|
<artifactId>odin-core</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.insigma</groupId>
|
||||||
|
<artifactId>odin-security-web</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.insigma</groupId>
|
||||||
|
<artifactId>odin-security-firewall</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.insigma</groupId>
|
||||||
|
<artifactId>odin-security-jasypt</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.insigma</groupId>
|
||||||
|
<artifactId>odin-file-storage-mongo</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.insigma</groupId>
|
||||||
|
<artifactId>odin-scheduler-quartz</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.insigma</groupId>
|
||||||
|
<artifactId>odin-redis-session</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.insigma</groupId>
|
||||||
|
<artifactId>odin-web-support-ep-dev</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.insigma</groupId>
|
||||||
|
<artifactId>odin-web-support-excel</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.insigma</groupId>
|
||||||
|
<artifactId>odin-web-support-module</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.insigma</groupId>
|
||||||
|
<artifactId>odin-log-core</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.insigma</groupId>
|
||||||
|
<artifactId>odin-est</artifactId>
|
||||||
|
<version>${odin-est.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba</groupId>
|
||||||
|
<artifactId>druid-spring-boot-3-starter</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.baomidou</groupId>
|
||||||
|
<artifactId>mybatis-plus-generator</artifactId>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.mysql</groupId>
|
||||||
|
<artifactId>mysql-connector-j</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.oracle</groupId>
|
||||||
|
<artifactId>ojdbc8</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.dameng</groupId>
|
||||||
|
<artifactId>DmJdbcDriver18</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-test</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.insigma_oracle</groupId>
|
||||||
|
<artifactId>account-entrance-web</artifactId>
|
||||||
|
<version>${revision}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.insigma_oracle</groupId>
|
||||||
|
<artifactId>account-entrance-rpc</artifactId>
|
||||||
|
<version>${revision}</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
<build>
|
||||||
|
<finalName>odin-web</finalName>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<goals>
|
||||||
|
<goal>repackage</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
<configuration>
|
||||||
|
<includeSystemScope>true</includeSystemScope>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</project>
|
||||||
118
template/odin-web/pom.xml
Normal file
118
template/odin-web/pom.xml
Normal file
@@ -0,0 +1,118 @@
|
|||||||
|
<?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">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<parent>
|
||||||
|
<groupId>{{.groupId}}</groupId>
|
||||||
|
<artifactId>{{.artifactId}}</artifactId>
|
||||||
|
<version>${revision}</version>
|
||||||
|
<relativePath>../pom.xml</relativePath>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<artifactId>odin-web</artifactId>
|
||||||
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<maven.compiler.source>17</maven.compiler.source>
|
||||||
|
<maven.compiler.target>17</maven.compiler.target>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
<odin-est.version>2.0.0</odin-est.version>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.insigma</groupId>
|
||||||
|
<artifactId>odin-core</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.insigma</groupId>
|
||||||
|
<artifactId>odin-security-web</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.insigma</groupId>
|
||||||
|
<artifactId>odin-security-firewall</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.insigma</groupId>
|
||||||
|
<artifactId>odin-security-jasypt</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.insigma</groupId>
|
||||||
|
<artifactId>odin-file-storage-mongo</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.insigma</groupId>
|
||||||
|
<artifactId>odin-scheduler-quartz</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.insigma</groupId>
|
||||||
|
<artifactId>odin-redis-session</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.insigma</groupId>
|
||||||
|
<artifactId>odin-web-support-ep-dev</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.insigma</groupId>
|
||||||
|
<artifactId>odin-web-support-excel</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.insigma</groupId>
|
||||||
|
<artifactId>odin-web-support-module</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.insigma</groupId>
|
||||||
|
<artifactId>odin-log-core</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.insigma</groupId>
|
||||||
|
<artifactId>odin-est</artifactId>
|
||||||
|
<version>${odin-est.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba</groupId>
|
||||||
|
<artifactId>druid-spring-boot-3-starter</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.baomidou</groupId>
|
||||||
|
<artifactId>mybatis-plus-generator</artifactId>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.oracle</groupId>
|
||||||
|
<artifactId>ojdbc8</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.dameng</groupId>
|
||||||
|
<artifactId>DmJdbcDriver18</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-test</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
|
||||||
|
<finalName>odin-web</finalName>
|
||||||
|
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<goals>
|
||||||
|
<goal>repackage</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
<configuration>
|
||||||
|
<includeSystemScope>true</includeSystemScope>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</project>
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
package com.insigma;
|
||||||
|
|
||||||
|
import com.vs.sqlmapper.spring.DataSourceConfig;
|
||||||
|
import com.vs.sqlmapper.spring.scan.VSDaoBeanScan;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import org.mybatis.spring.annotation.MapperScan;
|
||||||
|
import org.springframework.boot.SpringApplication;
|
||||||
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
import org.springframework.context.annotation.Import;
|
||||||
|
|
||||||
|
@SpringBootApplication(scanBasePackages = {"com.insigma", "com.vs","{{.groupId}}"})
|
||||||
|
@VSDaoBeanScan(basePackages = {"com.vs","{{.groupId}}"})
|
||||||
|
@Import(DataSourceConfig.class)
|
||||||
|
@MapperScan(value ={"{{.groupId}}.**.persist.mapper.mybatis","com.insigma.**.mapper","com.insigma.**.dao"})
|
||||||
|
public class OdinWebApplication {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
SpringApplication.run(OdinWebApplication.class, args);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,139 @@
|
|||||||
|
package com.insigma.business.demo.controller;
|
||||||
|
|
||||||
|
import com.insigma.business.demo.dto.DemoPersonDTO;
|
||||||
|
import com.insigma.business.demo.service.DemoPersonService;
|
||||||
|
import com.insigma.framework.core.ResponseMessage;
|
||||||
|
import com.insigma.framework.log.core.annotation.OpLog;
|
||||||
|
import com.insigma.framework.web.support.ep.dev.annotation.OdinRequest;
|
||||||
|
import com.insigma.framework.web.support.ep.dev.annotation.OdinRequestParam;
|
||||||
|
import com.insigma.framework.web.support.ep.dev.controller.BaseController;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.util.ObjectUtils;
|
||||||
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 人员增删改查demo
|
||||||
|
* <p>
|
||||||
|
* 实体类传参开发方式,需继承BaseController,并且需要实体类传参的方法上加上@OdinRequest
|
||||||
|
* 在doInit方法上需要加上注解@OdinRequest(init = true),init = true为初始化字典数据和模块信息,其他方法上只需加@OdinRequest即可,不需要参数
|
||||||
|
* 方法参数如果不指定@OdinRequestParam注解,则按照参数名去取前端传过来的数据,并将其转化成实体类
|
||||||
|
* 如果指定了@OdinRequestParam注解,并且设定了value值,则根据value值去取前端传过来的数据
|
||||||
|
* 其中@OdinRequestParam参数required默认为true,即如果找不到对应的数据,则返回错误,当设置成false,则不会
|
||||||
|
* 如果需要接收前端传过来的表格数据,则可以通过定义PageInfo<T>来接收数据
|
||||||
|
*
|
||||||
|
* @author yinjh
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/business/demo/DemoPerson")
|
||||||
|
public class DemoPersonController extends BaseController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private DemoPersonService demoPersonService;
|
||||||
|
|
||||||
|
@OdinRequest(init = true)
|
||||||
|
@PostMapping("/doInit")
|
||||||
|
public ResponseMessage doInit(DemoPersonDTO f_form, Integer t_tableData_size) {
|
||||||
|
tableDataQuery(f_form, 1, t_tableData_size);
|
||||||
|
return this.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
@OdinRequest
|
||||||
|
@PostMapping("/query")
|
||||||
|
public ResponseMessage query(@OdinRequestParam("f_form") DemoPersonDTO queryDTO,
|
||||||
|
//@OdinRequestParam("t_tableData") PageInfo<DemoPersonDTO> pageInfo, // 没用到,只作如何取表格数据的演示
|
||||||
|
Integer t_tableData_size) {
|
||||||
|
tableDataQuery(queryDTO, 1, t_tableData_size);
|
||||||
|
// this.set("page", 1); // 需要将前端表格中:currentPage定义的值设置成1
|
||||||
|
return this.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
@OdinRequest
|
||||||
|
@PostMapping("/doGridQuery/{name}")
|
||||||
|
public ResponseMessage doGridQuery(@OdinRequestParam("f_form") DemoPersonDTO queryDTO,
|
||||||
|
@OdinRequestParam("t_tableData_page") Integer page,
|
||||||
|
@OdinRequestParam("t_tableData_size") Integer size,
|
||||||
|
@PathVariable String name) {
|
||||||
|
tableDataQuery(queryDTO, page, size);
|
||||||
|
// this.set("page", page); // 需要将t_tableData_page的值赋值到前端表格:currentPage的值中
|
||||||
|
return this.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
@OdinRequest
|
||||||
|
@PostMapping("/add")
|
||||||
|
public ResponseMessage add() {
|
||||||
|
this.clearForm("f_personForm");
|
||||||
|
this.set("dialogFormVisible", true);
|
||||||
|
this.set("dialogFormTitle", "新增人员");
|
||||||
|
return this.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
@OdinRequest
|
||||||
|
@PostMapping("/update")
|
||||||
|
public ResponseMessage update(String id) {
|
||||||
|
DemoPersonDTO dto = demoPersonService.queryPerson(id);
|
||||||
|
this.toForm("f_personForm", dto);
|
||||||
|
this.set("dialogFormVisible", true);
|
||||||
|
this.set("dialogFormTitle", "修改人员");
|
||||||
|
return this.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
@OdinRequest(refresh = true)
|
||||||
|
@PostMapping("/batchDelete")
|
||||||
|
public ResponseMessage batchDelete() {
|
||||||
|
List<DemoPersonDTO> list = this.getCheckedTableData("t_tableData", DemoPersonDTO.class);
|
||||||
|
if (list.size() == 0) {
|
||||||
|
return this.error("请勾选需要删除的人员!");
|
||||||
|
}
|
||||||
|
List<String> ids = list.stream().map(o -> o.getId()).collect(Collectors.toList());
|
||||||
|
demoPersonService.deletePersons(ids);
|
||||||
|
// this.refresh();
|
||||||
|
return this.ok("删除成功!");
|
||||||
|
}
|
||||||
|
|
||||||
|
@OdinRequest(refresh = true) // refresh = true 请求结束后刷新页面
|
||||||
|
@PostMapping("/delete")
|
||||||
|
public ResponseMessage delete(String id) {
|
||||||
|
List<String> ids = Arrays.asList(id);
|
||||||
|
demoPersonService.deletePersons(ids);
|
||||||
|
// this.refresh();
|
||||||
|
return this.ok("删除成功!");
|
||||||
|
}
|
||||||
|
|
||||||
|
@OpLog
|
||||||
|
@OdinRequest(refresh = true)
|
||||||
|
@PostMapping("/doSave/{name}")
|
||||||
|
public ResponseMessage doSave(@OdinRequestParam("f_personForm") DemoPersonDTO demoPersonDTO, @PathVariable String name) {
|
||||||
|
|
||||||
|
if (ObjectUtils.isEmpty(demoPersonDTO.getId())) {
|
||||||
|
DemoPersonDTO dto = demoPersonService.selectOne(demoPersonDTO);
|
||||||
|
if (dto != null) {
|
||||||
|
return this.error("不可添加重复数据!!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
demoPersonService.savePerson(demoPersonDTO);
|
||||||
|
this.set("dialogFormVisible", false);
|
||||||
|
//this.refresh();
|
||||||
|
return this.ok("保存成功!");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void tableDataQuery(DemoPersonDTO queryDTO, Integer t_tableData_page, Integer t_tableData_size) {
|
||||||
|
this.pageQuery("t_tableData", () -> {
|
||||||
|
this.set("page", t_tableData_page); // 需要将前端表格中:currentPage定义的值设置成page的值
|
||||||
|
return demoPersonService.queryPersonListByExport(queryDTO, t_tableData_page, t_tableData_size);
|
||||||
|
}, (demoPersonDTO, checkbox) -> {
|
||||||
|
if ("1".equals(demoPersonDTO.getSex())) {
|
||||||
|
// checkbox.setDisabled(true); // 设置行复选框不可编辑
|
||||||
|
} else {
|
||||||
|
// checkbox.setChecked(true); // 设置行复选框已选中
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
package com.insigma.business.demo.dao;
|
||||||
|
|
||||||
|
import com.insigma.business.demo.entity.DemoPerson;
|
||||||
|
import com.insigma.framework.persistence.mybatis.plus.BaseDAO;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* Mapper 接口
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author yinjh
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface DemoPersonDAO extends BaseDAO<DemoPerson> {
|
||||||
|
|
||||||
|
DemoPerson selectDemoPersonById(String id);
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
package com.insigma.business.demo.dto;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson2.annotation.JSONField;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 人员信息DTO
|
||||||
|
*
|
||||||
|
* @author yinjh
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class DemoPersonDTO implements Serializable {
|
||||||
|
private Boolean checked;//用于设置复选框是否选中
|
||||||
|
|
||||||
|
private Boolean disabled;//用于设置复选框是否可编辑
|
||||||
|
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
private String sex;
|
||||||
|
|
||||||
|
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
private Date birthday;
|
||||||
|
|
||||||
|
private String mobile;
|
||||||
|
|
||||||
|
private String address;
|
||||||
|
|
||||||
|
private String startTime;
|
||||||
|
|
||||||
|
private Date create_time;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
package com.insigma.business.demo.entity;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 人员信息
|
||||||
|
*
|
||||||
|
* @author yinjh
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = false)
|
||||||
|
@Accessors(chain = true)
|
||||||
|
@TableName("DEMO_PERSON")
|
||||||
|
public class DemoPerson implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@TableId("ID")
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
@TableField("NAME")
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
@TableField("SEX")
|
||||||
|
private String sex;
|
||||||
|
|
||||||
|
@TableField("BIRTHDAY")
|
||||||
|
private Date birthday;
|
||||||
|
|
||||||
|
@TableField("MOBILE")
|
||||||
|
private String mobile;
|
||||||
|
|
||||||
|
@TableField("ADDRESS")
|
||||||
|
private String address;
|
||||||
|
|
||||||
|
@TableField("PRSENO")
|
||||||
|
private Long prseno;
|
||||||
|
|
||||||
|
@TableField("CREATE_TIME")
|
||||||
|
private Date create_time;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
package com.insigma.business.demo.service;
|
||||||
|
|
||||||
|
import com.insigma.business.demo.dto.DemoPersonDTO;
|
||||||
|
import com.insigma.framework.persistence.core.jdbc.PageInfo;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 人员管理服务接口
|
||||||
|
*
|
||||||
|
* @author yinjh
|
||||||
|
*/
|
||||||
|
public interface DemoPersonService {
|
||||||
|
|
||||||
|
DemoPersonDTO queryPerson(String id);
|
||||||
|
|
||||||
|
void deletePersons(List<String> ids);
|
||||||
|
|
||||||
|
void savePerson(DemoPersonDTO demoPersonDTO);
|
||||||
|
|
||||||
|
PageInfo<DemoPersonDTO> queryPersonList(DemoPersonDTO queryDTO, Integer page, Integer size);
|
||||||
|
|
||||||
|
DemoPersonDTO selectOne(DemoPersonDTO demoPersonDTO);
|
||||||
|
|
||||||
|
PageInfo<DemoPersonDTO> queryPersonListByExport(DemoPersonDTO queryDTO, Integer page, Integer size);
|
||||||
|
}
|
||||||
@@ -0,0 +1,152 @@
|
|||||||
|
package com.insigma.business.demo.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.insigma.business.demo.dao.DemoPersonDAO;
|
||||||
|
import com.insigma.business.demo.dto.DemoPersonDTO;
|
||||||
|
import com.insigma.business.demo.entity.DemoPerson;
|
||||||
|
import com.insigma.business.demo.service.DemoPersonService;
|
||||||
|
import com.insigma.framework.core.util.DtoEntityUtil;
|
||||||
|
import com.insigma.framework.core.util.IDUtil;
|
||||||
|
import com.insigma.framework.persistence.core.jdbc.JdbcPageHelper;
|
||||||
|
import com.insigma.framework.persistence.core.jdbc.PageInfo;
|
||||||
|
import com.insigma.framework.web.support.ep.dev.util.SysFunctionManager;
|
||||||
|
import lombok.SneakyThrows;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.jdbc.core.JdbcTemplate;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
import org.springframework.util.ObjectUtils;
|
||||||
|
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 人员管理业务实现类
|
||||||
|
*
|
||||||
|
* @author yinjh
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class DemoPersonServiceImpl implements DemoPersonService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private DemoPersonDAO demoPersonDAO;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private JdbcTemplate jdbcTemplate;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DemoPersonDTO queryPerson(String id) {
|
||||||
|
DemoPerson dp = demoPersonDAO.selectDemoPersonById(id);
|
||||||
|
// DemoPerson dp = demoPersonDAO.sqlSession().selectOne("selectDemoPersonById", id);
|
||||||
|
// DemoPerson dp = demoPersonDAO.getById(id);
|
||||||
|
DemoPersonDTO dto = DtoEntityUtil.trans(dp, DemoPersonDTO.class);
|
||||||
|
return dto;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public void deletePersons(List<String> ids) {
|
||||||
|
demoPersonDAO.deleteByIds(ids);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public void savePerson(DemoPersonDTO demoPersonDTO) {
|
||||||
|
DemoPerson dp = DtoEntityUtil.trans(demoPersonDTO, DemoPerson.class);
|
||||||
|
String id = null;
|
||||||
|
if (ObjectUtils.isEmpty(demoPersonDTO.getId())) { // 新增
|
||||||
|
id = IDUtil.generateUUID();
|
||||||
|
dp.setCreate_time(new Date());
|
||||||
|
} else {
|
||||||
|
id = demoPersonDTO.getId();
|
||||||
|
}
|
||||||
|
dp.setId(id);
|
||||||
|
demoPersonDAO.insertOrUpdate(dp);
|
||||||
|
// OpLogUtil.saveOpLog(SecurityUserUtil.getCurrentUser().getUsername(), "000000");
|
||||||
|
// demoPersonDTO = DtoEntityUtil.trans(dp, DemoPersonDTO.class);
|
||||||
|
// HUtil.insert("demo_person", JSONObject.parseObject(JSONObject.toJSONString(demoPersonDTO)), false, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@SneakyThrows
|
||||||
|
@Override
|
||||||
|
public PageInfo<DemoPersonDTO> queryPersonList(DemoPersonDTO queryDTO, Integer page, Integer size) {
|
||||||
|
//查询条件为时间段选项
|
||||||
|
SimpleDateFormat st = new SimpleDateFormat("yyyy-MM-dd");
|
||||||
|
Date oTime = null;
|
||||||
|
Date pTime = null;
|
||||||
|
if (!ObjectUtils.isEmpty(queryDTO.getStartTime())) {
|
||||||
|
oTime = st.parse(queryDTO.getStartTime().split(",")[0]);
|
||||||
|
pTime = st.parse(queryDTO.getStartTime().split(",")[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
LambdaQueryWrapper<DemoPerson> wrapper = new QueryWrapper<DemoPerson>().lambda();
|
||||||
|
wrapper.like(!ObjectUtils.isEmpty(queryDTO.getName()), DemoPerson::getName, "%" + queryDTO.getName() + "%")
|
||||||
|
.eq(!ObjectUtils.isEmpty(queryDTO.getSex()), DemoPerson::getSex, queryDTO.getSex())
|
||||||
|
.ge(!ObjectUtils.isEmpty(queryDTO.getStartTime()), DemoPerson::getBirthday, oTime)
|
||||||
|
.le(!ObjectUtils.isEmpty(queryDTO.getStartTime()), DemoPerson::getBirthday, pTime)
|
||||||
|
.orderByDesc(DemoPerson::getCreate_time);
|
||||||
|
|
||||||
|
Page<DemoPerson> dpPage = new Page<>(page, size);
|
||||||
|
|
||||||
|
IPage<DemoPerson> mapIPage = demoPersonDAO.selectPage(dpPage, wrapper);
|
||||||
|
List<DemoPerson> records = mapIPage.getRecords();
|
||||||
|
List<DemoPersonDTO> list = DtoEntityUtil.trans(records, DemoPersonDTO.class);
|
||||||
|
|
||||||
|
PageInfo<DemoPersonDTO> pageInfo = new PageInfo<>();
|
||||||
|
pageInfo.setTotal(mapIPage.getTotal());
|
||||||
|
pageInfo.setData(list);
|
||||||
|
return pageInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DemoPersonDTO selectOne(DemoPersonDTO demoPersonDTO) {
|
||||||
|
LambdaQueryWrapper<DemoPerson> wrapper = new QueryWrapper<DemoPerson>().lambda();
|
||||||
|
wrapper.eq(!ObjectUtils.isEmpty(demoPersonDTO.getName()), DemoPerson::getName, demoPersonDTO.getName())
|
||||||
|
.eq(!ObjectUtils.isEmpty(demoPersonDTO.getSex()), DemoPerson::getSex, demoPersonDTO.getSex())
|
||||||
|
.eq(!ObjectUtils.isEmpty(demoPersonDTO.getBirthday()), DemoPerson::getBirthday, demoPersonDTO.getBirthday())
|
||||||
|
.eq(!ObjectUtils.isEmpty(demoPersonDTO.getMobile()), DemoPerson::getMobile, demoPersonDTO.getAddress())
|
||||||
|
.eq(!ObjectUtils.isEmpty(demoPersonDTO.getAddress()), DemoPerson::getAddress, demoPersonDTO.getAddress());
|
||||||
|
//查询有没有相同的数据
|
||||||
|
DemoPerson demoPerson = demoPersonDAO.selectOne(wrapper);
|
||||||
|
DemoPersonDTO personDTO = DtoEntityUtil.trans(demoPerson, DemoPersonDTO.class);
|
||||||
|
return personDTO;
|
||||||
|
}
|
||||||
|
|
||||||
|
@SneakyThrows
|
||||||
|
@Override
|
||||||
|
public PageInfo<DemoPersonDTO> queryPersonListByExport(DemoPersonDTO queryDTO, Integer page, Integer size) {
|
||||||
|
Map<String, Object> params = new HashMap<>();
|
||||||
|
StringBuffer sql = new StringBuffer("select * from demo_person");
|
||||||
|
boolean hasWhere = false;
|
||||||
|
|
||||||
|
if (!ObjectUtils.isEmpty(queryDTO.getName())) {
|
||||||
|
sql.append(hasWhere ? " and" : " where").append(" name like :name");
|
||||||
|
params.put("name", "%" + queryDTO.getName() + "%");
|
||||||
|
hasWhere = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!ObjectUtils.isEmpty(queryDTO.getSex())) {
|
||||||
|
sql.append(hasWhere ? " and" : " where").append(" sex = :sex");
|
||||||
|
params.put("sex", queryDTO.getSex());
|
||||||
|
hasWhere = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!ObjectUtils.isEmpty(queryDTO.getStartTime())) {
|
||||||
|
SimpleDateFormat st = new SimpleDateFormat("yyyy-MM-dd");
|
||||||
|
Date oTime = st.parse(queryDTO.getStartTime().split(",")[0]);
|
||||||
|
Date pTime = st.parse(queryDTO.getStartTime().split(",")[1]);
|
||||||
|
sql.append(hasWhere ? " and" : " where").append(" birthday > :startTime and birthday < :endTime");
|
||||||
|
params.put("startTime", oTime);
|
||||||
|
params.put("endTime", pTime);
|
||||||
|
}
|
||||||
|
JdbcPageHelper jdbcPageHelper = new JdbcPageHelper(jdbcTemplate, page, size, "grid", SysFunctionManager.getFunctionId());
|
||||||
|
return jdbcPageHelper.queryPagination(sql.toString(), params, DemoPersonDTO.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
package com.insigma.config;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.context.annotation.Primary;
|
||||||
|
import org.springframework.http.client.ClientHttpRequestFactory;
|
||||||
|
import org.springframework.http.client.SimpleClientHttpRequestFactory;
|
||||||
|
import org.springframework.web.client.RestTemplate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* RestTemplate配置
|
||||||
|
*
|
||||||
|
* @author yinjh
|
||||||
|
*/
|
||||||
|
@Configuration
|
||||||
|
public class RestTemplateConfig {
|
||||||
|
|
||||||
|
@Value("${sys.rest-template.connect-timeout:30000}")
|
||||||
|
private int connectTimeout;
|
||||||
|
|
||||||
|
@Value("${sys.rest-template.read-timeout:30000}")
|
||||||
|
private int readTimeout;
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
@Primary
|
||||||
|
public RestTemplate restTemplate(ClientHttpRequestFactory factory){
|
||||||
|
return new RestTemplate(factory);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public ClientHttpRequestFactory simpleClientHttpRequestFactory(){
|
||||||
|
SimpleClientHttpRequestFactory factory = new SimpleClientHttpRequestFactory();
|
||||||
|
factory.setConnectTimeout(connectTimeout);
|
||||||
|
factory.setReadTimeout(readTimeout);
|
||||||
|
return factory;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,138 @@
|
|||||||
|
package com.insigma.sys.common;
|
||||||
|
|
||||||
|
import com.insigma.framework.core.exception.AppException;
|
||||||
|
import com.insigma.framework.domain.core.entity.Aa26;
|
||||||
|
import com.insigma.framework.domain.core.entity.SysOrg;
|
||||||
|
import com.insigma.framework.domain.core.entity.SysRole;
|
||||||
|
import com.insigma.framework.domain.core.entity.SysUser;
|
||||||
|
import com.insigma.sys.service.Aa26Service;
|
||||||
|
import com.insigma.sys.service.SysOrgService;
|
||||||
|
import com.insigma.sys.service.SysRoleService;
|
||||||
|
import com.insigma.sys.service.SysUserService;
|
||||||
|
import jakarta.annotation.Resource;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 统一验证器
|
||||||
|
*
|
||||||
|
* @author yinjh
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
public class CommonValidator {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private CurrentUserService currentUserService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private SysUserService sysUserService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private SysRoleService sysRoleService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private Aa26Service aa26Service;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private SysOrgService sysOrgService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 校验当前登录用户是否有相应角色的操作权限
|
||||||
|
* @param roleId 角色ID
|
||||||
|
* @return true:有权限;false:无权限
|
||||||
|
*/
|
||||||
|
public boolean validateRole(String roleId) {
|
||||||
|
SysUser sysUser = currentUserService.getCurrentUser();
|
||||||
|
SysRole sysRole = sysRoleService.getByRoleId(roleId);
|
||||||
|
if (sysRole == null) {
|
||||||
|
throw new AppException("角色不存在!");
|
||||||
|
}
|
||||||
|
if ("1".equals(sysUser.getUserType())) {
|
||||||
|
return true;
|
||||||
|
} else if ("2".equals(sysUser.getUserType())) {
|
||||||
|
return sysUser.getAreaId() != null && sysUser.getAreaId().equals(sysRole.getAreaId());
|
||||||
|
} else if ("3".equals(sysUser.getUserType())) {
|
||||||
|
return sysUser.getOrgId() != null && sysUser.getOrgId().equals(sysRole.getOrgId());
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 校验角色列表
|
||||||
|
* @param roleIds 角色ID列表
|
||||||
|
* @return true:有权限;false:无权限
|
||||||
|
*/
|
||||||
|
public boolean validateRoleIds(List<String> roleIds) {
|
||||||
|
for (String roleId : roleIds) {
|
||||||
|
if (!validateRole(roleId)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 校验当前登录用户是否有相应行政区划的操作权限
|
||||||
|
* @param areaId 区域ID
|
||||||
|
* @return true:有权限;false:无权限
|
||||||
|
*/
|
||||||
|
public boolean validateArea(String areaId, String userType) {
|
||||||
|
SysUser sysUser = currentUserService.getCurrentUser();
|
||||||
|
if ("1".equals(sysUser.getUserType()) && "1".equals(userType)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
Aa26 aa26 = aa26Service.getByAab301(areaId);
|
||||||
|
if (aa26 == null) {
|
||||||
|
throw new AppException("行政区划不存在!");
|
||||||
|
}
|
||||||
|
if ("1".equals(sysUser.getUserType())) {
|
||||||
|
return true;
|
||||||
|
} else if ("2".equals(sysUser.getUserType())) {
|
||||||
|
List<Aa26> list = aa26Service.getByAab301AndIdPath(sysUser.getAreaId() + "", aa26.getIdPath());
|
||||||
|
return !list.isEmpty();
|
||||||
|
} else if ("3".equals(sysUser.getUserType())) {
|
||||||
|
return aa26.getAab301().equals(sysUser.getAreaId() + "");
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 校验当前登录用户是否有相应机构的操作权限
|
||||||
|
* @param orgId 机构ID
|
||||||
|
* @return true:有权限;false:无权限
|
||||||
|
*/
|
||||||
|
public boolean validateOrg(Long orgId, String userType) {
|
||||||
|
SysUser sysUser = currentUserService.getCurrentUser();
|
||||||
|
if ("1".equals(userType)) {
|
||||||
|
return "1".equals(sysUser.getUserType());
|
||||||
|
}
|
||||||
|
SysOrg sysOrg = sysOrgService.getByOrgId(orgId);
|
||||||
|
if (sysOrg == null) {
|
||||||
|
throw new AppException("机构不存在!");
|
||||||
|
}
|
||||||
|
if ("1".equals(sysUser.getUserType())) {
|
||||||
|
return true;
|
||||||
|
} else if ("2".equals(sysUser.getUserType())) {
|
||||||
|
List<SysOrg> list = sysOrgService.getByRegionCodeAndIdPath(sysUser.getAreaId() + "", sysOrg.getIdPath());
|
||||||
|
return !list.isEmpty();
|
||||||
|
} else if ("3".equals(sysUser.getUserType())) {
|
||||||
|
return sysOrg.getOrgId().equals(orgId);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 校验当前登录用户是否有相应用户的操作权限
|
||||||
|
* @param userId 用户ID
|
||||||
|
* @return true:有权限;false:无权限
|
||||||
|
*/
|
||||||
|
public boolean validateUser(String userId) {
|
||||||
|
SysUser sysUser = sysUserService.getByUserId(userId);
|
||||||
|
if (sysUser == null) {
|
||||||
|
throw new AppException("用户不存在!");
|
||||||
|
}
|
||||||
|
return validateOrg(sysUser.getOrgId(), sysUser.getUserType());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package com.insigma.sys.common;
|
||||||
|
|
||||||
|
import com.insigma.framework.domain.core.entity.SysUser;
|
||||||
|
import com.insigma.framework.security.web.dto.SysUserDetails;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取当前用户信息的接口
|
||||||
|
*
|
||||||
|
* @author yinjh
|
||||||
|
*/
|
||||||
|
public interface CurrentUserService {
|
||||||
|
|
||||||
|
SysUser getCurrentUser();
|
||||||
|
|
||||||
|
SysUserDetails getCurrentUserDetails();
|
||||||
|
}
|
||||||
@@ -0,0 +1,60 @@
|
|||||||
|
package com.insigma.sys.common;
|
||||||
|
|
||||||
|
import com.insigma.framework.core.util.SpringContextUtil;
|
||||||
|
import com.insigma.odin.framework.est.EstException;
|
||||||
|
import com.insigma.odin.framework.est.auth.ClientAuth;
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
|
import org.springframework.context.ApplicationContext;
|
||||||
|
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
||||||
|
import org.springframework.security.core.context.SecurityContext;
|
||||||
|
import org.springframework.security.core.context.SecurityContextHolder;
|
||||||
|
import org.springframework.security.core.userdetails.UserDetails;
|
||||||
|
import org.springframework.security.core.userdetails.UserDetailsService;
|
||||||
|
import org.springframework.security.web.authentication.WebAuthenticationDetails;
|
||||||
|
import org.springframework.security.web.authentication.logout.LogoutHandler;
|
||||||
|
import org.springframework.web.context.support.WebApplicationContextUtils;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 登录认证
|
||||||
|
*
|
||||||
|
* @author jinw
|
||||||
|
*/
|
||||||
|
public class OdinClientAuth implements ClientAuth {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean syslogon(String loginName, HttpServletRequest request) throws EstException {
|
||||||
|
UserDetailsService userDetailsService;
|
||||||
|
ApplicationContext applicationContext = WebApplicationContextUtils.findWebApplicationContext(request.getServletContext());
|
||||||
|
if (SpringContextUtil.getAppContext() != null) {
|
||||||
|
userDetailsService = SpringContextUtil.getBean(UserDetailsService.class);
|
||||||
|
} else {
|
||||||
|
userDetailsService = applicationContext.getBean(UserDetailsService.class);
|
||||||
|
}
|
||||||
|
UserDetails userDetails = userDetailsService.loadUserByUsername(loginName);
|
||||||
|
UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken(userDetails, userDetails.getPassword(), userDetails.getAuthorities());
|
||||||
|
token.setDetails(new WebAuthenticationDetails(request));
|
||||||
|
SecurityContextHolder.getContext().setAuthentication(token);
|
||||||
|
request.getSession().setAttribute("SPRING_SECURITY_CONTEXT", SecurityContextHolder.getContext());
|
||||||
|
request.getSession().setAttribute(OdinClientAuthExtendFilter.IS_SAVE_LOGONLOG_SESSION_KEY, Boolean.TRUE);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean syslogout(String loginName, HttpServletRequest request, HttpServletResponse response) throws EstException {
|
||||||
|
LogoutHandler logoutHandler;
|
||||||
|
if (SpringContextUtil.getAppContext() != null) {
|
||||||
|
logoutHandler = SpringContextUtil.getBean("myLogoutHandler", LogoutHandler.class);;
|
||||||
|
} else {
|
||||||
|
logoutHandler = WebApplicationContextUtils.findWebApplicationContext(request.getServletContext()).getBean("myLogoutHandler",LogoutHandler.class);
|
||||||
|
}
|
||||||
|
SecurityContext securityContext = (SecurityContext) request.getSession().getAttribute("SPRING_SECURITY_CONTEXT");
|
||||||
|
if (securityContext != null) {
|
||||||
|
logoutHandler.logout(request, response, securityContext.getAuthentication());
|
||||||
|
request.getSession().removeAttribute("SPRING_SECURITY_CONTEXT");
|
||||||
|
}
|
||||||
|
request.getSession().invalidate();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
package com.insigma.sys.common;
|
||||||
|
|
||||||
|
import com.insigma.framework.security.core.consts.SecurityConst;
|
||||||
|
import com.insigma.framework.security.web.dto.SysUserDetails;
|
||||||
|
import com.insigma.framework.security.web.handler.SysLoginHandler;
|
||||||
|
import jakarta.annotation.Resource;
|
||||||
|
import jakarta.servlet.FilterChain;
|
||||||
|
import jakarta.servlet.ServletException;
|
||||||
|
import jakarta.servlet.annotation.WebFilter;
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
|
import jakarta.servlet.http.HttpSession;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.security.core.context.SecurityContextHolder;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.springframework.web.filter.OncePerRequestFilter;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 单点登录扩展过滤器,用于记录登录日志
|
||||||
|
*
|
||||||
|
* @author jinw
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@Component
|
||||||
|
@WebFilter(filterName = "odinClientExtendFilter",urlPatterns = "/*")
|
||||||
|
public class OdinClientAuthExtendFilter extends OncePerRequestFilter {
|
||||||
|
|
||||||
|
public static final String IS_SAVE_LOGONLOG_SESSION_KEY = "save_logonlog_flag";
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private SysLoginHandler sysLoginHandler;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain chain) throws ServletException, IOException {
|
||||||
|
HttpSession session = request.getSession();
|
||||||
|
Boolean isSaveLogonlog = null;
|
||||||
|
try {
|
||||||
|
isSaveLogonlog = (Boolean) session.getAttribute(IS_SAVE_LOGONLOG_SESSION_KEY);
|
||||||
|
if (isSaveLogonlog != null && isSaveLogonlog) {
|
||||||
|
SysUserDetails userDetails = (SysUserDetails) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
|
||||||
|
sysLoginHandler.innerLoginSuccess(userDetails, SecurityConst.LoginType.SSO_EST, request);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("记录登录日志失败!", e);
|
||||||
|
} finally {
|
||||||
|
if (isSaveLogonlog != null) {
|
||||||
|
session.removeAttribute(IS_SAVE_LOGONLOG_SESSION_KEY);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
chain.doFilter(request, response);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
package com.insigma.sys.common;
|
||||||
|
|
||||||
|
import jakarta.annotation.PostConstruct;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 系统管理模式
|
||||||
|
*
|
||||||
|
* @author jinw
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
public final class SysManageMode {
|
||||||
|
|
||||||
|
@Value("${odin.sys.configure.triple-mode:false}")
|
||||||
|
private boolean tripleMode;
|
||||||
|
|
||||||
|
private static boolean TRIPLE_MODE = false;
|
||||||
|
|
||||||
|
@PostConstruct
|
||||||
|
public void init() {
|
||||||
|
TRIPLE_MODE = tripleMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isTripleMode() {
|
||||||
|
return TRIPLE_MODE;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <T> T doActionInTripleMode(Supplier<T> tripleModeAction) {
|
||||||
|
if (TRIPLE_MODE)
|
||||||
|
return tripleModeAction.get();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void doActionInTripleMode(Runnable tripleModeRun) {
|
||||||
|
if (TRIPLE_MODE)
|
||||||
|
tripleModeRun.run();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void doAction(Runnable tripleModeRun, Runnable notTripleModeRun) {
|
||||||
|
if (TRIPLE_MODE) {
|
||||||
|
tripleModeRun.run();
|
||||||
|
} else {
|
||||||
|
notTripleModeRun.run();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,58 @@
|
|||||||
|
package com.insigma.sys.common.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
|
import com.insigma.framework.domain.core.entity.SysUser;
|
||||||
|
import com.insigma.framework.domain.core.mapper.SysUserBaseMapper;
|
||||||
|
import com.insigma.framework.security.web.dto.SysUserDetails;
|
||||||
|
import com.insigma.framework.security.core.util.SecurityUserUtil;
|
||||||
|
import com.insigma.sys.common.CurrentUserService;
|
||||||
|
import jakarta.annotation.Resource;
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
import org.springframework.security.core.context.SecurityContextHolder;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.web.context.request.RequestContextHolder;
|
||||||
|
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取当前登录人
|
||||||
|
*
|
||||||
|
* @author yinjh
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class CurrentUserServiceImpl implements CurrentUserService {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private SysUserBaseMapper sysUserBaseMapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SysUser getCurrentUser() {
|
||||||
|
return currentUserFromSecurityContext();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SysUserDetails getCurrentUserDetails() {
|
||||||
|
return (SysUserDetails) SecurityUserUtil.getCurrentUser();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 从SpringSecurity中获取当前用户信息 jinw
|
||||||
|
*
|
||||||
|
* @return 当前登录用户
|
||||||
|
*/
|
||||||
|
private SysUser currentUserFromSecurityContext() {
|
||||||
|
SysUser sysUser = null;
|
||||||
|
SysUserDetails userDetails = (SysUserDetails) SecurityUserUtil.getCurrentUser();
|
||||||
|
if (userDetails != null) {
|
||||||
|
sysUser = (SysUser) userDetails.getOthers().get("sysUser");
|
||||||
|
if (sysUser == null) {
|
||||||
|
sysUser = sysUserBaseMapper.selectOne(Wrappers.<SysUser>lambdaQuery().eq(SysUser::getLogonName, userDetails.getUsername()));
|
||||||
|
userDetails.getOthers().put("sysUser", sysUser);
|
||||||
|
HttpServletRequest request = ((ServletRequestAttributes) Objects.requireNonNull(RequestContextHolder.getRequestAttributes())).getRequest();
|
||||||
|
request.getSession().setAttribute("SPRING_SECURITY_CONTEXT", SecurityContextHolder.getContext());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return sysUser;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
package com.insigma.sys.common.impl;//package com.insigma.sys.common.impl;
|
||||||
|
|
||||||
|
import com.insigma.odin.framework.est.EstException;
|
||||||
|
import com.insigma.odin.framework.est.auth.LogoutOrFailedExceptionHandler;
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 登出或失败异常处理器
|
||||||
|
*
|
||||||
|
* @author yinjh
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
public class MyLogoutOrFailedExceptionHandler extends LogoutOrFailedExceptionHandler {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handle(EstException ex, HttpServletRequest request, HttpServletResponse response) {
|
||||||
|
try {
|
||||||
|
log.debug("异常处理:", ex);
|
||||||
|
response.sendError(401, "登录已失效,请重新登录!");
|
||||||
|
} catch (IOException e) {
|
||||||
|
log.error("返回异常码时失败!", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
package com.insigma.sys.common.impl;
|
||||||
|
|
||||||
|
import com.insigma.framework.security.core.dto.BaseUserInfo;
|
||||||
|
import com.insigma.framework.security.web.dto.SysUserDetails;
|
||||||
|
import com.insigma.framework.security.web.handler.SysLoginHandler;
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.security.core.AuthenticationException;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 登录处理器
|
||||||
|
*
|
||||||
|
* @author yinjh
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@Service
|
||||||
|
public class MySysLoginHandler extends SysLoginHandler {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BaseUserInfo success(SysUserDetails sysUserDetails, String loginType, HttpServletRequest request) {
|
||||||
|
request.getSession().setAttribute("auth_filter_ignored",Boolean.TRUE);
|
||||||
|
BaseUserInfo baseUserInfo = new BaseUserInfo();
|
||||||
|
baseUserInfo.setUserid(sysUserDetails.getUserId());
|
||||||
|
baseUserInfo.setUsername(sysUserDetails.getUsername());
|
||||||
|
baseUserInfo.setNickname(sysUserDetails.getNickname());
|
||||||
|
return baseUserInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void failure(String username, String loginType, HttpServletRequest request, AuthenticationException exception) {
|
||||||
|
log.info("{} 登录失败,原因: {}", username, exception.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
package com.insigma.sys.common.impl;
|
||||||
|
|
||||||
|
import com.insigma.framework.security.web.handler.SysLogoutHandler;
|
||||||
|
import com.insigma.odin.framework.est.service.SSOServiceFactory;
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||||
|
import org.springframework.security.core.Authentication;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 登出处理器
|
||||||
|
*
|
||||||
|
* @author yinjh
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@Component
|
||||||
|
@ConditionalOnProperty(prefix = "sso", name = "app-name", matchIfMissing = false)
|
||||||
|
public class MySysLogoutHandler extends SysLogoutHandler {
|
||||||
|
|
||||||
|
@Value("${sso.app-name:}")
|
||||||
|
private String appName;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handle(HttpServletRequest request, HttpServletResponse response, Authentication authentication) {
|
||||||
|
String est = (String) request.getSession().getAttribute("est");
|
||||||
|
if (est != null) {
|
||||||
|
log.info("存在est令牌,执行注销操作!est: {}, appName: {}", est, appName);
|
||||||
|
SSOServiceFactory.logoutService().logout(est, appName, request);
|
||||||
|
} else {
|
||||||
|
log.info("无est令牌,不执行注销操作!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,55 @@
|
|||||||
|
package com.insigma.sys.config;//package com.insigma.sys.config;
|
||||||
|
|
||||||
|
import com.insigma.framework.security.core.config.SysSecurityConfig;
|
||||||
|
import com.insigma.framework.security.core.config.SysSecurityNoopConfig;
|
||||||
|
import com.insigma.odin.framework.est.auth.GenericAuthFilter;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
|
||||||
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||||
|
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||||
|
import org.springframework.boot.web.servlet.FilterRegistrationBean;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.util.ObjectUtils;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 单点登录配置类
|
||||||
|
*
|
||||||
|
* @author jinw
|
||||||
|
*/
|
||||||
|
@Configuration
|
||||||
|
@EnableConfigurationProperties(SSOConfigProperties.class)
|
||||||
|
@AutoConfigureAfter({SysSecurityConfig.class, SysSecurityNoopConfig.class})
|
||||||
|
@ConditionalOnProperty(prefix = "sso", name = "app-name", matchIfMissing = false)
|
||||||
|
public class SSOConfig {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SSOConfigProperties configProperties;
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public FilterRegistrationBean genericAuth() {
|
||||||
|
FilterRegistrationBean<GenericAuthFilter> filterRegistrationBean = new FilterRegistrationBean<>();
|
||||||
|
filterRegistrationBean.setFilter(new GenericAuthFilter());
|
||||||
|
Map<String, String> initParameters = new HashMap<>();
|
||||||
|
initParameters.put("app-name", configProperties.getAppName());
|
||||||
|
initParameters.put("auth-service-root-url", configProperties.getAuthServiceRootUrl());
|
||||||
|
initParameters.put("auth-logon-page-root-url", configProperties.getAuthLogonPageRootUrl());
|
||||||
|
initParameters.put("client-auth-class", configProperties.getClientAuthClass());
|
||||||
|
initParameters.put("free-urls", configProperties.getFreeUrls());
|
||||||
|
initParameters.put("auth-mode", configProperties.getAuthMode());
|
||||||
|
if (!ObjectUtils.isEmpty(configProperties.getAuthServiceContextPath())) {
|
||||||
|
initParameters.put("auth-service-context-path", configProperties.getAuthServiceContextPath());
|
||||||
|
}
|
||||||
|
if (!ObjectUtils.isEmpty(configProperties.getLogoutOrFailedExceptionHandler())) {
|
||||||
|
initParameters.put("logout-or-failed-exception-handler", configProperties.getLogoutOrFailedExceptionHandler());
|
||||||
|
}
|
||||||
|
filterRegistrationBean.setInitParameters(initParameters);
|
||||||
|
filterRegistrationBean.addUrlPatterns("/*");
|
||||||
|
filterRegistrationBean.setOrder(-100);
|
||||||
|
return filterRegistrationBean;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
package com.insigma.sys.config;//package com.insigma.sys.config;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 单点登录参数配置类
|
||||||
|
*
|
||||||
|
* @author jinw
|
||||||
|
*/
|
||||||
|
@ConfigurationProperties(prefix = "sso")
|
||||||
|
@Data
|
||||||
|
public class SSOConfigProperties {
|
||||||
|
|
||||||
|
private String appName;
|
||||||
|
private String authServiceRootUrl;
|
||||||
|
private String authLogonPageRootUrl;
|
||||||
|
private String clientAuthClass = "com.insigma.sys.common.OdinClientAuth";
|
||||||
|
private String freeUrls;
|
||||||
|
private String authMode;
|
||||||
|
private String authServiceContextPath;
|
||||||
|
private String logoutOrFailedExceptionHandler;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
package com.insigma.sys.config;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 系统配置参数类
|
||||||
|
*
|
||||||
|
* @author yinjh
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
@ConfigurationProperties(prefix = "odin.sys.configure")
|
||||||
|
@Data
|
||||||
|
public class SysConfigProperties {
|
||||||
|
/**
|
||||||
|
* 重置默认密码
|
||||||
|
*/
|
||||||
|
private String defaultPassword;
|
||||||
|
|
||||||
|
private Boolean ipAndUserAgentControl = false;
|
||||||
|
}
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
package com.insigma.sys.controller;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
|
import com.insigma.framework.core.ResponseMessage;
|
||||||
|
import com.insigma.framework.core.encryption.util.SM3Utils;
|
||||||
|
import com.insigma.framework.core.util.IpUtil;
|
||||||
|
import com.insigma.framework.domain.core.entity.SysUser;
|
||||||
|
import com.insigma.sys.common.CurrentUserService;
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.data.redis.core.RedisTemplate;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author yinjh
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/auth")
|
||||||
|
public class AuthController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private CurrentUserService currentUserService;
|
||||||
|
|
||||||
|
@Autowired(required = false)
|
||||||
|
private RedisTemplate redisTemplate;
|
||||||
|
|
||||||
|
@GetMapping("/getToken")
|
||||||
|
public ResponseMessage getToken(HttpServletRequest request) {
|
||||||
|
SysUser sysUser = currentUserService.getCurrentUser();
|
||||||
|
Date date = new Date();
|
||||||
|
long timetamp = date.getTime();
|
||||||
|
String token = SM3Utils.digest(IpUtil.getClientIp(request) + ";" + sysUser.getLogonName() + ";" + timetamp); // 生成token
|
||||||
|
redisTemplate.opsForValue().set(token, sysUser);
|
||||||
|
redisTemplate.expire(token, 300, TimeUnit.SECONDS);
|
||||||
|
return ResponseMessage.ok("", token);
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/getUserInfo")
|
||||||
|
public ResponseMessage getUserInfo(@RequestBody JSONObject jsonObject) {
|
||||||
|
String token = jsonObject.getString("token");
|
||||||
|
SysUser sysUser = (SysUser) redisTemplate.opsForValue().get(token);
|
||||||
|
if(sysUser == null) {
|
||||||
|
return ResponseMessage.error("获取用户信息失败!");
|
||||||
|
}
|
||||||
|
return ResponseMessage.ok("", sysUser);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,55 @@
|
|||||||
|
package com.insigma.sys.controller;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
|
import com.insigma.framework.core.ResponseMessage;
|
||||||
|
import com.insigma.framework.domain.core.entity.SysHoliday;
|
||||||
|
import com.insigma.sys.service.HolidayService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author yinjh
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/sys/holiday")
|
||||||
|
public class HolidayController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private HolidayService holidayService;
|
||||||
|
|
||||||
|
@GetMapping("/query")
|
||||||
|
public ResponseMessage getHolidayList(int year){
|
||||||
|
List<SysHoliday> holidayList = holidayService.getHolidaysByYear(year);
|
||||||
|
if (holidayList == null || holidayList.isEmpty()) {
|
||||||
|
holidayList = holidayService.getWeekdays(year);
|
||||||
|
holidayService.updateHolidaysByYear(year, holidayList);
|
||||||
|
}
|
||||||
|
List<String> dates = holidayToDate(holidayList);
|
||||||
|
return ResponseMessage.ok("", dates);
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/{year}/update")
|
||||||
|
public ResponseMessage updateHolidays(@PathVariable int year, @RequestBody JSONObject jsonObject){
|
||||||
|
List<String> holidays = jsonObject.getJSONArray("holidays").toJavaList(String.class);
|
||||||
|
holidayService.updateHolidaysByYear(year, dateToHoliday(holidays));
|
||||||
|
return ResponseMessage.ok("保存成功!");
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<String> holidayToDate(List<SysHoliday> holidays) {
|
||||||
|
return holidays.stream().map(s -> s.getYear() + "-" + (s.getMonth() < 10 ? "0" : "") + s.getMonth() + "-" + (s.getDay() < 10 ? "0" : "") + s.getDay()).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<SysHoliday> dateToHoliday(List<String> dates) {
|
||||||
|
return dates.stream().map(s -> {
|
||||||
|
String[] date = s.split("-");
|
||||||
|
SysHoliday sysHoliday = new SysHoliday();
|
||||||
|
sysHoliday.setYear(Integer.parseInt(date[0]));
|
||||||
|
sysHoliday.setMonth(Integer.parseInt(date[1]));
|
||||||
|
sysHoliday.setDay(Integer.parseInt(date[2]));
|
||||||
|
return sysHoliday;
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,147 @@
|
|||||||
|
package com.insigma.sys.controller;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
|
import com.insigma.framework.core.ResponseMessage;
|
||||||
|
import com.insigma.framework.core.encryption.util.SM3Utils;
|
||||||
|
import com.insigma.framework.core.exception.AppException;
|
||||||
|
import com.insigma.framework.domain.core.entity.Aa01;
|
||||||
|
import com.insigma.framework.domain.core.entity.SysLogonLog;
|
||||||
|
import com.insigma.framework.domain.core.entity.SysUser;
|
||||||
|
import com.insigma.framework.security.core.password.SM3PasswordEncoder;
|
||||||
|
import com.insigma.sys.common.CurrentUserService;
|
||||||
|
import com.insigma.sys.config.SysConfigProperties;
|
||||||
|
import com.insigma.sys.service.Aa01Service;
|
||||||
|
import com.insigma.sys.service.SysLogonLogService;
|
||||||
|
import com.insigma.sys.service.SysUserService;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.util.ObjectUtils;
|
||||||
|
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 java.text.SimpleDateFormat;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 首页面公共Controller,密码修改等在首页面的请求处理可统一放到这里来
|
||||||
|
* @author jinw
|
||||||
|
* @version 2019/4/2
|
||||||
|
* <p>epsoft - insiis7</p>
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@Slf4j
|
||||||
|
public class HomeController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SysUserService sysUserService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private CurrentUserService currentUserService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SysConfigProperties sysConfigProperties;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private Aa01Service aa01Service;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SysLogonLogService syslogonLogService;
|
||||||
|
|
||||||
|
@PostMapping("/sys/modifypd")
|
||||||
|
public ResponseMessage modifyPasswd(@RequestBody JSONObject data) {
|
||||||
|
SysUser currentUser = currentUserService.getCurrentUser();
|
||||||
|
try {
|
||||||
|
String oldPass=data.getString("opasswd");
|
||||||
|
String newPass=data.getString("npasswd");
|
||||||
|
String confirmPass = data.getString("rpasswd");
|
||||||
|
if (ObjectUtils.isEmpty(newPass) || !newPass.equals(confirmPass)){
|
||||||
|
throw new AppException("新密码为空或两次输入不等!");
|
||||||
|
}
|
||||||
|
String sm3LogonName = SM3Utils.digest(currentUser.getLogonName());
|
||||||
|
String sm3ReverseLogonName = SM3Utils.digest(new StringBuffer(currentUser.getLogonName()).reverse().toString());
|
||||||
|
if (sm3LogonName.equals(newPass) || sm3ReverseLogonName.equals(newPass)) {
|
||||||
|
throw new AppException("新密码不能与登录名(包含逆序)相同!");
|
||||||
|
}
|
||||||
|
sysUserService.updataPassWD(oldPass,newPass);
|
||||||
|
return ResponseMessage.ok("修改密码成功");
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.getMessage(),e);
|
||||||
|
return ResponseMessage.error("修改密码失败,失败原因:" + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/sys/checkDefaultPasswd")
|
||||||
|
public ResponseMessage checkDefaultPasswd() {
|
||||||
|
SysUser sysUser = currentUserService.getCurrentUser();
|
||||||
|
sysUser = sysUserService.getByLogonName(sysUser.getLogonName());
|
||||||
|
Date date = sysUser.getPwEditDate();
|
||||||
|
if(date==null){
|
||||||
|
return ResponseMessage.ok("", true);
|
||||||
|
}
|
||||||
|
String passwd = sysUser.getPassWD();
|
||||||
|
String defaultPasswd = sysConfigProperties.getDefaultPassword();
|
||||||
|
if(ObjectUtils.isEmpty(defaultPasswd)) {
|
||||||
|
return ResponseMessage.ok("", false);
|
||||||
|
}
|
||||||
|
return ResponseMessage.ok("", new SM3PasswordEncoder().matches(SM3Utils.digest(defaultPasswd), passwd));
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/sys/checkPasswordDisabled")
|
||||||
|
public ResponseMessage checkPasswordDisabled() {
|
||||||
|
SysUser sysUser = currentUserService.getCurrentUser();
|
||||||
|
sysUser = sysUserService.getByLogonName(sysUser.getLogonName());
|
||||||
|
if ("1".equals(sysUser.getPwExpireType())) {
|
||||||
|
// 密码周期过期
|
||||||
|
Aa01 aa01 = aa01Service.getByAaa001("PASSWORD_EXPIRED_PERIOD");
|
||||||
|
if (aa01 != null) {
|
||||||
|
Long period = Long.valueOf(aa01.getAaa005());
|
||||||
|
if (sysUser.getPwEditDate() != null) {
|
||||||
|
// 密码修改过,以修改之后的周期计算
|
||||||
|
if (sysUser.getPwEditDate().getTime() + period * 24 * 60 * 60 * 1000 <= System.currentTimeMillis()) {
|
||||||
|
return ResponseMessage.ok("", true);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// 密码没有修改过,以新建用户之后的周期计算
|
||||||
|
if (sysUser.getCreateTime().getTime() + period * 24 * 60 * 60 * 1000 <= System.currentTimeMillis()) {
|
||||||
|
return ResponseMessage.ok("", true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if ("3".equals(sysUser.getPwExpireType())) {
|
||||||
|
// 指定日期过期
|
||||||
|
if (sysUser.getPwExpireDate() != null && sysUser.getPwExpireDate().getTime() <= System.currentTimeMillis()) {
|
||||||
|
return ResponseMessage.ok("", true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ResponseMessage.ok("", false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/sys/getLastLoginTime")
|
||||||
|
public ResponseMessage getLastLoginTime() {
|
||||||
|
SysUser sysUser = currentUserService.getCurrentUser();
|
||||||
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||||
|
List<SysLogonLog> list = syslogonLogService.getLast(sysUser.getUserId(), 2);
|
||||||
|
String lastLoginTime = "首次登录";
|
||||||
|
if(list != null&& list.size() > 1){
|
||||||
|
lastLoginTime = sdf.format(list.get(1).getLogonTime());
|
||||||
|
}
|
||||||
|
return ResponseMessage.ok("", lastLoginTime);
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/sys/getUserInfo")
|
||||||
|
public ResponseMessage getUserInfo(){
|
||||||
|
SysUser sysUser = currentUserService.getCurrentUser();
|
||||||
|
// SysUser sysUser = sysUserService.queryOneUser(currentUserService.getCurrentUser().getUserId());
|
||||||
|
return ResponseMessage.ok("", sysUser);
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/sys/updateUserInfo")
|
||||||
|
public ResponseMessage updateUserInfo(@RequestBody SysUser sysUser){
|
||||||
|
sysUserService.update(sysUser);
|
||||||
|
return ResponseMessage.ok("修改成功");
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,95 @@
|
|||||||
|
package com.insigma.sys.controller;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson2.JSONArray;
|
||||||
|
import com.insigma.framework.core.ResponseMessage;
|
||||||
|
import com.insigma.framework.core.exception.AppException;
|
||||||
|
import com.insigma.framework.core.util.TreeUtil;
|
||||||
|
import com.insigma.framework.web.support.excel.ExcelFactory;
|
||||||
|
import com.insigma.framework.web.support.module.dto.ImportConfigDTO;
|
||||||
|
import com.insigma.framework.web.support.module.dto.ImportConfigDetailDTO;
|
||||||
|
import com.insigma.framework.web.support.module.service.ImportConfigService;
|
||||||
|
import com.insigma.sys.common.CurrentUserService;
|
||||||
|
import com.insigma.sys.dto.ImportConfigReDTO;
|
||||||
|
import com.insigma.sys.dto.MenuDTO;
|
||||||
|
import com.insigma.sys.service.SysFunctionService;
|
||||||
|
import jakarta.annotation.Resource;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通用导入配置
|
||||||
|
*
|
||||||
|
* @author yinjh
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/sys/import/config")
|
||||||
|
public class ImportConfigController {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private ImportConfigService importConfigService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SysFunctionService sysFunctionService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private CurrentUserService currentUserService;
|
||||||
|
|
||||||
|
@GetMapping("/queryMenuList")
|
||||||
|
public ResponseMessage queryMenuList() {
|
||||||
|
List<MenuDTO> menuDTOS = sysFunctionService.getMenuList(currentUserService.getCurrentUser());
|
||||||
|
JSONArray jsonArray = TreeUtil.listToTree(JSONArray.parseArray(JSONArray.toJSONString(menuDTOS)), "functionid", "parentid", "children", "0");
|
||||||
|
return ResponseMessage.ok("查询成功", jsonArray);
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/query")
|
||||||
|
public ResponseMessage query(String configCode, String configName) {
|
||||||
|
List<ImportConfigDTO> list = importConfigService.queryConfigList(configCode, configName);
|
||||||
|
return ResponseMessage.ok(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/queryConfig")
|
||||||
|
public ResponseMessage queryConfig(String configId) {
|
||||||
|
ImportConfigDTO config = importConfigService.queryConfig(configId);
|
||||||
|
List<ImportConfigDetailDTO> details = importConfigService.queryConfigDetails(configId);
|
||||||
|
ImportConfigReDTO reDTO = new ImportConfigReDTO();
|
||||||
|
reDTO.setConfig(config);
|
||||||
|
reDTO.setDetails(details);
|
||||||
|
return ResponseMessage.ok(reDTO);
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/importExcelTemplate")
|
||||||
|
public ResponseMessage importExcelTemplate(MultipartFile file, String sheetNameOrIndex, Integer headerRowIndex) {
|
||||||
|
try {
|
||||||
|
List<ImportConfigDetailDTO> list = new ArrayList<>();
|
||||||
|
ExcelFactory.readSax(file.getInputStream(), sheetNameOrIndex, (sheetIndexOrName, rowIndex, rowList) -> {
|
||||||
|
if (rowIndex == headerRowIndex) {
|
||||||
|
for (Object field : rowList) {
|
||||||
|
ImportConfigDetailDTO detailDTO = new ImportConfigDetailDTO();
|
||||||
|
detailDTO.setOriginFieldName(String.valueOf(field));
|
||||||
|
detailDTO.setFieldType("0");
|
||||||
|
list.add(detailDTO);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return ResponseMessage.ok(list);
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new AppException("读取模板失败:" + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/save")
|
||||||
|
public ResponseMessage save(@RequestBody ImportConfigReDTO reqDTO) {
|
||||||
|
importConfigService.saveConfig(reqDTO.getConfig(), reqDTO.getDetails());
|
||||||
|
return ResponseMessage.ok("保存成功");
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/delete/{configId}")
|
||||||
|
public ResponseMessage delete(@PathVariable String configId) {
|
||||||
|
importConfigService.deleteConfig(configId);
|
||||||
|
return ResponseMessage.ok("删除成功");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,238 @@
|
|||||||
|
package com.insigma.sys.controller;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson2.JSONArray;
|
||||||
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
|
import com.insigma.framework.core.ResponseMessage;
|
||||||
|
import com.insigma.framework.core.util.DtoEntityUtil;
|
||||||
|
import com.insigma.framework.core.util.TreeUtil;
|
||||||
|
import com.insigma.framework.domain.core.entity.SysFunction;
|
||||||
|
import com.insigma.framework.web.support.core.service.CodeTypeService;
|
||||||
|
import com.insigma.sys.common.CurrentUserService;
|
||||||
|
import com.insigma.sys.dto.MenuDTO;
|
||||||
|
import com.insigma.sys.dto.SysAppDTO;
|
||||||
|
import com.insigma.sys.dto.SysFunctionDTO;
|
||||||
|
import com.insigma.sys.service.SysAppService;
|
||||||
|
import com.insigma.sys.service.SysFunctionService;
|
||||||
|
import com.insigma.sys.service.SysRoleFunctionService;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 菜单管理
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/sys/menu")
|
||||||
|
public class MenuController {
|
||||||
|
@Autowired
|
||||||
|
private SysFunctionService sysFunctionService;
|
||||||
|
@Autowired
|
||||||
|
private CodeTypeService codeTypeService;
|
||||||
|
@Autowired
|
||||||
|
private CurrentUserService currentUserService;
|
||||||
|
@Autowired
|
||||||
|
private SysAppService sysAppService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SysRoleFunctionService sysRoleFunctionService;
|
||||||
|
/**
|
||||||
|
* 初始化页面数据
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping("/initCodeTypes")
|
||||||
|
public ResponseMessage initCodeTypes(@RequestBody JSONObject jsonObject) {
|
||||||
|
try {
|
||||||
|
JSONObject codeTypes = codeTypeService.getCodeTypes(jsonObject);
|
||||||
|
List<SysAppDTO> list = sysAppService.querySysAppDTO();
|
||||||
|
JSONArray jsonArray = new JSONArray();
|
||||||
|
for (SysAppDTO sysAppDTO : list) {
|
||||||
|
JSONObject j = new JSONObject();
|
||||||
|
j.put("value",sysAppDTO.getAppName());
|
||||||
|
j.put("key",sysAppDTO.getAppId());
|
||||||
|
jsonArray.add(j);
|
||||||
|
}
|
||||||
|
codeTypes.put("APPID",jsonArray);
|
||||||
|
return ResponseMessage.ok("", codeTypes);
|
||||||
|
} catch (Exception e) {
|
||||||
|
return ResponseMessage.error(e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@GetMapping("/queryTree")
|
||||||
|
public ResponseMessage queryTable(){
|
||||||
|
List<MenuDTO> menuDTOS = sysFunctionService.queryAllMenu();
|
||||||
|
JSONArray jsonArray = TreeUtil.listToTree(JSONArray.parseArray(JSONArray.toJSONString(menuDTOS)), "functionid", "parentid", "children");
|
||||||
|
return ResponseMessage.ok("查询成功", jsonArray);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 拖拽成功完成时触发
|
||||||
|
* @param jsonObject
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping("/nodeDrop")
|
||||||
|
public ResponseMessage nodeDrop(@RequestBody JSONObject jsonObject){
|
||||||
|
System.out.println(jsonObject);
|
||||||
|
JSONArray jsonArray = jsonObject.getJSONArray("data");
|
||||||
|
for (int i = 0; i < jsonArray.size(); i++) {
|
||||||
|
JSONObject oneMenu = jsonArray.getJSONObject(i);
|
||||||
|
SysFunction sysFunction = new SysFunction();
|
||||||
|
sysFunction.setFunctionId(oneMenu.getLong("functionid"));
|
||||||
|
sysFunction.setFunOrder(oneMenu.getInteger("funorder"));
|
||||||
|
sysFunction.setParentId(oneMenu.getLong("parentid"));
|
||||||
|
sysFunction.setTitle(oneMenu.getString("title"));
|
||||||
|
sysFunctionService.update(sysFunction);
|
||||||
|
}
|
||||||
|
return ResponseMessage.ok();
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 点击左侧菜单后
|
||||||
|
*/
|
||||||
|
@PostMapping("/nodeClick")
|
||||||
|
public ResponseMessage nodeClick(@RequestBody() JSONObject jsonObject) {
|
||||||
|
String a = jsonObject.get("functionid").toString();
|
||||||
|
if (a != null){
|
||||||
|
long functionId = Long.parseLong(a);
|
||||||
|
SysFunction sysFunction = sysFunctionService.getByFunctionId(functionId);
|
||||||
|
List<SysFunction> menulist= sysFunctionService.getByParentId(sysFunction.getFunctionId());
|
||||||
|
SysFunctionDTO sysFunctionDTO = DtoEntityUtil.trans(sysFunction, SysFunctionDTO.class, true);
|
||||||
|
if (!menulist.isEmpty()){
|
||||||
|
//有子类
|
||||||
|
return ResponseMessage.ok("", sysFunctionDTO);
|
||||||
|
}else {
|
||||||
|
//没有子类
|
||||||
|
return ResponseMessage.ok("重复", sysFunctionDTO);
|
||||||
|
}
|
||||||
|
}else {
|
||||||
|
return ResponseMessage.error();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据id查找对象
|
||||||
|
* @param jsonObject
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping("/queryById")
|
||||||
|
public ResponseMessage queryById(@RequestBody JSONObject jsonObject) {
|
||||||
|
String id=jsonObject.get("functionid").toString();
|
||||||
|
String funtype=jsonObject.get("funtype").toString();
|
||||||
|
List<MenuDTO> menuDTOS= sysFunctionService.queryMenuByFuntypeAndActive(funtype);
|
||||||
|
JSONArray jsonArray = TreeUtil.listToTree(JSONArray.parseArray(JSONArray.toJSONString(menuDTOS)), "functionid", "parentid", "children");
|
||||||
|
jsonObject.put("treedata",jsonArray);
|
||||||
|
long fId=Integer.parseInt(id);
|
||||||
|
SysFunction menu= sysFunctionService.getByFunctionId(fId);
|
||||||
|
List list=new ArrayList();
|
||||||
|
if(menu!=null){
|
||||||
|
String [] ms=menu.getIdPath().split("/");
|
||||||
|
if (ms.length>0){
|
||||||
|
for (String s:ms){
|
||||||
|
if(s.equals("0")){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
list.add(Long.valueOf(s));
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
jsonObject.put("pname",list);
|
||||||
|
return ResponseMessage.ok("", jsonObject);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 查询是否多于三层
|
||||||
|
* @param jsonObject
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping("/querySumIsThree")
|
||||||
|
public ResponseMessage querySumIsThree(@RequestBody JSONObject jsonObject) {
|
||||||
|
try {
|
||||||
|
String id=jsonObject.get("functionid").toString();
|
||||||
|
Map<String,List> list= (Map<String, List>) jsonObject.get("pname");
|
||||||
|
long fId=Integer.parseInt(id);
|
||||||
|
SysFunction sysFunction= sysFunctionService.getByFunctionId(fId);
|
||||||
|
List<SysFunction> menu= sysFunctionService.getByIdPath(sysFunction.getIdPath());//查询当前子节点
|
||||||
|
for(int i=0;i<list.get("value").size();i++){
|
||||||
|
for (SysFunction menu1:menu){
|
||||||
|
if(String.valueOf(menu1.getFunctionId()).equals(list.get("value").get(i).toString())){
|
||||||
|
return ResponseMessage.error("上级菜单无法选择本身及下级菜单");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ResponseMessage.ok();
|
||||||
|
}catch (Exception e){
|
||||||
|
return ResponseMessage.error(e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@PostMapping("/saveMenu")
|
||||||
|
public ResponseMessage saveMenu(@RequestBody JSONObject pageData){
|
||||||
|
Map<String,Object> map= (Map<String, Object>) pageData.get("form");
|
||||||
|
SysFunction sysFunction = sysFunctionService.getSysFunctionBean(map);
|
||||||
|
boolean flag = sysFunctionService.isManyLocations(sysFunction);
|
||||||
|
if (flag) {
|
||||||
|
return ResponseMessage.error("路径重复");
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
sysFunctionService.save(sysFunction);
|
||||||
|
return ResponseMessage.ok("保存成功", sysFunction);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.getMessage(), e);
|
||||||
|
return ResponseMessage.error("保存失败,失败原因:" +e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@PostMapping("/deleteMenu")
|
||||||
|
public ResponseMessage deleteMenu(@RequestBody JSONObject pageData){
|
||||||
|
if (!"1".equals(currentUserService.getCurrentUser().getUserType())) {
|
||||||
|
return ResponseMessage.error("无权操作!");
|
||||||
|
}
|
||||||
|
Long node=Long.valueOf(pageData.get("node").toString());
|
||||||
|
try {
|
||||||
|
// 根据ID删除,会级联删除子节点和对应角色菜单关系
|
||||||
|
SysFunction sysFunction = sysFunctionService.getByFunctionId(node);
|
||||||
|
sysFunctionService.delete(sysFunction);
|
||||||
|
return ResponseMessage.ok("删除成功");
|
||||||
|
}catch (Exception e){
|
||||||
|
log.error(e.getMessage(), e);
|
||||||
|
return ResponseMessage.error("删除失败,失败原因:" +e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 查找是否有角色关系
|
||||||
|
*/
|
||||||
|
@PostMapping("/queryRoleBy")
|
||||||
|
public ResponseMessage queryRoleBy(@RequestBody JSONObject pageData){
|
||||||
|
Map<String,Object> map= (Map<String, Object>) pageData.get("form");
|
||||||
|
SysFunction sysFunction = sysFunctionService.getSysFunctionBean(map);
|
||||||
|
boolean f = sysFunctionService.findFunctionRoles(sysFunction);
|
||||||
|
if (f==true){
|
||||||
|
return ResponseMessage.error("有权限");
|
||||||
|
}else if (f==false){
|
||||||
|
return ResponseMessage.ok("没有权限");
|
||||||
|
}else {
|
||||||
|
return ResponseMessage.error();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//判断是否三级
|
||||||
|
@PostMapping("queryMenuByPid")
|
||||||
|
public ResponseMessage queryMenuByPid(@RequestBody JSONObject pageData) {
|
||||||
|
ResponseMessage rm=new ResponseMessage();
|
||||||
|
String a=pageData.get("parentid").toString();
|
||||||
|
if (a!=null){
|
||||||
|
long parentId = Long.parseLong(a);
|
||||||
|
SysFunction menu= sysFunctionService.getByFunctionId(parentId);
|
||||||
|
if (menu!=null){
|
||||||
|
SysFunction menu1= sysFunctionService.getByFunctionId(menu.getParentId());
|
||||||
|
if (menu1!=null){
|
||||||
|
rm= ResponseMessage.error("最多添加三级");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}else {
|
||||||
|
rm= ResponseMessage.error("没取到父节点");
|
||||||
|
}
|
||||||
|
return rm;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,136 @@
|
|||||||
|
package com.insigma.sys.controller;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
|
import com.insigma.framework.core.ResponseMessage;
|
||||||
|
import com.insigma.framework.domain.core.entity.SysFunction;
|
||||||
|
import com.insigma.framework.domain.core.entity.SysUser;
|
||||||
|
import com.insigma.framework.web.support.ep.dev.controller.BaseController;
|
||||||
|
import com.insigma.sys.common.CurrentUserService;
|
||||||
|
import com.insigma.sys.dto.MonitorCentersDTO;
|
||||||
|
import com.insigma.sys.service.MonitorCentersService;
|
||||||
|
import com.insigma.sys.service.SysFunctionService;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author GH
|
||||||
|
* @ClassName: MonitorCentersController
|
||||||
|
* @Description: 监控中心
|
||||||
|
* @version 2021/12/7 14:53
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/sys/monitoringcenter/MonitoringDetails")
|
||||||
|
public class MonitorCentersController extends BaseController {
|
||||||
|
@Autowired
|
||||||
|
private MonitorCentersService monitorCentersService;
|
||||||
|
@Autowired
|
||||||
|
private SysFunctionService sysFunctionService;
|
||||||
|
@Autowired
|
||||||
|
private CurrentUserService currentUserService;
|
||||||
|
/**
|
||||||
|
* 查询应用数据源信息
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping("/querServiceDataSouce")
|
||||||
|
public JSONObject querServiceDataSouce(@RequestBody MonitorCentersDTO monitorCentersDTO) {
|
||||||
|
return monitorCentersService.querServiceDataSouce(monitorCentersDTO);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询应用SQL监控列表
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping("/querServiceDataSqlList")
|
||||||
|
public JSONObject querServiceDataSqlList(@RequestBody MonitorCentersDTO MonitorCentersDTO) {
|
||||||
|
return monitorCentersService.querServiceDataSqlList(MonitorCentersDTO);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询WBEAPP监控信息
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping("/querServiceWebApp")
|
||||||
|
public JSONObject querServiceWebApp(@RequestBody MonitorCentersDTO monitorCentersDTO) {
|
||||||
|
return monitorCentersService.querServiceWebApp(monitorCentersDTO);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询应用URI监控列表
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping("/querServiceDataUriList")
|
||||||
|
public JSONObject querServiceDataUriList(@RequestBody MonitorCentersDTO monitorCentersDTO) {
|
||||||
|
return monitorCentersService.querServiceDataUriList(monitorCentersDTO);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询应用Session监控列表
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping("/querServiceDataSessionList")
|
||||||
|
public JSONObject querServiceDataSessionList(@RequestBody MonitorCentersDTO monitorCentersDTO) {
|
||||||
|
return monitorCentersService.querServiceDataSessionList(monitorCentersDTO);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询每个应用下对应的实例IP
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping("/querServiceIp")
|
||||||
|
public JSONObject querServiceIp(@RequestBody MonitorCentersDTO monitorCentersDTO) {
|
||||||
|
return monitorCentersService.querServiceIp(monitorCentersDTO);
|
||||||
|
}
|
||||||
|
|
||||||
|
//获取菜单名称和id实体
|
||||||
|
@PostMapping("/queryEntity")
|
||||||
|
public ResponseMessage queryEntity(@RequestBody JSONObject jsonObject) {
|
||||||
|
String url = jsonObject.getString("url");
|
||||||
|
SysFunction sysFunction = sysFunctionService.getByLocation(url);
|
||||||
|
return ResponseMessage.ok("", sysFunction);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 清理全部监控数据
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping("/clearAllMonitorData")
|
||||||
|
public JSONObject clearAllMonitorData() {
|
||||||
|
return monitorCentersService.clearAllMonitorData();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 清理对应的监控数据
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping("/clearOneServiceData")
|
||||||
|
public JSONObject clearOneServiceData(@RequestBody MonitorCentersDTO monitorCentersDTO) {
|
||||||
|
return monitorCentersService.clearOneServiceData(monitorCentersDTO);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//查询用户是否为超级管理员
|
||||||
|
@GetMapping("/queryUser")
|
||||||
|
public ResponseMessage queryUser() {
|
||||||
|
SysUser sysUser = currentUserService.getCurrentUser();
|
||||||
|
//超级管理员
|
||||||
|
if ("1".equals(sysUser.getUserType())) {
|
||||||
|
return ResponseMessage.ok("", true);
|
||||||
|
} else {
|
||||||
|
return ResponseMessage.ok("", false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,160 @@
|
|||||||
|
package com.insigma.sys.controller;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
|
import com.insigma.framework.web.support.excel.ExcelFactory;
|
||||||
|
import com.insigma.framework.web.support.excel.ExcelWriter;
|
||||||
|
import com.insigma.framework.web.support.excel.config.ExcelColConfig;
|
||||||
|
import com.insigma.framework.web.support.excel.config.ExcelConfig;
|
||||||
|
import com.insigma.framework.web.support.excel.enums.ExcelTypeEnum;
|
||||||
|
import com.insigma.sys.dto.MonitorCentersDTO;
|
||||||
|
import com.insigma.sys.service.MonitorCentersService;
|
||||||
|
import com.insigma.sys.util.WordUtil;
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.io.*;
|
||||||
|
import java.net.URLEncoder;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author GH
|
||||||
|
* @version 2022/3/8 16:46
|
||||||
|
* @ClassName: MonitorDataController
|
||||||
|
* @Description:
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/sys/monitoringcenter/index")
|
||||||
|
public class MonitorDataController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
MonitorCentersService monitorCentersService;
|
||||||
|
|
||||||
|
@Value("${spring.application.name}")
|
||||||
|
private String appName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取报告数据
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping("/getReportData")
|
||||||
|
public JSONObject getReportData(@RequestBody MonitorCentersDTO monitorCentersDTO) {
|
||||||
|
return monitorCentersService.getReportData(monitorCentersDTO);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//导出监控大屏数据
|
||||||
|
@GetMapping("/dataExport")
|
||||||
|
public void dataExport(@RequestParam("excelName") String excelName, HttpServletRequest request, HttpServletResponse response) throws IOException {
|
||||||
|
response.setContentType("application/octet-stream; charset=UTF-8");
|
||||||
|
response.setHeader("Content-disposition", "attachment; filename=" + URLEncoder.encode(excelName, "utf-8"));
|
||||||
|
|
||||||
|
ExcelTypeEnum excelType = excelName.endsWith(".xls") ? ExcelTypeEnum.XLS : ExcelTypeEnum.XLSX;
|
||||||
|
ExcelWriter writer = ExcelFactory.getWriter(response.getOutputStream(), new ExcelConfig(excelType, true,
|
||||||
|
ExcelColConfig.of("CREATE_TIME", "创建时间"),
|
||||||
|
ExcelColConfig.of("START_TIME", "统计开始时间"),
|
||||||
|
ExcelColConfig.of("END_TIME", "统计结束时间"),
|
||||||
|
ExcelColConfig.of("SQL_EXECUTE_COUNT", "SQL执行总数"),
|
||||||
|
ExcelColConfig.of("SQL_TOTAL_TIME", "SQL耗时总数"),
|
||||||
|
ExcelColConfig.of("SQL_AVG_TIME", "SQL执行平均耗时"),
|
||||||
|
ExcelColConfig.of("SQL_SLOWEST_TIME", "SQL执行最慢耗时"),
|
||||||
|
ExcelColConfig.of("SQL_AVG_READ_ROWS", "SQL单次平均读取行数"),
|
||||||
|
ExcelColConfig.of("URL_EXECUTE_COUNT", "URL执行总数"),
|
||||||
|
ExcelColConfig.of("URL_TOTAL_TIME", "URL耗时总数"),
|
||||||
|
ExcelColConfig.of("URL_AVG_TIME", "URL执行平均耗时"),
|
||||||
|
ExcelColConfig.of("URL_SLOWEST_TIME", "URL执行最慢耗时"),
|
||||||
|
ExcelColConfig.of("URL_AVG_JDBC_COUNT", "URL单次平均JDBC执行数"),
|
||||||
|
ExcelColConfig.of("SLOW_SQL_ONE", "慢SQL最慢第一段个数"),
|
||||||
|
ExcelColConfig.of("SLOW_SQL_TWO", "慢SQL最慢第二段个数"),
|
||||||
|
ExcelColConfig.of("SLOW_SQL_THREE", "慢SQL最慢第三段个数"),
|
||||||
|
ExcelColConfig.of("SLOW_SQL_AVG_ONE", "慢SQL平均第一段个数"),
|
||||||
|
ExcelColConfig.of("SLOW_SQL_AVG_TWO", "慢SQL平均第二段个数"),
|
||||||
|
ExcelColConfig.of("SLOW_SQL_AVG_THREE", "慢SQL平均第三段个数"),
|
||||||
|
ExcelColConfig.of("SQL_ERROR_COUNT", "SQL执行错误数"),
|
||||||
|
ExcelColConfig.of("URL_JDBC_ERROR_COUNT", "URLJDBC执行错误数"),
|
||||||
|
ExcelColConfig.of("SCORE", "得分"),
|
||||||
|
ExcelColConfig.of("SCORE_SLOW_SQL", "慢SQL影响分"),
|
||||||
|
ExcelColConfig.of("SCORE_ERROR_SQL", "错误SQL影响分"),
|
||||||
|
ExcelColConfig.of("SCORE_SLOW_URL", "慢URL影响分"),
|
||||||
|
ExcelColConfig.of("SCORE_JDBC_ERROR_URL", "JDBC错误URL影响分"),
|
||||||
|
ExcelColConfig.of("INSTANCE_COUNT", "集群实例数"),
|
||||||
|
ExcelColConfig.of("DS_MAX_ACTIVE", "数据库最大连接数")
|
||||||
|
));
|
||||||
|
final int[] index = {0};
|
||||||
|
List<Map> mapList = monitorCentersService.getDataExport(appName);
|
||||||
|
for (Map map : mapList) {
|
||||||
|
writer.writeRow(map, ++index[0]);
|
||||||
|
}
|
||||||
|
writer.finish();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//获取word文档数据
|
||||||
|
@PostMapping("/getWrodData")
|
||||||
|
public Map<String, Object> getWrodData(@RequestBody MonitorCentersDTO monitorCentersDTO) {
|
||||||
|
return monitorCentersService.getReportDetailedData(monitorCentersDTO);
|
||||||
|
}
|
||||||
|
|
||||||
|
//导出word文档
|
||||||
|
@GetMapping("/word")
|
||||||
|
public void generateWord(HttpServletRequest request, HttpServletResponse response) throws IOException {
|
||||||
|
MonitorCentersDTO dto = new MonitorCentersDTO();
|
||||||
|
dto.setAppName(appName);
|
||||||
|
// 要填入模本的数据文件
|
||||||
|
Map<String, Object> dataMap = monitorCentersService.getReportDetailedData(dto);
|
||||||
|
|
||||||
|
//提示:在调用工具类生成Word文档之前应当检查所有字段是否完整
|
||||||
|
//否则Freemarker的模板殷勤在处理时可能会因为找不到值而报错,这里暂时忽略这个步骤
|
||||||
|
File file = null;
|
||||||
|
InputStream in = null;
|
||||||
|
OutputStream out = null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
//调用工具类WordGenerator的createDoc方法生成Word文档
|
||||||
|
file = WordUtil.createDoc(dataMap, "monReportTemplet");
|
||||||
|
in = new FileInputStream(file);
|
||||||
|
response.setCharacterEncoding("UTF-8");
|
||||||
|
response.setContentType("application/msword");
|
||||||
|
out = response.getOutputStream();
|
||||||
|
//缓冲区
|
||||||
|
byte[] bytes = new byte[2048];
|
||||||
|
int len;
|
||||||
|
// 通过循环将读入的Word文件的内容输出到浏览器中
|
||||||
|
while ((len = in.read(bytes)) > 0) {
|
||||||
|
out.write(bytes, 0, len);
|
||||||
|
}
|
||||||
|
out.flush();
|
||||||
|
} catch (Exception ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
log.error("报告导出异常", ex);
|
||||||
|
} finally {
|
||||||
|
//释放资源
|
||||||
|
if (out != null) {
|
||||||
|
try {
|
||||||
|
out.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
log.error("IO close error!", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (in != null) {
|
||||||
|
try {
|
||||||
|
in.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
log.error("IO close error!", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (file != null) {
|
||||||
|
// 删除临时文件
|
||||||
|
file.delete();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,103 @@
|
|||||||
|
package com.insigma.sys.controller;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
|
import com.insigma.framework.core.ResponseMessage;
|
||||||
|
import com.insigma.framework.domain.core.entity.SbdsUserLog;
|
||||||
|
import com.insigma.framework.domain.core.entity.SysFunction;
|
||||||
|
import com.insigma.framework.log.core.util.OpLogUtil;
|
||||||
|
import com.insigma.framework.persistence.core.jdbc.PageInfo;
|
||||||
|
import com.insigma.framework.web.support.ep.dev.service.PageInitService;
|
||||||
|
import com.insigma.framework.web.support.module.dto.UserLogDTO;
|
||||||
|
import com.insigma.framework.web.support.module.service.SbdsUserLogService;
|
||||||
|
import com.insigma.sys.common.CurrentUserService;
|
||||||
|
import com.insigma.sys.dto.MenuDTO;
|
||||||
|
import com.insigma.sys.service.SysFunctionService;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by yinjh on 2019/1/29.
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/sys/oplog")
|
||||||
|
public class OpLogController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SbdsUserLogService sbdsUserLogService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private CurrentUserService currentUserService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private PageInitService pageInitService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SysFunctionService sysFunctionService;
|
||||||
|
|
||||||
|
@PostMapping("/initSysFunctions")
|
||||||
|
public ResponseMessage initSysFuntions(@RequestBody JSONObject jsonObject) {
|
||||||
|
List<MenuDTO> menuList = sysFunctionService.queryAllMenu();
|
||||||
|
menuList = menuList.stream().filter(menu -> "2".equals(menu.getNodetype())).toList();
|
||||||
|
jsonObject = pageInitService.loadCustomCodeType(jsonObject, menuList, "functionid", "title", "SYSFUNCTIONS");
|
||||||
|
return ResponseMessage.ok(jsonObject.getJSONObject("codeTypes"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/query")
|
||||||
|
public ResponseMessage query(@RequestBody JSONObject jsonObject) throws SQLException {
|
||||||
|
Integer page = jsonObject.getInteger("page");
|
||||||
|
Integer size = jsonObject.getInteger("size");
|
||||||
|
UserLogDTO queryParam = jsonObject.toJavaObject(UserLogDTO.class);
|
||||||
|
Boolean more = jsonObject.getBoolean("more");
|
||||||
|
if (more != null && !more) {
|
||||||
|
if (queryParam.getAae036() != null) {
|
||||||
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||||
|
String aae036 = sdf.format(queryParam.getAae036());
|
||||||
|
queryParam.setStartTime(aae036 + " 00:00:00");
|
||||||
|
queryParam.setEndTime(aae036 + " 23:59:59");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
PageInfo<UserLogDTO> pageInfo = sbdsUserLogService.queryUserLogList(queryParam, page, size);
|
||||||
|
return ResponseMessage.ok(pageInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/location")
|
||||||
|
public ResponseMessage getLocation(Long opseno) {
|
||||||
|
SbdsUserLog log = sbdsUserLogService.getByOpseno(opseno);
|
||||||
|
if (log != null) {
|
||||||
|
Long functionId = log.getFunctionId();
|
||||||
|
SysFunction sysFunction = sysFunctionService.getByFunctionId(functionId);
|
||||||
|
return ResponseMessage.ok("", sysFunction.getLocation());
|
||||||
|
}
|
||||||
|
return ResponseMessage.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/orisource")
|
||||||
|
public ResponseMessage getOriSource(Long opseno) {
|
||||||
|
String oriSource = OpLogUtil.getOriSource(opseno);
|
||||||
|
return ResponseMessage.ok("", oriSource);
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/oridata")
|
||||||
|
public ResponseMessage getOriData(Long opseno) {
|
||||||
|
String oriData = OpLogUtil.getOriData(opseno);
|
||||||
|
return ResponseMessage.ok("", oriData);
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/rollback")
|
||||||
|
public ResponseMessage rollback(Long opseno) {
|
||||||
|
try {
|
||||||
|
String logonName = currentUserService.getCurrentUser().getLogonName();
|
||||||
|
OpLogUtil.rollBack(opseno, logonName);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("回退失败!", e);
|
||||||
|
return ResponseMessage.error("回退失败:" + e.getMessage());
|
||||||
|
}
|
||||||
|
return ResponseMessage.ok("回退成功!");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,185 @@
|
|||||||
|
package com.insigma.sys.controller;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson2.JSONArray;
|
||||||
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
|
import com.insigma.framework.core.ResponseMessage;
|
||||||
|
import com.insigma.framework.core.util.DtoEntityUtil;
|
||||||
|
import com.insigma.framework.core.util.TreeUtil;
|
||||||
|
import com.insigma.framework.domain.core.entity.Aa26;
|
||||||
|
import com.insigma.framework.domain.core.entity.SysOrg;
|
||||||
|
import com.insigma.framework.web.support.core.service.CodeTypeService;
|
||||||
|
import com.insigma.sys.dto.Aa26DTO;
|
||||||
|
import com.insigma.sys.dto.SysOrgDTO;
|
||||||
|
import com.insigma.sys.service.Aa26Service;
|
||||||
|
import com.insigma.sys.service.SysOrgService;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 菜单管理
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/sys/org")
|
||||||
|
public class OrgController {
|
||||||
|
@Autowired
|
||||||
|
private SysOrgService sysOrgService;
|
||||||
|
@Autowired
|
||||||
|
private Aa26Service aa26Service;
|
||||||
|
@Autowired
|
||||||
|
private CodeTypeService codeTypeService;
|
||||||
|
/**
|
||||||
|
* 初始化页面数据
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping("/doInit")
|
||||||
|
public ResponseMessage doInit(@RequestBody JSONObject jsonObject) {
|
||||||
|
List<SysOrg> orgs=sysOrgService.getAll();
|
||||||
|
JSONArray jsonArray = TreeUtil.listToTree(JSONArray.parseArray(JSONArray.toJSONString(DtoEntityUtil.trans(orgs, SysOrgDTO.class, true))), "orgid", "parentid", "children");
|
||||||
|
return ResponseMessage.ok("查询成功", jsonArray);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 根据id查找org对象
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping("/findOrgById")
|
||||||
|
public ResponseMessage findOrgById(@RequestBody JSONObject jsonObject) {
|
||||||
|
ResponseMessage rm;
|
||||||
|
String a=jsonObject.get("orgid").toString();
|
||||||
|
SysOrg sysOrg;
|
||||||
|
if (a!=null){
|
||||||
|
int orgid= Integer.parseInt(a) ;
|
||||||
|
sysOrg=sysOrgService.getByOrgId((long) orgid);
|
||||||
|
rm= ResponseMessage.ok(null, DtoEntityUtil.trans(sysOrg, SysOrgDTO.class, true));
|
||||||
|
}else {
|
||||||
|
rm= ResponseMessage.error();
|
||||||
|
}
|
||||||
|
return rm;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 保存机构
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping("/saveOrg")
|
||||||
|
public ResponseMessage saveOrg(@RequestBody JSONObject jsonObject) {
|
||||||
|
ResponseMessage rm=null;
|
||||||
|
//List checkedCities= (List) jsonObject.get("checkedCities");
|
||||||
|
Map<String,Object> map= (Map<String, Object>) jsonObject.get("form");
|
||||||
|
SysOrg sysOrg=sysOrgService.getSysOrgBean(map);
|
||||||
|
Boolean flag=sysOrgService.isMany(sysOrg);
|
||||||
|
try {
|
||||||
|
if (flag==false){
|
||||||
|
//没有重复
|
||||||
|
if (sysOrg!=null){
|
||||||
|
sysOrgService.saveOrg(sysOrg);
|
||||||
|
rm= ResponseMessage.ok("保存成功");
|
||||||
|
}
|
||||||
|
}else {
|
||||||
|
//重复
|
||||||
|
rm= ResponseMessage.error("重复");
|
||||||
|
}
|
||||||
|
}catch (Exception e){
|
||||||
|
log.error(e.getMessage(), e);
|
||||||
|
rm = ResponseMessage.error(e.getMessage());
|
||||||
|
}
|
||||||
|
return rm;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 初始化页面aa26
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping("/initAA26")
|
||||||
|
public ResponseMessage initAA26() {
|
||||||
|
ResponseMessage rm;
|
||||||
|
try {
|
||||||
|
List<Aa26> aa26s = aa26Service.getAll();
|
||||||
|
JSONArray orgNodes = TreeUtil.listToTree(JSONArray.parseArray(JSONArray.toJSONString(DtoEntityUtil.trans(aa26s, Aa26DTO.class, true))), "aab301", "aaa148", "children");
|
||||||
|
rm= ResponseMessage.ok(null, orgNodes);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.getMessage(), e);
|
||||||
|
rm = ResponseMessage.error(e.getMessage());
|
||||||
|
}
|
||||||
|
return rm;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
根据id查找aa26
|
||||||
|
*/
|
||||||
|
@PostMapping("/queryAa26By301/{id}")
|
||||||
|
public ResponseMessage queryAa26By301(@PathVariable("id") String aab301) {
|
||||||
|
ResponseMessage rm;
|
||||||
|
try {
|
||||||
|
Aa26 aa26s = aa26Service.getByAab301(aab301);
|
||||||
|
rm= ResponseMessage.ok(null, DtoEntityUtil.trans(aa26s, Aa26DTO.class, true));
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.getMessage(), e);
|
||||||
|
rm = ResponseMessage.error(e.getMessage());
|
||||||
|
}
|
||||||
|
return rm;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 初始化页面数据
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping("/initCodeTypes")
|
||||||
|
public ResponseMessage initCodeTypes(@RequestBody JSONObject jsonObject) {
|
||||||
|
ResponseMessage rm;
|
||||||
|
try {
|
||||||
|
JSONObject codeTypes = codeTypeService.getCodeTypes(jsonObject);
|
||||||
|
rm = ResponseMessage.ok(null, codeTypes);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.getMessage(), e);
|
||||||
|
rm = ResponseMessage.error(e.getMessage());
|
||||||
|
}
|
||||||
|
return rm;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping("/queryUserOrg")
|
||||||
|
public ResponseMessage queryUserOrg(@RequestBody JSONObject jsonObject) {
|
||||||
|
ResponseMessage rm;
|
||||||
|
String regioncode="";
|
||||||
|
long node=Long.valueOf(jsonObject.get("node").toString());
|
||||||
|
Map<String,Object> form= (Map<String, Object>) jsonObject.get("form");
|
||||||
|
// JSONArray orgTreeData=jsonObject.getJSONArray("orgTreeData"); // 首先转成 JSONArray 对象
|
||||||
|
// String trees=orgTreeData.toJSONString();
|
||||||
|
List<SysOrg> list=sysOrgService.findNodes(node);
|
||||||
|
boolean s =sysOrgService.findByArea(list);
|
||||||
|
if (s==true){
|
||||||
|
rm= ResponseMessage.ok("有联系");
|
||||||
|
}else {
|
||||||
|
rm= ResponseMessage.error("没联系");
|
||||||
|
}
|
||||||
|
return rm;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 删除机构
|
||||||
|
*/
|
||||||
|
@PostMapping("/deleteOrg")
|
||||||
|
public ResponseMessage deleteMenu(@RequestBody JSONObject pageData){
|
||||||
|
ResponseMessage rm;
|
||||||
|
long node=Long.valueOf(pageData.get("node").toString());
|
||||||
|
boolean withUser= (boolean) pageData.get("withUser");
|
||||||
|
List<SysOrg> list=sysOrgService.findNodes(node);
|
||||||
|
try {
|
||||||
|
if (list.size()>0){
|
||||||
|
//withUser为true则和用户有关
|
||||||
|
sysOrgService.delOrg(list,withUser);
|
||||||
|
rm= ResponseMessage.ok("删除成功");
|
||||||
|
}else {
|
||||||
|
rm= ResponseMessage.error("数据不存在");
|
||||||
|
}
|
||||||
|
}catch (Exception e){
|
||||||
|
log.error(e.getMessage(), e);
|
||||||
|
rm = ResponseMessage.error(e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
return rm;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
package com.insigma.sys.controller;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
|
import com.insigma.framework.core.ResponseMessage;
|
||||||
|
import com.insigma.framework.core.exception.AppException;
|
||||||
|
import com.insigma.framework.persistence.core.jdbc.PageInfo;
|
||||||
|
import com.insigma.sys.dto.Aa01DTO;
|
||||||
|
import com.insigma.sys.service.Aa01Service;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author yinjh
|
||||||
|
* @version 2022/10/17
|
||||||
|
* @since 2.7.0
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/sys/param/config")
|
||||||
|
public class ParamConfigController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private Aa01Service aa01Service;
|
||||||
|
|
||||||
|
@GetMapping("/query")
|
||||||
|
public ResponseMessage query(String aaa001, String aaa002, Integer page, Integer size) {
|
||||||
|
PageInfo<Aa01DTO> pageInfo = aa01Service.query(aaa001, aaa002, page, size);
|
||||||
|
return ResponseMessage.ok(null, pageInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/insert")
|
||||||
|
public ResponseMessage insert(@RequestBody Aa01DTO aa01) {
|
||||||
|
aa01Service.save(aa01, false);
|
||||||
|
return ResponseMessage.ok("保存成功");
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/update")
|
||||||
|
public ResponseMessage update(@RequestBody Aa01DTO aa01) {
|
||||||
|
aa01Service.save(aa01, true);
|
||||||
|
return ResponseMessage.ok("修改成功");
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/delete")
|
||||||
|
public ResponseMessage delete(@RequestBody JSONObject jsonObject) throws AppException {
|
||||||
|
String aaa001 = jsonObject.getString("aaa001");
|
||||||
|
aa01Service.deleteByAaa001(aaa001);
|
||||||
|
return ResponseMessage.ok("删除成功");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,222 @@
|
|||||||
|
package com.insigma.sys.controller;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson2.JSONArray;
|
||||||
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
|
import com.insigma.framework.core.ResponseMessage;
|
||||||
|
import com.insigma.framework.core.util.TreeUtil;
|
||||||
|
import com.insigma.framework.domain.core.entity.SysRole;
|
||||||
|
import com.insigma.framework.domain.core.entity.SysUser;
|
||||||
|
import com.insigma.framework.persistence.core.jdbc.PageInfo;
|
||||||
|
import com.insigma.framework.web.support.core.service.CodeTypeService;
|
||||||
|
import com.insigma.sys.common.CurrentUserService;
|
||||||
|
import com.insigma.sys.common.SysManageMode;
|
||||||
|
import com.insigma.sys.dto.MenuDTO;
|
||||||
|
import com.insigma.sys.dto.SysRoleDTO;
|
||||||
|
import com.insigma.sys.dto.SysUserDTO;
|
||||||
|
import com.insigma.sys.service.SysFunctionService;
|
||||||
|
import com.insigma.sys.service.SysRoleService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by zhangxy on 2019/1/4.
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/sys/role")
|
||||||
|
public class RoleController {
|
||||||
|
@Autowired
|
||||||
|
private CodeTypeService codeTypeService;
|
||||||
|
@Autowired
|
||||||
|
private SysRoleService sysRoleService;
|
||||||
|
@Autowired
|
||||||
|
private SysFunctionService sysFunctionService;
|
||||||
|
@Autowired
|
||||||
|
private CurrentUserService currentUserService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 初始化页面数据
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping("/doInit")
|
||||||
|
public ResponseMessage initPageDate(@RequestBody JSONObject jsonObject) {
|
||||||
|
JSONObject codeTypes = jsonObject.getJSONObject("codeTypes");
|
||||||
|
JSONObject codeTypesRes = codeTypeService.getCodeTypes(codeTypes);
|
||||||
|
jsonObject.put("codeTypes", codeTypesRes);
|
||||||
|
return ResponseMessage.ok(null, jsonObject);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@PostMapping("/initCodeTypes")
|
||||||
|
public ResponseMessage initCodeTypes(@RequestBody JSONObject jsonObject) {
|
||||||
|
ResponseMessage rm;
|
||||||
|
try {
|
||||||
|
JSONObject codeTypes = codeTypeService.getCodeTypes(jsonObject);
|
||||||
|
rm = ResponseMessage.ok(null, codeTypes);
|
||||||
|
} catch (Exception e) {
|
||||||
|
rm = ResponseMessage.error(e.getMessage());
|
||||||
|
}
|
||||||
|
return rm;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@PostMapping("/save")
|
||||||
|
public ResponseMessage saveRole(@RequestBody SysRoleDTO sysRoleDTO) {
|
||||||
|
ResponseMessage rm = null;
|
||||||
|
String roleid = sysRoleDTO.getRoleid();
|
||||||
|
String rolename = sysRoleDTO.getRolename();
|
||||||
|
boolean flag = sysRoleService.checkRoleByRolename(rolename);
|
||||||
|
if (!"".equals(roleid) && roleid != null) {//说明是更新
|
||||||
|
flag = sysRoleService.checkRoleByRolenameAndRoleid(rolename, roleid);
|
||||||
|
}
|
||||||
|
if (flag) {
|
||||||
|
try {
|
||||||
|
SysUser sysUser = currentUserService.getCurrentUser();
|
||||||
|
Long areaid = sysUser.getAreaId();
|
||||||
|
Long orgid = sysUser.getOrgId();
|
||||||
|
String userid = sysUser.getUserId();
|
||||||
|
sysRoleDTO.setAreaid(areaid);
|
||||||
|
sysRoleDTO.setOrgid(orgid);
|
||||||
|
sysRoleDTO.setCreatorid(userid);
|
||||||
|
sysRoleService.save(sysRoleDTO);
|
||||||
|
rm = ResponseMessage.ok("保存成功");
|
||||||
|
} catch (Exception e) {
|
||||||
|
rm = ResponseMessage.error(e.getMessage());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
rm = ResponseMessage.error("该角色名称已被其他行政区或机构占用!");
|
||||||
|
}
|
||||||
|
return rm;
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/queryRole")
|
||||||
|
public ResponseMessage queryRole(@RequestParam(name = "rolename") String rolename,
|
||||||
|
@RequestParam(name = "roledesc") String roledesc,
|
||||||
|
@RequestParam(name = "roletype") String roletype,
|
||||||
|
@RequestParam(name = "page") Integer page,
|
||||||
|
@RequestParam(name = "size") Integer size) {
|
||||||
|
SysUser sysUser = currentUserService.getCurrentUser();
|
||||||
|
Long areaid = sysUser.getAreaId();
|
||||||
|
Long orgid = sysUser.getOrgId();
|
||||||
|
String usertype = sysUser.getUserType();
|
||||||
|
|
||||||
|
if (SysManageMode.isTripleMode()) {//三员制
|
||||||
|
if ("5".equals(usertype)) {//安全管理员
|
||||||
|
usertype = "1";//按照超级管理员处理,可以查询所有的角色
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ResponseMessage rm;
|
||||||
|
if (!"".equals(usertype) && usertype != null) {
|
||||||
|
PageInfo<SysRoleDTO> pageInfo = sysRoleService.query(rolename, roledesc, roletype, page, size, areaid, orgid, usertype);
|
||||||
|
rm = ResponseMessage.ok(null, pageInfo);
|
||||||
|
} else {//非管理员角色,不能看到任何角色
|
||||||
|
rm = ResponseMessage.ok();
|
||||||
|
}
|
||||||
|
return rm;
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/delete")
|
||||||
|
public ResponseMessage delete(@RequestBody SysRoleDTO sysRoleDTO) {
|
||||||
|
SysRole role = sysRoleService.getByRoleId(sysRoleDTO.getRoleid());
|
||||||
|
if (role == null) {
|
||||||
|
return ResponseMessage.error("角色不存在");
|
||||||
|
}
|
||||||
|
SysUser sysUser = currentUserService.getCurrentUser();
|
||||||
|
if (!sysRoleService.roleCanOperate(sysUser, role)) {
|
||||||
|
return ResponseMessage.error("无权操作");
|
||||||
|
}
|
||||||
|
sysRoleService.deleteRoleRef(role);
|
||||||
|
return ResponseMessage.ok("删除成功");
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/queryTree")
|
||||||
|
public ResponseMessage queryTable(String roletype) {
|
||||||
|
String funtype = "";
|
||||||
|
if (roletype != null && !"".equals(roletype)) {
|
||||||
|
if ("1".equals(roletype)) {//管理员角色
|
||||||
|
funtype = "1";
|
||||||
|
} else if ("2".equals(roletype)) {
|
||||||
|
funtype = "2";
|
||||||
|
} else if ("3".equals(roletype)) {
|
||||||
|
funtype = "3";
|
||||||
|
} else if ("4".equals(roletype)) {
|
||||||
|
funtype = "4";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
List<MenuDTO> menuDTOS = sysFunctionService.queryMenuByFuntypeAndActive(funtype);
|
||||||
|
JSONArray jsonArray = TreeUtil.listToTree(JSONArray.parseArray(JSONArray.toJSONString(menuDTOS)), "functionid"
|
||||||
|
, "parentid", "children", "0");
|
||||||
|
return ResponseMessage.ok("查询成功", jsonArray);
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/getCheckedTree")
|
||||||
|
public ResponseMessage getCheckedTree(String roleId) {
|
||||||
|
List<Long> list = sysRoleService.queryFuncitonidByRoleid(roleId);
|
||||||
|
return ResponseMessage.ok("查询成功", list);
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/addRoleRef")
|
||||||
|
public ResponseMessage addRoleRef(@RequestBody JSONObject jsonObject) {
|
||||||
|
String roleid = (String) jsonObject.get("roleId");
|
||||||
|
SysRole role = sysRoleService.getByRoleId(roleid);
|
||||||
|
if (role == null) {
|
||||||
|
return ResponseMessage.error("角色不存在");
|
||||||
|
}
|
||||||
|
SysUser sysUser = currentUserService.getCurrentUser();
|
||||||
|
if (!sysRoleService.roleCanOperate(sysUser, role)) {
|
||||||
|
return ResponseMessage.error("无权操作");
|
||||||
|
}
|
||||||
|
sysRoleService.saveGrant(currentUserService.getCurrentUser(), role, jsonObject);
|
||||||
|
return ResponseMessage.ok("授权成功");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@GetMapping("getRoleTypeCode")
|
||||||
|
public ResponseMessage getUserTypeCode() {
|
||||||
|
List<Map<String, Object>> list = sysRoleService.findRoleTypesCode();
|
||||||
|
return ResponseMessage.ok(null, list);
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/queryToGrantUser")
|
||||||
|
public ResponseMessage queryToGrantUser(
|
||||||
|
@RequestParam(name = "roleId") String roleId,
|
||||||
|
@RequestParam(name = "roleType") String roleType,
|
||||||
|
@RequestParam(name = "logonname") String logonname,
|
||||||
|
@RequestParam(name = "displayname") String displayname,
|
||||||
|
@RequestParam(name = "page") Integer page,
|
||||||
|
@RequestParam(name = "size") Integer size) throws SQLException {
|
||||||
|
SysUser sysUser = currentUserService.getCurrentUser();
|
||||||
|
PageInfo<SysUserDTO> list = sysRoleService.queryToGrantUser(roleId, roleType, logonname, displayname, page, size);
|
||||||
|
return ResponseMessage.ok("查询成功", list);
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/queryGrantedUser")
|
||||||
|
public ResponseMessage queryGrantedUser(@RequestParam(name = "roleId") String roleId) throws SQLException {
|
||||||
|
SysUser sysUser = currentUserService.getCurrentUser();
|
||||||
|
SysRole sysRole = sysRoleService.getByRoleId(roleId);
|
||||||
|
if (!sysRoleService.roleCanOperate(sysUser, sysRole)) {
|
||||||
|
return ResponseMessage.error("无权访问");
|
||||||
|
}
|
||||||
|
List<SysUserDTO> list = sysRoleService.queryGrantedUser(roleId);
|
||||||
|
return ResponseMessage.ok("查询成功", list);
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/removeGrantUserRole")
|
||||||
|
public ResponseMessage removeGrantUserRole(@RequestParam(name = "roleId") String roleId,
|
||||||
|
@RequestParam(name = "userId") String userId) throws SQLException {
|
||||||
|
sysRoleService.removeGrantUserRole(roleId, userId);
|
||||||
|
return ResponseMessage.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/saveGrantUser")
|
||||||
|
public ResponseMessage saveGrantUser(@RequestBody JSONObject jsonObject) {
|
||||||
|
sysRoleService.saveGrantUser(jsonObject);
|
||||||
|
return ResponseMessage.ok("保存成功");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
package com.insigma.sys.controller;
|
||||||
|
|
||||||
|
import com.insigma.framework.core.ResponseMessage;
|
||||||
|
import com.insigma.framework.security.core.dto.BaseUserInfo;
|
||||||
|
import com.insigma.framework.security.core.exception.UnauthorizedException;
|
||||||
|
import com.insigma.framework.security.web.handler.SysLoginHandler;
|
||||||
|
import com.insigma.sys.common.CurrentUserService;
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 单点登录控制器
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping({"/sso", "/check"})
|
||||||
|
public class SSOController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private CurrentUserService currentUserService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SysLoginHandler sysLoginHandler;
|
||||||
|
|
||||||
|
@PostMapping("/login")
|
||||||
|
public ResponseMessage login(HttpServletRequest request) {
|
||||||
|
try {
|
||||||
|
BaseUserInfo userInfo = sysLoginHandler.success(currentUserService.getCurrentUserDetails(), null, request);
|
||||||
|
return ResponseMessage.ok("", userInfo);
|
||||||
|
} catch (UnauthorizedException e) {
|
||||||
|
ResponseMessage rm = new ResponseMessage();
|
||||||
|
rm.setStatus("401");
|
||||||
|
rm.setMessage(e.getMessage());
|
||||||
|
return rm;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
package com.insigma.sys.controller;
|
||||||
|
|
||||||
|
import com.insigma.framework.core.ResponseMessage;
|
||||||
|
import com.insigma.framework.persistence.core.jdbc.PageInfo;
|
||||||
|
import com.insigma.sys.dto.SafetyFilterLogDTO;
|
||||||
|
import com.insigma.sys.service.SafetyFilterLogService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author yinjh
|
||||||
|
* @version 2022/9/15
|
||||||
|
* @since 2.7.0
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/safety/filter/log")
|
||||||
|
public class SafetyFilterLogController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SafetyFilterLogService safetyFilterLogService;
|
||||||
|
|
||||||
|
@PostMapping("/query")
|
||||||
|
public ResponseMessage query(@RequestBody SafetyFilterLogDTO safetyFilterLogDTO) {
|
||||||
|
PageInfo<SafetyFilterLogDTO> pageInfo = safetyFilterLogService.query(safetyFilterLogDTO);
|
||||||
|
return ResponseMessage.ok(null, pageInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,323 @@
|
|||||||
|
package com.insigma.sys.controller;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson2.JSONArray;
|
||||||
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
|
import com.insigma.framework.core.ResponseMessage;
|
||||||
|
import com.insigma.framework.core.encryption.util.SM3Utils;
|
||||||
|
import com.insigma.framework.core.util.ByteUtil;
|
||||||
|
import com.insigma.framework.domain.core.entity.SysUser;
|
||||||
|
import com.insigma.framework.security.core.password.SM3PasswordEncoder;
|
||||||
|
import com.insigma.framework.web.support.core.service.CodeTypeService;
|
||||||
|
import com.insigma.framework.web.support.ep.dev.annotation.OdinRequest;
|
||||||
|
import com.insigma.framework.web.support.ep.dev.annotation.OdinRequestParam;
|
||||||
|
import com.insigma.framework.web.support.ep.dev.controller.BaseController;
|
||||||
|
import com.insigma.framework.web.support.ep.dev.util.pe.PageTable;
|
||||||
|
import com.insigma.sys.common.CurrentUserService;
|
||||||
|
import com.insigma.sys.dto.SysAppAddressDTO;
|
||||||
|
import com.insigma.sys.dto.SysAppDTO;
|
||||||
|
import com.insigma.sys.service.SysAppService;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.util.ObjectUtils;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.security.SecureRandom;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 应用系统管理接口
|
||||||
|
*
|
||||||
|
* @author GH
|
||||||
|
* @version 2022/3/28
|
||||||
|
* @since 2.6.5
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/sys/sysapp/sysApp")
|
||||||
|
public class SysAppController extends BaseController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private CurrentUserService currentUserService;
|
||||||
|
@Autowired
|
||||||
|
private SysAppService sysAppService;
|
||||||
|
@Autowired
|
||||||
|
private CodeTypeService codeTypeService;
|
||||||
|
|
||||||
|
|
||||||
|
@OdinRequest(init = true)
|
||||||
|
@PostMapping("/doInit")
|
||||||
|
public ResponseMessage doInit(@OdinRequestParam("f_form") SysAppDTO queryDTO, Integer size) throws SQLException {
|
||||||
|
tableDataQuery(queryDTO, 1, size);
|
||||||
|
return this.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
@OdinRequest
|
||||||
|
@PostMapping("/query")
|
||||||
|
public ResponseMessage doGridQuery(@OdinRequestParam("f_form") SysAppDTO queryDTO,
|
||||||
|
Integer size) {
|
||||||
|
tableDataQuery(queryDTO, 1, size);
|
||||||
|
return this.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
@OdinRequest
|
||||||
|
@PostMapping("/doGridQuery/{name}")
|
||||||
|
public ResponseMessage doGridQuery(@OdinRequestParam("f_form") SysAppDTO queryDTO,
|
||||||
|
@OdinRequestParam("t_tableData_page") Integer page,
|
||||||
|
@OdinRequestParam("t_tableData_size") Integer size,
|
||||||
|
@PathVariable String name) {
|
||||||
|
tableDataQuery(queryDTO, page, size);
|
||||||
|
this.set("page", page);
|
||||||
|
return this.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void tableDataQuery(SysAppDTO queryDTO, Integer page, Integer size) {
|
||||||
|
this.pageQuery("t_tableData", () -> {
|
||||||
|
this.set("page", page); // 需要将前端表格中:currentPage定义的值设置成page的值
|
||||||
|
return sysAppService.pageQuery(queryDTO, page, size);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@OdinRequest
|
||||||
|
@PostMapping("/add")
|
||||||
|
public ResponseMessage add() {
|
||||||
|
this.set("dialogFormVisible", true);
|
||||||
|
this.set("dialogFormTitle", "新增应用");
|
||||||
|
this.clearForm("f_sysAppForm");
|
||||||
|
this.getTable("t_tableData1").setData(new ArrayList<>());
|
||||||
|
this.getTable("t_tableData1").setTotal(0L);
|
||||||
|
return this.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@OdinRequest
|
||||||
|
@PostMapping("/doSave/{name}")
|
||||||
|
public ResponseMessage doSave(@OdinRequestParam("f_sysAppForm") SysAppDTO sysAppDTO) {
|
||||||
|
PageTable t_tableData1 = this.getTable("t_tableData1");
|
||||||
|
List<SysAppAddressDTO> listsysAppAddressDTO = t_tableData1.getData(SysAppAddressDTO.class);
|
||||||
|
String portalurl = null;
|
||||||
|
String appurl = null;
|
||||||
|
for (int i = 0; i < listsysAppAddressDTO.size(); i++) {
|
||||||
|
portalurl = listsysAppAddressDTO.get(i).getPortalUrl();
|
||||||
|
if (portalurl == null || "".equals(portalurl)) {
|
||||||
|
return this.error("门户名称不能为空");
|
||||||
|
}
|
||||||
|
appurl = listsysAppAddressDTO.get(i).getAppUrl();
|
||||||
|
if (appurl == null || "".equals(appurl)) {
|
||||||
|
return this.error("应用地址不能为空");
|
||||||
|
} else {
|
||||||
|
if (appurl.indexOf("http://") == 0 || appurl.indexOf("https://") == 0) {
|
||||||
|
|
||||||
|
} else {
|
||||||
|
return this.error("门户名称为" + portalurl + "的应用地址不合法,请检查!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ObjectUtils.isEmpty(sysAppDTO.getAppId())) {
|
||||||
|
boolean flag = sysAppService.selectAppCode(sysAppDTO.getAppCode());
|
||||||
|
if (flag) {
|
||||||
|
return ResponseMessage.error("异常应用编码重复!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ObjectUtils.isEmpty(sysAppDTO.getAppId())) {
|
||||||
|
String secretKey = generateSecretKey();
|
||||||
|
sysAppDTO.setSecretKey(secretKey);
|
||||||
|
}
|
||||||
|
sysAppService.saveSysApp(sysAppDTO, listsysAppAddressDTO);
|
||||||
|
this.set("dialogFormVisible", false);
|
||||||
|
this.clearForm("f_sysAppForm");
|
||||||
|
this.getTable("t_tableData1").setData(new ArrayList<>());
|
||||||
|
this.getTable("t_tableData1").setTotal(0L);
|
||||||
|
this.refresh();
|
||||||
|
return this.ok("保存成功!");
|
||||||
|
}
|
||||||
|
|
||||||
|
@OdinRequest
|
||||||
|
@PostMapping("/update")
|
||||||
|
public ResponseMessage update(String appId) {
|
||||||
|
SysAppDTO sysAppDTO = sysAppService.querySysApp(appId);
|
||||||
|
this.toForm("f_sysAppForm", sysAppDTO);
|
||||||
|
List<SysAppAddressDTO> list = sysAppService.querySysAddressDTO(appId);
|
||||||
|
this.getTable("t_tableData1").setData(list);
|
||||||
|
this.set("dialogFormVisible", true);
|
||||||
|
this.set("dialogFormTitle", "修改应用");
|
||||||
|
return this.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
@OdinRequest(refresh = true) // refresh = true 请求结束后刷新页面
|
||||||
|
@PostMapping("/delete")
|
||||||
|
public ResponseMessage delete(String appId) {
|
||||||
|
sysAppService.deleteSysApp(appId);
|
||||||
|
return this.ok("删除成功!");
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/deleteSysAppAddress")
|
||||||
|
public ResponseMessage deleteSysAppAddress(@RequestBody SysAppAddressDTO sysAppAddressDTO) {
|
||||||
|
if (sysAppAddressDTO.getAddressId() == null || "".equals(sysAppAddressDTO.getAddressId())) {
|
||||||
|
return this.ok("删除成功!");
|
||||||
|
}
|
||||||
|
sysAppService.deleteSysAppAddress(sysAppAddressDTO.getAddressId());
|
||||||
|
return this.ok("删除成功!");
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/toActiveSysApp")
|
||||||
|
public ResponseMessage toActiveSysApp(@RequestParam(name = "appId") String appId) {
|
||||||
|
sysAppService.toActiveSysApp(appId);
|
||||||
|
return this.ok("启用成功!");
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/toNotActiveSysApp")
|
||||||
|
public ResponseMessage toNotActiveSysApp(@RequestParam(name = "appId") String appId) {
|
||||||
|
sysAppService.toNotActiveSysApp(appId);
|
||||||
|
return this.ok("禁用成功!");
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/verify")
|
||||||
|
public ResponseMessage verify(@RequestBody JSONObject jsonObject) {
|
||||||
|
//获取当前登录人去验证密码是否正确
|
||||||
|
SysUser sysUser = currentUserService.getCurrentUser();
|
||||||
|
String password = jsonObject.getString("password");
|
||||||
|
String id = jsonObject.getString("id");
|
||||||
|
SM3PasswordEncoder sm3PasswordEncoder = new SM3PasswordEncoder();
|
||||||
|
boolean b = sm3PasswordEncoder.matches(SM3Utils.digest(password), sysUser.getPassWD());
|
||||||
|
HashMap<String, Object> map = new HashMap<>();
|
||||||
|
if(b){
|
||||||
|
//查询安全key
|
||||||
|
SysAppDTO sysAppDTO = sysAppService.querySysApp(id);
|
||||||
|
map.put("appId",sysAppDTO.getAppId());
|
||||||
|
map.put("secretKey",sysAppDTO.getSecretKey());
|
||||||
|
map.put("verify",b);
|
||||||
|
}
|
||||||
|
map.put("verify",b);
|
||||||
|
return ResponseMessage.ok(null, map);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 以下都是vue3的请求
|
||||||
|
*/
|
||||||
|
@PostMapping("/new/initCodeTypes")
|
||||||
|
public ResponseMessage initCodeTypesVue3(@RequestBody JSONObject jsonObject) {
|
||||||
|
ResponseMessage rm;
|
||||||
|
try {
|
||||||
|
JSONObject codeTypes = codeTypeService.getCodeTypes(jsonObject);
|
||||||
|
rm = ResponseMessage.ok(codeTypes);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.getMessage(), e);
|
||||||
|
rm = ResponseMessage.error(e.getMessage());
|
||||||
|
}
|
||||||
|
return rm;
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/new/queryApp")
|
||||||
|
public ResponseMessage queryAppVue3(@RequestBody SysAppDTO sysAppDTO) {
|
||||||
|
return ResponseMessage.ok(sysAppService.pageQuery(sysAppDTO,sysAppDTO.getPage(),sysAppDTO.getSize()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/new/toActiveSysApp")
|
||||||
|
public ResponseMessage toActiveSysAppVue3(@RequestParam(name = "appId") String appId) {
|
||||||
|
sysAppService.toActiveSysApp(appId);
|
||||||
|
return ResponseMessage.ok("启用成功!");
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/new/toNotActiveSysApp")
|
||||||
|
public ResponseMessage toNotActiveSysAppVue3(@RequestParam(name = "appId") String appId) {
|
||||||
|
sysAppService.toNotActiveSysApp(appId);
|
||||||
|
return ResponseMessage.ok("禁用成功!");
|
||||||
|
}
|
||||||
|
@PostMapping("/new/verify")
|
||||||
|
public ResponseMessage verifyVue3(@RequestBody JSONObject jsonObject) {
|
||||||
|
//获取当前登录人去验证密码是否正确
|
||||||
|
SysUser sysUser = currentUserService.getCurrentUser();
|
||||||
|
String password = jsonObject.getString("password");
|
||||||
|
String id = jsonObject.getString("id");
|
||||||
|
SM3PasswordEncoder sm3PasswordEncoder = new SM3PasswordEncoder();
|
||||||
|
boolean b = sm3PasswordEncoder.matches(SM3Utils.digest(password), sysUser.getPassWD());
|
||||||
|
HashMap<String, Object> map = new HashMap<>();
|
||||||
|
if(b){
|
||||||
|
//查询安全key
|
||||||
|
SysAppDTO sysAppDTO = sysAppService.querySysApp(id);
|
||||||
|
map.put("appId",sysAppDTO.getAppId());
|
||||||
|
map.put("secretKey",sysAppDTO.getSecretKey());
|
||||||
|
map.put("verify",b);
|
||||||
|
}
|
||||||
|
map.put("verify",b);
|
||||||
|
return ResponseMessage.ok(map);
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/new/delete")
|
||||||
|
public ResponseMessage deleteVue3(@RequestParam(name = "appId") String appId) {
|
||||||
|
sysAppService.deleteSysApp(appId);
|
||||||
|
return ResponseMessage.ok("删除成功!");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@PostMapping("/new/save")
|
||||||
|
public ResponseMessage doSaveVue3(@RequestBody JSONObject jsonObject) throws Exception {
|
||||||
|
JSONArray jsonArray =jsonObject.getJSONArray("tableData1");
|
||||||
|
List<SysAppAddressDTO> listsysAppAddressDTO=jsonArray.toList(SysAppAddressDTO.class);
|
||||||
|
String portalurl = null;
|
||||||
|
String appurl = null;
|
||||||
|
for (int i = 0; i < listsysAppAddressDTO.size(); i++) {
|
||||||
|
portalurl = listsysAppAddressDTO.get(i).getPortalUrl();
|
||||||
|
if (portalurl == null || "".equals(portalurl)) {
|
||||||
|
return ResponseMessage.error("门户地址不能为空");
|
||||||
|
}
|
||||||
|
appurl = listsysAppAddressDTO.get(i).getAppUrl();
|
||||||
|
if (appurl == null || "".equals(appurl)) {
|
||||||
|
return ResponseMessage.error("应用地址不能为空");
|
||||||
|
} else {
|
||||||
|
if (appurl.indexOf("http://") == 0 || appurl.indexOf("https://") == 0) {
|
||||||
|
|
||||||
|
} else {
|
||||||
|
return ResponseMessage.error("门户地址为" + portalurl + "的应用地址不合法,请检查!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
JSONObject jsonObject1=jsonObject.getJSONObject("sysAppDTO");
|
||||||
|
SysAppDTO sysAppDTO=new SysAppDTO();
|
||||||
|
sysAppDTO.setAppId(jsonObject1.getString("appId"));
|
||||||
|
sysAppDTO.setAppCode(jsonObject1.getString("appCode"));
|
||||||
|
sysAppDTO.setAppName(jsonObject1.getString("appName"));
|
||||||
|
|
||||||
|
if (ObjectUtils.isEmpty(jsonObject.getString("appId"))) {
|
||||||
|
boolean flag = sysAppService.selectAppCode(jsonObject.getString("appCode"));
|
||||||
|
if (flag) {
|
||||||
|
return ResponseMessage.error("异常应用编码重复!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ObjectUtils.isEmpty(sysAppDTO.getAppId())) {
|
||||||
|
String secretKey = generateSecretKey();
|
||||||
|
sysAppDTO.setSecretKey(secretKey);
|
||||||
|
}
|
||||||
|
sysAppService.saveSysApp(sysAppDTO, listsysAppAddressDTO);
|
||||||
|
return ResponseMessage.ok("保存成功!");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@GetMapping("/new/update")
|
||||||
|
public ResponseMessage updateVue3(String appId) {
|
||||||
|
List<SysAppAddressDTO> list = sysAppService.querySysAddressDTO(appId);
|
||||||
|
return ResponseMessage.ok(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/new/deleteSysAppAddress")
|
||||||
|
public ResponseMessage deleteSysAppAddressVue3(String addressId) {
|
||||||
|
if (addressId == null || "".equals(addressId)) {
|
||||||
|
return ResponseMessage.ok("删除成功!");
|
||||||
|
}
|
||||||
|
sysAppService.deleteSysAppAddress(addressId);
|
||||||
|
return ResponseMessage.ok("删除成功!");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private String generateSecretKey() {
|
||||||
|
byte[] bytes = new byte[8];
|
||||||
|
SecureRandom random = new SecureRandom();
|
||||||
|
random.nextBytes(bytes);
|
||||||
|
return ByteUtil.byteToHex(bytes);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,56 @@
|
|||||||
|
package com.insigma.sys.controller;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
|
import com.insigma.framework.core.ResponseMessage;
|
||||||
|
import com.insigma.framework.core.exception.AppException;
|
||||||
|
import com.insigma.framework.persistence.core.jdbc.PageInfo;
|
||||||
|
import com.insigma.framework.web.support.core.service.CodeTypeService;
|
||||||
|
import com.insigma.sys.dto.Aa10DTO;
|
||||||
|
import com.insigma.sys.service.Aa10Service;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 字典管理模块
|
||||||
|
*
|
||||||
|
* @author yinjh
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/sys/code")
|
||||||
|
public class SysCodeController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private Aa10Service aa10Service;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private CodeTypeService codeTypeService;
|
||||||
|
|
||||||
|
@PostMapping("/initCodeTypes")
|
||||||
|
public ResponseMessage initCodeTypes(@RequestBody JSONObject jsonObject) {
|
||||||
|
JSONObject codeTypes = codeTypeService.getCodeTypes(jsonObject);
|
||||||
|
return ResponseMessage.ok(null, codeTypes);
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/query")
|
||||||
|
public ResponseMessage query(String aaa100, String aaa103, Integer page, Integer size) {
|
||||||
|
PageInfo<Aa10DTO> pageInfo = aa10Service.query(aaa100, aaa103, page, size);
|
||||||
|
return ResponseMessage.ok(null, pageInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/save")
|
||||||
|
public ResponseMessage save(@RequestBody Aa10DTO aa10DTO) {
|
||||||
|
aa10Service.saveCode(aa10DTO);
|
||||||
|
return ResponseMessage.ok("保存成功");
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/delete")
|
||||||
|
public ResponseMessage delete(@RequestBody JSONObject jsonObject) {
|
||||||
|
try {
|
||||||
|
Long aaz093=Long.valueOf(jsonObject.get("aaz093").toString());
|
||||||
|
aa10Service.deleteCode(aaz093);
|
||||||
|
}catch (Exception e){
|
||||||
|
throw new AppException("数据转换异常!");
|
||||||
|
}
|
||||||
|
return ResponseMessage.ok("删除成功");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,575 @@
|
|||||||
|
package com.insigma.sys.controller;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson2.JSONArray;
|
||||||
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
|
import com.insigma.framework.core.ResponseMessage;
|
||||||
|
import com.insigma.framework.core.exception.AppException;
|
||||||
|
import com.insigma.framework.core.util.StringUtil;
|
||||||
|
import com.insigma.framework.domain.core.entity.SysUser;
|
||||||
|
import com.insigma.framework.file.storage.core.FSObject;
|
||||||
|
import com.insigma.framework.file.storage.core.FSService;
|
||||||
|
import com.insigma.framework.web.support.core.service.CodeTypeService;
|
||||||
|
import com.insigma.framework.web.support.ep.dev.annotation.OdinRequest;
|
||||||
|
import com.insigma.framework.web.support.ep.dev.annotation.OdinRequestParam;
|
||||||
|
import com.insigma.framework.web.support.ep.dev.controller.BaseController;
|
||||||
|
import com.insigma.sys.common.CurrentUserService;
|
||||||
|
import com.insigma.sys.dto.SysDownloadCenterDTO;
|
||||||
|
import com.insigma.sys.service.SysDownloadCenterService;
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.http.MediaType;
|
||||||
|
import org.springframework.util.ObjectUtils;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
import java.io.BufferedInputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.OutputStream;
|
||||||
|
import java.text.DecimalFormat;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.zip.ZipEntry;
|
||||||
|
import java.util.zip.ZipOutputStream;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author GH
|
||||||
|
* @ClassName: SysDownloadCenterController
|
||||||
|
* @Description:
|
||||||
|
* @version 2021/8/4 10:13
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/sys/downloadcenter/DownloadCenter")
|
||||||
|
public class SysDownloadCenterController extends BaseController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SysDownloadCenterService sysDownloadCenterService;
|
||||||
|
|
||||||
|
@Autowired(required = false)
|
||||||
|
private FSService fsService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private CurrentUserService currentUserService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private CodeTypeService codeTypeService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 初始化
|
||||||
|
*
|
||||||
|
* @param f_form
|
||||||
|
* @param size
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@OdinRequest(init = true)
|
||||||
|
@PostMapping("/doInit")
|
||||||
|
public ResponseMessage doInit(SysDownloadCenterDTO f_form, Integer size) {
|
||||||
|
tableDataQuery(f_form, 1, size);
|
||||||
|
return this.ok();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询
|
||||||
|
*
|
||||||
|
* @param queryDTO
|
||||||
|
* @param size
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@OdinRequest
|
||||||
|
@PostMapping("/query")
|
||||||
|
public ResponseMessage query(@OdinRequestParam("f_form") SysDownloadCenterDTO queryDTO,
|
||||||
|
Integer size) {
|
||||||
|
tableDataQuery(queryDTO, 1, size);
|
||||||
|
return this.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return
|
||||||
|
* @Description: 分页查询
|
||||||
|
* @author GH
|
||||||
|
* @version 2021/8/4 13:29
|
||||||
|
*/
|
||||||
|
@OdinRequest
|
||||||
|
@PostMapping("/doGridQuery/{name}")
|
||||||
|
public ResponseMessage doGridQuery(@OdinRequestParam("f_form") SysDownloadCenterDTO queryDTO,
|
||||||
|
@OdinRequestParam("t_tableData_page") Integer page,
|
||||||
|
@OdinRequestParam("t_tableData_size") Integer size,
|
||||||
|
@PathVariable String name) {
|
||||||
|
tableDataQuery(queryDTO, page, size);
|
||||||
|
return this.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void tableDataQuery(SysDownloadCenterDTO queryDTO, Integer page, Integer size) {
|
||||||
|
this.pageQuery("t_tableData", () -> {
|
||||||
|
this.set("page", page); // 需要将前端表格中:currentPage定义的值设置成page的值
|
||||||
|
return sysDownloadCenterService.queryDownloadCenterList(queryDTO, page, size);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@OdinRequest
|
||||||
|
@PostMapping("/add")
|
||||||
|
public ResponseMessage add() {
|
||||||
|
this.clearForm("f_downloadCenterForm");
|
||||||
|
this.set("sysDownloadCenterDTO", new Object[]{});
|
||||||
|
this.set("fileList", new Object[]{});
|
||||||
|
this.set("dialogFormVisible", true);
|
||||||
|
this.set("dialogFormTitle", "材料新增");
|
||||||
|
return this.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 保存
|
||||||
|
*
|
||||||
|
* @param sysDownloadCenterDTO
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@OdinRequest(refresh = true) // refresh = true 请求结束后刷新页面
|
||||||
|
@PostMapping("/doSave/{name}")
|
||||||
|
public ResponseMessage doSave(@OdinRequestParam("f_downloadCenterForm") SysDownloadCenterDTO sysDownloadCenterDTO,
|
||||||
|
@PathVariable String name) {
|
||||||
|
if(sysDownloadCenterDTO.getMaterial_type()==null|| "".equals(sysDownloadCenterDTO.getMaterial_type())){
|
||||||
|
return this.error("请选择文件类型!");
|
||||||
|
}
|
||||||
|
//设置保留位数
|
||||||
|
DecimalFormat df = new DecimalFormat("0.00");
|
||||||
|
JSONArray array = this.getPageData().getJSONArray("sysDownloadCenterDTO");
|
||||||
|
List<SysDownloadCenterDTO> list = array.toJavaList(SysDownloadCenterDTO.class);
|
||||||
|
if (list.isEmpty()) {
|
||||||
|
return ResponseMessage.error("请上传附件!");
|
||||||
|
} else {
|
||||||
|
for (SysDownloadCenterDTO downloadCenterDTO : list) {
|
||||||
|
//录入数据库
|
||||||
|
SysDownloadCenterDTO dto = new SysDownloadCenterDTO();
|
||||||
|
dto.setId(downloadCenterDTO.getId());
|
||||||
|
dto.setMaterial_name(downloadCenterDTO.getMaterial_name());
|
||||||
|
String size;
|
||||||
|
//字节
|
||||||
|
long baty = Long.parseLong(downloadCenterDTO.getMaterial_size());
|
||||||
|
//小于M用kb
|
||||||
|
if (baty < 1048576 && baty > 0) {
|
||||||
|
String kb = df.format((double) baty / 1024);
|
||||||
|
size = kb + "KB";
|
||||||
|
} else if (baty >= 1048576 && baty < 1073741824) { //用m表示
|
||||||
|
String m = df.format((double) baty / 1048576);
|
||||||
|
size = m + "M";
|
||||||
|
} else { //G表示
|
||||||
|
String g = df.format((double) baty / 1073741824);
|
||||||
|
size = g + "G";
|
||||||
|
}
|
||||||
|
dto.setMaterial_size(size);
|
||||||
|
dto.setMaterial_type(sysDownloadCenterDTO.getMaterial_type());
|
||||||
|
dto.setUpload_time(new Date());
|
||||||
|
sysDownloadCenterService.saveDownloadCenter(dto);
|
||||||
|
}
|
||||||
|
this.set("dialogFormVisible", false);
|
||||||
|
return this.ok("保存成功!!!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除
|
||||||
|
*
|
||||||
|
* @param id
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@OdinRequest(refresh = true) // refresh = true 请求结束后刷新页面
|
||||||
|
@PostMapping("/delete")
|
||||||
|
public ResponseMessage delete(String id) {
|
||||||
|
sysDownloadCenterService.deleteById(id);
|
||||||
|
fsService.deleteObject(id);
|
||||||
|
return this.ok("删除成功!");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//移除文件
|
||||||
|
@GetMapping("/del/{id}")
|
||||||
|
public ResponseMessage del(@PathVariable String id) {
|
||||||
|
fsService.deleteObject(id);
|
||||||
|
return this.ok("文件移除成功!");
|
||||||
|
}
|
||||||
|
|
||||||
|
//批量下载
|
||||||
|
@GetMapping("/batchDownload/{ids}")
|
||||||
|
public void batchDownload(@PathVariable String ids, HttpServletResponse response) {
|
||||||
|
String[] s = ids.split(",");
|
||||||
|
String zipFileName = "batchDownload.zip";
|
||||||
|
// response.reset();
|
||||||
|
response.setCharacterEncoding("UTF-8");
|
||||||
|
response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE);
|
||||||
|
response.setHeader("Content-Disposition", "attachment;filename=" + zipFileName);
|
||||||
|
ZipOutputStream zos = null;
|
||||||
|
try {
|
||||||
|
zos = new ZipOutputStream(response.getOutputStream());
|
||||||
|
for (String fileId : s) {
|
||||||
|
FSObject fsObject;
|
||||||
|
try {
|
||||||
|
fsObject = fsService.getObject(fileId);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("{}文件不存在!", fileId);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
InputStream is = fsObject.getInputStream();
|
||||||
|
BufferedInputStream bis = null;
|
||||||
|
try {
|
||||||
|
bis = new BufferedInputStream(is);
|
||||||
|
//将文件写入zip内,即将文件进行打包
|
||||||
|
zos.putNextEntry(new ZipEntry(fsObject.getName()));
|
||||||
|
//写入文件的方法,同上
|
||||||
|
int size = 0;
|
||||||
|
byte[] buffer = new byte[1024];
|
||||||
|
//设置读取数据缓存大小
|
||||||
|
while ((size = bis.read(buffer)) > 0) {
|
||||||
|
zos.write(buffer, 0, size);
|
||||||
|
}
|
||||||
|
//关闭输入输出流
|
||||||
|
zos.closeEntry();
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw e;
|
||||||
|
} finally {
|
||||||
|
if (bis != null) {
|
||||||
|
bis.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new AppException("批量下载失败");
|
||||||
|
} finally {
|
||||||
|
if (zos != null) {
|
||||||
|
try {
|
||||||
|
zos.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 下载
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping("/download/{id}")
|
||||||
|
public void download(@PathVariable String id, HttpServletResponse response) throws IOException {
|
||||||
|
FSObject fsObject = null;
|
||||||
|
try {
|
||||||
|
fsObject = fsService.getObject(id);
|
||||||
|
} catch (Exception e) {
|
||||||
|
response.sendError(404, "文件不存在!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
sysDownloadCenterService.saveDownloadLog(id, currentUserService.getCurrentUser().getLogonName());
|
||||||
|
OutputStream out = null;
|
||||||
|
InputStream in = fsObject.getInputStream();
|
||||||
|
try {
|
||||||
|
response.addHeader("content-type", "application/octet-stream");
|
||||||
|
response.setContentType("application/octet-stream");
|
||||||
|
response.addHeader("Content-Disposition", "attachment;filename=" + new String(fsObject.getName().getBytes("UTF-8"), "ISO8859-1"));
|
||||||
|
out = response.getOutputStream();
|
||||||
|
|
||||||
|
byte[] bytes = new byte[2048];
|
||||||
|
int len;
|
||||||
|
while ((len = in.read(bytes)) > 0) {
|
||||||
|
out.write(bytes, 0, len);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("文件下载异常", e);
|
||||||
|
} finally {
|
||||||
|
//释放资源
|
||||||
|
if (out != null) {
|
||||||
|
try {
|
||||||
|
out.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
log.error("IO close error!", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (in != null) {
|
||||||
|
try {
|
||||||
|
in.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
log.error("IO close error!", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//上传
|
||||||
|
@PostMapping("/upload")
|
||||||
|
public ResponseMessage upload(@RequestParam MultipartFile file, HttpServletRequest request) throws IOException {
|
||||||
|
SysUser sysUser = currentUserService.getCurrentUser();
|
||||||
|
if (!"1".equals(sysUser.getUserType())) {
|
||||||
|
return ResponseMessage.error("只允许超级管理员上传附件!");
|
||||||
|
}
|
||||||
|
ResponseMessage rm;
|
||||||
|
String originalFilename = file.getOriginalFilename();
|
||||||
|
String fileType = originalFilename.substring(originalFilename.lastIndexOf("."));
|
||||||
|
/*if (!".zip".equals(fileType)) {
|
||||||
|
rm = ResponseMessage.ok("文件类型不对!!!");
|
||||||
|
return rm;
|
||||||
|
}*/
|
||||||
|
//创建文件存储对象
|
||||||
|
FSObject fsObject = new FSObject();
|
||||||
|
fsObject.setName(file.getOriginalFilename());
|
||||||
|
fsObject.setContentType(file.getContentType());
|
||||||
|
fsObject.setInputStream(file.getInputStream());
|
||||||
|
fsObject.setSize(file.getSize());
|
||||||
|
//该id在文件存入后由mongodb返回
|
||||||
|
String id = fsService.pubObject(fsObject);
|
||||||
|
if (!ObjectUtils.isEmpty(id)) {
|
||||||
|
SysDownloadCenterDTO dto = new SysDownloadCenterDTO();
|
||||||
|
dto.setId(id);
|
||||||
|
dto.setMaterial_size(Long.toString(fsObject.getSize()));
|
||||||
|
dto.setMaterial_name(fsObject.getName());
|
||||||
|
rm = ResponseMessage.ok("文件上传成功!!!", dto);
|
||||||
|
} else {
|
||||||
|
rm = ResponseMessage.ok("文件上传失败!!!");
|
||||||
|
}
|
||||||
|
return rm;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//查询用户是否为超级管理员
|
||||||
|
@GetMapping("/queryUser")
|
||||||
|
public ResponseMessage queryUser() {
|
||||||
|
SysUser sysUser = currentUserService.getCurrentUser();
|
||||||
|
//超级管理员
|
||||||
|
if ("1".equals(sysUser.getUserType())) {
|
||||||
|
return ResponseMessage.ok(null, true);
|
||||||
|
} else {
|
||||||
|
return ResponseMessage.ok(null, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* 以下都是vue3
|
||||||
|
*/
|
||||||
|
@PostMapping("/new/initCodeTypes")
|
||||||
|
public ResponseMessage initCodeTypesVue3(@RequestBody JSONObject jsonObject) {
|
||||||
|
ResponseMessage rm;
|
||||||
|
try {
|
||||||
|
JSONObject codeTypes = codeTypeService.getCodeTypes(jsonObject);
|
||||||
|
rm = ResponseMessage.ok(codeTypes);
|
||||||
|
} catch (Exception e) {
|
||||||
|
rm = ResponseMessage.error(e.getMessage());
|
||||||
|
}
|
||||||
|
return rm;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/new/query")
|
||||||
|
public ResponseMessage queryVue3(@RequestBody SysDownloadCenterDTO queryDTO) {
|
||||||
|
return ResponseMessage.ok(sysDownloadCenterService.queryDownloadCenterList(queryDTO, queryDTO.getPage(), queryDTO.getSize()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/new/delete")
|
||||||
|
public ResponseMessage deleteVue3(String id) {
|
||||||
|
sysDownloadCenterService.deleteById(id);
|
||||||
|
fsService.deleteObject(id);
|
||||||
|
return ResponseMessage.ok("删除成功!");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/new/queryUser")
|
||||||
|
public ResponseMessage queryUserVue3() {
|
||||||
|
SysUser sysUser = currentUserService.getCurrentUser();
|
||||||
|
//超级管理员
|
||||||
|
if ("1".equals(sysUser.getUserType())) {
|
||||||
|
return ResponseMessage.ok(true);
|
||||||
|
} else {
|
||||||
|
return ResponseMessage.ok(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//上传
|
||||||
|
@PostMapping("/new/upload")
|
||||||
|
public ResponseMessage uploadVue3(@RequestParam MultipartFile file, HttpServletRequest request) throws IOException {
|
||||||
|
SysUser sysUser = currentUserService.getCurrentUser();
|
||||||
|
if (!"1".equals(sysUser.getUserType())) {
|
||||||
|
return ResponseMessage.error("只允许超级管理员上传附件!");
|
||||||
|
}
|
||||||
|
ResponseMessage rm;
|
||||||
|
String originalFilename = file.getOriginalFilename();
|
||||||
|
String fileType = originalFilename.substring(originalFilename.lastIndexOf("."));
|
||||||
|
/*if (!".zip".equals(fileType)) {
|
||||||
|
rm = ResponseMessage.ok("文件类型不对!!!");
|
||||||
|
return rm;
|
||||||
|
}*/
|
||||||
|
//创建文件存储对象
|
||||||
|
FSObject fsObject = new FSObject();
|
||||||
|
fsObject.setName(file.getOriginalFilename());
|
||||||
|
fsObject.setContentType(file.getContentType());
|
||||||
|
fsObject.setInputStream(file.getInputStream());
|
||||||
|
fsObject.setSize(file.getSize());
|
||||||
|
//该id在文件存入后由mongodb返回
|
||||||
|
String id = fsService.pubObject(fsObject);
|
||||||
|
if (StringUtil.isNotEmpty(id)) {
|
||||||
|
SysDownloadCenterDTO dto = new SysDownloadCenterDTO();
|
||||||
|
dto.setId(id);
|
||||||
|
dto.setMaterial_size(Long.toString(fsObject.getSize()));
|
||||||
|
dto.setMaterial_name(fsObject.getName());
|
||||||
|
rm = ResponseMessage.ok("文件上传成功!!!", dto);
|
||||||
|
} else {
|
||||||
|
rm = ResponseMessage.ok("文件上传失败!!!");
|
||||||
|
}
|
||||||
|
return rm;
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/new/save")
|
||||||
|
public ResponseMessage doSaveVue3(@RequestBody JSONObject jsonObjecte) {
|
||||||
|
if(jsonObjecte.get("material_type")==null|| "".equals(jsonObjecte.get("material_type"))){
|
||||||
|
return ResponseMessage.error("请选择文件类型!");
|
||||||
|
}
|
||||||
|
//设置保留位数
|
||||||
|
DecimalFormat df = new DecimalFormat("0.00");
|
||||||
|
JSONArray array = jsonObjecte.getJSONArray("sysDownloadCenterDTO");
|
||||||
|
List<SysDownloadCenterDTO> list = array.toJavaList(SysDownloadCenterDTO.class);
|
||||||
|
if (list.size() < 1) {
|
||||||
|
return ResponseMessage.error("请上传附件!");
|
||||||
|
} else {
|
||||||
|
for (SysDownloadCenterDTO downloadCenterDTO : list) {
|
||||||
|
//录入数据库
|
||||||
|
SysDownloadCenterDTO dto = new SysDownloadCenterDTO();
|
||||||
|
dto.setId(downloadCenterDTO.getId());
|
||||||
|
dto.setMaterial_name(downloadCenterDTO.getMaterial_name());
|
||||||
|
String size;
|
||||||
|
//字节
|
||||||
|
long baty = Long.parseLong(downloadCenterDTO.getMaterial_size());
|
||||||
|
//小于M用kb
|
||||||
|
if (baty < 1048576 && baty > 0) {
|
||||||
|
String kb = df.format((double) baty / 1024);
|
||||||
|
size = kb + "KB";
|
||||||
|
} else if (baty >= 1048576 && baty < 1073741824) { //用m表示
|
||||||
|
String m = df.format((double) baty / 1048576);
|
||||||
|
size = m + "M";
|
||||||
|
} else { //G表示
|
||||||
|
String g = df.format((double) baty / 1073741824);
|
||||||
|
size = g + "G";
|
||||||
|
}
|
||||||
|
dto.setMaterial_size(size);
|
||||||
|
dto.setMaterial_type((String) jsonObjecte.get("material_type"));
|
||||||
|
dto.setUpload_time(new Date());
|
||||||
|
sysDownloadCenterService.saveDownloadCenter(dto);
|
||||||
|
}
|
||||||
|
//this.set("dialogFormVisible", false);
|
||||||
|
return ResponseMessage.ok("保存成功!!!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 下载
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping("/new/download/{id}")
|
||||||
|
public void downloadVue3(@PathVariable String id, HttpServletResponse response) throws IOException {
|
||||||
|
FSObject fsObject = null;
|
||||||
|
try {
|
||||||
|
fsObject = fsService.getObject(id);
|
||||||
|
} catch (Exception e) {
|
||||||
|
response.sendError(404, "文件不存在!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
sysDownloadCenterService.saveDownloadLog(id, currentUserService.getCurrentUser().getLogonName());
|
||||||
|
OutputStream out = null;
|
||||||
|
InputStream in = fsObject.getInputStream();
|
||||||
|
try {
|
||||||
|
response.addHeader("content-type", "application/octet-stream");
|
||||||
|
response.setContentType("application/octet-stream");
|
||||||
|
response.addHeader("Content-Disposition", "attachment;filename=" + new String(fsObject.getName().getBytes("UTF-8"), "ISO8859-1"));
|
||||||
|
out = response.getOutputStream();
|
||||||
|
|
||||||
|
byte[] bytes = new byte[2048];
|
||||||
|
int len;
|
||||||
|
while ((len = in.read(bytes)) > 0) {
|
||||||
|
out.write(bytes, 0, len);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("文件下载异常", e);
|
||||||
|
} finally {
|
||||||
|
//释放资源
|
||||||
|
if (out != null) {
|
||||||
|
try {
|
||||||
|
out.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
log.error("IO close error!", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (in != null) {
|
||||||
|
try {
|
||||||
|
in.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
log.error("IO close error!", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//批量下载
|
||||||
|
@GetMapping("/new/batchDownload/{ids}")
|
||||||
|
public void batchDownloadVue3(@PathVariable String ids, HttpServletResponse response) {
|
||||||
|
String[] s = ids.split(",");
|
||||||
|
String zipFileName = "batchDownload.zip";
|
||||||
|
// response.reset();
|
||||||
|
response.setCharacterEncoding("UTF-8");
|
||||||
|
response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE);
|
||||||
|
response.setHeader("Content-Disposition", "attachment;filename=" + zipFileName);
|
||||||
|
ZipOutputStream zos = null;
|
||||||
|
try {
|
||||||
|
zos = new ZipOutputStream(response.getOutputStream());
|
||||||
|
for (String fileId : s) {
|
||||||
|
FSObject fsObject;
|
||||||
|
try {
|
||||||
|
fsObject = fsService.getObject(fileId);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("{}文件不存在!", fileId);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
InputStream is = fsObject.getInputStream();
|
||||||
|
BufferedInputStream bis = null;
|
||||||
|
try {
|
||||||
|
bis = new BufferedInputStream(is);
|
||||||
|
//将文件写入zip内,即将文件进行打包
|
||||||
|
zos.putNextEntry(new ZipEntry(fsObject.getName()));
|
||||||
|
//写入文件的方法,同上
|
||||||
|
int size = 0;
|
||||||
|
byte[] buffer = new byte[1024];
|
||||||
|
//设置读取数据缓存大小
|
||||||
|
while ((size = bis.read(buffer)) > 0) {
|
||||||
|
zos.write(buffer, 0, size);
|
||||||
|
}
|
||||||
|
//关闭输入输出流
|
||||||
|
zos.closeEntry();
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw e;
|
||||||
|
} finally {
|
||||||
|
if (bis != null) {
|
||||||
|
bis.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new AppException("批量下载失败");
|
||||||
|
} finally {
|
||||||
|
if (zos != null) {
|
||||||
|
try {
|
||||||
|
zos.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,162 @@
|
|||||||
|
package com.insigma.sys.controller;
|
||||||
|
|
||||||
|
|
||||||
|
import com.alibaba.fastjson2.JSON;
|
||||||
|
import com.alibaba.fastjson2.JSONArray;
|
||||||
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
|
import com.insigma.framework.core.ResponseMessage;
|
||||||
|
import com.insigma.framework.domain.core.entity.SysError;
|
||||||
|
import com.insigma.framework.persistence.core.jdbc.JdbcPageHelper;
|
||||||
|
import com.insigma.framework.persistence.core.jdbc.PageInfo;
|
||||||
|
import com.insigma.sys.service.SysErrorService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.jdbc.core.JdbcTemplate;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 异常信息维护
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/sys/error")
|
||||||
|
public class SysErrorController {
|
||||||
|
@Autowired
|
||||||
|
private JdbcTemplate jdbcTemplate;
|
||||||
|
@Autowired
|
||||||
|
private SysErrorService sysErrorService;
|
||||||
|
@PostMapping("/doInit")
|
||||||
|
public ResponseMessage doInit(@RequestBody JSONObject pageData) throws SQLException {
|
||||||
|
|
||||||
|
Integer size = pageData.getInteger("size");
|
||||||
|
HashMap<String, Object> tableData = tableDataQuery(pageData, 1, size);
|
||||||
|
pageData.put("t_tableData", tableData);
|
||||||
|
|
||||||
|
/* List<SysError> errors=sysErrorService.queryAllErrors();
|
||||||
|
// JSONArray array1=new JSONArray();
|
||||||
|
JSONArray array=JSONArray.parseArray(JSONArray.toJSONString(errors));
|
||||||
|
JSONObject tableData = new JSONObject();
|
||||||
|
|
||||||
|
tableData.put("Data",array);
|
||||||
|
tableData.put("total",errors.size());*/
|
||||||
|
pageData.put("t_tableData", tableData);
|
||||||
|
return ResponseMessage.ok(null, pageData);
|
||||||
|
}
|
||||||
|
@PostMapping("/doQuery/goIt")
|
||||||
|
public ResponseMessage queryBySome(@RequestBody JSONObject pageData){
|
||||||
|
Map<String, HashMap<String,String>> map= (Map<String, HashMap<String, String>>) pageData.get("f_form1_n");
|
||||||
|
String serviceName=map.get("serviceName").get("value");
|
||||||
|
String functionName=map.get("functionName").get("value");
|
||||||
|
String errorCode= map.get("errorCode").get("value");
|
||||||
|
List<SysError> errors=sysErrorService.findAllBySome(serviceName,functionName,errorCode);
|
||||||
|
JSONArray array=JSONArray.parseArray(JSONArray.toJSONString(errors));
|
||||||
|
JSONObject tableData = new JSONObject();
|
||||||
|
tableData.put("Data",array);
|
||||||
|
tableData.put("total",errors.size());
|
||||||
|
pageData.put("t_tableData", tableData);
|
||||||
|
return ResponseMessage.ok(null, pageData);
|
||||||
|
}
|
||||||
|
@PostMapping("/doGridQuery/{id}")
|
||||||
|
public ResponseMessage doGridQuery(@RequestBody JSONObject jsonObject, @PathVariable String id) throws SQLException {
|
||||||
|
Integer page = jsonObject.getInteger("t_tableData_page");
|
||||||
|
Integer size = jsonObject.getInteger("t_tableData_size");
|
||||||
|
HashMap<String, Object> tableData = tableDataQuery(jsonObject, page, size);
|
||||||
|
jsonObject.put("t_tableData", tableData);
|
||||||
|
return ResponseMessage.ok(null, jsonObject);
|
||||||
|
}
|
||||||
|
@PostMapping("/delete")
|
||||||
|
public ResponseMessage deleteError(@RequestBody JSONObject pageData){
|
||||||
|
Map<String,String> map= (Map<String,String>) pageData.get("data");
|
||||||
|
try {
|
||||||
|
SysError sysError=sysErrorService.getSysErrorBean2(map);
|
||||||
|
sysErrorService.deleteError(sysError);
|
||||||
|
List<SysError> errors=sysErrorService.queryAllErrors();
|
||||||
|
JSONArray array=JSONArray.parseArray(JSONArray.toJSONString(errors));
|
||||||
|
JSONObject tableData = new JSONObject();
|
||||||
|
tableData.put("Data",array);
|
||||||
|
tableData.put("total",errors.size());
|
||||||
|
return ResponseMessage.ok("删除成功",tableData);
|
||||||
|
}catch (Exception e){
|
||||||
|
return ResponseMessage.error("删除失败");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@PostMapping("/doSave/addError")
|
||||||
|
public ResponseMessage addError(@RequestBody JSONObject pageData){
|
||||||
|
try {
|
||||||
|
Map<String,HashMap<String,String>> map= (Map<String,HashMap<String,String>>) pageData.get("f_errorForm_n");
|
||||||
|
SysError sysError=sysErrorService.getSysErrorBean1(map);
|
||||||
|
sysErrorService.save(sysError);
|
||||||
|
List<SysError> errors=sysErrorService.queryAllErrors();
|
||||||
|
JSONArray array=JSONArray.parseArray(JSONArray.toJSONString(errors));
|
||||||
|
JSONObject tableData = new JSONObject();
|
||||||
|
tableData.put("Data",array);
|
||||||
|
tableData.put("total",errors.size());
|
||||||
|
//将table装载到pageData
|
||||||
|
pageData.put("t_tableData", tableData);
|
||||||
|
pageData.put("dialogFormVisible",false);
|
||||||
|
return ResponseMessage.ok("增加成功",pageData);
|
||||||
|
}catch (Exception e){
|
||||||
|
pageData.put("dialogFormVisible",false);
|
||||||
|
return ResponseMessage.error("异常编码重复");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@PostMapping("/doCheck/{checkname}")
|
||||||
|
public ResponseMessage updateError(@RequestBody JSONObject pageData){
|
||||||
|
try {
|
||||||
|
int index=Integer.parseInt(pageData.get("index").toString());
|
||||||
|
HashMap<String,Object> maps= (HashMap<String,Object>) pageData.get("t_tableData_n");
|
||||||
|
// String datas=maps.get("Data").toString();
|
||||||
|
String datas=JSONObject.toJSONString(maps.get("Data"));
|
||||||
|
JSONArray jsonArray = JSON.parseArray(datas);
|
||||||
|
SysError sysError=JSON.toJavaObject(jsonArray.getJSONObject(index),SysError.class);
|
||||||
|
sysErrorService.save(sysError);
|
||||||
|
List<SysError> errors=sysErrorService.queryAllErrors();
|
||||||
|
JSONArray array=JSONArray.parseArray(JSONArray.toJSONString(errors));
|
||||||
|
JSONObject tableData = new JSONObject();
|
||||||
|
tableData.put("Data",array);
|
||||||
|
tableData.put("total",errors.size());
|
||||||
|
//将table装载到pageData
|
||||||
|
pageData.put("t_tableData_n", tableData);
|
||||||
|
return ResponseMessage.ok("修改成功",pageData);
|
||||||
|
}catch (Exception e){
|
||||||
|
return ResponseMessage.error(e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/queryIsMany")
|
||||||
|
public ResponseMessage queryIsMany(@RequestBody JSONObject pageData){
|
||||||
|
Map<String,HashMap<String,String>> map= (Map<String,HashMap<String,String>>) pageData.get("f_errorForm_n");
|
||||||
|
String errCode=map.get("errorCode1").get("value");
|
||||||
|
boolean flag=sysErrorService.queryByErrCode(errCode);
|
||||||
|
if (flag==true){
|
||||||
|
map.get("errorCode1").put("value","");
|
||||||
|
pageData.put("f_errorForm",map);
|
||||||
|
return ResponseMessage.error("异常编码重复");
|
||||||
|
}
|
||||||
|
return ResponseMessage.ok(null, pageData);
|
||||||
|
}
|
||||||
|
public HashMap<String, Object> tableDataQuery(JSONObject jsonObject, Integer page, Integer size) throws SQLException {
|
||||||
|
StringBuffer querySQL = new StringBuffer("select * from syserror where 1=1 ");
|
||||||
|
|
||||||
|
JdbcPageHelper helper = new JdbcPageHelper(jdbcTemplate, page, size);
|
||||||
|
PageInfo<Map<String, Object>> data = helper.queryPagination(querySQL.toString(), new ArrayList<>(), rs -> {
|
||||||
|
Map<String, Object> map = new HashMap<>();
|
||||||
|
map.put("id", rs.getString("id"));
|
||||||
|
map.put("serviceName", rs.getString("servicename"));
|
||||||
|
map.put("functionName", rs.getString("functionname"));
|
||||||
|
map.put("errorCode", rs.getString("errorcode"));
|
||||||
|
map.put("message", rs.getString("message"));
|
||||||
|
map.put("createTime", rs.getDate("createtime"));
|
||||||
|
return map;
|
||||||
|
});
|
||||||
|
|
||||||
|
HashMap<String, Object> gridData = new HashMap<>();
|
||||||
|
gridData.put("total", data.getTotal());
|
||||||
|
gridData.put("Data", data.getData());
|
||||||
|
return gridData;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,134 @@
|
|||||||
|
package com.insigma.sys.controller;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
|
import com.insigma.framework.core.ResponseMessage;
|
||||||
|
import com.insigma.framework.file.storage.core.FSObject;
|
||||||
|
import com.insigma.framework.file.storage.core.FSService;
|
||||||
|
import com.insigma.framework.persistence.core.jdbc.PageInfo;
|
||||||
|
import com.insigma.sys.dto.FeedbackAnswerDTO;
|
||||||
|
import com.insigma.sys.dto.FeedbackDTO;
|
||||||
|
import com.insigma.sys.service.SysFeedbackService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.core.io.InputStreamResource;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.util.ObjectUtils;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author yinjh
|
||||||
|
* @version 2022/2/23
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/sys/feedback")
|
||||||
|
public class SysFeedbackController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SysFeedbackService sysFeedbackService;
|
||||||
|
|
||||||
|
@Autowired(required = false)
|
||||||
|
private FSService fsService;
|
||||||
|
|
||||||
|
@PostMapping("/query")
|
||||||
|
public ResponseMessage query(@RequestBody JSONObject jsonObject) throws SQLException {
|
||||||
|
FeedbackDTO queryDTO = jsonObject.toJavaObject(FeedbackDTO.class);
|
||||||
|
Integer page = jsonObject.getInteger("page");
|
||||||
|
Integer size = jsonObject.getInteger("size");
|
||||||
|
PageInfo<FeedbackDTO> pageInfo = sysFeedbackService.page(queryDTO, page, size);
|
||||||
|
return ResponseMessage.ok(null, pageInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/save")
|
||||||
|
public ResponseMessage save(@RequestBody FeedbackDTO feedbackDTO) {
|
||||||
|
if (ObjectUtils.isEmpty(feedbackDTO.getTitle())) {
|
||||||
|
return ResponseMessage.error("意见标题不能为空!");
|
||||||
|
}
|
||||||
|
if (ObjectUtils.isEmpty(feedbackDTO.getContent())) {
|
||||||
|
return ResponseMessage.error("意见内容不能为空!");
|
||||||
|
}
|
||||||
|
sysFeedbackService.save(feedbackDTO);
|
||||||
|
return ResponseMessage.ok("提交成功!");
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/get/{id}")
|
||||||
|
public ResponseMessage get(@PathVariable String id) {
|
||||||
|
if (ObjectUtils.isEmpty(id)) {
|
||||||
|
return ResponseMessage.error("意见ID不能为空!");
|
||||||
|
}
|
||||||
|
FeedbackDTO feedbackDTO = sysFeedbackService.get(id);
|
||||||
|
return ResponseMessage.ok(null, feedbackDTO);
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/saveAnswer")
|
||||||
|
public ResponseMessage saveAnswer(@RequestBody FeedbackAnswerDTO feedbackAnswerDTO) {
|
||||||
|
if (ObjectUtils.isEmpty(feedbackAnswerDTO.getFeedbackId())) {
|
||||||
|
return ResponseMessage.error("意见ID不能为空!");
|
||||||
|
}
|
||||||
|
if (ObjectUtils.isEmpty(feedbackAnswerDTO.getContent())) {
|
||||||
|
return ResponseMessage.error("回复内容不能为空!");
|
||||||
|
}
|
||||||
|
sysFeedbackService.saveAnswer(feedbackAnswerDTO);
|
||||||
|
return ResponseMessage.ok("提交成功!");
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/images")
|
||||||
|
public ResponseMessage upload(MultipartFile file) {
|
||||||
|
try {
|
||||||
|
if (fsService == null) {
|
||||||
|
return ResponseMessage.error("未启用FS");
|
||||||
|
}
|
||||||
|
if (ObjectUtils.isEmpty(file.getContentType())) {
|
||||||
|
return ResponseMessage.error("content-type不能为空");
|
||||||
|
}
|
||||||
|
if (!file.getContentType().toLowerCase().contains("image")) {
|
||||||
|
return ResponseMessage.error("图片格式不正确");
|
||||||
|
}
|
||||||
|
FSObject fsObject = new FSObject();
|
||||||
|
fsObject.setName(file.getOriginalFilename());
|
||||||
|
fsObject.setUploadDate(new Date());
|
||||||
|
fsObject.setInputStream(file.getInputStream());
|
||||||
|
fsObject.setContentType(file.getContentType());
|
||||||
|
fsObject.setSize(file.getSize());
|
||||||
|
|
||||||
|
Map<String, String> result = new HashMap<>();
|
||||||
|
result.put("location", "/sys/feedback/static/images/" + fsService.pubObject(fsObject) + file.getContentType().substring(file.getContentType().lastIndexOf("/")).toLowerCase().replace("/", "."));
|
||||||
|
return ResponseMessage.ok(null, result);
|
||||||
|
} catch (Exception e) {
|
||||||
|
return ResponseMessage.error(e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/static/images/{prefix}.{suffix}")
|
||||||
|
public ResponseEntity view(@PathVariable String prefix, @PathVariable String suffix) {
|
||||||
|
try {
|
||||||
|
if (fsService == null) {
|
||||||
|
return ResponseEntity.notFound().build();
|
||||||
|
}
|
||||||
|
FSObject fsObject;
|
||||||
|
try {
|
||||||
|
fsObject = fsService.getObject(prefix);
|
||||||
|
} catch (Exception e) {
|
||||||
|
fsObject = null;
|
||||||
|
}
|
||||||
|
if (fsObject == null || !fsObject.getContentType().toLowerCase().contains(suffix.toLowerCase())) {
|
||||||
|
return ResponseEntity.notFound().build();
|
||||||
|
}
|
||||||
|
return ResponseEntity.ok()
|
||||||
|
.header("Pragma", "no-cache")
|
||||||
|
.header("Cache-Control", "no-cache")
|
||||||
|
.header("Expires", "0")
|
||||||
|
.header("Content-Type", fsObject.getContentType())
|
||||||
|
.header("Content-Length", String.valueOf(fsObject.getSize()))
|
||||||
|
.body(new InputStreamResource(fsObject.getInputStream()));
|
||||||
|
} catch (Exception e) {
|
||||||
|
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,217 @@
|
|||||||
|
package com.insigma.sys.controller;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson2.JSONArray;
|
||||||
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
|
import com.insigma.framework.core.ResponseMessage;
|
||||||
|
import com.insigma.framework.core.util.TreeUtil;
|
||||||
|
import com.insigma.framework.domain.core.entity.SysFunction;
|
||||||
|
import com.insigma.framework.domain.core.entity.SysUser;
|
||||||
|
import com.insigma.framework.file.storage.core.FSObject;
|
||||||
|
import com.insigma.framework.file.storage.core.FSService;
|
||||||
|
import com.insigma.framework.web.support.ep.dev.annotation.OdinRequest;
|
||||||
|
import com.insigma.framework.web.support.ep.dev.controller.BaseController;
|
||||||
|
import com.insigma.sys.common.CurrentUserService;
|
||||||
|
import com.insigma.sys.dto.MenuDTO;
|
||||||
|
import com.insigma.sys.dto.SysFunctionDocDTO;
|
||||||
|
import com.insigma.sys.service.SysFunctionDocService;
|
||||||
|
import com.insigma.sys.service.SysFunctionService;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.core.io.InputStreamResource;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.util.ObjectUtils;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/sys/sysFunctionDoc")
|
||||||
|
public class SysFunctionDocController extends BaseController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SysFunctionDocService sysFunctionDocService;
|
||||||
|
|
||||||
|
@Autowired(required = false)
|
||||||
|
private FSService fsService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private CurrentUserService currentUserService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SysFunctionService sysFunctionService;
|
||||||
|
|
||||||
|
@GetMapping("/queryTree")
|
||||||
|
public ResponseMessage queryTable(){
|
||||||
|
List<MenuDTO> menuDTOS = sysFunctionService.queryAllMenu();
|
||||||
|
JSONArray jsonArray = TreeUtil.listToTree(JSONArray.parseArray(JSONArray.toJSONString(menuDTOS)), "functionid", "parentid", "children");
|
||||||
|
return ResponseMessage.ok("查询成功", jsonArray);
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/nodeClick")
|
||||||
|
public ResponseMessage nodeClick(@RequestBody JSONObject jsonObject) {
|
||||||
|
SysFunction sysFunction;
|
||||||
|
String a=jsonObject.get("functionid").toString();
|
||||||
|
if (a!=null){
|
||||||
|
long functionid =(long)Integer.parseInt(a);
|
||||||
|
sysFunction = sysFunctionService.getByFunctionId(functionid);
|
||||||
|
List<SysFunction> menulist= sysFunctionService.getByParentId(sysFunction.getFunctionId());
|
||||||
|
if (menulist.size()>0){
|
||||||
|
//有子类
|
||||||
|
return ResponseMessage.ok(null, sysFunction);
|
||||||
|
}else {
|
||||||
|
//没有子类
|
||||||
|
return ResponseMessage.ok("重复", sysFunction);
|
||||||
|
}
|
||||||
|
}else {
|
||||||
|
return ResponseMessage.error();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据id查找对象
|
||||||
|
* @param jsonObject
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping("/queryById")
|
||||||
|
public ResponseMessage queryById(@RequestBody JSONObject jsonObject) {
|
||||||
|
try {
|
||||||
|
String id=jsonObject.get("functionid").toString();
|
||||||
|
String funtype=jsonObject.get("funtype").toString();
|
||||||
|
List<MenuDTO> menuDTOS= sysFunctionService.queryMenuByFuntypeAndActive(funtype);
|
||||||
|
JSONArray jsonArray = TreeUtil.listToTree(JSONArray.parseArray(JSONArray.toJSONString(menuDTOS)), "functionid", "parentid", "children");
|
||||||
|
jsonObject.put("treedata",jsonArray);
|
||||||
|
long fId=Integer.parseInt(id);
|
||||||
|
SysFunction menu= sysFunctionService.getByFunctionId(fId);
|
||||||
|
List list=new ArrayList();
|
||||||
|
if(menu!=null){
|
||||||
|
String [] ms=menu.getIdPath().split("/");
|
||||||
|
if (ms.length>0){
|
||||||
|
for (String s:ms){
|
||||||
|
if(s.equals("0")){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
list.add(Long.valueOf(s));
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
jsonObject.put("pname",list);
|
||||||
|
return ResponseMessage.ok(null, jsonObject);
|
||||||
|
}catch (Exception e){
|
||||||
|
return ResponseMessage.error(e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/doQuery")
|
||||||
|
public ResponseMessage doQuery(@RequestBody JSONObject jsonObject) {
|
||||||
|
String tmp = jsonObject.getString("functionid");
|
||||||
|
Long functionid;
|
||||||
|
if (ObjectUtils.isEmpty(tmp)) {
|
||||||
|
String location = jsonObject.getString("location");
|
||||||
|
if (ObjectUtils.isEmpty(location)) {
|
||||||
|
return ResponseMessage.error("传入菜单ID为空");
|
||||||
|
}
|
||||||
|
SysFunction sysFunction = sysFunctionService.getByLocation(location);
|
||||||
|
if (sysFunction == null) {
|
||||||
|
return ResponseMessage.error("模块不存在");
|
||||||
|
}
|
||||||
|
functionid = sysFunction.getFunctionId();
|
||||||
|
} else {
|
||||||
|
functionid = Long.parseLong(tmp);
|
||||||
|
}
|
||||||
|
SysFunctionDocDTO aysFunctionDocDTO = sysFunctionDocService.queryByFunctionID(functionid);
|
||||||
|
if (aysFunctionDocDTO == null) {
|
||||||
|
return ResponseMessage.error("未配置该模块的功能介绍");
|
||||||
|
}
|
||||||
|
return ResponseMessage.ok(null, aysFunctionDocDTO);
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/doSave")
|
||||||
|
public ResponseMessage doSave(@RequestBody SysFunctionDocDTO sysFunctionDocDTO ) {
|
||||||
|
try {
|
||||||
|
sysFunctionDocService.saveDoc(sysFunctionDocDTO);
|
||||||
|
return ResponseMessage.ok();
|
||||||
|
} catch (Exception e) {
|
||||||
|
return ResponseMessage.error(e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@OdinRequest
|
||||||
|
@PostMapping("/deleteMenu")
|
||||||
|
public ResponseMessage delete(@RequestBody JSONObject jsonObject) {
|
||||||
|
try {
|
||||||
|
String tmp = jsonObject.get("functionid").toString();
|
||||||
|
Long functionid = Long.parseLong(tmp);
|
||||||
|
if(functionid==0){
|
||||||
|
return ResponseMessage.error("传入菜单ID为空");
|
||||||
|
}
|
||||||
|
sysFunctionDocService.deleteByFunctionid(functionid);
|
||||||
|
return ResponseMessage.ok();
|
||||||
|
} catch (Exception e) {
|
||||||
|
return ResponseMessage.error(e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/images")
|
||||||
|
public ResponseMessage upload(MultipartFile file, String messageId) {
|
||||||
|
try {
|
||||||
|
if (fsService == null) {
|
||||||
|
return ResponseMessage.error("未启用FS");
|
||||||
|
}
|
||||||
|
if (ObjectUtils.isEmpty(file.getContentType())) {
|
||||||
|
return ResponseMessage.error("content-type不能为空");
|
||||||
|
}
|
||||||
|
if (!file.getContentType().toLowerCase().contains("image")) {
|
||||||
|
return ResponseMessage.error("图片格式不正确");
|
||||||
|
}
|
||||||
|
FSObject fsObject = new FSObject();
|
||||||
|
fsObject.setName(file.getOriginalFilename());
|
||||||
|
fsObject.setUploadDate(new Date());
|
||||||
|
fsObject.setInputStream(file.getInputStream());
|
||||||
|
fsObject.setContentType(file.getContentType());
|
||||||
|
fsObject.setSize(file.getSize());
|
||||||
|
|
||||||
|
Map<String, String> result = new HashMap<>();
|
||||||
|
result.put("location", "/sys/sysFunctionDoc/static/images/" + fsService.pubObject(fsObject) + file.getContentType().substring(file.getContentType().lastIndexOf("/")).toLowerCase().replace("/", ".") + "?messageId=" + messageId);
|
||||||
|
return ResponseMessage.ok(null, result);
|
||||||
|
} catch (Exception e) {
|
||||||
|
return ResponseMessage.error(e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@GetMapping("/static/images/{prefix}.{suffix}")
|
||||||
|
public ResponseEntity view(@PathVariable String prefix, @PathVariable String suffix, String messageId) {
|
||||||
|
try {
|
||||||
|
SysUser sysUser = currentUserService.getCurrentUser();
|
||||||
|
SysFunctionDocDTO sysFunctionDocDTO = sysFunctionDocService.queryByFunctionID(Long.parseLong(messageId));
|
||||||
|
if (sysFunctionDocDTO != null ) {
|
||||||
|
if (sysFunctionDocDTO == null) {
|
||||||
|
return ResponseEntity.status(403).build();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (fsService == null) {
|
||||||
|
return ResponseEntity.notFound().build();
|
||||||
|
}
|
||||||
|
FSObject fsObject;
|
||||||
|
try {
|
||||||
|
fsObject = fsService.getObject(prefix);
|
||||||
|
} catch (Exception e) {
|
||||||
|
fsObject = null;
|
||||||
|
}
|
||||||
|
if (fsObject == null || !fsObject.getContentType().toLowerCase().contains(suffix.toLowerCase())) {
|
||||||
|
return ResponseEntity.notFound().build();
|
||||||
|
}
|
||||||
|
return ResponseEntity.ok()
|
||||||
|
.header("Pragma", "no-cache")
|
||||||
|
.header("Cache-Control", "no-cache")
|
||||||
|
.header("Expires", "0")
|
||||||
|
.header("Content-Type", fsObject.getContentType())
|
||||||
|
.header("Content-Length", String.valueOf(fsObject.getSize()))
|
||||||
|
.body(new InputStreamResource(fsObject.getInputStream()));
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.getMessage(), e);
|
||||||
|
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,212 @@
|
|||||||
|
package com.insigma.sys.controller;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
|
import com.insigma.framework.core.ResponseMessage;
|
||||||
|
import com.insigma.framework.web.support.ep.dev.annotation.OdinRequest;
|
||||||
|
import com.insigma.framework.web.support.ep.dev.annotation.OdinRequestParam;
|
||||||
|
import com.insigma.framework.web.support.ep.dev.controller.BaseController;
|
||||||
|
import com.insigma.sys.dto.SysGuideDTO;
|
||||||
|
import com.insigma.sys.service.SysGuideService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.util.ObjectUtils;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/sys/guide/Guide")
|
||||||
|
public class SysGuideController extends BaseController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SysGuideService sysGuideService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 初始化
|
||||||
|
*
|
||||||
|
* @param f_form
|
||||||
|
* @param size
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@OdinRequest(init = true)
|
||||||
|
@PostMapping("/doInit")
|
||||||
|
public ResponseMessage doInit(SysGuideDTO f_form, Integer size) {
|
||||||
|
tableDataQuery(f_form, 1, size);
|
||||||
|
return this.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页查询
|
||||||
|
*
|
||||||
|
* @param queryDTO
|
||||||
|
* @param page
|
||||||
|
* @param size
|
||||||
|
* @param name
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@OdinRequest
|
||||||
|
@PostMapping("/doGridQuery/{name}")
|
||||||
|
public ResponseMessage doGridQuery(@OdinRequestParam("f_form") SysGuideDTO queryDTO,
|
||||||
|
@OdinRequestParam("t_tableData_page") Integer page,
|
||||||
|
@OdinRequestParam("t_tableData_size") Integer size,
|
||||||
|
@PathVariable String name) {
|
||||||
|
tableDataQuery(queryDTO, page, size);
|
||||||
|
return this.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询
|
||||||
|
*
|
||||||
|
* @param queryDTO
|
||||||
|
* @param size
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@OdinRequest
|
||||||
|
@PostMapping("/query")
|
||||||
|
public ResponseMessage query(@OdinRequestParam("f_form") SysGuideDTO queryDTO,
|
||||||
|
Integer size) {
|
||||||
|
tableDataQuery(queryDTO, 1, size);
|
||||||
|
return this.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void tableDataQuery(SysGuideDTO queryDTO, Integer page, Integer size) {
|
||||||
|
this.pageQuery("t_tableData", () -> {
|
||||||
|
this.set("page", page); // 需要将前端表格中:currentPage定义的值设置成page的值
|
||||||
|
return sysGuideService.queryGuideList(queryDTO, page, size);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@OdinRequest
|
||||||
|
@PostMapping("/add")
|
||||||
|
public ResponseMessage add() {
|
||||||
|
this.clearForm("f_guideForm");
|
||||||
|
this.set("dialogFormVisible", true);
|
||||||
|
this.set("dialogFormTitle", "新增");
|
||||||
|
return this.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改
|
||||||
|
*
|
||||||
|
* @param id
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@OdinRequest
|
||||||
|
@PostMapping("/update")
|
||||||
|
public ResponseMessage update(String id) {
|
||||||
|
SysGuideDTO dto = sysGuideService.queryGuide(id);
|
||||||
|
|
||||||
|
if(!ObjectUtils.isEmpty(dto.getAnswer_content())){
|
||||||
|
String s = dto.getAnswer_content().replaceAll("<br/>", "\n");
|
||||||
|
dto.setAnswer_content(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.toForm("f_guideForm", dto);
|
||||||
|
this.set("dialogFormVisible", true);
|
||||||
|
this.set("dialogFormTitle", "修改");
|
||||||
|
return this.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@OdinRequest(refresh = true)
|
||||||
|
@PostMapping("/batchDelete")
|
||||||
|
public ResponseMessage batchDelete() {
|
||||||
|
List<SysGuideDTO> list = this.getCheckedTableData("t_tableData", SysGuideDTO.class);
|
||||||
|
if (list.size() == 0) {
|
||||||
|
return this.error("请勾选需要删除的内容!");
|
||||||
|
}
|
||||||
|
sysGuideService.deleteGuides(list);
|
||||||
|
return this.ok("删除成功!");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除
|
||||||
|
*
|
||||||
|
* @param id
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@OdinRequest
|
||||||
|
@PostMapping("/delete")
|
||||||
|
public ResponseMessage delete(String id) {
|
||||||
|
sysGuideService.delete(id);
|
||||||
|
this.setBackFunType("rQuery");
|
||||||
|
return this.ok("删除成功!");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 保存
|
||||||
|
*
|
||||||
|
* @param sysGuideDTO
|
||||||
|
* @param name
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@OdinRequest
|
||||||
|
@PostMapping("/doSave/{name}")
|
||||||
|
public ResponseMessage doSave(@OdinRequestParam("f_guideForm") SysGuideDTO sysGuideDTO, @PathVariable String name) {
|
||||||
|
sysGuideService.saveGuide(sysGuideDTO);
|
||||||
|
this.set("dialogFormVisible", false);
|
||||||
|
// doInit(new SysGuideDTO(),size);
|
||||||
|
this.setBackFunType("rQuery");
|
||||||
|
return this.ok("保存成功!");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 点击问题名称触发热度+1
|
||||||
|
*/
|
||||||
|
@GetMapping("/hot/{id}")
|
||||||
|
public ResponseMessage hot(@PathVariable String id) {
|
||||||
|
sysGuideService.hot(id);
|
||||||
|
return this.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description: 根据不同选择进行详细的查询数据
|
||||||
|
* @author GH
|
||||||
|
* @version 2021/7/23 14:53
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping("/findByQuestion_type")
|
||||||
|
public ResponseMessage findByQuestion_type(@RequestBody JSONObject jsonObjecte) {
|
||||||
|
Integer page = jsonObjecte.getInteger("page");
|
||||||
|
Integer size = jsonObjecte.getInteger("size");
|
||||||
|
String question_type = jsonObjecte.getString("question_type");
|
||||||
|
String sort = jsonObjecte.getString("sort");
|
||||||
|
String str = jsonObjecte.getString("str");
|
||||||
|
return ResponseMessage.ok(null, sysGuideService.findByQuestion_type(question_type,sort,str,page,size));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description: 查询首页引导信息
|
||||||
|
* @author GH
|
||||||
|
* @version 2021/7/30 13:09
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping("/findFrontPage")
|
||||||
|
public ResponseMessage findFrontPage() {
|
||||||
|
List<HashMap<String, Object>> map = sysGuideService.findFrontPage();
|
||||||
|
return ResponseMessage.ok(null, map);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description: 更多详情页面
|
||||||
|
* @author GH
|
||||||
|
* @version 2021/7/30 13:09
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping("/findDetailsPage/{id}")
|
||||||
|
public ResponseMessage findDetailsPage(@PathVariable String id) {
|
||||||
|
sysGuideService.hot(id);
|
||||||
|
return ResponseMessage.ok(null, sysGuideService.findDetailsPage(id));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,62 @@
|
|||||||
|
package com.insigma.sys.controller;
|
||||||
|
|
||||||
|
import com.insigma.framework.core.ResponseMessage;
|
||||||
|
import com.insigma.framework.persistence.core.jdbc.PageInfo;
|
||||||
|
import com.insigma.framework.web.support.ep.dev.annotation.OdinRequest;
|
||||||
|
import com.insigma.framework.web.support.ep.dev.annotation.OdinRequestParam;
|
||||||
|
import com.insigma.framework.web.support.ep.dev.controller.BaseController;
|
||||||
|
import com.insigma.sys.dto.SysLogonLogDTO;
|
||||||
|
import com.insigma.sys.service.SysLogonLogService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* fukq 2020/6/2
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/sys/syslogonlog")
|
||||||
|
public class SysLogonLogController extends BaseController {
|
||||||
|
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SysLogonLogService syslogonLogService;
|
||||||
|
|
||||||
|
@OdinRequest(init = true)
|
||||||
|
@PostMapping("/doInit")
|
||||||
|
public ResponseMessage doInit(SysLogonLogDTO f_form, Integer page, Integer size) {
|
||||||
|
tableDataQuery(f_form, page, size);
|
||||||
|
return this.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
@OdinRequest
|
||||||
|
@PostMapping("/doGridQuery/{name}")
|
||||||
|
public ResponseMessage doGridQuery(@OdinRequestParam("f_form") SysLogonLogDTO queryDTO,
|
||||||
|
@OdinRequestParam("t_tableData_page") Integer page,
|
||||||
|
@OdinRequestParam("t_tableData_size") Integer size,
|
||||||
|
@PathVariable String name) {
|
||||||
|
tableDataQuery(queryDTO, page, size);
|
||||||
|
this.set("page", page);
|
||||||
|
return this.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
@OdinRequest
|
||||||
|
@PostMapping("/query")
|
||||||
|
public ResponseMessage query(@OdinRequestParam("f_form") SysLogonLogDTO queryDTO,
|
||||||
|
@OdinRequestParam("t_tableData") PageInfo<SysLogonLogDTO> pageInfo,
|
||||||
|
Integer size) {
|
||||||
|
tableDataQuery(queryDTO, 1, size);
|
||||||
|
this.set("page", 1);
|
||||||
|
return this.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void tableDataQuery(SysLogonLogDTO queryDTO, Integer page, Integer size) {
|
||||||
|
this.pageQuery("t_tableData", () -> syslogonLogService.querySysLogonList(queryDTO, page, size));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/new/query")
|
||||||
|
public ResponseMessage doGridQueryVue3(@RequestBody SysLogonLogDTO queryDTO) {
|
||||||
|
return ResponseMessage.ok(syslogonLogService.querySysLogonList(queryDTO, queryDTO.getPage(), queryDTO.getSize()));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,119 @@
|
|||||||
|
package com.insigma.sys.controller;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
|
import com.insigma.framework.core.ResponseMessage;
|
||||||
|
import com.insigma.framework.domain.core.entity.SysUser;
|
||||||
|
import com.insigma.framework.file.storage.core.FSObject;
|
||||||
|
import com.insigma.framework.file.storage.core.FSService;
|
||||||
|
import com.insigma.framework.persistence.core.jdbc.PageInfo;
|
||||||
|
import com.insigma.sys.common.CurrentUserService;
|
||||||
|
import com.insigma.sys.dto.MessageDTO;
|
||||||
|
import com.insigma.sys.service.SysMessageService;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.core.io.InputStreamResource;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.util.ObjectUtils;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.sql.SQLException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by yinjh on 2020/6/16.
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/sys/message")
|
||||||
|
public class SysMessageController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SysMessageService sysMessageService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private CurrentUserService currentUserService;
|
||||||
|
|
||||||
|
@Autowired(required = false)
|
||||||
|
private FSService fsService;
|
||||||
|
|
||||||
|
@PostMapping("/list")
|
||||||
|
public ResponseMessage list(@RequestBody JSONObject jsonObject) throws SQLException {
|
||||||
|
SysUser sysUser = currentUserService.getCurrentUser();
|
||||||
|
MessageDTO queryDTO = jsonObject.toJavaObject(MessageDTO.class);
|
||||||
|
Integer page = jsonObject.getInteger("page");
|
||||||
|
Integer size = jsonObject.getInteger("size");
|
||||||
|
PageInfo<MessageDTO> pageInfo = sysMessageService.getSysMessageList(sysUser, queryDTO, page, size, false);
|
||||||
|
return ResponseMessage.ok(null, pageInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/save")
|
||||||
|
public ResponseMessage save(@RequestBody MessageDTO messageDTO) {
|
||||||
|
String userId = currentUserService.getCurrentUser().getUserId();
|
||||||
|
if (ObjectUtils.isEmpty(messageDTO.getTitle())) {
|
||||||
|
return ResponseMessage.error("消息标题不能为空!");
|
||||||
|
}
|
||||||
|
if (ObjectUtils.isEmpty(messageDTO.getContent())) {
|
||||||
|
return ResponseMessage.error("消息内容不能为空!");
|
||||||
|
}
|
||||||
|
if (ObjectUtils.isEmpty(messageDTO.getType())) {
|
||||||
|
return ResponseMessage.error("消息类型不能为空!");
|
||||||
|
}
|
||||||
|
if ("1".equals(messageDTO.getType())) {
|
||||||
|
if (messageDTO.getUserIds() == null || messageDTO.getUserIds().size() == 0) {
|
||||||
|
return ResponseMessage.error("消息通知目标不能为空!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sysMessageService.save(userId, messageDTO);
|
||||||
|
return ResponseMessage.ok("保存成功!");
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/read")
|
||||||
|
public ResponseMessage read(String messageId) {
|
||||||
|
String userId = currentUserService.getCurrentUser().getUserId();
|
||||||
|
MessageDTO messageDTO = sysMessageService.getSysMessage(userId, messageId);
|
||||||
|
if ("1".equals(messageDTO.getType()) && "-1".equals(messageDTO.getFlag())) {
|
||||||
|
return ResponseMessage.error("无权查看!");
|
||||||
|
}
|
||||||
|
if (!"1".equals(messageDTO.getFlag())) {
|
||||||
|
sysMessageService.updateFlag(userId, messageId);
|
||||||
|
}
|
||||||
|
return ResponseMessage.ok(null, messageDTO);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@GetMapping("/static/images/{prefix}.{suffix}")
|
||||||
|
public ResponseEntity view(@PathVariable String prefix, @PathVariable String suffix, String messageId) {
|
||||||
|
try {
|
||||||
|
SysUser sysUser = currentUserService.getCurrentUser();
|
||||||
|
MessageDTO messageDTO = sysMessageService.getSysMessage(messageId);
|
||||||
|
if (messageDTO != null && "1".equals(messageDTO.getType()) && !"1".equals(sysUser.getUserType())) {
|
||||||
|
messageDTO = sysMessageService.getSysUserMessage(sysUser.getUserId(), messageId);
|
||||||
|
if (messageDTO == null) {
|
||||||
|
return ResponseEntity.status(403).build();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (fsService == null) {
|
||||||
|
return ResponseEntity.notFound().build();
|
||||||
|
}
|
||||||
|
FSObject fsObject;
|
||||||
|
try {
|
||||||
|
fsObject = fsService.getObject(prefix);
|
||||||
|
} catch (Exception e) {
|
||||||
|
fsObject = null;
|
||||||
|
}
|
||||||
|
if (fsObject == null || !fsObject.getContentType().toLowerCase().contains(suffix.toLowerCase())) {
|
||||||
|
return ResponseEntity.notFound().build();
|
||||||
|
}
|
||||||
|
return ResponseEntity.ok()
|
||||||
|
.header("Pragma", "no-cache")
|
||||||
|
.header("Cache-Control", "no-cache")
|
||||||
|
.header("Expires", "0")
|
||||||
|
.header("Content-Type", fsObject.getContentType())
|
||||||
|
.header("Content-Length", String.valueOf(fsObject.getSize()))
|
||||||
|
.body(new InputStreamResource(fsObject.getInputStream()));
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.getMessage(), e);
|
||||||
|
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,130 @@
|
|||||||
|
package com.insigma.sys.controller;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
|
import com.insigma.framework.core.ResponseMessage;
|
||||||
|
import com.insigma.framework.core.util.IDUtil;
|
||||||
|
import com.insigma.framework.domain.core.entity.SysUser;
|
||||||
|
import com.insigma.framework.file.storage.core.FSObject;
|
||||||
|
import com.insigma.framework.file.storage.core.FSService;
|
||||||
|
import com.insigma.framework.persistence.core.jdbc.PageInfo;
|
||||||
|
import com.insigma.sys.common.CurrentUserService;
|
||||||
|
import com.insigma.sys.dto.LazyTreeNode;
|
||||||
|
import com.insigma.sys.dto.MessageDTO;
|
||||||
|
import com.insigma.sys.service.SysMessageService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.util.ObjectUtils;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author yinjh
|
||||||
|
* @version 2021/8/23
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/sys/message/manage")
|
||||||
|
public class SysMessageManageController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SysMessageService sysMessageService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private CurrentUserService currentUserService;
|
||||||
|
|
||||||
|
@Autowired(required = false)
|
||||||
|
private FSService fsService;
|
||||||
|
|
||||||
|
@PostMapping("/init")
|
||||||
|
public ResponseMessage init() {
|
||||||
|
return ResponseMessage.ok("", IDUtil.generateUUID());
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/list")
|
||||||
|
public ResponseMessage list(@RequestBody JSONObject jsonObject) throws SQLException {
|
||||||
|
SysUser sysUser = currentUserService.getCurrentUser();
|
||||||
|
MessageDTO queryDTO = jsonObject.toJavaObject(MessageDTO.class);
|
||||||
|
Integer page = jsonObject.getInteger("page");
|
||||||
|
Integer size = jsonObject.getInteger("size");
|
||||||
|
PageInfo<MessageDTO> pageInfo = sysMessageService.getSysMessageList(sysUser, queryDTO, page, size, true);
|
||||||
|
return ResponseMessage.ok(null, pageInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/save")
|
||||||
|
public ResponseMessage save(@RequestBody MessageDTO messageDTO) {
|
||||||
|
String userId = currentUserService.getCurrentUser().getUserId();
|
||||||
|
if (ObjectUtils.isEmpty(messageDTO.getTitle())) {
|
||||||
|
return ResponseMessage.error("消息标题不能为空!");
|
||||||
|
}
|
||||||
|
if (ObjectUtils.isEmpty(messageDTO.getContent())) {
|
||||||
|
return ResponseMessage.error("消息内容不能为空!");
|
||||||
|
}
|
||||||
|
if (ObjectUtils.isEmpty(messageDTO.getType())) {
|
||||||
|
return ResponseMessage.error("消息类型不能为空!");
|
||||||
|
}
|
||||||
|
if ("1".equals(messageDTO.getType())) {
|
||||||
|
if (messageDTO.getUserIds() == null || messageDTO.getUserIds().size() == 0) {
|
||||||
|
return ResponseMessage.error("消息通知目标不能为空!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
MessageDTO message = sysMessageService.getSysMessage(messageDTO.getMessageId());
|
||||||
|
if (message == null) {
|
||||||
|
sysMessageService.save(userId, messageDTO);
|
||||||
|
} else {
|
||||||
|
sysMessageService.update(userId, messageDTO);
|
||||||
|
}
|
||||||
|
return ResponseMessage.ok("保存成功!");
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/read")
|
||||||
|
public ResponseMessage read(String messageId) {
|
||||||
|
MessageDTO messageDTO = sysMessageService.getSysMessage(messageId);
|
||||||
|
return ResponseMessage.ok(null, messageDTO);
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/delete")
|
||||||
|
public ResponseMessage delete(@RequestBody MessageDTO messageDTO) {
|
||||||
|
if (ObjectUtils.isEmpty(messageDTO.getMessageId())) {
|
||||||
|
return ResponseMessage.error("消息ID不能为空!");
|
||||||
|
}
|
||||||
|
sysMessageService.deleteSysMessage(messageDTO.getMessageId());
|
||||||
|
return ResponseMessage.ok("删除成功!");
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/userOrgTree")
|
||||||
|
public ResponseMessage getUserOrgTree(String parentId) {
|
||||||
|
List<LazyTreeNode<String>> list = sysMessageService.getUserOrgTree(parentId);
|
||||||
|
return ResponseMessage.ok(null, list);
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/images")
|
||||||
|
public ResponseMessage upload(MultipartFile file, String messageId) {
|
||||||
|
try {
|
||||||
|
if (fsService == null) {
|
||||||
|
return ResponseMessage.error("未启用FS");
|
||||||
|
}
|
||||||
|
if (ObjectUtils.isEmpty(file.getContentType())) {
|
||||||
|
return ResponseMessage.error("content-type不能为空");
|
||||||
|
}
|
||||||
|
if (!file.getContentType().toLowerCase().contains("image")) {
|
||||||
|
return ResponseMessage.error("图片格式不正确");
|
||||||
|
}
|
||||||
|
FSObject fsObject = new FSObject();
|
||||||
|
fsObject.setName(file.getOriginalFilename());
|
||||||
|
fsObject.setUploadDate(new Date());
|
||||||
|
fsObject.setInputStream(file.getInputStream());
|
||||||
|
fsObject.setContentType(file.getContentType());
|
||||||
|
fsObject.setSize(file.getSize());
|
||||||
|
|
||||||
|
Map<String, String> result = new HashMap<>();
|
||||||
|
result.put("location", "/sys/message/static/images/" + fsService.pubObject(fsObject) + file.getContentType().substring(file.getContentType().lastIndexOf("/")).toLowerCase().replace("/", ".") + "?messageId=" + messageId);
|
||||||
|
return ResponseMessage.ok(null, result);
|
||||||
|
} catch (Exception e) {
|
||||||
|
return ResponseMessage.error(e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,64 @@
|
|||||||
|
package com.insigma.sys.controller;
|
||||||
|
|
||||||
|
import com.insigma.framework.core.ResponseMessage;
|
||||||
|
import com.insigma.framework.persistence.core.jdbc.PageInfo;
|
||||||
|
import com.insigma.framework.web.support.ep.dev.annotation.OdinRequest;
|
||||||
|
import com.insigma.framework.web.support.ep.dev.annotation.OdinRequestParam;
|
||||||
|
import com.insigma.framework.web.support.ep.dev.controller.BaseController;
|
||||||
|
import com.insigma.sys.dto.SysOperateLogDTO;
|
||||||
|
import com.insigma.sys.service.SysOperateLogService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.sql.SQLException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* fukq 2020/6/1
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/sys/sysoplog")
|
||||||
|
public class SysOpLogController extends BaseController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
SysOperateLogService sysOperateLogService;
|
||||||
|
|
||||||
|
@OdinRequest(init = true)
|
||||||
|
@PostMapping("/doInit")
|
||||||
|
public ResponseMessage doInit(SysOperateLogDTO f_form, Integer page, Integer size) {
|
||||||
|
tableDataQuery(f_form, page, size);
|
||||||
|
return this.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
@OdinRequest
|
||||||
|
@PostMapping("/doGridQuery/{name}")
|
||||||
|
public ResponseMessage doGridQuery(@OdinRequestParam("f_form") SysOperateLogDTO queryDTO,
|
||||||
|
@OdinRequestParam("t_tableData_page") Integer page,
|
||||||
|
@OdinRequestParam("t_tableData_size") Integer size,
|
||||||
|
@PathVariable String name) {
|
||||||
|
tableDataQuery(queryDTO, page, size);
|
||||||
|
this.set("page", page);
|
||||||
|
return this.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
@OdinRequest
|
||||||
|
@PostMapping("/query")
|
||||||
|
public ResponseMessage query(@OdinRequestParam("f_form") SysOperateLogDTO queryDTO,
|
||||||
|
@OdinRequestParam("t_tableData") PageInfo<SysOperateLogDTO> pageInfo,
|
||||||
|
Integer size) {
|
||||||
|
tableDataQuery(queryDTO, 1, size);
|
||||||
|
this.set("page", 1);
|
||||||
|
return this.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void tableDataQuery(SysOperateLogDTO queryDTO, Integer page, Integer size) {
|
||||||
|
this.pageQuery("t_tableData", () -> sysOperateLogService.querySysOperateLogList(queryDTO, page, size));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/new/query")
|
||||||
|
public ResponseMessage query(@RequestBody SysOperateLogDTO queryDTO) throws SQLException {
|
||||||
|
return ResponseMessage.ok(sysOperateLogService.querySysOperateLogList(queryDTO, queryDTO.getPage(), queryDTO.getSize()));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,495 @@
|
|||||||
|
package com.insigma.sys.controller;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson2.JSONArray;
|
||||||
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
|
import com.insigma.framework.core.ResponseMessage;
|
||||||
|
import com.insigma.framework.core.encryption.util.SM3Utils;
|
||||||
|
import com.insigma.framework.core.exception.AppException;
|
||||||
|
import com.insigma.framework.core.util.DtoEntityUtil;
|
||||||
|
import com.insigma.framework.core.util.IdCardUtil;
|
||||||
|
import com.insigma.framework.core.util.TreeUtil;
|
||||||
|
import com.insigma.framework.domain.core.entity.*;
|
||||||
|
import com.insigma.framework.persistence.core.jdbc.PageInfo;
|
||||||
|
import com.insigma.framework.security.core.dto.BaseUserInfo;
|
||||||
|
import com.insigma.framework.web.support.core.service.CodeTypeService;
|
||||||
|
import com.insigma.framework.web.support.ep.dev.util.pe.PageForm;
|
||||||
|
import com.insigma.sys.common.CommonValidator;
|
||||||
|
import com.insigma.sys.common.CurrentUserService;
|
||||||
|
import com.insigma.sys.dto.*;
|
||||||
|
import com.insigma.sys.service.Aa26Service;
|
||||||
|
import com.insigma.sys.service.SysOrgService;
|
||||||
|
import com.insigma.sys.service.SysUserService;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.util.ObjectUtils;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: caic
|
||||||
|
* @version: 10:40 2019/1/7
|
||||||
|
* @Description:
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/sys/user")
|
||||||
|
@Slf4j
|
||||||
|
public class SysUserController {
|
||||||
|
@Autowired
|
||||||
|
private CodeTypeService codeTypeService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SysUserService sysUserService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private CurrentUserService currentUserService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SysOrgService sysOrgService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private Aa26Service aa26Service;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private CommonValidator validator;
|
||||||
|
|
||||||
|
Pattern patternCn = Pattern.compile("^[\u4E00-\u9FA5]+$");
|
||||||
|
Pattern patternEn = Pattern.compile("^[A-Za-z]+$");
|
||||||
|
Pattern patternEnCn = Pattern.compile("^[0-9a-zA-Z]+$");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 初始化页面数据
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping("/doInit")
|
||||||
|
public ResponseMessage initPageDate(@RequestBody JSONObject jsonObject) {
|
||||||
|
String userType = currentUserService.getCurrentUser().getUserType();//获取当前登录用户类型
|
||||||
|
JSONObject codeTypes = jsonObject.getJSONObject("codeTypes");
|
||||||
|
JSONObject codeTypesRes = codeTypeService.getCodeTypes(codeTypes);
|
||||||
|
jsonObject.put("codeTypes", codeTypesRes);
|
||||||
|
jsonObject.put("currentUserType", userType);//设置当前登录用户类型
|
||||||
|
return ResponseMessage.ok(null, jsonObject);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 保存用户
|
||||||
|
*
|
||||||
|
* @param pageData
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping("/doSave")
|
||||||
|
public ResponseMessage save(@RequestBody JSONObject pageData) {
|
||||||
|
try {
|
||||||
|
PageForm pageForm = new PageForm(pageData);
|
||||||
|
SysUserDTO sysUser = toUser(pageForm);
|
||||||
|
if (!patternEnCn.matcher(sysUser.getLogonName()).matches()) {
|
||||||
|
throw new AppException("登录名必须是英文或数字");
|
||||||
|
}
|
||||||
|
if (!patternCn.matcher(sysUser.getDisplayName()).matches() && !patternEn.matcher(sysUser.getDisplayName()).matches()) {
|
||||||
|
throw new AppException("姓名必须是中文或英文");
|
||||||
|
}
|
||||||
|
if ("1".equals(sysUser.getCardType()) && !IdCardUtil.verify(sysUser.getCardId())) {
|
||||||
|
throw new AppException("身份证号码格式不正确");
|
||||||
|
}
|
||||||
|
if ("1".equals(sysUser.getUserType()) && !"1".equals(currentUserService.getCurrentUser().getUserType())) {
|
||||||
|
throw new AppException("非超级管理员不能创建超级管理员");
|
||||||
|
}
|
||||||
|
String sm3LogonName = SM3Utils.digest(sysUser.getLogonName());
|
||||||
|
String sm3ReverseLogonName = SM3Utils.digest(new StringBuffer(sysUser.getLogonName()).reverse().toString());
|
||||||
|
if (sm3LogonName.equals(sysUser.getPassWD()) || sm3ReverseLogonName.equals(sysUser.getPassWD())) {
|
||||||
|
throw new AppException("新密码不能与登录名(包含逆序)相同!");
|
||||||
|
}
|
||||||
|
sysUser.setUserState("1");
|
||||||
|
JSONArray orgIds = pageData.getJSONObject("orgId").getJSONArray("value");
|
||||||
|
if (orgIds.size() > 0)
|
||||||
|
sysUser.setOrgId(Long.parseLong(orgIds.get(orgIds.size() - 1) + ""));
|
||||||
|
|
||||||
|
JSONArray aa26Ids = pageData.getJSONObject("aa26").getJSONArray("value");
|
||||||
|
if (aa26Ids.size() > 0)
|
||||||
|
sysUser.setAreaId(Long.parseLong(aa26Ids.get(aa26Ids.size() - 1) + ""));
|
||||||
|
|
||||||
|
JSONArray roleIds = pageData.getJSONObject("roleIds").getJSONArray("value");
|
||||||
|
List<SysUserRoleDTO> list = new ArrayList<>();
|
||||||
|
for (Object roleId : roleIds) {
|
||||||
|
if (roleId != null) {
|
||||||
|
SysUserRoleDTO sysUserRole = new SysUserRoleDTO();
|
||||||
|
sysUserRole.setRoleId(roleId.toString());
|
||||||
|
list.add(sysUserRole);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sysUser.setUserRoles(list);
|
||||||
|
sysUser.setCreateTime(new Date());
|
||||||
|
// 设定用户过期时间
|
||||||
|
sysUser.setUserExpireDate(pageData.getJSONObject("userExpireDate").getDate("value"));
|
||||||
|
// 获取密码过期策略
|
||||||
|
String pwExpireType = (String) pageData.getJSONObject("pwExpireType").get("value");
|
||||||
|
if (!ObjectUtils.isEmpty(pwExpireType) && pwExpireType.equals("1")) {
|
||||||
|
// 系统配置周期
|
||||||
|
long l = new Date().getTime() + 7 * 24 * 3600 * 1000;
|
||||||
|
sysUser.setPwExpireDate(new Date(l));
|
||||||
|
} else if (ObjectUtils.isEmpty(pwExpireType) || pwExpireType.equals("2")) {
|
||||||
|
// 永不过期
|
||||||
|
sysUser.setPwExpireDate(null);
|
||||||
|
} else if (!ObjectUtils.isEmpty(pwExpireType) && pwExpireType.equals("3")) {
|
||||||
|
// 指定日期
|
||||||
|
sysUser.setPwExpireDate(pageData.getJSONObject("pwExpireDate").getDate("value"));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
JSONArray areaIds = pageData.getJSONObject("aa26Tree").getJSONArray("value");
|
||||||
|
List<String> addAreaIds = new ArrayList<>();
|
||||||
|
for (int i = 0; i < areaIds.size(); i++) {
|
||||||
|
JSONObject obj = areaIds.getJSONObject(i);
|
||||||
|
addAreaIds.add(obj.get("key").toString());
|
||||||
|
}
|
||||||
|
Map<String, List<String>> map = new ConcurrentHashMap<>();
|
||||||
|
map.put("addAreaIds", addAreaIds);
|
||||||
|
|
||||||
|
if (!validator.validateArea(sysUser.getAreaId() + "", sysUser.getUserType())
|
||||||
|
|| !validator.validateOrg(sysUser.getOrgId(), sysUser.getUserType())
|
||||||
|
|| !validator.validateRoleIds(roleIds.toJavaList(String.class))) {
|
||||||
|
throw new AppException("无权操作");
|
||||||
|
}
|
||||||
|
|
||||||
|
sysUserService.saveUser(sysUser, map);
|
||||||
|
|
||||||
|
return ResponseMessage.ok("保存成功");
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.getMessage(), e);
|
||||||
|
return ResponseMessage.error("保存失败,失败原因:" + e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/queryOneUser/{userId}")
|
||||||
|
public ResponseMessage queryOneUser(@PathVariable String userId) throws AppException {
|
||||||
|
SysUser sysUser = sysUserService.getByUserId(userId);
|
||||||
|
if (!validator.validateUser(sysUser.getUserId())) {
|
||||||
|
throw new AppException("无权查看");
|
||||||
|
}
|
||||||
|
//sysUser.setPassWD(null);
|
||||||
|
List<SysUserRole> roleList = sysUserService.queryUserRole(userId);
|
||||||
|
List<SysUserArea> areaList = sysUserService.queryUserArea(userId);
|
||||||
|
SysOrg sysOrg = sysOrgService.getByOrgId(sysUser.getOrgId());
|
||||||
|
Aa26 aa26 = aa26Service.getByAab301(sysUser.getAreaId() + "");
|
||||||
|
Map<String, Object> map = new ConcurrentHashMap<>();
|
||||||
|
map.put("sysUser", DtoEntityUtil.trans(sysUser, SysUserDTO.class, true));
|
||||||
|
map.put("roleList", DtoEntityUtil.trans(roleList, SysUserRoleDTO.class, true));
|
||||||
|
map.put("areaList", DtoEntityUtil.trans(areaList, SysUserAreaDTO.class, true));
|
||||||
|
|
||||||
|
if (sysOrg != null) {
|
||||||
|
map.put("orgId", sysUser.getOrgId());
|
||||||
|
map.put("sysOrgs", DtoEntityUtil.trans(sysOrg, SysOrgDTO.class, true));
|
||||||
|
//sysOrgService.findByRegioncode(sysUser.getAreaId()+"")
|
||||||
|
}
|
||||||
|
if (aa26 != null)
|
||||||
|
map.put("aa26", DtoEntityUtil.trans(aa26, Aa26DTO.class, true));
|
||||||
|
return ResponseMessage.ok(null, map);
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/queryTable")
|
||||||
|
public ResponseMessage queryTable(@RequestParam(name = "logonName") String logonName,
|
||||||
|
@RequestParam(name = "displayName") String displayName,
|
||||||
|
@RequestParam(name = "orgId") String orgId,
|
||||||
|
@RequestParam(name = "userState") String userState,
|
||||||
|
@RequestParam(name = "userType") String userType,
|
||||||
|
@RequestParam(name = "aa26") String aa26,
|
||||||
|
@RequestParam(name = "cardId") String cardId,
|
||||||
|
@RequestParam(name = "page") Integer page,
|
||||||
|
@RequestParam(name = "size") Integer size) {
|
||||||
|
PageInfo<SysUserDTO> pageInfo = sysUserService.findAll(logonName, displayName, orgId, userState,userType,aa26,cardId, page, size,"1");
|
||||||
|
JSONObject jsonObject=new JSONObject();
|
||||||
|
JSONArray jsonArray=JSONArray.parseArray(JSONArray.toJSONString(pageInfo.getData()));
|
||||||
|
for(int i=0; i < jsonArray.size(); i++){
|
||||||
|
if(jsonArray.getJSONObject(i).getString("orgId") != null) {
|
||||||
|
SysOrg sysOrg = sysOrgService.getByOrgId(Long.valueOf(jsonArray.getJSONObject(i).getString("orgId")));
|
||||||
|
if(sysOrg != null){
|
||||||
|
jsonArray.getJSONObject(i).put("orgId", sysOrg.getOrgName());
|
||||||
|
}else{
|
||||||
|
jsonArray.getJSONObject(i).put("orgId", "");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(jsonArray.getJSONObject(i).getString("areaId") != null) {
|
||||||
|
Aa26 a=aa26Service.getByAab301(jsonArray.getJSONObject(i).getString("areaId"));
|
||||||
|
if(a != null) {
|
||||||
|
jsonArray.getJSONObject(i).put("areaId", a.getAaa146());
|
||||||
|
}else{
|
||||||
|
jsonArray.getJSONObject(i).put("areaId", "");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
jsonObject.put("totalElements",pageInfo.getTotal());
|
||||||
|
jsonObject.put("content",jsonArray);
|
||||||
|
return ResponseMessage.ok(null, jsonObject);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 复制用户
|
||||||
|
* @param data
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping(value = "/copyUser")
|
||||||
|
public ResponseMessage copyUser(@RequestBody JSONObject data){
|
||||||
|
try {
|
||||||
|
if (!validator.validateUser(currentUserService.getCurrentUser().getUserId())) {
|
||||||
|
throw new AppException("无权操作");
|
||||||
|
}
|
||||||
|
sysUserService.copyUser(data);
|
||||||
|
return ResponseMessage.ok("复制成功");
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.getMessage(), e);
|
||||||
|
return ResponseMessage.error("复制失败原因:" + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 注销用户
|
||||||
|
*
|
||||||
|
* @param data
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping(value = "/logoutUser")
|
||||||
|
public ResponseMessage logoutUser(@RequestBody(required = true) JSONObject data) {
|
||||||
|
try {
|
||||||
|
String userId = data.getString("userId");
|
||||||
|
if (!validator.validateUser(userId)) {
|
||||||
|
throw new AppException("无权操作");
|
||||||
|
}
|
||||||
|
sysUserService.logoutUser(userId);
|
||||||
|
sysUserService.clearSessions(userId);
|
||||||
|
return ResponseMessage.ok("注销成功");
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.getMessage(), e);
|
||||||
|
return ResponseMessage.error("注销失败,失败原因:" + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 解锁用户
|
||||||
|
*
|
||||||
|
* @param data
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping(value = "/unlockUser")
|
||||||
|
public ResponseMessage unlockUser(@RequestBody(required = true) JSONObject data) {
|
||||||
|
try {
|
||||||
|
String userId = data.getString("userId");
|
||||||
|
if (!validator.validateUser(userId)) {
|
||||||
|
throw new AppException("无权操作");
|
||||||
|
}
|
||||||
|
sysUserService.unlockUser(userId);
|
||||||
|
return ResponseMessage.ok("解锁成功");
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.getMessage(), e);
|
||||||
|
return ResponseMessage.error("解锁失败,失败原因:" + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 锁定用户
|
||||||
|
*
|
||||||
|
* @param data
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping(value = "/lockUser")
|
||||||
|
public ResponseMessage lockUser(@RequestBody(required = true) JSONObject data) {
|
||||||
|
try {
|
||||||
|
String userId = data.getString("userId");
|
||||||
|
if (!validator.validateUser(userId)) {
|
||||||
|
throw new AppException("无权操作");
|
||||||
|
}
|
||||||
|
sysUserService.lockUser(userId);
|
||||||
|
sysUserService.clearSessions(userId);
|
||||||
|
return ResponseMessage.ok("锁定成功");
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.getMessage(), e);
|
||||||
|
return ResponseMessage.error("锁定失败,失败原因:" + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 重置密码
|
||||||
|
*
|
||||||
|
* @param data
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping("/resetPassWD")
|
||||||
|
public ResponseMessage resetPassWD(@RequestBody(required = true) JSONObject data) {
|
||||||
|
try {
|
||||||
|
String userId = data.getString("userId");
|
||||||
|
if (!validator.validateUser(userId)) {
|
||||||
|
throw new AppException("无权操作");
|
||||||
|
}
|
||||||
|
sysUserService.resetPassWD(userId);
|
||||||
|
// return ResponseMessage.ok("重置密码成功,默认密码为:" + resetPassWD);
|
||||||
|
return ResponseMessage.ok("重置密码成功");
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.getMessage(), e);
|
||||||
|
return ResponseMessage.error("重置密码失败,失败原因:" + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/editPass")
|
||||||
|
public ResponseMessage editPassWD(@RequestBody(required = true) JSONObject data){
|
||||||
|
try {
|
||||||
|
String oldPass=data.getString("oldPass");
|
||||||
|
String newPass=data.getString("newPass");
|
||||||
|
sysUserService.updataPassWD(oldPass,newPass);
|
||||||
|
return ResponseMessage.ok("修改密码成功");
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.getMessage(), e);
|
||||||
|
return ResponseMessage.error("修改密码失败,失败原因:" + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/getOrgTreeNodes/{areaId}")
|
||||||
|
public ResponseMessage getOrgTreeNodes(@PathVariable String areaId) {
|
||||||
|
JSONArray orgNodes = TreeUtil.listToTree(JSONArray.parseArray(JSONArray.toJSONString(sysUserService.queryOrgNodes(areaId))), "orgid", "parentid", "children");
|
||||||
|
return ResponseMessage.ok(null, orgNodes);
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/getAa26TreeNodes/{userType}")
|
||||||
|
public ResponseMessage getAa26TreeNodes(@PathVariable String userType) {
|
||||||
|
JSONArray orgNodes = TreeUtil.listToTree(JSONArray.parseArray(JSONArray.toJSONString(sysUserService.queryAa26Nodes())), "aab301", "aaa148", "children");
|
||||||
|
//orgNodes= JSONArray.parseArray(JSONArray.toJSONString(orgNodes).replace("aab301","id"));
|
||||||
|
return ResponseMessage.ok(null, orgNodes);
|
||||||
|
}
|
||||||
|
@GetMapping("/getOrgTreeNodes1/{userType}")
|
||||||
|
public ResponseMessage getOrgTreeNodes1(@PathVariable String userType) {
|
||||||
|
List<SysOrg> list = sysOrgService.getAll();
|
||||||
|
JSONArray orgNodes = TreeUtil.listToTree(JSONArray.parseArray(JSONArray.toJSONString(DtoEntityUtil.trans(list, SysOrgDTO.class, true))), "orgid", "parentid", "children");
|
||||||
|
return ResponseMessage.ok(null, orgNodes);
|
||||||
|
}
|
||||||
|
@GetMapping("/getUserTypeCode")
|
||||||
|
public ResponseMessage getUserTypeCode() {
|
||||||
|
List<Map<String, Object>> list = sysUserService.findUsetTypeCode();
|
||||||
|
return ResponseMessage.ok(null, list);
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/getUserStateCode")
|
||||||
|
public ResponseMessage getUserStateCode() {
|
||||||
|
return ResponseMessage.ok(null, sysUserService.getUserStateCode());
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/getRoleList/{userType}")
|
||||||
|
public ResponseMessage getRoleList(@PathVariable("userType") String userType) {
|
||||||
|
List<SysRole> list = sysUserService.findByRoleType(userType);
|
||||||
|
return ResponseMessage.ok(null, DtoEntityUtil.trans(list, SysRoleDTO.class, true));
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/doCheck/{id}")
|
||||||
|
public ResponseMessage doCheck(@PathVariable("id") String id, @RequestBody JSONObject data) {
|
||||||
|
boolean bool = true;//校验是否通过
|
||||||
|
if ("logonName".equals(id)) {
|
||||||
|
String logonName = data.getJSONObject("logonName").getString("value");
|
||||||
|
String userId=data.getJSONObject("userId").getString("value");
|
||||||
|
bool = sysUserService.checkLogonName(logonName,userId);
|
||||||
|
}
|
||||||
|
if (bool) {
|
||||||
|
ResponseMessage rm = ResponseMessage.error("存在相同登录名");
|
||||||
|
return rm;
|
||||||
|
} else {
|
||||||
|
return ResponseMessage.ok();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取所有机构
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping("/findAllOrg")
|
||||||
|
private ResponseMessage findAllOrg() {
|
||||||
|
List<SysOrg> list = sysOrgService.getAll();
|
||||||
|
return ResponseMessage.ok(null, DtoEntityUtil.trans(list, SysOrgDTO.class, true));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取所有区域
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping("/findAllAa26")
|
||||||
|
private ResponseMessage findAllAa26() {
|
||||||
|
List<Aa26> list = aa26Service.getAll();
|
||||||
|
return ResponseMessage.ok(null, DtoEntityUtil.trans(list, Aa26DTO.class, true));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取所有机构,返回格式为树结构
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping("/findAllOrgTree")
|
||||||
|
private ResponseMessage findAllOrgTree() {
|
||||||
|
List<SysOrg> list = sysOrgService.getAll();
|
||||||
|
JSONArray orgNodes = TreeUtil.listToTree(JSONArray.parseArray(JSONArray.toJSONString(DtoEntityUtil.trans(list, SysOrgDTO.class, true))), "orgid", "parentid", "children");
|
||||||
|
return ResponseMessage.ok(null, orgNodes);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通用获取下拉框选项
|
||||||
|
* @param codeType
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping("/getAa10Code/{codeType}")
|
||||||
|
public ResponseMessage getAa10Code(@PathVariable String codeType){
|
||||||
|
List<Map<String, Object>> list = sysUserService.getAa10Code(codeType);
|
||||||
|
return ResponseMessage.ok(null, list);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取当前登录用户
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping("/getCurrentUser")
|
||||||
|
public ResponseMessage getCurrentUser(){
|
||||||
|
SysUser currentUser = currentUserService.getCurrentUser();
|
||||||
|
BaseUserInfo baseUserInfo = new BaseUserInfo();
|
||||||
|
baseUserInfo.setUserid(currentUser.getUserId());
|
||||||
|
baseUserInfo.setUsername(currentUser.getLogonName());
|
||||||
|
baseUserInfo.setNickname(currentUser.getUserType());
|
||||||
|
return ResponseMessage.ok(null, baseUserInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取当前登录用户
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping("/getUserSlevel")
|
||||||
|
public ResponseMessage getUserSlevel(){
|
||||||
|
|
||||||
|
/*return ResponseMessage.ok(sysUserService.getUserSlevel());*/
|
||||||
|
ResponseMessage t = new ResponseMessage();
|
||||||
|
t.setStatus("0");
|
||||||
|
t.setData(sysUserService.getUserSlevel());
|
||||||
|
return t;
|
||||||
|
}
|
||||||
|
|
||||||
|
private SysUserDTO toUser(PageForm pageForm) {
|
||||||
|
SysUserDTO sysUserDTO = new SysUserDTO();
|
||||||
|
sysUserDTO.setUserId(pageForm.getValue("userId", String.class));
|
||||||
|
sysUserDTO.setLogonName(pageForm.getValue("logonName", String.class));
|
||||||
|
sysUserDTO.setDisplayName(pageForm.getValue("displayName", String.class));
|
||||||
|
sysUserDTO.setUserType(pageForm.getValue("userType", String.class));
|
||||||
|
sysUserDTO.setPassWD(pageForm.getValue("passWD", String.class));
|
||||||
|
sysUserDTO.setUserExpireDate(pageForm.getValue("userExpireDate", Date.class));
|
||||||
|
sysUserDTO.setPwExpireType(pageForm.getValue("pwExpireType", String.class));
|
||||||
|
sysUserDTO.setPwExpireDate(pageForm.getValue("pwExpireDate", Date.class));
|
||||||
|
sysUserDTO.setPwEditDate(pageForm.getValue("pwEditDate", Date.class));
|
||||||
|
sysUserDTO.setCardType(pageForm.getValue("cardType", String.class));
|
||||||
|
sysUserDTO.setCardId(pageForm.getValue("cardId", String.class));
|
||||||
|
sysUserDTO.setTel(pageForm.getValue("tel", String.class));
|
||||||
|
sysUserDTO.setDepartment(pageForm.getValue("department", String.class));
|
||||||
|
return sysUserDTO;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
package com.insigma.sys.controller;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson2.JSONArray;
|
||||||
|
import com.insigma.framework.core.ResponseMessage;
|
||||||
|
import com.insigma.framework.core.util.TreeUtil;
|
||||||
|
import com.insigma.framework.domain.core.entity.SysUser;
|
||||||
|
import com.insigma.sys.common.CurrentUserService;
|
||||||
|
import com.insigma.sys.dto.MenuDTO;
|
||||||
|
import com.insigma.sys.service.SysFunctionService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.util.ObjectUtils;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by yinjh on 2019/3/15.
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/sys/usermenu")
|
||||||
|
public class UserMenuController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SysFunctionService sysFunctionService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private CurrentUserService currentUserService;
|
||||||
|
|
||||||
|
@GetMapping("/getMenuList")
|
||||||
|
public ResponseMessage getMenuList() {
|
||||||
|
SysUser sysUser = currentUserService.getCurrentUser();
|
||||||
|
List<MenuDTO> menuDTOS = sysFunctionService.getMenuList(sysUser);
|
||||||
|
JSONArray jsonArray = TreeUtil.listToTree(JSONArray.parseArray(JSONArray.toJSONString(menuDTOS)), "functionid", "parentid", "children", "0");
|
||||||
|
return ResponseMessage.ok("查询成功", jsonArray);
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/getButtonAuthList")
|
||||||
|
public ResponseMessage getButtonList(String location) {
|
||||||
|
if (ObjectUtils.isEmpty(location)) {
|
||||||
|
return ResponseMessage.error("location不能为空!");
|
||||||
|
}
|
||||||
|
SysUser sysUser = currentUserService.getCurrentUser();
|
||||||
|
List<String> buttonAuthList = sysFunctionService.getButtonAuthList(sysUser, location);
|
||||||
|
return ResponseMessage.ok(null, buttonAuthList);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
package com.insigma.sys.controller;
|
||||||
|
|
||||||
|
import jakarta.servlet.ServletException;
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author yinjh
|
||||||
|
* @since 2025/2/8
|
||||||
|
*/
|
||||||
|
@Controller
|
||||||
|
public class ValidateCodeForwardController {
|
||||||
|
|
||||||
|
@RequestMapping("/validateCodeEnabled")
|
||||||
|
public void forward(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
|
||||||
|
request.getRequestDispatcher("/validateCode/enabled").forward(request, response);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
package com.insigma.sys.dto;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 系统参数 DTO
|
||||||
|
*
|
||||||
|
* @author yinjh
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class Aa01DTO implements Serializable {
|
||||||
|
|
||||||
|
@Serial
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 参数类别代码
|
||||||
|
*/
|
||||||
|
private String aaa001;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 参数类别名称
|
||||||
|
*/
|
||||||
|
private String aaa002;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 参数值
|
||||||
|
*/
|
||||||
|
private String aaa005;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 参数值域说明
|
||||||
|
*/
|
||||||
|
private String aaa105;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 代码可维护标志:1-可维护、0-不可维护
|
||||||
|
*/
|
||||||
|
private String aaa104;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
package com.insigma.sys.dto;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 字典代码 DTO
|
||||||
|
*
|
||||||
|
* @author yinjh
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class Aa10DTO implements Serializable {
|
||||||
|
|
||||||
|
@Serial
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 代码ID
|
||||||
|
*/
|
||||||
|
private Long aaz093;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 代码类型
|
||||||
|
*/
|
||||||
|
private String aaa100;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 代码值
|
||||||
|
*/
|
||||||
|
private String aaa102;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 代码名称
|
||||||
|
*/
|
||||||
|
private String aaa103;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 参数分类
|
||||||
|
*/
|
||||||
|
private String aaa105;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 有效标志:1-有效、0-无效
|
||||||
|
*/
|
||||||
|
private String aae100;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 可维护标志:1-可维护、0-不可维护
|
||||||
|
*/
|
||||||
|
private String aaa104;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
package com.insigma.sys.dto;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 行政区划 DTO
|
||||||
|
*
|
||||||
|
* @author yinjh
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class Aa26DTO implements Serializable {
|
||||||
|
|
||||||
|
@Serial
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 行政区划代码
|
||||||
|
*/
|
||||||
|
private String aab301;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 行政区划名称
|
||||||
|
*/
|
||||||
|
private String aaa146;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 行政区划级别
|
||||||
|
*/
|
||||||
|
private String aaa147;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 行政区划父级代码
|
||||||
|
*/
|
||||||
|
private String aaa148;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否统筹区,0:否,1:是
|
||||||
|
*/
|
||||||
|
private String eae037;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* id路径
|
||||||
|
*/
|
||||||
|
private String idpath;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
package com.insigma.sys.dto;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson2.annotation.JSONField;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 系统反馈答复 DTO
|
||||||
|
*
|
||||||
|
* @author yinjh
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class FeedbackAnswerDTO implements Serializable {
|
||||||
|
|
||||||
|
@Serial
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 主键ID
|
||||||
|
*/
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 反馈答复内容
|
||||||
|
*/
|
||||||
|
private String content;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户ID
|
||||||
|
*/
|
||||||
|
private String userId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建时间
|
||||||
|
*/
|
||||||
|
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
private Date createTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 反馈ID
|
||||||
|
*/
|
||||||
|
private String feedbackId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 回复类型:0-问、1-答
|
||||||
|
*/
|
||||||
|
private String type;
|
||||||
|
}
|
||||||
@@ -0,0 +1,71 @@
|
|||||||
|
package com.insigma.sys.dto;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson2.annotation.JSONField;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 问题反馈 DTO
|
||||||
|
*
|
||||||
|
* @author yinjh
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class FeedbackDTO implements Serializable {
|
||||||
|
|
||||||
|
@Serial
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 主键ID
|
||||||
|
*/
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 标题
|
||||||
|
*/
|
||||||
|
private String title;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 内容
|
||||||
|
*/
|
||||||
|
private String content;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户ID
|
||||||
|
*/
|
||||||
|
private String userId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 显示名称
|
||||||
|
*/
|
||||||
|
private String displayName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建时间
|
||||||
|
*/
|
||||||
|
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
private Date createTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 最近应答:0-无、1-有
|
||||||
|
*/
|
||||||
|
private String answered;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 日期范围
|
||||||
|
*/
|
||||||
|
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
private List<Date> dateRange;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 答复列表
|
||||||
|
*/
|
||||||
|
List<FeedbackAnswerDTO> answerList;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
package com.insigma.sys.dto;
|
||||||
|
|
||||||
|
import com.insigma.framework.web.support.module.dto.ImportConfigDTO;
|
||||||
|
import com.insigma.framework.web.support.module.dto.ImportConfigDetailDTO;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导入配置返回 DTO
|
||||||
|
*
|
||||||
|
* @author yinjh
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class ImportConfigReDTO implements Serializable {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导入配置
|
||||||
|
*/
|
||||||
|
private ImportConfigDTO config;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导入配置明细
|
||||||
|
*/
|
||||||
|
private List<ImportConfigDetailDTO> details;
|
||||||
|
}
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
package com.insigma.sys.dto;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 懒加载树节点对象
|
||||||
|
*
|
||||||
|
* @author yinjh
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class LazyTreeNode<T> implements Serializable {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 节点ID
|
||||||
|
*/
|
||||||
|
private T id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 节点名称
|
||||||
|
*/
|
||||||
|
private String label;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 节点父ID
|
||||||
|
*/
|
||||||
|
private T parent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否是叶子节点
|
||||||
|
*/
|
||||||
|
private Boolean isLeaf;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 扩展属性
|
||||||
|
*/
|
||||||
|
private Object extra;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,68 @@
|
|||||||
|
package com.insigma.sys.dto;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 菜单 DTO
|
||||||
|
*
|
||||||
|
* @author yinjh
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class MenuDTO implements Serializable {
|
||||||
|
/**
|
||||||
|
* 功能ID
|
||||||
|
*/
|
||||||
|
private long functionid;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 链接
|
||||||
|
*/
|
||||||
|
private String path;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 标题
|
||||||
|
*/
|
||||||
|
private String title;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 功能分类:0-通用、1-系统管理、2-业务功能(扩展:个人、单位、机构)
|
||||||
|
*/
|
||||||
|
private String funtype;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 父功能ID
|
||||||
|
*/
|
||||||
|
private long parentid;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 节点图标
|
||||||
|
*/
|
||||||
|
private String icon;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 排序号
|
||||||
|
*/
|
||||||
|
private int funorder;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 节点类型:1-菜单节点,2-菜单叶子
|
||||||
|
*/
|
||||||
|
private String nodetype;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 功能描述
|
||||||
|
*/
|
||||||
|
private String description;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 所属应用系统
|
||||||
|
*/
|
||||||
|
private String appid;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 打开模式:1-tab页打开,2-浏览器tab页打开
|
||||||
|
*/
|
||||||
|
private String openmode;
|
||||||
|
}
|
||||||
@@ -0,0 +1,69 @@
|
|||||||
|
package com.insigma.sys.dto;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson2.annotation.JSONField;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 消息 DTO
|
||||||
|
*
|
||||||
|
* @author yinjh
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class MessageDTO implements Serializable {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 消息ID
|
||||||
|
*/
|
||||||
|
private String messageId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 消息标题
|
||||||
|
*/
|
||||||
|
private String title;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 消息内容
|
||||||
|
*/
|
||||||
|
private String content;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 消息创建人
|
||||||
|
*/
|
||||||
|
private String creator;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 消息创建时间
|
||||||
|
*/
|
||||||
|
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
private Date createTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 消息状态,0:未读,1:已读
|
||||||
|
*/
|
||||||
|
private String flag;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 消息接收人列表
|
||||||
|
*/
|
||||||
|
private List<String> userIds;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 开始时间
|
||||||
|
*/
|
||||||
|
private Date startDate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 结束时间
|
||||||
|
*/
|
||||||
|
private Date endDate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 消息类型,0:全员消息,1:局部消息
|
||||||
|
*/
|
||||||
|
private String type;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
package com.insigma.sys.dto;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author GH
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class MonitorCentersDTO implements Serializable {
|
||||||
|
private String ip;
|
||||||
|
private String appName;
|
||||||
|
private String timeStart;
|
||||||
|
private String timeEnd;
|
||||||
|
private String start;
|
||||||
|
private String rows;
|
||||||
|
private String uriFieldName;
|
||||||
|
private String sessionFieldName;
|
||||||
|
private String sqlFieldName;
|
||||||
|
private String sort;
|
||||||
|
private String appId;
|
||||||
|
private String title;
|
||||||
|
private String company;
|
||||||
|
private Date ctime;
|
||||||
|
}
|
||||||
@@ -0,0 +1,78 @@
|
|||||||
|
package com.insigma.sys.dto;
|
||||||
|
|
||||||
|
import com.insigma.framework.domain.core.entity.ScmSafetyFilterLog;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author yinjh
|
||||||
|
* @since 2025/1/21
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
public class SafetyFilterLogDTO extends ScmSafetyFilterLog implements Serializable {
|
||||||
|
|
||||||
|
@Serial
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 日志ID
|
||||||
|
*/
|
||||||
|
private String logId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 请求URL
|
||||||
|
*/
|
||||||
|
private String requestUrl;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 请求时间
|
||||||
|
*/
|
||||||
|
private Date requestTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 登录名
|
||||||
|
*/
|
||||||
|
private String loginName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 过滤内容
|
||||||
|
*/
|
||||||
|
private String filterContent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 过滤类型
|
||||||
|
*/
|
||||||
|
private String filterType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 功能ID
|
||||||
|
*/
|
||||||
|
private Long functionId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 功能名称
|
||||||
|
*/
|
||||||
|
private String functionName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 请求来源IP
|
||||||
|
*/
|
||||||
|
private String requestOriginIp;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页
|
||||||
|
*/
|
||||||
|
private Integer page;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 每页显示数量
|
||||||
|
*/
|
||||||
|
private Integer size;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
package com.insigma.sys.dto;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 应用地址配置 DTO
|
||||||
|
*
|
||||||
|
* @author yinjh
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class SysAppAddressDTO implements Serializable {
|
||||||
|
|
||||||
|
@Serial
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 应用地址ID
|
||||||
|
*/
|
||||||
|
private String addressId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 门户地址
|
||||||
|
*/
|
||||||
|
private String portalUrl;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 应用地址
|
||||||
|
*/
|
||||||
|
private String appUrl;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 应用登录地址
|
||||||
|
*/
|
||||||
|
private String appLogoutUrl;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 应用ID
|
||||||
|
*/
|
||||||
|
private String appId;
|
||||||
|
}
|
||||||
@@ -0,0 +1,66 @@
|
|||||||
|
package com.insigma.sys.dto;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson2.annotation.JSONField;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 应用 DTO
|
||||||
|
*
|
||||||
|
* @author yinjh
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class SysAppDTO implements Serializable {
|
||||||
|
|
||||||
|
@Serial
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 应用ID
|
||||||
|
*/
|
||||||
|
private String appId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 应用编码
|
||||||
|
*/
|
||||||
|
private String appCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 应用名称
|
||||||
|
*/
|
||||||
|
private String appName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 排序号
|
||||||
|
*/
|
||||||
|
private Long orderNo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建时间
|
||||||
|
*/
|
||||||
|
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
private Date createTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改时间
|
||||||
|
*/
|
||||||
|
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
private Date updateTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否有效:1-有效、0-无效
|
||||||
|
*/
|
||||||
|
private String active;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 应用安全key
|
||||||
|
*/
|
||||||
|
private String secretKey;
|
||||||
|
|
||||||
|
public Integer page;
|
||||||
|
|
||||||
|
private Integer size;
|
||||||
|
}
|
||||||
@@ -0,0 +1,58 @@
|
|||||||
|
package com.insigma.sys.dto;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson2.annotation.JSONField;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 审核配置 DTO
|
||||||
|
*
|
||||||
|
* @author yinjh
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class SysAuditConfigDTO implements Serializable {
|
||||||
|
|
||||||
|
@Serial
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 主键ID
|
||||||
|
*/
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 模块ID
|
||||||
|
*/
|
||||||
|
private Long functionId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 审核总级别
|
||||||
|
*/
|
||||||
|
private Integer auditTotalLevel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 服务名(SpringBean的名称,实现AuditResultHandler接口)
|
||||||
|
*/
|
||||||
|
private String serviceName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否允许回退到上一级
|
||||||
|
*/
|
||||||
|
private String allowRollback;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建时间
|
||||||
|
*/
|
||||||
|
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
private Date createTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改时间
|
||||||
|
*/
|
||||||
|
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
private Date updateTime;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
package com.insigma.sys.dto;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson2.annotation.JSONField;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 下载中心 DTO
|
||||||
|
*
|
||||||
|
* @author yinjh
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class SysDownloadCenterDTO implements Serializable {
|
||||||
|
|
||||||
|
@Serial
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 材料ID
|
||||||
|
*/
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 材料名称
|
||||||
|
*/
|
||||||
|
private String material_name;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 材料类型
|
||||||
|
*/
|
||||||
|
private String material_type;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 材料大小
|
||||||
|
*/
|
||||||
|
private String material_size;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 上传时间
|
||||||
|
*/
|
||||||
|
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
private Date upload_time;
|
||||||
|
|
||||||
|
private Integer page;
|
||||||
|
|
||||||
|
private Integer size;
|
||||||
|
}
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
package com.insigma.sys.dto;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson2.annotation.JSONField;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 系统错误信息 DTO
|
||||||
|
*
|
||||||
|
* @author yinjh
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class SysErrorDTO implements Serializable {
|
||||||
|
|
||||||
|
@Serial
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 主键ID
|
||||||
|
*/
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 服务编码
|
||||||
|
*/
|
||||||
|
private String serviceName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 模块编码
|
||||||
|
*/
|
||||||
|
private String functionName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 错误编码
|
||||||
|
*/
|
||||||
|
private String errorCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 错误信息
|
||||||
|
*/
|
||||||
|
private String message;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建时间
|
||||||
|
*/
|
||||||
|
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
private Date createTime;
|
||||||
|
}
|
||||||
@@ -0,0 +1,119 @@
|
|||||||
|
package com.insigma.sys.dto;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 功能菜单 DTO
|
||||||
|
*
|
||||||
|
* @author yinjh
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class SysFunctionDTO implements Serializable {
|
||||||
|
|
||||||
|
@Serial
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 功能ID
|
||||||
|
*/
|
||||||
|
private Long functionid;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 链接
|
||||||
|
*/
|
||||||
|
private String location;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 标题
|
||||||
|
*/
|
||||||
|
private String title;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 父功能ID
|
||||||
|
*/
|
||||||
|
private Long parentid;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 排序号
|
||||||
|
*/
|
||||||
|
private int funorder;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 节点类型:1-菜单节点,2-菜单叶子
|
||||||
|
*/
|
||||||
|
private String nodetype;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否记录日志 1-记,0-不记
|
||||||
|
*/
|
||||||
|
private String islog;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 开发人员
|
||||||
|
*/
|
||||||
|
private String developer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 节点图标
|
||||||
|
*/
|
||||||
|
private String icon;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 功能的中文描述
|
||||||
|
*/
|
||||||
|
private String description;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 功能分类,0通用1系统管理2业务功能(扩展:个人、单位、机构)
|
||||||
|
*/
|
||||||
|
private String funtype;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否有效
|
||||||
|
*/
|
||||||
|
private String active;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 功能编号
|
||||||
|
*/
|
||||||
|
private String funcode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 审核标志,0-不自动审核,1-自动审核
|
||||||
|
*/
|
||||||
|
private String auflag;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 操作日志回退标志,0-不可以,1-可以
|
||||||
|
*/
|
||||||
|
private String rbflag;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ID路径
|
||||||
|
*/
|
||||||
|
private String idpath;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 摘要字段
|
||||||
|
*/
|
||||||
|
private String digest;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 密级字段 0-普通,1-秘密,2-机密
|
||||||
|
*/
|
||||||
|
private String slevel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 所属应用系统
|
||||||
|
*/
|
||||||
|
private String appId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 打开模式:1-tab页打开,2-浏览器tab页打开
|
||||||
|
*/
|
||||||
|
private String openmode;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
package com.insigma.sys.dto;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson2.annotation.JSONField;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 功能文档 DTO
|
||||||
|
*
|
||||||
|
* @author yinjh
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class SysFunctionDocDTO implements Serializable {
|
||||||
|
|
||||||
|
@Serial
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 菜单ID
|
||||||
|
*/
|
||||||
|
private Long functionid;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 概述
|
||||||
|
*/
|
||||||
|
private String overview;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 详细说明
|
||||||
|
*/
|
||||||
|
private String detailed_view;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新时间
|
||||||
|
*/
|
||||||
|
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
private Date update_time;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新人
|
||||||
|
*/
|
||||||
|
private String update_name;
|
||||||
|
|
||||||
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user