commit
b1ddf743c6
@ -0,0 +1,58 @@
|
||||
pipeline {
|
||||
options {
|
||||
timeout(time: 12, unit: 'MINUTES')
|
||||
}
|
||||
agent any
|
||||
|
||||
environment {
|
||||
JOB_NAME = 'enterprise-policy-api_test'
|
||||
testServerIP = '192.168.1.7'
|
||||
productServerIP = '192.168.1.8'
|
||||
}
|
||||
|
||||
parameters {
|
||||
booleanParam(name: 'FAST_MODE', defaultValue: false, description: '此操作将会跳过单元测试以及代码质量检查。')
|
||||
}
|
||||
|
||||
stages {
|
||||
stage('pipeline环境准备') {
|
||||
|
||||
steps {
|
||||
script {
|
||||
echo "开始构建"
|
||||
hostIP = ""
|
||||
sh "echo 当前分支 : ${env.BRANCH_NAME}"
|
||||
sh "echo 当前环境 : ${env.env}"
|
||||
sh "echo 当前提交 : ${env.commit}"
|
||||
sh "echo WORKSPACE : ${env.WORKSPACE}"
|
||||
sh "echo GIT_BRANCH : ${env.GIT_BRANCH}"
|
||||
sh "echo BUILD_NUMBER : ${env.BUILD_NUMBER}"
|
||||
sh "echo JOB_NAME : ${env.JOB_NAME}"
|
||||
sh "java -version"
|
||||
if(env.BRANCH_NAME=="master"){
|
||||
//开始打jar包
|
||||
sh "mvn clean package -P prod -Dmaven.test.skip=true -U"
|
||||
hostIP = productServerIP;
|
||||
}
|
||||
if(env.BRANCH_NAME=="test"){
|
||||
//开始打jar包
|
||||
sh "mvn clean package -P test -Dmaven.test.skip=true -U"
|
||||
hostIP = testServerIP;
|
||||
}
|
||||
if(env.BRANCH_NAME=="dev"){
|
||||
//开始打jar包
|
||||
sh "mvn clean package -P dev -Dmaven.test.skip=true -U"
|
||||
}
|
||||
if(env.BRANCH_NAME=="dev"){
|
||||
sh 'cp enterprise-policy/target/enterprise-policy-2.4.3.jar /vdb/www/9028-enterprise-policy-api'
|
||||
sh 'cd /vdb/www/9028-enterprise-policy-api;source /etc/profile;sudo -su root ./shutdown.sh;sudo -su root ./startup.sh'
|
||||
}else{
|
||||
sh "scp enterprise-policy/target/enterprise-policy-2.4.3.jar ${hostIP}:/vdb/www/9028-enterprise-policy-api"
|
||||
sh "ssh ${hostIP} \"source /etc/profile;cd /vdb/www/9028-enterprise-policy-api;./shutdown.sh;./startup.sh;\""
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>jeecg-boot-base-api</artifactId>
|
||||
<groupId>org.jeecgframework.boot</groupId>
|
||||
<version>2.4.3</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>jeecg-system-cloud-api</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<!-- feign -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-openfeign</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@ -0,0 +1,17 @@
|
||||
package org.jeecg.common.system.api.factory;
|
||||
|
||||
import org.jeecg.common.system.api.ISysBaseAPI;
|
||||
import org.jeecg.common.system.api.fallback.SysBaseAPIFallback;
|
||||
import org.springframework.cloud.openfeign.FallbackFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class SysBaseAPIFallbackFactory implements FallbackFactory<ISysBaseAPI> {
|
||||
|
||||
@Override
|
||||
public ISysBaseAPI create(Throwable throwable) {
|
||||
SysBaseAPIFallback fallback = new SysBaseAPIFallback();
|
||||
fallback.setCause(throwable);
|
||||
return fallback;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,272 @@
|
||||
package org.jeecg.common.system.api.fallback;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.Setter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.jeecg.common.api.dto.OnlineAuthDTO;
|
||||
import org.jeecg.common.api.dto.message.*;
|
||||
import org.jeecg.common.system.api.ISysBaseAPI;
|
||||
import org.jeecg.common.system.vo.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 进入fallback的方法 检查是否token未设置
|
||||
*/
|
||||
@Slf4j
|
||||
public class SysBaseAPIFallback implements ISysBaseAPI {
|
||||
|
||||
@Setter
|
||||
private Throwable cause;
|
||||
|
||||
@Override
|
||||
public void sendSysAnnouncement(MessageDTO message) {
|
||||
log.error("发送消息失败 {}", cause);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendBusAnnouncement(BusMessageDTO message) {
|
||||
log.error("发送消息失败 {}", cause);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendTemplateAnnouncement(TemplateMessageDTO message) {
|
||||
log.error("发送消息失败 {}", cause);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendBusTemplateAnnouncement(BusTemplateMessageDTO message) {
|
||||
log.error("发送消息失败 {}", cause);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String parseTemplateByCode(TemplateDTO templateDTO) {
|
||||
log.error("通过模板获取消息内容失败 {}", cause);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LoginUser getUserById(String id) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getRolesByUsername(String username) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getDepartIdsByUsername(String username) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getDepartNamesByUsername(String username) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DictModel> queryDictItemsByCode(String code) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DictModel> queryAllDict() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SysCategoryModel> queryAllDSysCategory() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DictModel> queryTableDictItemsByCode(String table, String text, String code) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DictModel> queryAllDepartBackDictModel() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateSysAnnounReadFlag(String busType, String busId) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DictModel> queryFilterTableDictInfo(String table, String text, String code, String filterSql) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> queryTableDictByKeys(String table, String text, String code, String[] keyArray) {
|
||||
log.error("queryTableDictByKeys查询失败 {}", cause);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ComboModel> queryAllUserBackCombo() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject queryAllUser(String userIds, Integer pageNo, int pageSize) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ComboModel> queryAllRole(String[] roleIds) {
|
||||
log.error("获取角色信息失败 {}", cause);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getRoleIdsByUsername(String username) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDepartIdsByOrgCode(String orgCode) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SysDepartModel> getAllSysDepart() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DictModel getParentDepartId(String departId) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getDeptHeadByDepId(String deptId) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendWebSocketMsg(String[] userIds, String cmd) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<LoginUser> queryAllUserByIds(String[] userIds) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void meetingSignWebsocket(String userId) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<LoginUser> queryUserByNames(String[] userNames) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> getUserRoleSet(String username) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> getUserPermissionSet(String username) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasOnlineAuth(OnlineAuthDTO onlineAuthDTO) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SysDepartModel selectAllById(String id) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> queryDeptUsersByUserId(String userId) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> queryUserRoles(String username) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> queryUserAuths(String username) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DynamicDataSourceModel getDynamicDbSourceById(String dbSourceId) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DynamicDataSourceModel getDynamicDbSourceByCode(String dbSourceCode) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LoginUser getUserByName(String username) {
|
||||
log.error("通过用户名获取当前登录用户信息 {}", cause);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String translateDictFromTable(String table, String text, String code, String key) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String translateDict(String code, String key) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SysPermissionDataRuleModel> queryPermissionDataRule(String component, String requestPath, String username) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SysUserCacheInfo getCacheUser(String username) {
|
||||
log.error("获取用户信息失败 {}", cause);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<JSONObject> queryUsersByUsernames(String usernames) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<JSONObject> queryUsersByIds(String ids) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<JSONObject> queryDepartsByOrgcodes(String orgCodes) {
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public void sendEmailMsg(String email,String title,String content) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Map> getDeptUserByOrgCode(String orgCode) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<JSONObject> queryDepartsByOrgIds(String ids) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>jeecg-boot-base-api</artifactId>
|
||||
<groupId>org.jeecgframework.boot</groupId>
|
||||
<version>2.4.3</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>jeecg-system-local-api</artifactId>
|
||||
|
||||
</project>
|
||||
@ -0,0 +1,27 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>jeecg-boot-base</artifactId>
|
||||
<groupId>org.jeecgframework.boot</groupId>
|
||||
<version>2.4.3</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>jeecg-boot-base-api</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<modules>
|
||||
<module>jeecg-system-local-api</module>
|
||||
<module>jeecg-system-cloud-api</module>
|
||||
</modules>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.jeecgframework.boot</groupId>
|
||||
<artifactId>jeecg-boot-base-core</artifactId>
|
||||
<version>2.4.3</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@ -0,0 +1,270 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<groupId>org.jeecgframework.boot</groupId>
|
||||
<artifactId>jeecg-boot-base</artifactId>
|
||||
<version>2.4.3</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>jeecg-boot-base-core</artifactId>
|
||||
|
||||
<repositories>
|
||||
<!--<repository>
|
||||
<id>aliyun</id>
|
||||
<name>aliyun Repository</name>
|
||||
<url>http://maven.aliyun.com/nexus/content/groups/public</url>
|
||||
<snapshots>
|
||||
<enabled>false</enabled>
|
||||
</snapshots>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>jeecg</id>
|
||||
<name>jeecg Repository</name>
|
||||
<url>http://maven.jeecg.org/nexus/content/repositories/jeecg</url>
|
||||
<snapshots>
|
||||
<enabled>false</enabled>
|
||||
</snapshots>
|
||||
</repository>-->
|
||||
</repositories>
|
||||
|
||||
|
||||
<dependencies>
|
||||
<!--jeecg-tools-->
|
||||
<dependency>
|
||||
<groupId>org.jeecgframework.boot</groupId>
|
||||
<artifactId>jeecg-boot-base-tools</artifactId>
|
||||
<version>2.4.3</version>
|
||||
</dependency>
|
||||
<!--集成springmvc框架并实现自动配置 -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
<!-- websocket -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-websocket</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-mail</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-aop</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||
</dependency>
|
||||
<!--springboot2.3+ 需引入validation对应的包-->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-validation</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- commons -->
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
<version>${commons.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-lang</groupId>
|
||||
<artifactId>commons-lang</artifactId>
|
||||
<version>${commons.version}</version>
|
||||
</dependency>
|
||||
<!-- freemarker -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-freemarker</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- mybatis-plus -->
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-boot-starter</artifactId>
|
||||
<version>${mybatis-plus.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- druid -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>druid-spring-boot-starter</artifactId>
|
||||
<version>${druid.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 动态数据源 -->
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>dynamic-datasource-spring-boot-starter</artifactId>
|
||||
<version>${dynamic-datasource-spring-boot-starter.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.hibernate</groupId>
|
||||
<artifactId>hibernate-core</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>commons-collections</groupId>
|
||||
<artifactId>commons-collections</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jeecgframework.boot</groupId>
|
||||
<artifactId>hibernate-re</artifactId>
|
||||
<version>2.4.3-RC</version>
|
||||
</dependency>
|
||||
|
||||
<!--mysql-->
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
<version>${mysql-connector-java.version}</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<!-- sqlserver-->
|
||||
<dependency>
|
||||
<groupId>com.microsoft.sqlserver</groupId>
|
||||
<artifactId>sqljdbc4</artifactId>
|
||||
<version>${sqljdbc4.version}</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<!-- oracle驱动 -->
|
||||
<dependency>
|
||||
<groupId>com.oracle</groupId>
|
||||
<artifactId>ojdbc6</artifactId>
|
||||
<version>${ojdbc6.version}</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<!-- postgresql驱动 -->
|
||||
<dependency>
|
||||
<groupId>org.postgresql</groupId>
|
||||
<artifactId>postgresql</artifactId>
|
||||
<version>${postgresql.version}</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- Quartz定时任务 -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-quartz</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!--JWT-->
|
||||
<dependency>
|
||||
<groupId>com.auth0</groupId>
|
||||
<artifactId>java-jwt</artifactId>
|
||||
<version>${java-jwt.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!--shiro-->
|
||||
<dependency>
|
||||
<groupId>org.apache.shiro</groupId>
|
||||
<artifactId>shiro-spring-boot-starter</artifactId>
|
||||
<version>${shiro.version}</version>
|
||||
</dependency>
|
||||
<!-- shiro-redis -->
|
||||
<dependency>
|
||||
<groupId>org.crazycake</groupId>
|
||||
<artifactId>shiro-redis</artifactId>
|
||||
<version>${shiro-redis.version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.apache.shiro</groupId>
|
||||
<artifactId>shiro-core</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<!-- knife4j -->
|
||||
<dependency>
|
||||
<groupId>com.github.xiaoymin</groupId>
|
||||
<artifactId>knife4j-spring-boot-starter</artifactId>
|
||||
<version>${knife4j-spring-boot-starter.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 代码生成器 -->
|
||||
<!-- 如下载失败,请参考此文档 http://doc.jeecg.com/2043876 -->
|
||||
<dependency>
|
||||
<groupId>org.jeecgframework.boot</groupId>
|
||||
<artifactId>codegenerate</artifactId>
|
||||
<version>${codegenerate.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- AutoPoi Excel工具类-->
|
||||
<dependency>
|
||||
<groupId>org.jeecgframework</groupId>
|
||||
<artifactId>autopoi-web</artifactId>
|
||||
<version>${autopoi-web.version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>commons-codec</groupId>
|
||||
<artifactId>commons-codec</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<!-- mini文件存储服务 -->
|
||||
<dependency>
|
||||
<groupId>io.minio</groupId>
|
||||
<artifactId>minio</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.guava</groupId>
|
||||
<artifactId>guava</artifactId>
|
||||
<version>${guava.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 阿里云短信 -->
|
||||
<dependency>
|
||||
<groupId>com.aliyun</groupId>
|
||||
<artifactId>aliyun-java-sdk-dysmsapi</artifactId>
|
||||
<version>${aliyun-java-sdk-dysmsapi.version}</version>
|
||||
</dependency>
|
||||
<!-- aliyun oss -->
|
||||
<dependency>
|
||||
<groupId>com.aliyun.oss</groupId>
|
||||
<artifactId>aliyun-sdk-oss</artifactId>
|
||||
<version>${aliyun.oss.version}</version>
|
||||
</dependency>
|
||||
<!-- 第三方登录 -->
|
||||
<dependency>
|
||||
<groupId>com.xkcoding.justauth</groupId>
|
||||
<artifactId>justauth-spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.squareup.okhttp3</groupId>
|
||||
<artifactId>okhttp</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>cn.dev33</groupId>
|
||||
<artifactId>sa-token-oauth2</artifactId>
|
||||
<version>1.28.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>cn.dev33</groupId>
|
||||
<artifactId>sa-token-spring-boot-starter</artifactId>
|
||||
<version>1.28.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.dev33</groupId>
|
||||
<artifactId>sa-token-dao-redis-jackson</artifactId>
|
||||
<version>1.28.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.sun</groupId>
|
||||
<artifactId>tools</artifactId>
|
||||
<version>1.8.0</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${JAVA_HOME}/lib/tools.jar</systemPath>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
@ -0,0 +1,102 @@
|
||||
package org.jeecg.common.api;
|
||||
|
||||
import org.jeecg.common.system.vo.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
public interface CommonAPI {
|
||||
|
||||
/**
|
||||
* 1查询用户角色信息
|
||||
* @param username
|
||||
* @return
|
||||
*/
|
||||
Set<String> queryUserRoles(String username);
|
||||
|
||||
|
||||
/**
|
||||
* 2查询用户权限信息
|
||||
* @param username
|
||||
* @return
|
||||
*/
|
||||
Set<String> queryUserAuths(String username);
|
||||
|
||||
/**
|
||||
* 3根据 id 查询数据库中存储的 DynamicDataSourceModel
|
||||
*
|
||||
* @param dbSourceId
|
||||
* @return
|
||||
*/
|
||||
DynamicDataSourceModel getDynamicDbSourceById(String dbSourceId);
|
||||
|
||||
/**
|
||||
* 4根据 code 查询数据库中存储的 DynamicDataSourceModel
|
||||
*
|
||||
* @param dbSourceCode
|
||||
* @return
|
||||
*/
|
||||
DynamicDataSourceModel getDynamicDbSourceByCode(String dbSourceCode);
|
||||
|
||||
/**
|
||||
* 5根据用户账号查询用户信息
|
||||
* @param username
|
||||
* @return
|
||||
*/
|
||||
public LoginUser getUserByName(String username);
|
||||
|
||||
|
||||
/**
|
||||
* 6字典表的 翻译
|
||||
* @param table
|
||||
* @param text
|
||||
* @param code
|
||||
* @param key
|
||||
* @return
|
||||
*/
|
||||
String translateDictFromTable(String table, String text, String code, String key);
|
||||
|
||||
/**
|
||||
* 7普通字典的翻译
|
||||
* @param code
|
||||
* @param key
|
||||
* @return
|
||||
*/
|
||||
String translateDict(String code, String key);
|
||||
|
||||
/**
|
||||
* 8查询数据权限
|
||||
* @return
|
||||
*/
|
||||
List<SysPermissionDataRuleModel> queryPermissionDataRule(String component, String requestPath, String username);
|
||||
|
||||
|
||||
/**
|
||||
* 9查询用户信息
|
||||
* @param username
|
||||
* @return
|
||||
*/
|
||||
SysUserCacheInfo getCacheUser(String username);
|
||||
|
||||
/**
|
||||
* 10获取数据字典
|
||||
* @param code
|
||||
* @return
|
||||
*/
|
||||
public List<DictModel> queryDictItemsByCode(String code);
|
||||
|
||||
/**
|
||||
* 13获取表数据字典
|
||||
* @param table
|
||||
* @param text
|
||||
* @param code
|
||||
* @return
|
||||
*/
|
||||
List<DictModel> queryTableDictItemsByCode(String table, String text, String code);
|
||||
|
||||
Map<String,String> queryUserDeptAreaInfo(String username);
|
||||
|
||||
List<String> queryUserAreaAuth(String username);
|
||||
|
||||
}
|
||||
@ -0,0 +1,24 @@
|
||||
package org.jeecg.common.api;
|
||||
|
||||
import org.jeecg.common.api.vo.OaWpsModel;
|
||||
|
||||
/**
|
||||
* @Description: WPS通用接口
|
||||
* @Author: wangshuai
|
||||
* @Date:20200709
|
||||
* @Version:V1.0
|
||||
*/
|
||||
public interface IWpsBaseAPI {
|
||||
|
||||
/*根据模板id获取模板信息*/
|
||||
OaWpsModel getById(String id);
|
||||
|
||||
/*根据文件路径下载文件*/
|
||||
void downloadOosFiles(String objectName, String basePath,String fileName);
|
||||
|
||||
/*WPS 设置数据存储,用于逻辑判断*/
|
||||
void context(String type,String text);
|
||||
|
||||
/*删除WPS模板相关信息*/
|
||||
void deleteById(String id);
|
||||
}
|
||||
@ -0,0 +1,30 @@
|
||||
package org.jeecg.common.api.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 文件下载
|
||||
* cloud api 用到的接口传输对象
|
||||
*/
|
||||
@Data
|
||||
public class FileDownDTO implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 6749126258686446019L;
|
||||
|
||||
private String filePath;
|
||||
private String uploadpath;
|
||||
private String uploadType;
|
||||
private HttpServletResponse response;
|
||||
|
||||
public FileDownDTO(){}
|
||||
|
||||
public FileDownDTO(String filePath, String uploadpath, String uploadType,HttpServletResponse response){
|
||||
this.filePath = filePath;
|
||||
this.uploadpath = uploadpath;
|
||||
this.uploadType = uploadType;
|
||||
this.response = response;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,55 @@
|
||||
package org.jeecg.common.api.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 文件上传
|
||||
* cloud api 用到的接口传输对象
|
||||
*/
|
||||
@Data
|
||||
public class FileUploadDTO implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -4111953058578954386L;
|
||||
|
||||
private MultipartFile file;
|
||||
|
||||
private String bizPath;
|
||||
|
||||
private String uploadType;
|
||||
|
||||
private String customBucket;
|
||||
|
||||
public FileUploadDTO(){
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 简单上传 构造器1
|
||||
* @param file
|
||||
* @param bizPath
|
||||
* @param uploadType
|
||||
*/
|
||||
public FileUploadDTO(MultipartFile file,String bizPath,String uploadType){
|
||||
this.file = file;
|
||||
this.bizPath = bizPath;
|
||||
this.uploadType = uploadType;
|
||||
}
|
||||
|
||||
/**
|
||||
* 申明桶 文件上传 构造器2
|
||||
* @param file
|
||||
* @param bizPath
|
||||
* @param uploadType
|
||||
* @param customBucket
|
||||
*/
|
||||
public FileUploadDTO(MultipartFile file,String bizPath,String uploadType,String customBucket){
|
||||
this.file = file;
|
||||
this.bizPath = bizPath;
|
||||
this.uploadType = uploadType;
|
||||
this.customBucket = customBucket;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,68 @@
|
||||
package org.jeecg.common.api.dto;
|
||||
import lombok.Data;
|
||||
import org.jeecg.common.system.vo.LoginUser;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 日志对象
|
||||
* cloud api 用到的接口传输对象
|
||||
*/
|
||||
@Data
|
||||
public class LogDTO implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 8482720462943906924L;
|
||||
|
||||
/**内容*/
|
||||
private String logContent;
|
||||
|
||||
/**日志类型(0:操作日志;1:登录日志;2:定时任务) */
|
||||
private Integer logType;
|
||||
|
||||
/**操作类型(1:添加;2:修改;3:删除;) */
|
||||
private Integer operateType;
|
||||
|
||||
/**登录用户 */
|
||||
private LoginUser loginUser;
|
||||
|
||||
private String id;
|
||||
private String createBy;
|
||||
private Date createTime;
|
||||
private Long costTime;
|
||||
private String ip;
|
||||
|
||||
/**请求参数 */
|
||||
private String requestParam;
|
||||
|
||||
/**请求类型*/
|
||||
private String requestType;
|
||||
|
||||
/**请求路径*/
|
||||
private String requestUrl;
|
||||
|
||||
/**请求方法 */
|
||||
private String method;
|
||||
|
||||
/**操作人用户名称*/
|
||||
private String username;
|
||||
|
||||
/**操作人用户账户*/
|
||||
private String userid;
|
||||
|
||||
public LogDTO(){
|
||||
|
||||
}
|
||||
|
||||
public LogDTO(String logContent, Integer logType, Integer operatetype){
|
||||
this.logContent = logContent;
|
||||
this.logType = logType;
|
||||
this.operateType = operatetype;
|
||||
}
|
||||
|
||||
public LogDTO(String logContent, Integer logType, Integer operatetype, LoginUser loginUser){
|
||||
this.logContent = logContent;
|
||||
this.logType = logType;
|
||||
this.operateType = operatetype;
|
||||
this.loginUser = loginUser;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,41 @@
|
||||
package org.jeecg.common.api.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* online 拦截器权限判断
|
||||
* cloud api 用到的接口传输对象
|
||||
*/
|
||||
@Data
|
||||
public class OnlineAuthDTO implements Serializable {
|
||||
private static final long serialVersionUID = 1771827545416418203L;
|
||||
|
||||
|
||||
/**
|
||||
* 用户名
|
||||
*/
|
||||
private String username;
|
||||
|
||||
/**
|
||||
* 可能的请求地址
|
||||
*/
|
||||
private List<String> possibleUrl;
|
||||
|
||||
/**
|
||||
* online开发的菜单地址
|
||||
*/
|
||||
private String onlineFormUrl;
|
||||
|
||||
public OnlineAuthDTO(){
|
||||
|
||||
}
|
||||
|
||||
public OnlineAuthDTO(String username, List<String> possibleUrl, String onlineFormUrl){
|
||||
this.username = username;
|
||||
this.possibleUrl = possibleUrl;
|
||||
this.onlineFormUrl = onlineFormUrl;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,43 @@
|
||||
package org.jeecg.common.api.dto.message;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 带业务参数的消息
|
||||
*/
|
||||
@Data
|
||||
public class BusMessageDTO extends MessageDTO implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 9104793287983367669L;
|
||||
/**
|
||||
* 业务类型
|
||||
*/
|
||||
private String busType;
|
||||
|
||||
/**
|
||||
* 业务id
|
||||
*/
|
||||
private String busId;
|
||||
|
||||
public BusMessageDTO(){
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 构造 带业务参数的消息
|
||||
* @param fromUser
|
||||
* @param toUser
|
||||
* @param title
|
||||
* @param msgContent
|
||||
* @param msgCategory
|
||||
* @param busType
|
||||
* @param busId
|
||||
*/
|
||||
public BusMessageDTO(String fromUser, String toUser, String title, String msgContent, String msgCategory, String busType, String busId){
|
||||
super(fromUser, toUser, title, msgContent, msgCategory);
|
||||
this.busId = busId;
|
||||
this.busType = busType;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,45 @@
|
||||
package org.jeecg.common.api.dto.message;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 带业务参数的模板消息
|
||||
*/
|
||||
@Data
|
||||
public class BusTemplateMessageDTO extends TemplateMessageDTO implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -4277810906346929459L;
|
||||
|
||||
/**
|
||||
* 业务类型
|
||||
*/
|
||||
private String busType;
|
||||
|
||||
/**
|
||||
* 业务id
|
||||
*/
|
||||
private String busId;
|
||||
|
||||
public BusTemplateMessageDTO(){
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 构造 带业务参数的模板消息
|
||||
* @param fromUser
|
||||
* @param toUser
|
||||
* @param title
|
||||
* @param templateParam
|
||||
* @param templateCode
|
||||
* @param busType
|
||||
* @param busId
|
||||
*/
|
||||
public BusTemplateMessageDTO(String fromUser, String toUser, String title, Map<String, String> templateParam, String templateCode, String busType, String busId){
|
||||
super(fromUser, toUser, title, templateParam, templateCode);
|
||||
this.busId = busId;
|
||||
this.busType = busType;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,69 @@
|
||||
package org.jeecg.common.api.dto.message;
|
||||
|
||||
import lombok.Data;
|
||||
import org.jeecg.common.constant.CommonConstant;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 普通消息
|
||||
*/
|
||||
@Data
|
||||
public class MessageDTO implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -5690444483968058442L;
|
||||
|
||||
/**
|
||||
* 发送人(用户登录账户)
|
||||
*/
|
||||
protected String fromUser;
|
||||
|
||||
/**
|
||||
* 发送给(用户登录账户)
|
||||
*/
|
||||
protected String toUser;
|
||||
|
||||
/**
|
||||
* 消息主题
|
||||
*/
|
||||
protected String title;
|
||||
|
||||
/**
|
||||
* 消息内容
|
||||
*/
|
||||
protected String content;
|
||||
|
||||
/**
|
||||
* 消息类型 1:消息 2:系统消息
|
||||
*/
|
||||
protected String category;
|
||||
|
||||
|
||||
public MessageDTO(){
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 构造器1 系统消息
|
||||
*/
|
||||
public MessageDTO(String fromUser,String toUser,String title, String content){
|
||||
this.fromUser = fromUser;
|
||||
this.toUser = toUser;
|
||||
this.title = title;
|
||||
this.content = content;
|
||||
//默认 都是2系统消息
|
||||
this.category = CommonConstant.MSG_CATEGORY_2;
|
||||
}
|
||||
|
||||
/**
|
||||
* 构造器2 支持设置category 1:消息 2:系统消息
|
||||
*/
|
||||
public MessageDTO(String fromUser,String toUser,String title, String content, String category){
|
||||
this.fromUser = fromUser;
|
||||
this.toUser = toUser;
|
||||
this.title = title;
|
||||
this.content = content;
|
||||
this.category = category;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,37 @@
|
||||
package org.jeecg.common.api.dto.message;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 消息模板dto
|
||||
*/
|
||||
@Data
|
||||
public class TemplateDTO implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 5848247133907528650L;
|
||||
|
||||
/**
|
||||
* 模板编码
|
||||
*/
|
||||
protected String templateCode;
|
||||
|
||||
/**
|
||||
* 模板参数
|
||||
*/
|
||||
protected Map<String, String> templateParam;
|
||||
|
||||
/**
|
||||
* 构造器 通过设置模板参数和模板编码 作为参数获取消息内容
|
||||
*/
|
||||
public TemplateDTO(String templateCode, Map<String, String> templateParam){
|
||||
this.templateCode = templateCode;
|
||||
this.templateParam = templateParam;
|
||||
}
|
||||
|
||||
public TemplateDTO(){
|
||||
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,48 @@
|
||||
package org.jeecg.common.api.dto.message;
|
||||
|
||||
import lombok.Data;
|
||||
import java.io.Serializable;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 模板消息
|
||||
*/
|
||||
@Data
|
||||
public class TemplateMessageDTO extends TemplateDTO implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 411137565170647585L;
|
||||
|
||||
|
||||
/**
|
||||
* 发送人(用户登录账户)
|
||||
*/
|
||||
protected String fromUser;
|
||||
|
||||
/**
|
||||
* 发送给(用户登录账户)
|
||||
*/
|
||||
protected String toUser;
|
||||
|
||||
/**
|
||||
* 消息主题
|
||||
*/
|
||||
protected String title;
|
||||
|
||||
|
||||
public TemplateMessageDTO(){
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 构造器1 发模板消息用
|
||||
*/
|
||||
public TemplateMessageDTO(String fromUser, String toUser,String title, Map<String, String> templateParam, String templateCode){
|
||||
super(templateCode, templateParam);
|
||||
this.fromUser = fromUser;
|
||||
this.toUser = toUser;
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,107 @@
|
||||
package org.jeecg.common.api.vo;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.jeecgframework.poi.excel.annotation.Excel;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @Description: 文档
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2020-06-09
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Data
|
||||
@TableName("oa_wps_file")
|
||||
@Accessors(chain = true)
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@ApiModel(value = "oa_wps_file对象", description = "文档")
|
||||
public class OaWpsModel implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
@ApiModelProperty(value = "id")
|
||||
private String id;
|
||||
/**
|
||||
* name
|
||||
*/
|
||||
@Excel(name = "name", width = 15)
|
||||
@ApiModelProperty(value = "name")
|
||||
private String name;
|
||||
/**
|
||||
* version
|
||||
*/
|
||||
@Excel(name = "version", width = 15)
|
||||
@ApiModelProperty(value = "version")
|
||||
private Integer version;
|
||||
/**
|
||||
* size
|
||||
*/
|
||||
@Excel(name = "size", width = 15)
|
||||
@ApiModelProperty(value = "size")
|
||||
private Integer size;
|
||||
/**
|
||||
* downloadUrl
|
||||
*/
|
||||
@Excel(name = "downloadUrl", width = 15)
|
||||
@ApiModelProperty(value = "downloadUrl")
|
||||
private String downloadUrl;
|
||||
/**
|
||||
* deleted
|
||||
*/
|
||||
@Excel(name = "deleted", width = 15)
|
||||
@ApiModelProperty(value = "deleted")
|
||||
private String deleted;
|
||||
/**
|
||||
* canDelete
|
||||
*/
|
||||
@Excel(name = "canDelete", width = 15)
|
||||
@ApiModelProperty(value = "canDelete")
|
||||
private String canDelete;
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
@ApiModelProperty(value = "创建人")
|
||||
private String createBy;
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
||||
@ApiModelProperty(value = "创建时间")
|
||||
private Date createTime;
|
||||
/**
|
||||
* 更新人
|
||||
*/
|
||||
@ApiModelProperty(value = "更新人")
|
||||
private String updateBy;
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
||||
@ApiModelProperty(value = "更新时间")
|
||||
private Date updateTime;
|
||||
/**
|
||||
* 组织机构编码
|
||||
*/
|
||||
@ApiModelProperty(value = "组织机构编码")
|
||||
private String sysOrgCode;
|
||||
|
||||
@TableField(exist = false)
|
||||
private String userId;
|
||||
}
|
||||
@ -0,0 +1,197 @@
|
||||
package org.jeecg.common.api.vo;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import org.jeecg.common.constant.CommonConstant;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 接口返回数据格式
|
||||
* @author scott
|
||||
* @email jeecgos@163.com
|
||||
* @date 2019年1月19日
|
||||
*/
|
||||
@Data
|
||||
@ApiModel(value="接口返回对象", description="接口返回对象")
|
||||
public class Result<T> implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 成功标志
|
||||
*/
|
||||
@ApiModelProperty(value = "成功标志")
|
||||
private boolean success = true;
|
||||
|
||||
/**
|
||||
* 返回处理消息
|
||||
*/
|
||||
@ApiModelProperty(value = "返回处理消息")
|
||||
private String message = "操作成功!";
|
||||
|
||||
/**
|
||||
* 返回代码
|
||||
*/
|
||||
@ApiModelProperty(value = "返回代码")
|
||||
private Integer code = 0;
|
||||
|
||||
/**
|
||||
* 返回数据对象 data
|
||||
*/
|
||||
@ApiModelProperty(value = "返回数据对象")
|
||||
private T result;
|
||||
|
||||
/**
|
||||
* 时间戳
|
||||
*/
|
||||
@ApiModelProperty(value = "时间戳")
|
||||
private long timestamp = System.currentTimeMillis();
|
||||
|
||||
public Result() {
|
||||
|
||||
}
|
||||
|
||||
public Result<T> success(String message) {
|
||||
this.message = message;
|
||||
this.code = CommonConstant.SC_OK_200;
|
||||
this.success = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static Result<Object> ok() {
|
||||
Result<Object> r = new Result<Object>();
|
||||
r.setSuccess(true);
|
||||
r.setCode(CommonConstant.SC_OK_200);
|
||||
r.setMessage("成功");
|
||||
return r;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static Result<Object> ok(String msg) {
|
||||
Result<Object> r = new Result<Object>();
|
||||
r.setSuccess(true);
|
||||
r.setCode(CommonConstant.SC_OK_200);
|
||||
r.setMessage(msg);
|
||||
return r;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static Result<Object> ok(Object data) {
|
||||
Result<Object> r = new Result<Object>();
|
||||
r.setSuccess(true);
|
||||
r.setCode(CommonConstant.SC_OK_200);
|
||||
r.setResult(data);
|
||||
return r;
|
||||
}
|
||||
|
||||
public static<T> Result<T> OK() {
|
||||
Result<T> r = new Result<T>();
|
||||
r.setSuccess(true);
|
||||
r.setCode(CommonConstant.SC_OK_200);
|
||||
r.setMessage("成功");
|
||||
return r;
|
||||
}
|
||||
|
||||
public static<T> Result<T> OK(T data) {
|
||||
Result<T> r = new Result<T>();
|
||||
r.setSuccess(true);
|
||||
r.setCode(CommonConstant.SC_OK_200);
|
||||
r.setResult(data);
|
||||
return r;
|
||||
}
|
||||
|
||||
public static<T> Result<T> OK(String msg, T data) {
|
||||
Result<T> r = new Result<T>();
|
||||
r.setSuccess(true);
|
||||
r.setCode(CommonConstant.SC_OK_200);
|
||||
r.setMessage(msg);
|
||||
r.setResult(data);
|
||||
return r;
|
||||
}
|
||||
|
||||
public static Result<Object> error(String msg) {
|
||||
return error(CommonConstant.SC_INTERNAL_SERVER_ERROR_500, msg);
|
||||
}
|
||||
|
||||
public static Result<Object> error(int code, String msg) {
|
||||
Result<Object> r = new Result<Object>();
|
||||
r.setCode(code);
|
||||
r.setMessage(msg);
|
||||
r.setSuccess(false);
|
||||
return r;
|
||||
}
|
||||
public Result<T> errorCode(int code, String msg) {
|
||||
Result<T> r = new Result<T>();
|
||||
r.setCode(code);
|
||||
r.setMessage(msg);
|
||||
r.setSuccess(false);
|
||||
return r;
|
||||
}
|
||||
|
||||
public Result<T> error400(String message) {
|
||||
this.message = message;
|
||||
this.code = CommonConstant.SC_INTERNAL_SERVER_ERROR_400;
|
||||
this.success = false;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Result<T> error10001(String message) {
|
||||
this.message = message;
|
||||
this.code = CommonConstant.SC_INTERNAL_SERVER_ERROR_10001;
|
||||
this.success = false;
|
||||
return this;
|
||||
}
|
||||
public Result<T> error10002(String message) {
|
||||
this.message = message;
|
||||
this.code = CommonConstant.SC_INTERNAL_SERVER_ERROR_10002;
|
||||
this.success = false;
|
||||
return this;
|
||||
}
|
||||
public Result<T> error10003(String message) {
|
||||
this.message = message;
|
||||
this.code = CommonConstant.SC_INTERNAL_SERVER_ERROR_10003;
|
||||
this.success = false;
|
||||
return this;
|
||||
}
|
||||
public Result<T> error10004(String message) {
|
||||
this.message = message;
|
||||
this.code = CommonConstant.SC_INTERNAL_SERVER_ERROR_10004;
|
||||
this.success = false;
|
||||
return this;
|
||||
}
|
||||
public Result<T> error10005(String message) {
|
||||
this.message = message;
|
||||
this.code = CommonConstant.SC_INTERNAL_SERVER_ERROR_10005;
|
||||
this.success = false;
|
||||
return this;
|
||||
}
|
||||
public Result<T> error10006(String message) {
|
||||
this.message = message;
|
||||
this.code = CommonConstant.SC_INTERNAL_SERVER_ERROR_10006;
|
||||
this.success = false;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Result<T> error500(String message) {
|
||||
this.message = message;
|
||||
this.code = CommonConstant.SC_INTERNAL_SERVER_ERROR_500;
|
||||
this.success = false;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 无权限访问返回结果
|
||||
*/
|
||||
public static Result<Object> noauth(String msg) {
|
||||
return error(CommonConstant.SC_JEECG_NO_AUTHZ, msg);
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
private String onlTable;
|
||||
|
||||
}
|
||||
@ -0,0 +1,29 @@
|
||||
package org.jeecg.common.aspect.annotation;
|
||||
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* 数据权限注解
|
||||
* @Author taoyan
|
||||
* @Date 2019年4月11日
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target({ElementType.TYPE,ElementType.METHOD})
|
||||
@Documented
|
||||
public @interface PermissionData {
|
||||
/**
|
||||
* 暂时没用
|
||||
* @return
|
||||
*/
|
||||
String value() default "";
|
||||
|
||||
|
||||
/**
|
||||
* 配置菜单的组件路径,用于数据权限
|
||||
*/
|
||||
String pageComponent() default "";
|
||||
}
|
||||
@ -0,0 +1,26 @@
|
||||
package org.jeecg.common.constant;
|
||||
|
||||
/**
|
||||
* 系统通告 - 发布状态
|
||||
* @Author LeeShaoQing
|
||||
*
|
||||
*/
|
||||
public interface CommonSendStatus {
|
||||
|
||||
public static final String UNPUBLISHED_STATUS_0 = "0"; //未发布
|
||||
|
||||
public static final String PUBLISHED_STATUS_1 = "1"; //已发布
|
||||
|
||||
public static final String REVOKE_STATUS_2 = "2"; //撤销
|
||||
//app端推送会话标识后缀
|
||||
public static final String APP_SESSION_SUFFIX = "_app"; //app端推送会话标识后缀
|
||||
|
||||
|
||||
|
||||
/**流程催办——系统通知消息模板*/
|
||||
public static final String TZMB_BPM_CUIBAN = "bpm_cuiban";
|
||||
/**标准模板—系统消息通知*/
|
||||
public static final String TZMB_SYS_TS_NOTE = "sys_ts_note";
|
||||
/**流程超时提醒——系统通知消息模板*/
|
||||
public static final String TZMB_BPM_CHAOSHI_TIP = "bpm_chaoshi_tip";
|
||||
}
|
||||
@ -0,0 +1,25 @@
|
||||
package org.jeecg.common.constant;
|
||||
|
||||
/**
|
||||
* 规则值生成 编码常量类
|
||||
* @author: taoyan
|
||||
* @date: 2020年04月02日
|
||||
*/
|
||||
public class FillRuleConstant {
|
||||
|
||||
/**
|
||||
* 公文发文编码
|
||||
*/
|
||||
public static final String DOC_SEND = "doc_send_code";
|
||||
|
||||
/**
|
||||
* 部门编码
|
||||
*/
|
||||
public static final String DEPART = "org_num_role";
|
||||
|
||||
/**
|
||||
* 分类字典编码
|
||||
*/
|
||||
public static final String CATEGORY = "category_code_rule";
|
||||
|
||||
}
|
||||
@ -0,0 +1,131 @@
|
||||
package org.jeecg.common.constant;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.jeecg.common.util.oConvertUtils;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Scanner;
|
||||
import java.util.Set;
|
||||
import java.util.List;
|
||||
|
||||
@Component("pca")
|
||||
public class ProvinceCityArea {
|
||||
List<Area> areaList;
|
||||
|
||||
public String getText(String code){
|
||||
this.initAreaList();
|
||||
if(this.areaList!=null || this.areaList.size()>0){
|
||||
List<String> ls = new ArrayList<String>();
|
||||
getAreaByCode(code,ls);
|
||||
return String.join("/",ls);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public String getCode(String text){
|
||||
this.initAreaList();
|
||||
if(areaList!=null || areaList.size()>0){
|
||||
for(int i=areaList.size()-1;i>=0;i--){
|
||||
if(text.indexOf(areaList.get(i).getText())>=0){
|
||||
return areaList.get(i).getId();
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void getAreaByCode(String code,List<String> ls){
|
||||
for(Area area: areaList){
|
||||
if(area.getId().equals(code)){
|
||||
String pid = area.getPid();
|
||||
ls.add(0,area.getText());
|
||||
getAreaByCode(pid,ls);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void initAreaList(){
|
||||
//System.out.println("=====================");
|
||||
if(this.areaList==null || this.areaList.size()==0){
|
||||
this.areaList = new ArrayList<Area>();
|
||||
try {
|
||||
String jsonData = oConvertUtils.readStatic("classpath:static/pca.json");
|
||||
JSONObject baseJson = JSONObject.parseObject(jsonData);
|
||||
//第一层 省
|
||||
JSONObject provinceJson = baseJson.getJSONObject("86");
|
||||
for(String provinceKey: provinceJson.keySet()){
|
||||
//System.out.println("===="+provinceKey);
|
||||
Area province = new Area(provinceKey,provinceJson.getString(provinceKey),"86");
|
||||
this.areaList.add(province);
|
||||
//第二层 市
|
||||
JSONObject cityJson = baseJson.getJSONObject(provinceKey);
|
||||
for(String cityKey:cityJson.keySet()){
|
||||
//System.out.println("-----"+cityKey);
|
||||
Area city = new Area(cityKey,cityJson.getString(cityKey),provinceKey);
|
||||
this.areaList.add(city);
|
||||
//第三层 区
|
||||
JSONObject areaJson = baseJson.getJSONObject(cityKey);
|
||||
if(areaJson!=null){
|
||||
for(String areaKey:areaJson.keySet()){
|
||||
//System.out.println("········"+areaKey);
|
||||
Area area = new Area(areaKey,areaJson.getString(areaKey),cityKey);
|
||||
this.areaList.add(area);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
private String jsonRead(File file){
|
||||
Scanner scanner = null;
|
||||
StringBuilder buffer = new StringBuilder();
|
||||
try {
|
||||
scanner = new Scanner(file, "utf-8");
|
||||
while (scanner.hasNextLine()) {
|
||||
buffer.append(scanner.nextLine());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
||||
} finally {
|
||||
if (scanner != null) {
|
||||
scanner.close();
|
||||
}
|
||||
}
|
||||
return buffer.toString();
|
||||
}
|
||||
|
||||
class Area{
|
||||
String id;
|
||||
String text;
|
||||
String pid;
|
||||
|
||||
public Area(String id,String text,String pid){
|
||||
this.id = id;
|
||||
this.text = text;
|
||||
this.pid = pid;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getText() {
|
||||
return text;
|
||||
}
|
||||
|
||||
public String getPid() {
|
||||
return pid;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,38 @@
|
||||
/*
|
||||
*
|
||||
* * Copyright (c) 2019-2020, 冷冷 (wangiegie@gmail.com).
|
||||
* * <p>
|
||||
* * Licensed under the GNU Lesser General Public License 3.0 (the "License");
|
||||
* * you may not use this file except in compliance with the License.
|
||||
* * You may obtain a copy of the License at
|
||||
* * <p>
|
||||
* * https://www.gnu.org/licenses/lgpl.html
|
||||
* * <p>
|
||||
* * 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.
|
||||
*
|
||||
*/
|
||||
|
||||
package org.jeecg.common.constant;
|
||||
|
||||
/**
|
||||
* @author scott
|
||||
* @date 2019年05月18日
|
||||
* 服务名称
|
||||
*/
|
||||
public interface ServiceNameConstants {
|
||||
|
||||
/**
|
||||
* 系统管理 admin
|
||||
*/
|
||||
String SYSTEM_SERVICE = "jeecg-system";
|
||||
|
||||
/**
|
||||
* gateway通过header传递根路径 basePath
|
||||
*/
|
||||
String X_GATEWAY_BASE_PATH = "X_GATEWAY_BASE_PATH";
|
||||
|
||||
}
|
||||
@ -0,0 +1,61 @@
|
||||
package org.jeecg.common.constant;
|
||||
|
||||
/**
|
||||
* @Description: Websocket常量类
|
||||
* @author: taoyan
|
||||
* @date: 2020年03月23日
|
||||
*/
|
||||
public class WebsocketConst {
|
||||
|
||||
|
||||
/**
|
||||
* 消息json key:cmd
|
||||
*/
|
||||
public static final String MSG_CMD = "cmd";
|
||||
|
||||
/**
|
||||
* 消息json key:msgId
|
||||
*/
|
||||
public static final String MSG_ID = "msgId";
|
||||
|
||||
/**
|
||||
* 消息json key:msgTxt
|
||||
*/
|
||||
public static final String MSG_TXT = "msgTxt";
|
||||
|
||||
/**
|
||||
* 消息json key:userId
|
||||
*/
|
||||
public static final String MSG_USER_ID = "userId";
|
||||
|
||||
/**
|
||||
* 消息类型 heartcheck
|
||||
*/
|
||||
public static final String CMD_CHECK = "heartcheck";
|
||||
|
||||
/**
|
||||
* 消息类型 user 用户消息
|
||||
*/
|
||||
public static final String CMD_USER = "user";
|
||||
|
||||
/**
|
||||
* 消息类型 topic 系统通知
|
||||
*/
|
||||
public static final String CMD_TOPIC = "topic";
|
||||
|
||||
/**
|
||||
* 消息类型 email
|
||||
*/
|
||||
public static final String CMD_EMAIL = "email";
|
||||
|
||||
/**
|
||||
* 消息类型 meetingsign 会议签到
|
||||
*/
|
||||
public static final String CMD_SIGN = "sign";
|
||||
|
||||
/**
|
||||
* 消息类型 新闻发布/取消
|
||||
*/
|
||||
public static final String NEWS_PUBLISH = "publish";
|
||||
|
||||
}
|
||||
@ -0,0 +1,17 @@
|
||||
package org.jeecg.common.constant.enums;
|
||||
|
||||
/**
|
||||
* 日志按模块分类
|
||||
*/
|
||||
public enum ModuleType {
|
||||
|
||||
/**
|
||||
* 普通
|
||||
*/
|
||||
COMMON,
|
||||
|
||||
/**
|
||||
* online
|
||||
*/
|
||||
ONLINE;
|
||||
}
|
||||
@ -0,0 +1,19 @@
|
||||
package org.jeecg.common.exception;
|
||||
|
||||
public class JeecgBootException extends RuntimeException {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public JeecgBootException(String message){
|
||||
super(message);
|
||||
}
|
||||
|
||||
public JeecgBootException(Throwable cause)
|
||||
{
|
||||
super(cause);
|
||||
}
|
||||
|
||||
public JeecgBootException(String message,Throwable cause)
|
||||
{
|
||||
super(message,cause);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,133 @@
|
||||
package org.jeecg.common.exception;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import org.apache.shiro.authz.AuthorizationException;
|
||||
import org.apache.shiro.authz.UnauthorizedException;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.springframework.dao.DataIntegrityViolationException;
|
||||
import org.springframework.dao.DuplicateKeyException;
|
||||
import org.springframework.data.redis.connection.PoolException;
|
||||
import org.springframework.validation.FieldError;
|
||||
import org.springframework.web.HttpRequestMethodNotSupportedException;
|
||||
import org.springframework.web.bind.MethodArgumentNotValidException;
|
||||
import org.springframework.web.bind.MissingServletRequestParameterException;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||
import org.springframework.web.multipart.MaxUploadSizeExceededException;
|
||||
import org.springframework.web.servlet.NoHandlerFoundException;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* 异常处理器
|
||||
*
|
||||
* @Author scott
|
||||
* @Date 2019
|
||||
*/
|
||||
@RestControllerAdvice
|
||||
@Slf4j
|
||||
public class JeecgBootExceptionHandler {
|
||||
|
||||
/**
|
||||
* 处理自定义异常
|
||||
*/
|
||||
@ExceptionHandler(JeecgBootException.class)
|
||||
public Result<?> handleRRException(JeecgBootException e){
|
||||
log.error(e.getMessage(), e);
|
||||
return Result.error(e.getMessage());
|
||||
}
|
||||
|
||||
@ExceptionHandler(NoHandlerFoundException.class)
|
||||
public Result<?> handlerNoFoundException(Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return Result.error(404, "路径不存在,请检查路径是否正确");
|
||||
}
|
||||
|
||||
@ExceptionHandler(DuplicateKeyException.class)
|
||||
public Result<?> handleDuplicateKeyException(DuplicateKeyException e){
|
||||
log.error(e.getMessage(), e);
|
||||
return Result.error("数据库中已存在该记录");
|
||||
}
|
||||
|
||||
@ExceptionHandler({UnauthorizedException.class, AuthorizationException.class})
|
||||
public Result<?> handleAuthorizationException(AuthorizationException e){
|
||||
log.error(e.getMessage(), e);
|
||||
return Result.noauth("没有权限,请联系管理员授权");
|
||||
}
|
||||
|
||||
@ExceptionHandler(Exception.class)
|
||||
public Result<?> handleException(Exception e){
|
||||
log.error(e.getMessage(), e);
|
||||
return Result.error("操作失败,请联系管理员。");
|
||||
}
|
||||
|
||||
/**
|
||||
* @Author 政辉
|
||||
* @param e
|
||||
* @return
|
||||
*/
|
||||
@ExceptionHandler(HttpRequestMethodNotSupportedException.class)
|
||||
public Result<?> httpRequestMethodNotSupportedException(HttpRequestMethodNotSupportedException e){
|
||||
StringBuffer sb = new StringBuffer();
|
||||
sb.append("不支持").append(e.getMethod()).append("请求方法,").append("支持以下");
|
||||
String [] methods = e.getSupportedMethods();
|
||||
if(methods!=null){
|
||||
for(String str:methods){
|
||||
sb.append(str);
|
||||
sb.append("、");
|
||||
}
|
||||
}
|
||||
log.error(sb.toString(), e);
|
||||
return Result.error(405,sb.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* spring默认上传大小100MB 超出大小捕获异常MaxUploadSizeExceededException
|
||||
*/
|
||||
@ExceptionHandler(MaxUploadSizeExceededException.class)
|
||||
public Result<?> handleMaxUploadSizeExceededException(MaxUploadSizeExceededException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return Result.error("文件大小超出10MB限制, 请压缩或降低文件质量! ");
|
||||
}
|
||||
|
||||
@ExceptionHandler(DataIntegrityViolationException.class)
|
||||
public Result<?> handleDataIntegrityViolationException(DataIntegrityViolationException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return Result.error("字段太长,超出数据库字段的长度");
|
||||
}
|
||||
|
||||
@ExceptionHandler(PoolException.class)
|
||||
public Result<?> handlePoolException(PoolException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return Result.error("Redis 连接异常!");
|
||||
}
|
||||
|
||||
@ExceptionHandler(MissingServletRequestParameterException.class)
|
||||
public Result<?> handleMissingServletRequestParameterException(MissingServletRequestParameterException e) {
|
||||
log.error(e.getParameterName() + ":必传");
|
||||
return Result.error(e.getParameterName() + ":必传");
|
||||
}
|
||||
|
||||
@ExceptionHandler(IllegalArgumentException.class)
|
||||
public Result<?> illegalArgumentException(IllegalArgumentException e) {
|
||||
log.error(e.getMessage());
|
||||
return Result.error(e.getMessage());
|
||||
}
|
||||
|
||||
/**
|
||||
* 统一处理请求参数校验(json)
|
||||
*
|
||||
* @param e MethodArgumentNotValidException
|
||||
* @return Result
|
||||
*/
|
||||
@ExceptionHandler(MethodArgumentNotValidException.class)
|
||||
public Result<?> handleMethodArgumentNotValidException(MethodArgumentNotValidException e) {
|
||||
StringBuilder message = new StringBuilder();
|
||||
for (FieldError error : e.getBindingResult().getFieldErrors()) {
|
||||
message.append(error.getDefaultMessage()).append(",");
|
||||
}
|
||||
message = new StringBuilder(message.substring(0, message.length() - 1));
|
||||
log.error(message.toString(), e);
|
||||
return Result.error("参数异常"+ StrUtil.COLON +message);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,52 @@
|
||||
package org.jeecg.common.system.base.entity;
|
||||
|
||||
import java.io.Serializable;
|
||||
import org.jeecgframework.poi.excel.annotation.Excel;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* @Description: Entity基类
|
||||
* @Author: dangzhenghui@163.com
|
||||
* @Date: 2019-4-28
|
||||
* @Version: 1.1
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Accessors(chain = true)
|
||||
public class JeecgEntity implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** ID */
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
@ApiModelProperty(value = "ID")
|
||||
private java.lang.String id;
|
||||
/** 创建人 */
|
||||
@ApiModelProperty(value = "创建人")
|
||||
@Excel(name = "创建人", width = 15)
|
||||
private java.lang.String createBy;
|
||||
/** 创建时间 */
|
||||
@ApiModelProperty(value = "创建时间")
|
||||
@Excel(name = "创建时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private java.util.Date createTime;
|
||||
/** 更新人 */
|
||||
@ApiModelProperty(value = "更新人")
|
||||
@Excel(name = "更新人", width = 15)
|
||||
private java.lang.String updateBy;
|
||||
/** 更新时间 */
|
||||
@ApiModelProperty(value = "更新时间")
|
||||
@Excel(name = "更新时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private java.util.Date updateTime;
|
||||
}
|
||||
@ -0,0 +1,12 @@
|
||||
package org.jeecg.common.system.base.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* @Description: Service基类
|
||||
* @Author: dangzhenghui@163.com
|
||||
* @Date: 2019-4-21 8:13
|
||||
* @Version: 1.0
|
||||
*/
|
||||
public interface JeecgService<T> extends IService<T> {
|
||||
}
|
||||
@ -0,0 +1,19 @@
|
||||
package org.jeecg.common.system.base.service.impl;
|
||||
|
||||
import org.jeecg.common.system.base.entity.JeecgEntity;
|
||||
import org.jeecg.common.system.base.service.JeecgService;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* @Description: ServiceImpl基类
|
||||
* @Author: dangzhenghui@163.com
|
||||
* @Date: 2019-4-21 8:13
|
||||
* @Version: 1.0
|
||||
*/
|
||||
@Slf4j
|
||||
public class JeecgServiceImpl<M extends BaseMapper<T>, T extends JeecgEntity> extends ServiceImpl<M, T> implements JeecgService<T> {
|
||||
|
||||
}
|
||||
@ -0,0 +1,43 @@
|
||||
package org.jeecg.common.system.query;
|
||||
|
||||
import org.jeecg.common.util.oConvertUtils;
|
||||
|
||||
/**
|
||||
* 查询链接规则
|
||||
*
|
||||
* @Author Sunjianlei
|
||||
*/
|
||||
public enum MatchTypeEnum {
|
||||
|
||||
AND("AND"),
|
||||
OR("OR");
|
||||
|
||||
private String value;
|
||||
|
||||
MatchTypeEnum(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public static MatchTypeEnum getByValue(Object value) {
|
||||
if (oConvertUtils.isEmpty(value)) {
|
||||
return null;
|
||||
}
|
||||
return getByValue(value.toString());
|
||||
}
|
||||
|
||||
public static MatchTypeEnum getByValue(String value) {
|
||||
if (oConvertUtils.isEmpty(value)) {
|
||||
return null;
|
||||
}
|
||||
for (MatchTypeEnum val : values()) {
|
||||
if (val.getValue().toLowerCase().equals(value.toLowerCase())) {
|
||||
return val;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,55 @@
|
||||
package org.jeecg.common.system.query;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class QueryCondition implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 4740166316629191651L;
|
||||
|
||||
private String field;
|
||||
private String type;
|
||||
private String rule;
|
||||
private String val;
|
||||
|
||||
public String getField() {
|
||||
return field;
|
||||
}
|
||||
|
||||
public void setField(String field) {
|
||||
this.field = field;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getRule() {
|
||||
return rule;
|
||||
}
|
||||
|
||||
public void setRule(String rule) {
|
||||
this.rule = rule;
|
||||
}
|
||||
|
||||
public String getVal() {
|
||||
return val;
|
||||
}
|
||||
|
||||
public void setVal(String val) {
|
||||
this.val = val;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(){
|
||||
StringBuffer sb =new StringBuffer();
|
||||
if(field == null || "".equals(field)){
|
||||
return "";
|
||||
}
|
||||
sb.append(this.field).append(" ").append(this.rule).append(" ").append(this.type).append(" ").append(this.val);
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,73 @@
|
||||
package org.jeecg.common.system.query;
|
||||
|
||||
import org.jeecg.common.util.oConvertUtils;
|
||||
|
||||
/**
|
||||
* Query 规则 常量
|
||||
* @Author Scott
|
||||
* @Date 2019年02月14日
|
||||
*/
|
||||
public enum QueryRuleEnum {
|
||||
|
||||
GT(">","gt","大于"),
|
||||
GE(">=","ge","大于等于"),
|
||||
LT("<","lt","小于"),
|
||||
LE("<=","le","小于等于"),
|
||||
EQ("=","eq","等于"),
|
||||
NE("!=","ne","不等于"),
|
||||
IN("IN","in","包含"),
|
||||
LIKE("LIKE","like","全模糊"),
|
||||
LEFT_LIKE("LEFT_LIKE","left_like","左模糊"),
|
||||
RIGHT_LIKE("RIGHT_LIKE","right_like","右模糊"),
|
||||
EQ_WITH_ADD("EQWITHADD","eq_with_add","带加号等于"),
|
||||
LIKE_WITH_AND("LIKEWITHAND","like_with_and","多词模糊匹配————暂时未用上"),
|
||||
SQL_RULES("USE_SQL_RULES","ext","自定义SQL片段");
|
||||
|
||||
private String value;
|
||||
|
||||
private String condition;
|
||||
|
||||
private String msg;
|
||||
|
||||
QueryRuleEnum(String value, String condition, String msg){
|
||||
this.value = value;
|
||||
this.condition = condition;
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getMsg() {
|
||||
return msg;
|
||||
}
|
||||
|
||||
public void setMsg(String msg) {
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
public String getCondition() {
|
||||
return condition;
|
||||
}
|
||||
|
||||
public void setCondition(String condition) {
|
||||
this.condition = condition;
|
||||
}
|
||||
|
||||
public static QueryRuleEnum getByValue(String value){
|
||||
if(oConvertUtils.isEmpty(value)) {
|
||||
return null;
|
||||
}
|
||||
for(QueryRuleEnum val :values()){
|
||||
if (val.getValue().equals(value) || val.getCondition().equals(value)){
|
||||
return val;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,36 @@
|
||||
package org.jeecg.common.system.vo;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Accessors(chain = true)
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class ComboModel implements Serializable {
|
||||
private String id;
|
||||
private String title;
|
||||
/**文档管理 表单table默认选中*/
|
||||
private boolean checked;
|
||||
/**文档管理 表单table 用户账号*/
|
||||
private String username;
|
||||
/**文档管理 表单table 用户邮箱*/
|
||||
private String email;
|
||||
/**文档管理 表单table 角色编码*/
|
||||
private String roleCode;
|
||||
|
||||
public ComboModel(){
|
||||
|
||||
};
|
||||
|
||||
public ComboModel(String id,String title,boolean checked,String username){
|
||||
this.id = id;
|
||||
this.title = title;
|
||||
this.checked = false;
|
||||
this.username = username;
|
||||
};
|
||||
}
|
||||
@ -0,0 +1,34 @@
|
||||
package org.jeecg.common.system.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 字典查询参数实体
|
||||
*/
|
||||
@Data
|
||||
public class DictQuery {
|
||||
/**
|
||||
* 表名
|
||||
*/
|
||||
private String table;
|
||||
/**
|
||||
* 存储列
|
||||
*/
|
||||
private String code;
|
||||
|
||||
/**
|
||||
* 显示列
|
||||
*/
|
||||
private String text;
|
||||
|
||||
/**
|
||||
* 关键字查询
|
||||
*/
|
||||
private String keyword;
|
||||
|
||||
/**
|
||||
* 存储列的值 用于回显查询
|
||||
*/
|
||||
private String codeValue;
|
||||
|
||||
}
|
||||
@ -0,0 +1,52 @@
|
||||
package org.jeecg.common.system.vo;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
|
||||
@Data
|
||||
public class DynamicDataSourceModel {
|
||||
|
||||
public DynamicDataSourceModel() {
|
||||
|
||||
}
|
||||
|
||||
public DynamicDataSourceModel(Object dbSource) {
|
||||
if (dbSource != null) {
|
||||
BeanUtils.copyProperties(dbSource, this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
private java.lang.String id;
|
||||
/**
|
||||
* 数据源编码
|
||||
*/
|
||||
private java.lang.String code;
|
||||
/**
|
||||
* 数据库类型
|
||||
*/
|
||||
private java.lang.String dbType;
|
||||
/**
|
||||
* 驱动类
|
||||
*/
|
||||
private java.lang.String dbDriver;
|
||||
/**
|
||||
* 数据源地址
|
||||
*/
|
||||
private java.lang.String dbUrl;
|
||||
/**
|
||||
* 数据库名称
|
||||
*/
|
||||
private java.lang.String dbName;
|
||||
/**
|
||||
* 用户名
|
||||
*/
|
||||
private java.lang.String dbUsername;
|
||||
/**
|
||||
* 密码
|
||||
*/
|
||||
private java.lang.String dbPassword;
|
||||
|
||||
}
|
||||
@ -0,0 +1,52 @@
|
||||
package org.jeecg.common.system.vo;
|
||||
|
||||
import org.jeecgframework.poi.excel.annotation.Excel;
|
||||
|
||||
/**
|
||||
* @Author qinfeng
|
||||
* @Date 2020/2/19 12:01
|
||||
* @Description:
|
||||
* @Version 1.0
|
||||
*/
|
||||
public class SysCategoryModel {
|
||||
/**主键*/
|
||||
private java.lang.String id;
|
||||
/**父级节点*/
|
||||
private java.lang.String pid;
|
||||
/**类型名称*/
|
||||
private java.lang.String name;
|
||||
/**类型编码*/
|
||||
private java.lang.String code;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getPid() {
|
||||
return pid;
|
||||
}
|
||||
|
||||
public void setPid(String pid) {
|
||||
this.pid = pid;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(String code) {
|
||||
this.code = code;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,151 @@
|
||||
package org.jeecg.common.system.vo;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 菜单权限规则表
|
||||
* </p>
|
||||
*
|
||||
* @Author huangzhilin
|
||||
* @since 2019-03-29
|
||||
*/
|
||||
public class SysPermissionDataRuleModel {
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 对应的菜单id
|
||||
*/
|
||||
private String permissionId;
|
||||
|
||||
/**
|
||||
* 规则名称
|
||||
*/
|
||||
private String ruleName;
|
||||
|
||||
/**
|
||||
* 字段
|
||||
*/
|
||||
private String ruleColumn;
|
||||
|
||||
/**
|
||||
* 条件
|
||||
*/
|
||||
private String ruleConditions;
|
||||
|
||||
/**
|
||||
* 规则值
|
||||
*/
|
||||
private String ruleValue;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
private String createBy;
|
||||
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
private Date updateTime;
|
||||
|
||||
/**
|
||||
* 修改人
|
||||
*/
|
||||
private String updateBy;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getPermissionId() {
|
||||
return permissionId;
|
||||
}
|
||||
|
||||
public void setPermissionId(String permissionId) {
|
||||
this.permissionId = permissionId;
|
||||
}
|
||||
|
||||
public String getRuleName() {
|
||||
return ruleName;
|
||||
}
|
||||
|
||||
public void setRuleName(String ruleName) {
|
||||
this.ruleName = ruleName;
|
||||
}
|
||||
|
||||
public String getRuleColumn() {
|
||||
return ruleColumn;
|
||||
}
|
||||
|
||||
public void setRuleColumn(String ruleColumn) {
|
||||
this.ruleColumn = ruleColumn;
|
||||
}
|
||||
|
||||
public String getRuleConditions() {
|
||||
return ruleConditions;
|
||||
}
|
||||
|
||||
public void setRuleConditions(String ruleConditions) {
|
||||
this.ruleConditions = ruleConditions;
|
||||
}
|
||||
|
||||
public String getRuleValue() {
|
||||
return ruleValue;
|
||||
}
|
||||
|
||||
public void setRuleValue(String ruleValue) {
|
||||
this.ruleValue = ruleValue;
|
||||
}
|
||||
|
||||
public Date getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
public void setCreateTime(Date createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
public String getCreateBy() {
|
||||
return createBy;
|
||||
}
|
||||
|
||||
public void setCreateBy(String createBy) {
|
||||
this.createBy = createBy;
|
||||
}
|
||||
|
||||
public Date getUpdateTime() {
|
||||
return updateTime;
|
||||
}
|
||||
|
||||
public void setUpdateTime(Date updateTime) {
|
||||
this.updateTime = updateTime;
|
||||
}
|
||||
|
||||
public String getUpdateBy() {
|
||||
return updateBy;
|
||||
}
|
||||
|
||||
public void setUpdateBy(String updateBy) {
|
||||
this.updateBy = updateBy;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,67 @@
|
||||
package org.jeecg.common.system.vo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.jeecg.common.util.DateUtils;
|
||||
|
||||
public class SysUserCacheInfo {
|
||||
|
||||
private String sysUserCode;
|
||||
|
||||
private String sysUserName;
|
||||
|
||||
private String sysOrgCode;
|
||||
|
||||
private List<String> sysMultiOrgCode;
|
||||
|
||||
private boolean oneDepart;
|
||||
|
||||
public boolean isOneDepart() {
|
||||
return oneDepart;
|
||||
}
|
||||
|
||||
public void setOneDepart(boolean oneDepart) {
|
||||
this.oneDepart = oneDepart;
|
||||
}
|
||||
|
||||
public String getSysDate() {
|
||||
return DateUtils.formatDate();
|
||||
}
|
||||
|
||||
public String getSysTime() {
|
||||
return DateUtils.now();
|
||||
}
|
||||
|
||||
public String getSysUserCode() {
|
||||
return sysUserCode;
|
||||
}
|
||||
|
||||
public void setSysUserCode(String sysUserCode) {
|
||||
this.sysUserCode = sysUserCode;
|
||||
}
|
||||
|
||||
public String getSysUserName() {
|
||||
return sysUserName;
|
||||
}
|
||||
|
||||
public void setSysUserName(String sysUserName) {
|
||||
this.sysUserName = sysUserName;
|
||||
}
|
||||
|
||||
public String getSysOrgCode() {
|
||||
return sysOrgCode;
|
||||
}
|
||||
|
||||
public void setSysOrgCode(String sysOrgCode) {
|
||||
this.sysOrgCode = sysOrgCode;
|
||||
}
|
||||
|
||||
public List<String> getSysMultiOrgCode() {
|
||||
return sysMultiOrgCode;
|
||||
}
|
||||
|
||||
public void setSysMultiOrgCode(List<String> sysMultiOrgCode) {
|
||||
this.sysMultiOrgCode = sysMultiOrgCode;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,10 @@
|
||||
package org.jeecg.common.util;
|
||||
|
||||
/**
|
||||
*
|
||||
* @Author 张代浩
|
||||
*
|
||||
*/
|
||||
public enum BrowserType {
|
||||
IE11,IE10,IE9,IE8,IE7,IE6,Firefox,Safari,Chrome,Opera,Camino,Gecko
|
||||
}
|
||||
@ -0,0 +1,206 @@
|
||||
package org.jeecg.common.util;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
/**
|
||||
*
|
||||
* @Author 张代浩
|
||||
*
|
||||
*/
|
||||
public class BrowserUtils {
|
||||
|
||||
// 判断是否是IE
|
||||
public static boolean isIE(HttpServletRequest request) {
|
||||
return (request.getHeader("USER-AGENT").toLowerCase().indexOf("msie") > 0 || request
|
||||
.getHeader("USER-AGENT").toLowerCase().indexOf("rv:11.0") > 0) ? true
|
||||
: false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取IE版本
|
||||
*
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
public static Double getIEversion(HttpServletRequest request) {
|
||||
Double version = 0.0;
|
||||
if (getBrowserType(request, IE11)) {
|
||||
version = 11.0;
|
||||
} else if (getBrowserType(request, IE10)) {
|
||||
version = 10.0;
|
||||
} else if (getBrowserType(request, IE9)) {
|
||||
version = 9.0;
|
||||
} else if (getBrowserType(request, IE8)) {
|
||||
version = 8.0;
|
||||
} else if (getBrowserType(request, IE7)) {
|
||||
version = 7.0;
|
||||
} else if (getBrowserType(request, IE6)) {
|
||||
version = 6.0;
|
||||
}
|
||||
return version;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取浏览器类型
|
||||
*
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
public static BrowserType getBrowserType(HttpServletRequest request) {
|
||||
BrowserType browserType = null;
|
||||
if (getBrowserType(request, IE11)) {
|
||||
browserType = BrowserType.IE11;
|
||||
}
|
||||
if (getBrowserType(request, IE10)) {
|
||||
browserType = BrowserType.IE10;
|
||||
}
|
||||
if (getBrowserType(request, IE9)) {
|
||||
browserType = BrowserType.IE9;
|
||||
}
|
||||
if (getBrowserType(request, IE8)) {
|
||||
browserType = BrowserType.IE8;
|
||||
}
|
||||
if (getBrowserType(request, IE7)) {
|
||||
browserType = BrowserType.IE7;
|
||||
}
|
||||
if (getBrowserType(request, IE6)) {
|
||||
browserType = BrowserType.IE6;
|
||||
}
|
||||
if (getBrowserType(request, FIREFOX)) {
|
||||
browserType = BrowserType.Firefox;
|
||||
}
|
||||
if (getBrowserType(request, SAFARI)) {
|
||||
browserType = BrowserType.Safari;
|
||||
}
|
||||
if (getBrowserType(request, CHROME)) {
|
||||
browserType = BrowserType.Chrome;
|
||||
}
|
||||
if (getBrowserType(request, OPERA)) {
|
||||
browserType = BrowserType.Opera;
|
||||
}
|
||||
if (getBrowserType(request, "Camino")) {
|
||||
browserType = BrowserType.Camino;
|
||||
}
|
||||
return browserType;
|
||||
}
|
||||
|
||||
private static boolean getBrowserType(HttpServletRequest request,
|
||||
String brosertype) {
|
||||
return request.getHeader("USER-AGENT").toLowerCase()
|
||||
.indexOf(brosertype) > 0 ? true : false;
|
||||
}
|
||||
|
||||
private final static String IE11 = "rv:11.0";
|
||||
private final static String IE10 = "MSIE 10.0";
|
||||
private final static String IE9 = "MSIE 9.0";
|
||||
private final static String IE8 = "MSIE 8.0";
|
||||
private final static String IE7 = "MSIE 7.0";
|
||||
private final static String IE6 = "MSIE 6.0";
|
||||
private final static String MAXTHON = "Maxthon";
|
||||
private final static String QQ = "QQBrowser";
|
||||
private final static String GREEN = "GreenBrowser";
|
||||
private final static String SE360 = "360SE";
|
||||
private final static String FIREFOX = "Firefox";
|
||||
private final static String OPERA = "Opera";
|
||||
private final static String CHROME = "Chrome";
|
||||
private final static String SAFARI = "Safari";
|
||||
private final static String OTHER = "其它";
|
||||
|
||||
public static String checkBrowse(HttpServletRequest request) {
|
||||
String userAgent = request.getHeader("USER-AGENT");
|
||||
if (regex(OPERA, userAgent)) {
|
||||
return OPERA;
|
||||
}
|
||||
if (regex(CHROME, userAgent)) {
|
||||
return CHROME;
|
||||
}
|
||||
if (regex(FIREFOX, userAgent)) {
|
||||
return FIREFOX;
|
||||
}
|
||||
if (regex(SAFARI, userAgent)) {
|
||||
return SAFARI;
|
||||
}
|
||||
if (regex(SE360, userAgent)) {
|
||||
return SE360;
|
||||
}
|
||||
if (regex(GREEN, userAgent)) {
|
||||
return GREEN;
|
||||
}
|
||||
if (regex(QQ, userAgent)) {
|
||||
return QQ;
|
||||
}
|
||||
if (regex(MAXTHON, userAgent)) {
|
||||
return MAXTHON;
|
||||
}
|
||||
if (regex(IE11, userAgent)) {
|
||||
return IE11;
|
||||
}
|
||||
if (regex(IE10, userAgent)) {
|
||||
return IE10;
|
||||
}
|
||||
if (regex(IE9, userAgent)) {
|
||||
return IE9;
|
||||
}
|
||||
if (regex(IE8, userAgent)) {
|
||||
return IE8;
|
||||
}
|
||||
if (regex(IE7, userAgent)) {
|
||||
return IE7;
|
||||
}
|
||||
if (regex(IE6, userAgent)) {
|
||||
return IE6;
|
||||
}
|
||||
return OTHER;
|
||||
}
|
||||
|
||||
public static boolean regex(String regex, String str) {
|
||||
Pattern p = Pattern.compile(regex, Pattern.MULTILINE);
|
||||
Matcher m = p.matcher(str);
|
||||
return m.find();
|
||||
}
|
||||
|
||||
|
||||
private static Map<String, String> langMap = new HashMap<String, String>();
|
||||
private final static String ZH = "zh";
|
||||
private final static String ZH_CN = "zh-cn";
|
||||
|
||||
private final static String EN = "en";
|
||||
private final static String EN_US = "en";
|
||||
|
||||
|
||||
static
|
||||
{
|
||||
langMap.put(ZH, ZH_CN);
|
||||
langMap.put(EN, EN_US);
|
||||
}
|
||||
|
||||
public static String getBrowserLanguage(HttpServletRequest request) {
|
||||
|
||||
String browserLang = request.getLocale().getLanguage();
|
||||
String browserLangCode = (String)langMap.get(browserLang);
|
||||
|
||||
if(browserLangCode == null)
|
||||
{
|
||||
browserLangCode = EN_US;
|
||||
}
|
||||
return browserLangCode;
|
||||
}
|
||||
|
||||
/** 判断请求是否来自电脑端 */
|
||||
public static boolean isDesktop(HttpServletRequest request) {
|
||||
return !isMobile(request);
|
||||
}
|
||||
|
||||
/** 判断请求是否来自移动端 */
|
||||
public static boolean isMobile(HttpServletRequest request) {
|
||||
String ua = request.getHeader("User-Agent").toLowerCase();
|
||||
Pattern pattern = Pattern.compile("(phone|pad|pod|iphone|ipod|ios|ipad|android|mobile|blackberry|iemobile|mqqbrowser|juc|fennec|wosbrowser|browserng|webos|symbian|windows phone)");
|
||||
return pattern.matcher(ua).find();
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,96 @@
|
||||
package org.jeecg.common.util;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.constant.CommonConstant;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 导出返回信息
|
||||
*/
|
||||
@Slf4j
|
||||
public class ImportExcelUtil {
|
||||
|
||||
public static Result<?> imporReturnRes(int errorLines,int successLines,List<String> errorMessage) throws IOException {
|
||||
if (errorLines == 0) {
|
||||
return Result.ok("共" + successLines + "行数据全部导入成功!");
|
||||
} else {
|
||||
JSONObject result = new JSONObject(5);
|
||||
int totalCount = successLines + errorLines;
|
||||
result.put("totalCount", totalCount);
|
||||
result.put("errorCount", errorLines);
|
||||
result.put("successCount", successLines);
|
||||
result.put("msg", "总上传行数:" + totalCount + ",已导入行数:" + successLines + ",错误行数:" + errorLines);
|
||||
String fileUrl = PmsUtil.saveErrorTxtByList(errorMessage, "userImportExcelErrorLog");
|
||||
int lastIndex = fileUrl.lastIndexOf(File.separator);
|
||||
String fileName = fileUrl.substring(lastIndex + 1);
|
||||
result.put("fileUrl", "/sys/common/static/" + fileUrl);
|
||||
result.put("fileName", fileName);
|
||||
Result res = Result.ok(result);
|
||||
res.setCode(201);
|
||||
res.setMessage("文件导入成功,但有错误。");
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
public static List<String> importDateSave(List<Object> list, Class serviceClass,List<String> errorMessage,String errorFlag) {
|
||||
IService bean =(IService) SpringContextUtils.getBean(serviceClass);
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
try {
|
||||
boolean save = bean.save(list.get(i));
|
||||
if(!save){
|
||||
throw new Exception(errorFlag);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
String message = e.getMessage().toLowerCase();
|
||||
int lineNumber = i + 1;
|
||||
// 通过索引名判断出错信息
|
||||
if (message.contains(CommonConstant.SQL_INDEX_UNIQ_SYS_ROLE_CODE)) {
|
||||
errorMessage.add("第 " + lineNumber + " 行:角色编码已经存在,忽略导入。");
|
||||
} else if (message.contains(CommonConstant.SQL_INDEX_UNIQ_JOB_CLASS_NAME)) {
|
||||
errorMessage.add("第 " + lineNumber + " 行:任务类名已经存在,忽略导入。");
|
||||
}else if (message.contains(CommonConstant.SQL_INDEX_UNIQ_CODE)) {
|
||||
errorMessage.add("第 " + lineNumber + " 行:职务编码已经存在,忽略导入。");
|
||||
}else if (message.contains(CommonConstant.SQL_INDEX_UNIQ_DEPART_ORG_CODE)) {
|
||||
errorMessage.add("第 " + lineNumber + " 行:部门编码已经存在,忽略导入。");
|
||||
}else {
|
||||
errorMessage.add("第 " + lineNumber + " 行:未知错误,忽略导入");
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
return errorMessage;
|
||||
}
|
||||
|
||||
public static List<String> importDateSaveOne(Object obj, Class serviceClass,List<String> errorMessage,int i,String errorFlag) {
|
||||
IService bean =(IService) SpringContextUtils.getBean(serviceClass);
|
||||
try {
|
||||
boolean save = bean.save(obj);
|
||||
if(!save){
|
||||
throw new Exception(errorFlag);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
String message = e.getMessage().toLowerCase();
|
||||
int lineNumber = i + 1;
|
||||
// 通过索引名判断出错信息
|
||||
if (message.contains(CommonConstant.SQL_INDEX_UNIQ_SYS_ROLE_CODE)) {
|
||||
errorMessage.add("第 " + lineNumber + " 行:角色编码已经存在,忽略导入。");
|
||||
} else if (message.contains(CommonConstant.SQL_INDEX_UNIQ_JOB_CLASS_NAME)) {
|
||||
errorMessage.add("第 " + lineNumber + " 行:任务类名已经存在,忽略导入。");
|
||||
}else if (message.contains(CommonConstant.SQL_INDEX_UNIQ_CODE)) {
|
||||
errorMessage.add("第 " + lineNumber + " 行:职务编码已经存在,忽略导入。");
|
||||
}else if (message.contains(CommonConstant.SQL_INDEX_UNIQ_DEPART_ORG_CODE)) {
|
||||
errorMessage.add("第 " + lineNumber + " 行:部门编码已经存在,忽略导入。");
|
||||
}else {
|
||||
errorMessage.add("第 " + lineNumber + " 行:未知错误,忽略导入");
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
return errorMessage;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,43 @@
|
||||
package org.jeecg.common.util;
|
||||
|
||||
import java.security.MessageDigest;
|
||||
|
||||
public class MD5Util {
|
||||
|
||||
public static String byteArrayToHexString(byte b[]) {
|
||||
StringBuffer resultSb = new StringBuffer();
|
||||
for (int i = 0; i < b.length; i++){
|
||||
resultSb.append(byteToHexString(b[i]));
|
||||
}
|
||||
return resultSb.toString();
|
||||
}
|
||||
|
||||
private static String byteToHexString(byte b) {
|
||||
int n = b;
|
||||
if (n < 0) {
|
||||
n += 256;
|
||||
}
|
||||
int d1 = n / 16;
|
||||
int d2 = n % 16;
|
||||
return hexDigits[d1] + hexDigits[d2];
|
||||
}
|
||||
|
||||
public static String MD5Encode(String origin, String charsetname) {
|
||||
String resultString = null;
|
||||
try {
|
||||
resultString = new String(origin);
|
||||
MessageDigest md = MessageDigest.getInstance("MD5");
|
||||
if (charsetname == null || "".equals(charsetname)) {
|
||||
resultString = byteArrayToHexString(md.digest(resultString.getBytes()));
|
||||
} else {
|
||||
resultString = byteArrayToHexString(md.digest(resultString.getBytes(charsetname)));
|
||||
}
|
||||
} catch (Exception exception) {
|
||||
}
|
||||
return resultString;
|
||||
}
|
||||
|
||||
private static final String hexDigits[] = { "0", "1", "2", "3", "4", "5",
|
||||
"6", "7", "8", "9", "a", "b", "c", "d", "e", "f" };
|
||||
|
||||
}
|
||||
@ -0,0 +1,209 @@
|
||||
package org.jeecg.common.util;
|
||||
|
||||
import io.minio.*;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.jeecg.common.util.filter.StrAttackFilter;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.net.URLDecoder;
|
||||
|
||||
/**
|
||||
* minio文件上传工具类
|
||||
*/
|
||||
@Slf4j
|
||||
public class MinioUtil {
|
||||
private static String minioUrl;
|
||||
private static String minioName;
|
||||
private static String minioPass;
|
||||
private static String bucketName;
|
||||
|
||||
public static void setMinioUrl(String minioUrl) {
|
||||
MinioUtil.minioUrl = minioUrl;
|
||||
}
|
||||
|
||||
public static void setMinioName(String minioName) {
|
||||
MinioUtil.minioName = minioName;
|
||||
}
|
||||
|
||||
public static void setMinioPass(String minioPass) {
|
||||
MinioUtil.minioPass = minioPass;
|
||||
}
|
||||
|
||||
public static void setBucketName(String bucketName) {
|
||||
MinioUtil.bucketName = bucketName;
|
||||
}
|
||||
|
||||
public static String getMinioUrl() {
|
||||
return minioUrl;
|
||||
}
|
||||
|
||||
public static String getBucketName() {
|
||||
return bucketName;
|
||||
}
|
||||
|
||||
private static MinioClient minioClient = null;
|
||||
|
||||
/**
|
||||
* 上传文件
|
||||
* @param file
|
||||
* @return
|
||||
*/
|
||||
public static String upload(MultipartFile file, String bizPath, String customBucket) {
|
||||
String file_url = "";
|
||||
//update-begin-author:wangshuai date:20201012 for: 过滤上传文件夹名特殊字符,防止攻击
|
||||
bizPath=StrAttackFilter.filter(bizPath);
|
||||
//update-end-author:wangshuai date:20201012 for: 过滤上传文件夹名特殊字符,防止攻击
|
||||
String newBucket = bucketName;
|
||||
if(oConvertUtils.isNotEmpty(customBucket)){
|
||||
newBucket = customBucket;
|
||||
}
|
||||
try {
|
||||
initMinio(minioUrl, minioName,minioPass);
|
||||
// 检查存储桶是否已经存在
|
||||
if(minioClient.bucketExists(BucketExistsArgs.builder().bucket(newBucket).build())) {
|
||||
log.info("Bucket already exists.");
|
||||
} else {
|
||||
// 创建一个名为ota的存储桶
|
||||
minioClient.makeBucket(MakeBucketArgs.builder().bucket(newBucket).build());
|
||||
log.info("create a new bucket.");
|
||||
}
|
||||
InputStream stream = file.getInputStream();
|
||||
// 获取文件名
|
||||
String orgName = file.getOriginalFilename();
|
||||
if("".equals(orgName)){
|
||||
orgName=file.getName();
|
||||
}
|
||||
orgName = CommonUtils.getFileName(orgName);
|
||||
String objectName = bizPath+"/"+orgName.substring(0, orgName.lastIndexOf(".")) + "_" + System.currentTimeMillis() + orgName.substring(orgName.lastIndexOf("."));
|
||||
|
||||
// 使用putObject上传一个本地文件到存储桶中。
|
||||
if(objectName.startsWith("/")){
|
||||
objectName = objectName.substring(1);
|
||||
}
|
||||
PutObjectArgs objectArgs = PutObjectArgs.builder().object(objectName)
|
||||
.bucket(newBucket)
|
||||
.contentType("application/octet-stream")
|
||||
.stream(stream,stream.available(),-1).build();
|
||||
minioClient.putObject(objectArgs);
|
||||
stream.close();
|
||||
file_url = minioUrl+newBucket+"/"+objectName;
|
||||
}catch (Exception e){
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
return file_url;
|
||||
}
|
||||
|
||||
/**
|
||||
* 文件上传
|
||||
* @param file
|
||||
* @param bizPath
|
||||
* @return
|
||||
*/
|
||||
public static String upload(MultipartFile file, String bizPath) {
|
||||
return upload(file,bizPath,null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取文件流
|
||||
* @param bucketName
|
||||
* @param objectName
|
||||
* @return
|
||||
*/
|
||||
public static InputStream getMinioFile(String bucketName,String objectName){
|
||||
InputStream inputStream = null;
|
||||
try {
|
||||
initMinio(minioUrl, minioName, minioPass);
|
||||
GetObjectArgs objectArgs = GetObjectArgs.builder().object(objectName)
|
||||
.bucket(bucketName).build();
|
||||
inputStream = minioClient.getObject(objectArgs);
|
||||
} catch (Exception e) {
|
||||
log.info("文件获取失败" + e.getMessage());
|
||||
}
|
||||
return inputStream;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除文件
|
||||
* @param bucketName
|
||||
* @param objectName
|
||||
* @throws Exception
|
||||
*/
|
||||
public static void removeObject(String bucketName, String objectName) {
|
||||
try {
|
||||
initMinio(minioUrl, minioName,minioPass);
|
||||
RemoveObjectArgs objectArgs = RemoveObjectArgs.builder().object(objectName)
|
||||
.bucket(bucketName).build();
|
||||
minioClient.removeObject(objectArgs);
|
||||
}catch (Exception e){
|
||||
log.info("文件删除失败" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取文件外链
|
||||
* @param bucketName
|
||||
* @param objectName
|
||||
* @param expires
|
||||
* @return
|
||||
*/
|
||||
public static String getObjectURL(String bucketName, String objectName, Integer expires) {
|
||||
initMinio(minioUrl, minioName,minioPass);
|
||||
try{
|
||||
GetPresignedObjectUrlArgs objectArgs = GetPresignedObjectUrlArgs.builder().object(objectName)
|
||||
.bucket(bucketName)
|
||||
.expiry(expires).build();
|
||||
String url = minioClient.getPresignedObjectUrl(objectArgs);
|
||||
return URLDecoder.decode(url,"UTF-8");
|
||||
}catch (Exception e){
|
||||
log.info("文件路径获取失败" + e.getMessage());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化客户端
|
||||
* @param minioUrl
|
||||
* @param minioName
|
||||
* @param minioPass
|
||||
* @return
|
||||
*/
|
||||
private static MinioClient initMinio(String minioUrl, String minioName,String minioPass) {
|
||||
if (minioClient == null) {
|
||||
try {
|
||||
minioClient = MinioClient.builder()
|
||||
.endpoint(minioUrl)
|
||||
.credentials(minioName, minioPass)
|
||||
.build();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return minioClient;
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传文件到minio
|
||||
* @param stream
|
||||
* @param relativePath
|
||||
* @return
|
||||
*/
|
||||
public static String upload(InputStream stream,String relativePath) throws Exception {
|
||||
initMinio(minioUrl, minioName,minioPass);
|
||||
if(minioClient.bucketExists(BucketExistsArgs.builder().bucket(bucketName).build())) {
|
||||
log.info("Bucket already exists.");
|
||||
} else {
|
||||
// 创建一个名为ota的存储桶
|
||||
minioClient.makeBucket(MakeBucketArgs.builder().bucket(bucketName).build());
|
||||
log.info("create a new bucket.");
|
||||
}
|
||||
PutObjectArgs objectArgs = PutObjectArgs.builder().object(relativePath)
|
||||
.bucket(bucketName)
|
||||
.contentType("application/octet-stream")
|
||||
.stream(stream,stream.available(),-1).build();
|
||||
minioClient.putObject(objectArgs);
|
||||
stream.close();
|
||||
return minioUrl+bucketName+"/"+relativePath;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,61 @@
|
||||
package org.jeecg.common.util;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class PmsUtil {
|
||||
|
||||
|
||||
private static String uploadPath;
|
||||
|
||||
@Value("${jeecg.path.upload}")
|
||||
public void setUploadPath(String uploadPath) {
|
||||
PmsUtil.uploadPath = uploadPath;
|
||||
}
|
||||
|
||||
public static String saveErrorTxtByList(List<String> msg, String name) {
|
||||
Date d = new Date();
|
||||
String saveDir = "logs" + File.separator + DateUtils.yyyyMMdd.get().format(d) + File.separator;
|
||||
String saveFullDir = uploadPath + File.separator + saveDir;
|
||||
|
||||
File saveFile = new File(saveFullDir);
|
||||
if (!saveFile.exists()) {
|
||||
saveFile.mkdirs();
|
||||
}
|
||||
name += DateUtils.yyyymmddhhmmss.get().format(d) + Math.round(Math.random() * 10000);
|
||||
String saveFilePath = saveFullDir + name + ".txt";
|
||||
|
||||
try {
|
||||
//封装目的地
|
||||
BufferedWriter bw = new BufferedWriter(new FileWriter(saveFilePath));
|
||||
//遍历集合
|
||||
for (String s : msg) {
|
||||
//写数据
|
||||
if (s.indexOf("_") > 0) {
|
||||
String arr[] = s.split("_");
|
||||
bw.write("第" + arr[0] + "行:" + arr[1]);
|
||||
} else {
|
||||
bw.write(s);
|
||||
}
|
||||
//bw.newLine();
|
||||
bw.write("\r\n");
|
||||
}
|
||||
//释放资源
|
||||
bw.flush();
|
||||
bw.close();
|
||||
} catch (Exception e) {
|
||||
log.info("excel导入生成错误日志文件异常:" + e.getMessage());
|
||||
}
|
||||
return saveDir + name + ".txt";
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,121 @@
|
||||
package org.jeecg.common.util;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
|
||||
/**
|
||||
* 通过 RESTful 风格的接口操纵 desform 里的数据
|
||||
*
|
||||
* @author sunjianlei
|
||||
*/
|
||||
public class RestDesformUtil {
|
||||
|
||||
private static String domain = null;
|
||||
private static String path = null;
|
||||
|
||||
static {
|
||||
domain = SpringContextUtils.getDomain();
|
||||
path = oConvertUtils.getString(SpringContextUtils.getApplicationContext().getEnvironment().getProperty("server.servlet.context-path"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询数据
|
||||
*
|
||||
* @param desformCode
|
||||
* @param dataId
|
||||
* @param token
|
||||
* @return
|
||||
*/
|
||||
public static Result queryOne(String desformCode, String dataId, String token) {
|
||||
String url = getBaseUrl(desformCode, dataId).toString();
|
||||
HttpHeaders headers = getHeaders(token);
|
||||
ResponseEntity<JSONObject> result = RestUtil.request(url, HttpMethod.GET, headers, null, null, JSONObject.class);
|
||||
return packageReturn(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增数据
|
||||
*
|
||||
* @param desformCode
|
||||
* @param formData
|
||||
* @param token
|
||||
* @return
|
||||
*/
|
||||
public static Result addOne(String desformCode, JSONObject formData, String token) {
|
||||
return addOrEditOne(desformCode, formData, token, HttpMethod.POST);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改数据
|
||||
*
|
||||
* @param desformCode
|
||||
* @param formData
|
||||
* @param token
|
||||
* @return
|
||||
*/
|
||||
public static Result editOne(String desformCode, JSONObject formData, String token) {
|
||||
return addOrEditOne(desformCode, formData, token, HttpMethod.PUT);
|
||||
}
|
||||
|
||||
private static Result addOrEditOne(String desformCode, JSONObject formData, String token, HttpMethod method) {
|
||||
String url = getBaseUrl(desformCode).toString();
|
||||
HttpHeaders headers = getHeaders(token);
|
||||
ResponseEntity<JSONObject> result = RestUtil.request(url, method, headers, null, formData, JSONObject.class);
|
||||
return packageReturn(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除数据
|
||||
*
|
||||
* @param desformCode
|
||||
* @param dataId
|
||||
* @param token
|
||||
* @return
|
||||
*/
|
||||
public static Result removeOne(String desformCode, String dataId, String token) {
|
||||
String url = getBaseUrl(desformCode, dataId).toString();
|
||||
HttpHeaders headers = getHeaders(token);
|
||||
ResponseEntity<JSONObject> result = RestUtil.request(url, HttpMethod.DELETE, headers, null, null, JSONObject.class);
|
||||
return packageReturn(result);
|
||||
}
|
||||
|
||||
private static Result packageReturn(ResponseEntity<JSONObject> result) {
|
||||
if (result.getBody() != null) {
|
||||
return result.getBody().toJavaObject(Result.class);
|
||||
}
|
||||
return Result.error("操作失败");
|
||||
}
|
||||
|
||||
private static StringBuilder getBaseUrl() {
|
||||
StringBuilder builder = new StringBuilder(domain).append(path);
|
||||
builder.append("/desform/api");
|
||||
return builder;
|
||||
}
|
||||
|
||||
private static StringBuilder getBaseUrl(String desformCode, String dataId) {
|
||||
StringBuilder builder = getBaseUrl();
|
||||
builder.append("/").append(desformCode);
|
||||
if (dataId != null) {
|
||||
builder.append("/").append(dataId);
|
||||
}
|
||||
return builder;
|
||||
}
|
||||
|
||||
private static StringBuilder getBaseUrl(String desformCode) {
|
||||
return getBaseUrl(desformCode, null);
|
||||
}
|
||||
|
||||
private static HttpHeaders getHeaders(String token) {
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
String mediaType = MediaType.APPLICATION_JSON_UTF8_VALUE;
|
||||
headers.setContentType(MediaType.parseMediaType(mediaType));
|
||||
headers.set("Accept", mediaType);
|
||||
headers.set("X-Access-Token", token);
|
||||
return headers;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,95 @@
|
||||
package org.jeecg.common.util;
|
||||
|
||||
|
||||
import java.net.InetAddress;
|
||||
|
||||
/**
|
||||
*
|
||||
* @Author 张代浩
|
||||
*
|
||||
*/
|
||||
public class UUIDGenerator {
|
||||
|
||||
|
||||
/**
|
||||
* 产生一个32位的UUID
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
|
||||
public static String generate() {
|
||||
return new StringBuilder(32).append(format(getIP())).append(
|
||||
format(getJVM())).append(format(getHiTime())).append(
|
||||
format(getLoTime())).append(format(getCount())).toString();
|
||||
|
||||
}
|
||||
|
||||
private static final int IP;
|
||||
static {
|
||||
int ipadd;
|
||||
try {
|
||||
ipadd = toInt(InetAddress.getLocalHost().getAddress());
|
||||
} catch (Exception e) {
|
||||
ipadd = 0;
|
||||
}
|
||||
IP = ipadd;
|
||||
}
|
||||
|
||||
private static short counter = (short) 0;
|
||||
|
||||
private static final int JVM = (int) (System.currentTimeMillis() >>> 8);
|
||||
|
||||
private final static String format(int intval) {
|
||||
String formatted = Integer.toHexString(intval);
|
||||
StringBuilder buf = new StringBuilder("00000000");
|
||||
buf.replace(8 - formatted.length(), 8, formatted);
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
private final static String format(short shortval) {
|
||||
String formatted = Integer.toHexString(shortval);
|
||||
StringBuilder buf = new StringBuilder("0000");
|
||||
buf.replace(4 - formatted.length(), 4, formatted);
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
private final static int getJVM() {
|
||||
return JVM;
|
||||
}
|
||||
|
||||
private final static short getCount() {
|
||||
synchronized (UUIDGenerator.class) {
|
||||
if (counter < 0) {
|
||||
counter = 0;
|
||||
}
|
||||
return counter++;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Unique in a local network
|
||||
*/
|
||||
private final static int getIP() {
|
||||
return IP;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unique down to millisecond
|
||||
*/
|
||||
private final static short getHiTime() {
|
||||
return (short) (System.currentTimeMillis() >>> 32);
|
||||
}
|
||||
|
||||
private final static int getLoTime() {
|
||||
return (int) System.currentTimeMillis();
|
||||
}
|
||||
|
||||
private final static int toInt(byte[] bytes) {
|
||||
int result = 0;
|
||||
for (int i = 0; i < 4; i++) {
|
||||
result = (result << 8) - Byte.MIN_VALUE + (int) bytes[i];
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,92 @@
|
||||
package org.jeecg.common.util.dynamic.db;
|
||||
|
||||
import com.alibaba.druid.pool.DruidDataSource;
|
||||
import org.jeecg.common.api.CommonAPI;
|
||||
import org.jeecg.common.constant.CacheConstant;
|
||||
import org.jeecg.common.system.vo.DynamicDataSourceModel;
|
||||
import org.jeecg.common.util.RedisUtil;
|
||||
import org.jeecg.common.util.SpringContextUtils;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
/**
|
||||
* 数据源缓存池
|
||||
*/
|
||||
public class DataSourceCachePool {
|
||||
/** 数据源连接池缓存【本地 class缓存 - 不支持分布式】 */
|
||||
private static Map<String, DruidDataSource> dbSources = new HashMap<>();
|
||||
private static RedisTemplate<String, Object> redisTemplate;
|
||||
|
||||
private static RedisTemplate<String, Object> getRedisTemplate() {
|
||||
if (redisTemplate == null) {
|
||||
redisTemplate = (RedisTemplate<String, Object>) SpringContextUtils.getBean("redisTemplate");
|
||||
}
|
||||
return redisTemplate;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取多数据源缓存
|
||||
*
|
||||
* @param dbKey
|
||||
* @return
|
||||
*/
|
||||
public static DynamicDataSourceModel getCacheDynamicDataSourceModel(String dbKey) {
|
||||
String redisCacheKey = CacheConstant.SYS_DYNAMICDB_CACHE + dbKey;
|
||||
if (getRedisTemplate().hasKey(redisCacheKey)) {
|
||||
return (DynamicDataSourceModel) getRedisTemplate().opsForValue().get(redisCacheKey);
|
||||
}
|
||||
CommonAPI commonAPI = SpringContextUtils.getBean(CommonAPI.class);
|
||||
DynamicDataSourceModel dbSource = commonAPI.getDynamicDbSourceByCode(dbKey);
|
||||
if (dbSource != null) {
|
||||
getRedisTemplate().opsForValue().set(redisCacheKey, dbSource);
|
||||
}
|
||||
return dbSource;
|
||||
}
|
||||
|
||||
public static DruidDataSource getCacheBasicDataSource(String dbKey) {
|
||||
return dbSources.get(dbKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* put 数据源缓存
|
||||
*
|
||||
* @param dbKey
|
||||
* @param db
|
||||
*/
|
||||
public static void putCacheBasicDataSource(String dbKey, DruidDataSource db) {
|
||||
dbSources.put(dbKey, db);
|
||||
}
|
||||
|
||||
/**
|
||||
* 清空数据源缓存
|
||||
*/
|
||||
public static void cleanAllCache() {
|
||||
//关闭数据源连接
|
||||
for(Map.Entry<String, DruidDataSource> entry : dbSources.entrySet()){
|
||||
String dbkey = entry.getKey();
|
||||
DruidDataSource druidDataSource = entry.getValue();
|
||||
if(druidDataSource!=null && druidDataSource.isEnable()){
|
||||
druidDataSource.close();
|
||||
}
|
||||
//清空redis缓存
|
||||
getRedisTemplate().delete(CacheConstant.SYS_DYNAMICDB_CACHE + dbkey);
|
||||
}
|
||||
//清空缓存
|
||||
dbSources.clear();
|
||||
}
|
||||
|
||||
public static void removeCache(String dbKey) {
|
||||
//关闭数据源连接
|
||||
DruidDataSource druidDataSource = dbSources.get(dbKey);
|
||||
if(druidDataSource!=null && druidDataSource.isEnable()){
|
||||
druidDataSource.close();
|
||||
}
|
||||
//清空redis缓存
|
||||
getRedisTemplate().delete(CacheConstant.SYS_DYNAMICDB_CACHE + dbKey);
|
||||
//清空缓存
|
||||
dbSources.remove(dbKey);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,28 @@
|
||||
package org.jeecg.common.util.jsonschema;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 列 配置基本信息
|
||||
*/
|
||||
@Data
|
||||
public class BaseColumn {
|
||||
|
||||
/**
|
||||
* 列配置 描述 -对应数据库字段描述
|
||||
*/
|
||||
private String title;
|
||||
|
||||
/**
|
||||
* 列配置 名称 -对应数据库字段名
|
||||
*/
|
||||
private String field;
|
||||
|
||||
public BaseColumn(){}
|
||||
|
||||
public BaseColumn(String title,String field){
|
||||
this.title = title;
|
||||
this.field = field;
|
||||
}
|
||||
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue