Add basic libraries
This commit is contained in:
parent
281f2a069e
commit
acdb7759a4
BIN
library/skyeye-dev/.DS_Store
vendored
Normal file
BIN
library/skyeye-dev/.DS_Store
vendored
Normal file
Binary file not shown.
45
library/skyeye-dev/.idea/compiler.xml
Normal file
45
library/skyeye-dev/.idea/compiler.xml
Normal file
@ -0,0 +1,45 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="CompilerConfiguration">
|
||||
<annotationProcessing>
|
||||
<profile name="Maven default annotation processors profile" enabled="true">
|
||||
<sourceOutputDir name="target/generated-sources/annotations" />
|
||||
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
|
||||
<outputRelativeToContentRoot value="true" />
|
||||
<module name="dt-dev-sms" />
|
||||
<module name="skyeye-generator" />
|
||||
<module name="skyeye-redis" />
|
||||
<module name="skyeye-db" />
|
||||
<module name="skyeye-util" />
|
||||
<module name="skyeye-websocket" />
|
||||
<module name="dt-dev-email" />
|
||||
<module name="dt-dev-db" />
|
||||
<module name="skyeye-knife4j" />
|
||||
<module name="dt-dev-office" />
|
||||
<module name="skyeye-job" />
|
||||
<module name="skyeye-common" />
|
||||
<module name="dt-dev-tx" />
|
||||
<module name="skyeye-quartz" />
|
||||
</profile>
|
||||
</annotationProcessing>
|
||||
</component>
|
||||
<component name="JavacSettings">
|
||||
<option name="ADDITIONAL_OPTIONS_OVERRIDE">
|
||||
<module name="dt-dev-db" options="-parameters" />
|
||||
<module name="dt-dev-email" options="" />
|
||||
<module name="dt-dev-office" options="" />
|
||||
<module name="dt-dev-sms" options="" />
|
||||
<module name="dt-dev-tx" options="" />
|
||||
<module name="skyeye-common" options="-parameters" />
|
||||
<module name="skyeye-db" options="-parameters" />
|
||||
<module name="skyeye-dev" options="-parameters" />
|
||||
<module name="skyeye-generator" options="-parameters" />
|
||||
<module name="skyeye-job" options="-parameters" />
|
||||
<module name="skyeye-knife4j" options="-parameters" />
|
||||
<module name="skyeye-quartz" options="-parameters" />
|
||||
<module name="skyeye-redis" options="-parameters" />
|
||||
<module name="skyeye-util" options="-parameters" />
|
||||
<module name="skyeye-websocket" options="-parameters" />
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
||||
16
library/skyeye-dev/.idea/encodings.xml
Normal file
16
library/skyeye-dev/.idea/encodings.xml
Normal file
@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Encoding">
|
||||
<file url="file://$PROJECT_DIR$/skyeye-common/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/skyeye-db/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/skyeye-generator/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/skyeye-job/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/skyeye-knife4j/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/skyeye-quartz/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/skyeye-redis/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/skyeye-util/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/skyeye-websocket/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" />
|
||||
</component>
|
||||
</project>
|
||||
20
library/skyeye-dev/.idea/jarRepositories.xml
Normal file
20
library/skyeye-dev/.idea/jarRepositories.xml
Normal file
@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="RemoteRepositoriesConfiguration">
|
||||
<remote-repository>
|
||||
<option name="id" value="central" />
|
||||
<option name="name" value="Central Repository" />
|
||||
<option name="url" value="https://repo.maven.apache.org/maven2" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="central" />
|
||||
<option name="name" value="Maven Central repository" />
|
||||
<option name="url" value="https://repo1.maven.org/maven2" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="jboss.community" />
|
||||
<option name="name" value="JBoss Community repository" />
|
||||
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
|
||||
</remote-repository>
|
||||
</component>
|
||||
</project>
|
||||
15
library/skyeye-dev/.idea/misc.xml
Normal file
15
library/skyeye-dev/.idea/misc.xml
Normal file
@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||
<component name="MavenProjectsManager">
|
||||
<option name="originalFiles">
|
||||
<list>
|
||||
<option value="$PROJECT_DIR$/pom.xml" />
|
||||
<option value="$PROJECT_DIR$/skyeye-db/pom.xml" />
|
||||
<option value="$PROJECT_DIR$/skyeye-job/pom.xml" />
|
||||
<option value="$PROJECT_DIR$/skyeye-util/pom.xml" />
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" project-jdk-name="liberica-25" project-jdk-type="JavaSDK" />
|
||||
</project>
|
||||
109
library/skyeye-dev/.idea/workspace.xml
Normal file
109
library/skyeye-dev/.idea/workspace.xml
Normal file
@ -0,0 +1,109 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="AutoImportSettings">
|
||||
<option name="autoReloadType" value="SELECTIVE" />
|
||||
</component>
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="ca5cd49c-a5d9-4f38-97d7-d00df846c40a" name="更改" comment="" />
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
|
||||
<option name="LAST_RESOLUTION" value="IGNORE" />
|
||||
</component>
|
||||
<component name="Git.Settings">
|
||||
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$/.." />
|
||||
</component>
|
||||
<component name="ProjectColorInfo">{
|
||||
"associatedIndex": 8
|
||||
}</component>
|
||||
<component name="ProjectId" id="37pokbVqjcB4HBvUBMNOedDT97C" />
|
||||
<component name="ProjectViewState">
|
||||
<option name="hideEmptyMiddlePackages" value="true" />
|
||||
<option name="showLibraryContents" value="true" />
|
||||
</component>
|
||||
<component name="PropertiesComponent"><![CDATA[{
|
||||
"keyToString": {
|
||||
"Maven.dt-dev [clean].executor": "Run",
|
||||
"Maven.dt-dev [compile].executor": "Run",
|
||||
"Maven.dt-dev-common [clean].executor": "Run",
|
||||
"Maven.dt-dev-common [compile].executor": "Run",
|
||||
"Maven.dt-dev-common [install].executor": "Run",
|
||||
"Maven.dt-dev-generator [clean].executor": "Run",
|
||||
"Maven.dt-dev-generator [compile].executor": "Run",
|
||||
"Maven.dt-dev-generator [install].executor": "Run",
|
||||
"Maven.dt-dev-job [clean].executor": "Run",
|
||||
"Maven.dt-dev-job [compile].executor": "Run",
|
||||
"Maven.dt-dev-job [install].executor": "Run",
|
||||
"Maven.skyeye-common [clean].executor": "Run",
|
||||
"Maven.skyeye-common [compile].executor": "Run",
|
||||
"Maven.skyeye-common [install].executor": "Run",
|
||||
"Maven.skyeye-db [clean].executor": "Run",
|
||||
"Maven.skyeye-db [compile].executor": "Run",
|
||||
"Maven.skyeye-db [install].executor": "Run",
|
||||
"Maven.skyeye-dev [clean].executor": "Run",
|
||||
"Maven.skyeye-dev [compile].executor": "Run",
|
||||
"Maven.skyeye-dev [install].executor": "Run",
|
||||
"Maven.skyeye-knife4j [clean].executor": "Run",
|
||||
"Maven.skyeye-knife4j [compile].executor": "Run",
|
||||
"Maven.skyeye-knife4j [install].executor": "Run",
|
||||
"Maven.skyeye-quartz [clean].executor": "Run",
|
||||
"Maven.skyeye-quartz [compile].executor": "Run",
|
||||
"Maven.skyeye-quartz [install].executor": "Run",
|
||||
"Maven.skyeye-redis [clean].executor": "Run",
|
||||
"Maven.skyeye-redis [compile].executor": "Run",
|
||||
"Maven.skyeye-redis [install].executor": "Run",
|
||||
"Maven.skyeye-util [clean].executor": "Run",
|
||||
"Maven.skyeye-util [compile].executor": "Run",
|
||||
"Maven.skyeye-util [install].executor": "Run",
|
||||
"Maven.skyeye-websocket [clean].executor": "Run",
|
||||
"Maven.skyeye-websocket [compile].executor": "Run",
|
||||
"Maven.skyeye-websocket [install].executor": "Run",
|
||||
"ModuleVcsDetector.initialDetectionPerformed": "true",
|
||||
"RunOnceActivity.ShowReadmeOnStart": "true",
|
||||
"RunOnceActivity.git.unshallow": "true",
|
||||
"RunOnceActivity.typescript.service.memoryLimit.init": "true",
|
||||
"git-widget-placeholder": "dev-2.7.8",
|
||||
"ignore.virus.scanning.warn.message": "true",
|
||||
"kotlin-language-version-configured": "true",
|
||||
"last_opened_file_path": "D:/logisen/ddd/skyeye-dev",
|
||||
"nodejs_package_manager_path": "npm",
|
||||
"vue.rearranger.settings.migration": "true"
|
||||
}
|
||||
}]]></component>
|
||||
<component name="RecentsManager">
|
||||
<key name="MoveFile.RECENT_KEYS">
|
||||
<recent name="D:\logisen\ddd\skyeye-dev\skyeye-util\src\main\java\com\zhangy\skyeye" />
|
||||
<recent name="D:\logisen\ddd\skyeye-dev\skyeye-redis\src\main\java\com\zhangy\skyeye" />
|
||||
<recent name="D:\logisen\ddd\skyeye-dev\skyeye-quartz\src\main\java\com\zhangy\skyeye" />
|
||||
<recent name="D:\logisen\ddd\skyeye-dev\skyeye-knife4j\src\main\java\com\zhangy\skyeye" />
|
||||
<recent name="D:\logisen\ddd\skyeye-dev\skyeye-job\src\main\java\com\zhangy\skyeye" />
|
||||
</key>
|
||||
</component>
|
||||
<component name="SharedIndexes">
|
||||
<attachedChunks>
|
||||
<set>
|
||||
<option value="bundled-jdk-30f59d01ecdd-26cb7f24e5b0-intellij.indexing.shared.core-IU-253.29346.138" />
|
||||
<option value="bundled-js-predefined-d6986cc7102b-9b0f141eb926-JavaScript-IU-253.29346.138" />
|
||||
</set>
|
||||
</attachedChunks>
|
||||
</component>
|
||||
<component name="TaskManager">
|
||||
<task active="true" id="Default" summary="默认任务">
|
||||
<changelist id="ca5cd49c-a5d9-4f38-97d7-d00df846c40a" name="更改" comment="" />
|
||||
<created>1767609517374</created>
|
||||
<option name="number" value="Default" />
|
||||
<option name="presentableId" value="Default" />
|
||||
<updated>1767609517374</updated>
|
||||
<workItem from="1767609518595" duration="12049000" />
|
||||
<workItem from="1768182073838" duration="540000" />
|
||||
<workItem from="1768182796901" duration="29000" />
|
||||
<workItem from="1768183913621" duration="7779000" />
|
||||
<workItem from="1768208317457" duration="2438000" />
|
||||
<workItem from="1768211114552" duration="4634000" />
|
||||
</task>
|
||||
<servers />
|
||||
</component>
|
||||
<component name="TypeScriptGeneratedFilesManager">
|
||||
<option name="version" value="3" />
|
||||
</component>
|
||||
</project>
|
||||
20
library/skyeye-dev/README.md
Normal file
20
library/skyeye-dev/README.md
Normal file
@ -0,0 +1,20 @@
|
||||
# SpaceDT Java开发库
|
||||
|
||||
## 目录结构
|
||||
|
||||
```java
|
||||
dt-dev
|
||||
|-- dt-dev-common:通用依赖及接口标准封装
|
||||
|-- dt-dev-db:数据库集成类库封装
|
||||
|-- dt-dev-email:邮件类库封装
|
||||
|-- dt-dev-generator:代码生成模块封装
|
||||
|-- dt-dev-knife4j:在线API集成封装
|
||||
|-- dt-dev-quartz:定时任务集成封装
|
||||
|-- dt-dev-redis:Redis集成封装
|
||||
|-- dt-dev-tx:分布式事务封装
|
||||
|-- dt-dev-util:常用工具类库封装
|
||||
|-- dt-dev-websocket:websocket集成封装
|
||||
|-- pom.xml:Maven配置文件
|
||||
|
||||
```
|
||||
|
||||
37
library/skyeye-dev/pom.xml
Normal file
37
library/skyeye-dev/pom.xml
Normal file
@ -0,0 +1,37 @@
|
||||
<?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>skyeye</artifactId>
|
||||
<groupId>com.zhangy</groupId>
|
||||
<version>1.0.0.RELEASE</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>com.zhangy</groupId>
|
||||
<artifactId>skyeye-dev</artifactId>
|
||||
<version>1.0.0.RELEASE</version>
|
||||
<packaging>pom</packaging>
|
||||
<description>skyeye library</description>
|
||||
|
||||
<modules>
|
||||
<module>skyeye-common</module>
|
||||
<module>skyeye-db</module>
|
||||
<module>skyeye-generator</module>
|
||||
<module>skyeye-job</module>
|
||||
<module>skyeye-knife4j</module>
|
||||
<module>skyeye-quartz</module>
|
||||
<module>skyeye-redis</module>
|
||||
<module>skyeye-websocket</module>
|
||||
<module>skyeye-util</module>
|
||||
<!--module>skyeye-tx</module>
|
||||
<module>skyeye-util</module>
|
||||
<module>skyeye-email</module>
|
||||
<module>skyeye-sms</module>
|
||||
<module>skyeye-office</module>
|
||||
<module>skyeye-job</module-->
|
||||
</modules>
|
||||
|
||||
</project>
|
||||
BIN
library/skyeye-dev/skyeye-common/.DS_Store
vendored
Normal file
BIN
library/skyeye-dev/skyeye-common/.DS_Store
vendored
Normal file
Binary file not shown.
50
library/skyeye-dev/skyeye-common/pom.xml
Normal file
50
library/skyeye-dev/skyeye-common/pom.xml
Normal file
@ -0,0 +1,50 @@
|
||||
<?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>skyeye-dev</artifactId>
|
||||
<groupId>com.zhangy</groupId>
|
||||
<version>1.0.0.RELEASE</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>skyeye-common</artifactId>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<!-- Lombok -->
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- JWT -->
|
||||
<dependency>
|
||||
<groupId>com.auth0</groupId>
|
||||
<artifactId>java-jwt</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- SpringBoot -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!--server-api-->
|
||||
<dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>javax.servlet-api</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- SpringWebMvc -->
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-webmvc</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
BIN
library/skyeye-dev/skyeye-common/src/.DS_Store
vendored
Normal file
BIN
library/skyeye-dev/skyeye-common/src/.DS_Store
vendored
Normal file
Binary file not shown.
BIN
library/skyeye-dev/skyeye-common/src/main/.DS_Store
vendored
Normal file
BIN
library/skyeye-dev/skyeye-common/src/main/.DS_Store
vendored
Normal file
Binary file not shown.
BIN
library/skyeye-dev/skyeye-common/src/main/java/.DS_Store
vendored
Normal file
BIN
library/skyeye-dev/skyeye-common/src/main/java/.DS_Store
vendored
Normal file
Binary file not shown.
BIN
library/skyeye-dev/skyeye-common/src/main/java/com/.DS_Store
vendored
Normal file
BIN
library/skyeye-dev/skyeye-common/src/main/java/com/.DS_Store
vendored
Normal file
Binary file not shown.
@ -0,0 +1,14 @@
|
||||
package com.zhangy.skyeye.common.pojo;
|
||||
|
||||
/**
|
||||
* 通用常量
|
||||
*/
|
||||
public interface CommonConstant {
|
||||
|
||||
/**
|
||||
* true and false
|
||||
*/
|
||||
Integer FALSE = 0;
|
||||
Integer TRUE = 1;
|
||||
|
||||
}
|
||||
@ -0,0 +1,103 @@
|
||||
package com.zhangy.skyeye.common.pojo;
|
||||
|
||||
public interface SecurityConstants {
|
||||
|
||||
|
||||
/**
|
||||
* 用户token header
|
||||
*/
|
||||
String AUTHORIZATION = "Authorization";
|
||||
|
||||
/**
|
||||
* 呕
|
||||
*/
|
||||
String BEARER = "Bearer ";
|
||||
|
||||
/**
|
||||
* 用户信息
|
||||
*/
|
||||
String DETAILS_USER = "user_info";
|
||||
|
||||
/**
|
||||
* 客户端模式
|
||||
*/
|
||||
String CLIENT_CREDENTIALS = "client_credentials";
|
||||
|
||||
/**
|
||||
* 客户端ID
|
||||
*/
|
||||
String CLIENT_ID = "clientId";
|
||||
|
||||
/**
|
||||
* 手机号登录
|
||||
*/
|
||||
String APP = "mobile";
|
||||
|
||||
/**
|
||||
* 协议字段
|
||||
*/
|
||||
String DETAILS_LICENSE = "license";
|
||||
|
||||
/**
|
||||
* 角色前缀
|
||||
*/
|
||||
String ROLE = "ROLE_";
|
||||
|
||||
/**
|
||||
* {bcrypt} 加密的特征码
|
||||
*/
|
||||
String BCRYPT = "{bcrypt}";
|
||||
|
||||
/**
|
||||
* sys_oauth_client_details 表的字段,不包括client_id、client_secret
|
||||
*/
|
||||
String CLIENT_FIELDS = "client_id, CONCAT('{noop}',client_secret) as client_secret, resource_ids, scope, "
|
||||
+ "authorized_grant_types, web_server_redirect_uri, authorities, access_token_validity, "
|
||||
+ "refresh_token_validity, additional_information, autoapprove";
|
||||
|
||||
/**
|
||||
* JdbcClientDetailsService 查询语句
|
||||
*/
|
||||
String BASE_FIND_STATEMENT = "select " + CLIENT_FIELDS + " from sys_oauth_client_details";
|
||||
|
||||
/**
|
||||
* 按条件client_id 查询
|
||||
*/
|
||||
String DEFAULT_SELECT_STATEMENT = BASE_FIND_STATEMENT + " where client_id = ? and del_flag = 0";
|
||||
|
||||
/**
|
||||
* 默认的查询语句
|
||||
*/
|
||||
String DEFAULT_FIND_STATEMENT = BASE_FIND_STATEMENT + " order by client_id";
|
||||
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
String STATUS_DEL = "1";
|
||||
|
||||
/**
|
||||
* 正常
|
||||
*/
|
||||
String STATUS_NORMAL = "0";
|
||||
|
||||
/**
|
||||
* 锁定
|
||||
*/
|
||||
String STATUS_LOCK = "9";
|
||||
|
||||
/***
|
||||
* 资源服务器默认bean名称
|
||||
*/
|
||||
String RESOURCE_SERVER_CONFIGURER = "resourceServerConfigurerAdapter";
|
||||
|
||||
/**
|
||||
* 内部val
|
||||
*/
|
||||
String SECRET_VALUE = "Y";
|
||||
|
||||
/**
|
||||
* 标志头
|
||||
*/
|
||||
String SECRET_KEY = "secret";
|
||||
}
|
||||
@ -0,0 +1,18 @@
|
||||
package com.zhangy.skyeye.common.pojo.param;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Controller接口,ID方法参数封装
|
||||
*/
|
||||
@Data
|
||||
public class IdParam<T> implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private T id;
|
||||
private List<T> ids;
|
||||
}
|
||||
@ -0,0 +1,159 @@
|
||||
package com.zhangy.skyeye.common.pojo.result;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 统一接口返回数据格式
|
||||
*/
|
||||
@Data
|
||||
public class Result<T> implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 返回代码
|
||||
*/
|
||||
private Integer code;
|
||||
|
||||
/**
|
||||
* 返回处理消息
|
||||
*/
|
||||
private String message;
|
||||
|
||||
/**
|
||||
* 返回数据对象 data
|
||||
*/
|
||||
private T data;
|
||||
|
||||
public Result() { }
|
||||
|
||||
/**
|
||||
* 成功
|
||||
* @return Result对象
|
||||
*/
|
||||
public static Result success() {
|
||||
Result r = new Result();
|
||||
r.setCode(ResultConstant.SUCCESS_200);
|
||||
r.setMessage("操作成功");
|
||||
return r;
|
||||
}
|
||||
|
||||
/**
|
||||
* 成功
|
||||
* @param message 消息
|
||||
* @return Result对象
|
||||
*/
|
||||
public static Result success(String message) {
|
||||
Result r = new Result();
|
||||
r.setCode(ResultConstant.SUCCESS_200);
|
||||
r.setMessage(message);
|
||||
return r;
|
||||
}
|
||||
|
||||
/**
|
||||
* 成功
|
||||
* @param data data数据
|
||||
* @return Result对象
|
||||
*/
|
||||
public static Result successData(Object data) {
|
||||
Result r = new Result();
|
||||
r.setCode(ResultConstant.SUCCESS_200);
|
||||
r.setData(data);
|
||||
return r;
|
||||
}
|
||||
|
||||
/**
|
||||
* 成功
|
||||
* @param msg 消息
|
||||
* @param data data数据
|
||||
* @return Result对象
|
||||
*/
|
||||
public static Result successData(String msg, Object data) {
|
||||
Result r = new Result();
|
||||
r.setCode(ResultConstant.SUCCESS_200);
|
||||
r.setMessage(msg);
|
||||
r.setData(data);
|
||||
return r;
|
||||
}
|
||||
|
||||
/**
|
||||
* 失败
|
||||
* @return Result对象
|
||||
*/
|
||||
public static Result error() {
|
||||
return error(ResultConstant.SERVER_ERROR_500, "操作失败,请重试!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 失败
|
||||
* @param msg 消息
|
||||
* @return Result对象
|
||||
*/
|
||||
public static Result error(String msg) {
|
||||
return error(ResultConstant.SERVER_ERROR_500, msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* 失败
|
||||
* @param code 自定义code
|
||||
* @param msg 消息
|
||||
* @return Result对象
|
||||
*/
|
||||
public static Result error(int code, String msg) {
|
||||
Result r = new Result();
|
||||
r.setCode(code);
|
||||
r.setMessage(msg);
|
||||
return r;
|
||||
}
|
||||
|
||||
/**
|
||||
* 失败
|
||||
* @param msg 消息
|
||||
* @param data data数据
|
||||
* @return Result对象
|
||||
*/
|
||||
public static Result errorData(String msg, Object data) {
|
||||
Result r = new Result();
|
||||
r.setCode(ResultConstant.SERVER_ERROR_500);
|
||||
r.setMessage(msg);
|
||||
r.setData(data);
|
||||
return r;
|
||||
}
|
||||
|
||||
/**
|
||||
* 无权限访问返回结果
|
||||
* @param msg 消息
|
||||
* @return 无权限访问返回结果
|
||||
*/
|
||||
public static Result unAuth(String msg) {
|
||||
return error(ResultConstant.NO_AUTH_401, msg);
|
||||
}
|
||||
|
||||
// /**
|
||||
// * 增加返回数据对象
|
||||
// * @param k
|
||||
// * @param v
|
||||
// * @return
|
||||
// */
|
||||
// public Result addData(String k, Object v) {
|
||||
// if(this.data == null){
|
||||
// this.data = new HashMap<>();
|
||||
// }
|
||||
//
|
||||
// ((Map)this.data).put(k, v);
|
||||
// return this;
|
||||
// }
|
||||
|
||||
/**
|
||||
* 返回成功或失败
|
||||
* @param flag 成功失败状态值
|
||||
* @return Result对象
|
||||
*/
|
||||
public static Result status(boolean flag){
|
||||
return flag ? success() : error();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,23 @@
|
||||
package com.zhangy.skyeye.common.pojo.result;
|
||||
|
||||
/**
|
||||
* 返回状态码枚举类
|
||||
*/
|
||||
public interface ResultConstant {
|
||||
|
||||
/**
|
||||
* 成功
|
||||
*/
|
||||
Integer SUCCESS_200 = 200;
|
||||
|
||||
/**
|
||||
* 权限不足
|
||||
*/
|
||||
Integer NO_AUTH_401 = 401;
|
||||
|
||||
/**
|
||||
* 失败
|
||||
*/
|
||||
Integer SERVER_ERROR_500 = 500;
|
||||
|
||||
}
|
||||
@ -0,0 +1,43 @@
|
||||
package com.zhangy.skyeye.common.pojo.tree;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 树状结构节点封装
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class TreeNode<T> implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private T id;
|
||||
private String label;
|
||||
private List<TreeNode> children;
|
||||
private Object data;
|
||||
private Integer order;
|
||||
private Object type;
|
||||
|
||||
public TreeNode(T id, String label, List<TreeNode> children, Object data) {
|
||||
this.id = id;
|
||||
this.label = label;
|
||||
this.children = children;
|
||||
this.data = data;
|
||||
this.order = 0;
|
||||
}
|
||||
|
||||
public TreeNode(T id, String label, List<TreeNode> children, Object data, Object type) {
|
||||
this.id = id;
|
||||
this.label = label;
|
||||
this.children = children;
|
||||
this.data = data;
|
||||
this.order = 0;
|
||||
this.type = type;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,198 @@
|
||||
package com.zhangy.skyeye.common.utils;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* 通用工具类
|
||||
*/
|
||||
public class CommonUtil {
|
||||
|
||||
/**
|
||||
* ids字符串转Long list,逗号分隔
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
public static List<Long> toList(String ids){
|
||||
if(ids == null || ids.isEmpty()){
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
String[] strArr = ids.split(",");
|
||||
Long[] longArr = new Long[strArr.length];
|
||||
for (int i = 0; i < strArr.length; i++) {
|
||||
Long v = Long.valueOf(strArr[i]);
|
||||
longArr[i] = v;
|
||||
}
|
||||
return Arrays.asList(longArr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Long list转ids字符串,逗号分隔
|
||||
* @param list
|
||||
* @return
|
||||
*/
|
||||
public static <T> String toStr(List<T> list){
|
||||
if(list == null || list.isEmpty()){
|
||||
return "";
|
||||
}
|
||||
|
||||
Iterator<T> it = list.iterator();
|
||||
|
||||
//使用StringJoiner方式实现
|
||||
StringJoiner sj = new StringJoiner(",");
|
||||
while (it.hasNext()){
|
||||
sj.add(String.valueOf(it.next()));
|
||||
}
|
||||
return sj.toString();
|
||||
|
||||
//使用StringBuilder方式实现
|
||||
/*StringBuilder sb = new StringBuilder();
|
||||
while (it.hasNext()){
|
||||
sb.append(it.next());
|
||||
if(it.hasNext()){
|
||||
sb.append(",");
|
||||
}
|
||||
}
|
||||
return sb.toString();*/
|
||||
}
|
||||
|
||||
/**
|
||||
* java去除字符串中的空格、回车、换行符、制表符
|
||||
*
|
||||
* @param str
|
||||
* @return
|
||||
*/
|
||||
public static String replaceBlank(String str) {
|
||||
String dest = "";
|
||||
if (str != null) {
|
||||
Pattern p = Pattern.compile("\\s*|\t|\r|\n");
|
||||
Matcher m = p.matcher(str);
|
||||
dest = m.replaceAll("");
|
||||
}
|
||||
return dest;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 将下划线大写方式命名的字符串转换为驼峰式。
|
||||
* 如果转换前的下划线大写方式命名的字符串为空,则返回空字符串。</br>
|
||||
* 例如:hello_world->helloWorld
|
||||
*
|
||||
* @param name
|
||||
* 转换前的下划线大写方式命名的字符串
|
||||
* @return 转换后的驼峰式命名的字符串
|
||||
*/
|
||||
public static String camelName(String name) {
|
||||
StringBuilder result = new StringBuilder();
|
||||
// 快速检查
|
||||
if (name == null || name.isEmpty()) {
|
||||
// 没必要转换
|
||||
return "";
|
||||
} else if (!name.contains("_")) {
|
||||
// 不含下划线,仅将首字母小写
|
||||
//update-begin--Author:zhoujf Date:20180503 for:TASK #2500 【代码生成器】代码生成器开发一通用模板生成功能
|
||||
//update-begin--Author:zhoujf Date:20180503 for:TASK #2500 【代码生成器】代码生成器开发一通用模板生成功能
|
||||
return name.substring(0, 1).toLowerCase() + name.substring(1).toLowerCase();
|
||||
//update-end--Author:zhoujf Date:20180503 for:TASK #2500 【代码生成器】代码生成器开发一通用模板生成功能
|
||||
}
|
||||
// 用下划线将原始字符串分割
|
||||
String camels[] = name.split("_");
|
||||
for (String camel : camels) {
|
||||
// 跳过原始字符串中开头、结尾的下换线或双重下划线
|
||||
if (camel.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
// 处理真正的驼峰片段
|
||||
if (result.length() == 0) {
|
||||
// 第一个驼峰片段,全部字母都小写
|
||||
result.append(camel.toLowerCase());
|
||||
} else {
|
||||
// 其他的驼峰片段,首字母大写
|
||||
result.append(camel.substring(0, 1).toUpperCase());
|
||||
result.append(camel.substring(1).toLowerCase());
|
||||
}
|
||||
}
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 将下划线大写方式命名的字符串转换为驼峰式。
|
||||
* 如果转换前的下划线大写方式命名的字符串为空,则返回空字符串。</br>
|
||||
* 例如:hello_world,test_id->helloWorld,testId
|
||||
*
|
||||
* @param names
|
||||
* 转换前的下划线大写方式命名的字符串
|
||||
* @return 转换后的驼峰式命名的字符串
|
||||
*/
|
||||
public static String camelNames(String names) {
|
||||
if(names==null||names.equals("")){
|
||||
return null;
|
||||
}
|
||||
StringBuffer sf = new StringBuffer();
|
||||
String[] fs = names.split(",");
|
||||
for (String field : fs) {
|
||||
field = camelName(field);
|
||||
sf.append(field + ",");
|
||||
}
|
||||
String result = sf.toString();
|
||||
return result.substring(0, result.length() - 1);
|
||||
}
|
||||
|
||||
//update-begin--Author:zhoujf Date:20180503 for:TASK #2500 【代码生成器】代码生成器开发一通用模板生成功能
|
||||
/**
|
||||
* 将下划线大写方式命名的字符串转换为驼峰式。(首字母写)
|
||||
* 如果转换前的下划线大写方式命名的字符串为空,则返回空字符串。</br>
|
||||
* 例如:hello_world->HelloWorld
|
||||
*
|
||||
* @param name
|
||||
* 转换前的下划线大写方式命名的字符串
|
||||
* @return 转换后的驼峰式命名的字符串
|
||||
*/
|
||||
public static String camelNameCapFirst(String name) {
|
||||
StringBuilder result = new StringBuilder();
|
||||
// 快速检查
|
||||
if (name == null || name.isEmpty()) {
|
||||
// 没必要转换
|
||||
return "";
|
||||
} else if (!name.contains("_")) {
|
||||
// 不含下划线,仅将首字母小写
|
||||
return name.substring(0, 1).toUpperCase() + name.substring(1).toLowerCase();
|
||||
}
|
||||
// 用下划线将原始字符串分割
|
||||
String camels[] = name.split("_");
|
||||
for (String camel : camels) {
|
||||
// 跳过原始字符串中开头、结尾的下换线或双重下划线
|
||||
if (camel.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
// 其他的驼峰片段,首字母大写
|
||||
result.append(camel.substring(0, 1).toUpperCase());
|
||||
result.append(camel.substring(1).toLowerCase());
|
||||
}
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 将驼峰命名转化成下划线
|
||||
* @param para
|
||||
* @return
|
||||
*/
|
||||
public static String camelToUnderline(String para){
|
||||
if(para.length()<3){
|
||||
return para.toLowerCase();
|
||||
}
|
||||
StringBuilder sb=new StringBuilder(para);
|
||||
int temp=0;//定位
|
||||
//从第三个字符开始 避免命名不规范
|
||||
for(int i=2;i<para.length();i++){
|
||||
if(Character.isUpperCase(para.charAt(i))){
|
||||
sb.insert(i+temp, "_");
|
||||
temp+=1;
|
||||
}
|
||||
}
|
||||
return sb.toString().toLowerCase();
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,73 @@
|
||||
package com.zhangy.skyeye.common.utils;
|
||||
|
||||
import lombok.experimental.UtilityClass;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.web.util.WebUtils;
|
||||
|
||||
import javax.servlet.http.Cookie;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* cookie工具类
|
||||
*/
|
||||
@UtilityClass
|
||||
public class CookieUtil {
|
||||
|
||||
/**
|
||||
* 读取cookie
|
||||
*
|
||||
* @param name cookie 键
|
||||
* @return cookie 值
|
||||
*/
|
||||
public String getCookieValue(String name) {
|
||||
HttpServletRequest request = WebUtil.getRequest();
|
||||
Assert.notNull(request, "request from RequestContextHolder is null");
|
||||
return getCookieValue(request, name);
|
||||
}
|
||||
|
||||
/**
|
||||
* 读取cookie
|
||||
*
|
||||
* @param request HttpServletRequest
|
||||
* @param name cookie 键
|
||||
* @return cookie 值
|
||||
*/
|
||||
public String getCookieValue(HttpServletRequest request, String name) {
|
||||
Cookie cookie = WebUtils.getCookie(request, name);
|
||||
return cookie != null ? cookie.getValue() : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 清除 指定的cookie
|
||||
*
|
||||
* @param response HttpServletResponse
|
||||
* @param key cookie 键
|
||||
*/
|
||||
public void removeCookie(HttpServletResponse response, String key) {
|
||||
setCookie(response, key, null, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置cookie
|
||||
*
|
||||
* @param response HttpServletResponse
|
||||
* @param name cookie 键
|
||||
* @param value cookie 值
|
||||
* @param maxAgeInSeconds 生命周期 秒
|
||||
*/
|
||||
public void setCookie(HttpServletResponse response, String name, String value, int maxAgeInSeconds) {
|
||||
Cookie cookie = new Cookie(name, value);
|
||||
cookie.setPath("/");
|
||||
cookie.setMaxAge(maxAgeInSeconds);
|
||||
cookie.setHttpOnly(true);
|
||||
cookie.setSecure(true);
|
||||
response.addCookie(cookie);
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
HttpServletResponse response = WebUtil.getResponse();
|
||||
CookieUtil.setCookie(response, "testKey", "123", 30);
|
||||
CookieUtil.removeCookie(response, "testKey");
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,63 @@
|
||||
package com.zhangy.skyeye.common.utils;
|
||||
|
||||
import java.net.InetAddress;
|
||||
import java.net.NetworkInterface;
|
||||
import java.net.SocketException;
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.Enumeration;
|
||||
|
||||
/**
|
||||
* IP工具类
|
||||
*/
|
||||
public class IPUtil {
|
||||
|
||||
/**
|
||||
* 获取本机IP
|
||||
* @return
|
||||
*/
|
||||
public static String getIp() {
|
||||
String ip = null;
|
||||
try {
|
||||
InetAddress address = InetAddress.getLocalHost();
|
||||
ip = address.getHostAddress();
|
||||
|
||||
} catch (UnknownHostException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return ip;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return 本机IP
|
||||
* @throws SocketException
|
||||
*/
|
||||
public static String getRealIp() throws SocketException {
|
||||
String localip = null;// 本地IP,如果没有配置外网IP则返回它
|
||||
String netip = null;// 外网IP
|
||||
|
||||
Enumeration<NetworkInterface> netInterfaces = NetworkInterface.getNetworkInterfaces();
|
||||
InetAddress ip = null;
|
||||
boolean finded = false;// 是否找到外网IP
|
||||
while (netInterfaces.hasMoreElements() && !finded) {
|
||||
NetworkInterface ni = netInterfaces.nextElement();
|
||||
Enumeration<InetAddress> address = ni.getInetAddresses();
|
||||
while (address.hasMoreElements()) {
|
||||
ip = address.nextElement();
|
||||
if (!ip.isSiteLocalAddress() && !ip.isLoopbackAddress() && ip.getHostAddress().indexOf(":") == -1) {// 外网IP
|
||||
netip = ip.getHostAddress();
|
||||
finded = true;
|
||||
break;
|
||||
} else if (ip.isSiteLocalAddress() && !ip.isLoopbackAddress() && ip.getHostAddress().indexOf(":") == -1) {// 内网IP
|
||||
localip = ip.getHostAddress();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (netip != null && !"".equals(netip)) {
|
||||
return netip;
|
||||
} else {
|
||||
return localip;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,84 @@
|
||||
package com.zhangy.skyeye.common.utils;
|
||||
|
||||
import com.auth0.jwt.JWT;
|
||||
import com.auth0.jwt.JWTVerifier;
|
||||
import com.auth0.jwt.algorithms.Algorithm;
|
||||
import com.auth0.jwt.exceptions.JWTDecodeException;
|
||||
import com.auth0.jwt.interfaces.DecodedJWT;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* JWT工具类
|
||||
**/
|
||||
public class JwtUtil {
|
||||
|
||||
// Token过期时间30分钟
|
||||
public static final long EXPIRE_TIME = 4 * 60 * 60 * 1000;
|
||||
|
||||
// Reuqest Header中token的key
|
||||
public static final String AUTH_TOKEN_KEY = "X-Access-Token";
|
||||
|
||||
/**
|
||||
* 校验token是否正确
|
||||
*
|
||||
* @param token 密钥
|
||||
* @param username 用户名
|
||||
* @param secret 用户的密码
|
||||
* @return 是否正确
|
||||
*/
|
||||
public static boolean verify(String token, String username, String secret) {
|
||||
try {
|
||||
// 根据密码生成JWT效验器
|
||||
Algorithm algorithm = Algorithm.HMAC256(secret);
|
||||
JWTVerifier verifier = JWT.require(algorithm).withClaim("username", username).build();
|
||||
// 效验TOKEN
|
||||
DecodedJWT jwt = verifier.verify(token);
|
||||
return true;
|
||||
} catch (Exception exception) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成签名,5min后过期
|
||||
*
|
||||
* @param username 用户名
|
||||
* @param secret 用户的密码
|
||||
* @return 加密的token
|
||||
*/
|
||||
public static String sign(String username, String secret) {
|
||||
Date date = new Date(System.currentTimeMillis() + EXPIRE_TIME);
|
||||
Algorithm algorithm = Algorithm.HMAC256(secret);
|
||||
// 附带username信息
|
||||
return JWT.create().withClaim("username", username).withExpiresAt(date).sign(algorithm);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据token获取用户账号
|
||||
*
|
||||
* @param accessToken
|
||||
* @return username
|
||||
*/
|
||||
public static String getUserName(String accessToken) {
|
||||
try {
|
||||
DecodedJWT jwt = JWT.decode(accessToken);
|
||||
return jwt.getClaim("username").asString();
|
||||
} catch (JWTDecodeException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断token是否已过期
|
||||
*
|
||||
* @param accessToken
|
||||
* @return true-过期,false-没过期
|
||||
*/
|
||||
public static Boolean isTokenExpired(String accessToken) {
|
||||
DecodedJWT jwt = JWT.decode(accessToken);
|
||||
return jwt.getExpiresAt().getTime() < new Date(System.currentTimeMillis()).getTime();
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,58 @@
|
||||
package com.zhangy.skyeye.common.utils;
|
||||
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.ApplicationContextAware;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class SpringUtil implements ApplicationContextAware {
|
||||
|
||||
private static ApplicationContext applicationContext;
|
||||
|
||||
@Override
|
||||
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
|
||||
if(SpringUtil.applicationContext == null) {
|
||||
SpringUtil.applicationContext = applicationContext;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取applicationContext
|
||||
* @return ApplicationContext
|
||||
*/
|
||||
public static ApplicationContext getApplicationContext() {
|
||||
return applicationContext;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过name获取 Bean.
|
||||
* @param name name
|
||||
* @return Bean对象
|
||||
*/
|
||||
public static Object getBean(String name){
|
||||
return getApplicationContext().getBean(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过class获取Bean
|
||||
* @param clazz class
|
||||
* @param <T>
|
||||
* @return Bean对象
|
||||
*/
|
||||
public static <T> T getBean(Class<T> clazz){
|
||||
return getApplicationContext().getBean(clazz);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过name,以及Clazz返回指定的Bean
|
||||
* @param name name
|
||||
* @param clazz class
|
||||
* @param <T>
|
||||
* @return Bean对象
|
||||
*/
|
||||
public static <T> T getBean(String name,Class<T> clazz){
|
||||
return getApplicationContext().getBean(name, clazz);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,78 @@
|
||||
package com.zhangy.skyeye.common.utils;
|
||||
|
||||
import lombok.experimental.UtilityClass;
|
||||
import org.springframework.web.context.request.RequestAttributes;
|
||||
import org.springframework.web.context.request.RequestContextHolder;
|
||||
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* web工具类
|
||||
*/
|
||||
@UtilityClass
|
||||
public class WebUtil {
|
||||
|
||||
private final String UNKNOWN = "unknown";
|
||||
|
||||
/**
|
||||
* 获取 HttpServletRequest
|
||||
*
|
||||
* @return HttpServletRequest
|
||||
*/
|
||||
public HttpServletRequest getRequest() {
|
||||
try {
|
||||
RequestAttributes requestAttributes = RequestContextHolder.currentRequestAttributes();
|
||||
return ((ServletRequestAttributes) requestAttributes).getRequest();
|
||||
} catch (IllegalStateException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取 HttpServletResponse
|
||||
*
|
||||
* @return HttpServletResponse
|
||||
*/
|
||||
public HttpServletResponse getResponse() {
|
||||
return ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getResponse();
|
||||
}
|
||||
|
||||
// /**
|
||||
// * 获取ip
|
||||
// * @return
|
||||
// */
|
||||
// public String getIP() {
|
||||
// return getIP(getRequest());
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 获取ip
|
||||
// * @param request
|
||||
// * @return
|
||||
// */
|
||||
// public String getIP(HttpServletRequest request) {
|
||||
// Assert.notNull(request, "HttpServletRequest is null");
|
||||
// String ip = request.getHeader("X-Requested-For");
|
||||
// if (StrUtil.isBlank(ip) || UNKNOWN.equalsIgnoreCase(ip)) {
|
||||
// ip = request.getHeader("X-Forwarded-For");
|
||||
// }
|
||||
// if (StrUtil.isBlank(ip) || UNKNOWN.equalsIgnoreCase(ip)) {
|
||||
// ip = request.getHeader("Proxy-Client-IP");
|
||||
// }
|
||||
// if (StrUtil.isBlank(ip) || UNKNOWN.equalsIgnoreCase(ip)) {
|
||||
// ip = request.getHeader("WL-Proxy-Client-IP");
|
||||
// }
|
||||
// if (StrUtil.isBlank(ip) || UNKNOWN.equalsIgnoreCase(ip)) {
|
||||
// ip = request.getHeader("HTTP_CLIENT_IP");
|
||||
// }
|
||||
// if (StrUtil.isBlank(ip) || UNKNOWN.equalsIgnoreCase(ip)) {
|
||||
// ip = request.getHeader("HTTP_X_FORWARDED_FOR");
|
||||
// }
|
||||
// if (StrUtil.isBlank(ip) || UNKNOWN.equalsIgnoreCase(ip)) {
|
||||
// ip = request.getRemoteAddr();
|
||||
// }
|
||||
// return StrUtil.isBlank(ip) ? null : ip.split(",")[0];
|
||||
// }
|
||||
}
|
||||
@ -0,0 +1,2 @@
|
||||
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
|
||||
com.zhangy.skyeye.common.utils.SpringUtil
|
||||
@ -0,0 +1,12 @@
|
||||
${AnsiColor.BRIGHT_BLUE}
|
||||
_____ _ _ ____ ____ _____
|
||||
|_ _(_) / \ _ __ ___ ___ / ___| _ __ __ _ ___ ___ | _ \_ _|
|
||||
| | | | / _ \ | '_ ` _ \ / _ \ \___ \| '_ \ / _` |/ __/ _ \_____| | | || |
|
||||
| | | |/ ___ \| | | | | | (_) | ___) | |_) | (_| | (_| __/_____| |_| || |
|
||||
|_| |_/_/ \_\_| |_| |_|\___/ |____/| .__/ \__,_|\___\___| |____/ |_|
|
||||
|_|
|
||||
${AnsiColor.BRIGHT_GREEN}
|
||||
Spring Boot Version: ${spring-boot.version}
|
||||
Spring Cloud Version: Hoxton.SR9
|
||||
Spring Cloud Alibaba Version: 2.2.2.RELEASE
|
||||
${AnsiColor.BLACK}
|
||||
@ -0,0 +1,62 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<configuration debug="false" scan="false">
|
||||
<springProperty scop="context" name="spring.application.name" source="spring.application.name" defaultValue=""/>
|
||||
<property name="log.path" value="logs/"/>
|
||||
<!-- 彩色日志格式 -->
|
||||
<property name="CONSOLE_LOG_PATTERN"
|
||||
value="${CONSOLE_LOG_PATTERN:-%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(${LOG_LEVEL_PATTERN:-%5p}) %clr(${PID:- }){magenta} %clr(---){faint} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}}"/>
|
||||
<!-- 彩色日志依赖的渲染类 -->
|
||||
<conversionRule conversionWord="clr" converterClass="org.springframework.boot.logging.logback.ColorConverter"/>
|
||||
<conversionRule conversionWord="wex"
|
||||
converterClass="org.springframework.boot.logging.logback.WhitespaceThrowableProxyConverter"/>
|
||||
<conversionRule conversionWord="wEx"
|
||||
converterClass="org.springframework.boot.logging.logback.ExtendedWhitespaceThrowableProxyConverter"/>
|
||||
<!-- Console log output -->
|
||||
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder>
|
||||
<pattern>${CONSOLE_LOG_PATTERN}</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<!-- Log file debug output -->
|
||||
<appender name="debug" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<file>${log.path}/java/${spring.application.name}/syslogTodayDebug.log</file>
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
|
||||
<fileNamePattern>${log.path}/%d{yyyy-MM-dd}/java/${spring.application.name}/syslogYesterdayDebug.%i.log</fileNamePattern>
|
||||
<maxFileSize>50MB</maxFileSize>
|
||||
<maxHistory>30</maxHistory>
|
||||
</rollingPolicy>
|
||||
<encoder>
|
||||
<pattern>%date [%thread] %-5level [%logger{50}] %file:%line - %msg%n</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<!-- Log file error output -->
|
||||
<appender name="error" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<file>${log.path}/java/${spring.application.name}/syslogTodayError.log</file>
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
|
||||
<fileNamePattern>${log.path}/%d{yyyy-MM-dd}/java/${spring.application.name}/syslogYesterdayError.%i.log</fileNamePattern>
|
||||
<maxFileSize>50MB</maxFileSize>
|
||||
<maxHistory>30</maxHistory>
|
||||
</rollingPolicy>
|
||||
<encoder>
|
||||
<pattern>%date [%thread] %-5level [%logger{50}] %file:%line - %msg%n</pattern>
|
||||
</encoder>
|
||||
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
|
||||
<level>ERROR</level>
|
||||
</filter>
|
||||
</appender>
|
||||
|
||||
<!--nacos 心跳 INFO 屏蔽-->
|
||||
<logger name="com.alibaba.nacos" level="OFF">
|
||||
<appender-ref ref="error"/>
|
||||
</logger>
|
||||
|
||||
<!-- Level: FATAL 0 ERROR 3 WARN 4 INFO 6 DEBUG 7 -->
|
||||
<root level="INFO">
|
||||
<appender-ref ref="console"/>
|
||||
<appender-ref ref="debug"/>
|
||||
<appender-ref ref="error"/>
|
||||
</root>
|
||||
</configuration>
|
||||
@ -0,0 +1,2 @@
|
||||
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
|
||||
com.zhangy.skyeye.common.utils.SpringUtil
|
||||
12
library/skyeye-dev/skyeye-common/target/classes/banner.txt
Normal file
12
library/skyeye-dev/skyeye-common/target/classes/banner.txt
Normal file
@ -0,0 +1,12 @@
|
||||
${AnsiColor.BRIGHT_BLUE}
|
||||
_____ _ _ ____ ____ _____
|
||||
|_ _(_) / \ _ __ ___ ___ / ___| _ __ __ _ ___ ___ | _ \_ _|
|
||||
| | | | / _ \ | '_ ` _ \ / _ \ \___ \| '_ \ / _` |/ __/ _ \_____| | | || |
|
||||
| | | |/ ___ \| | | | | | (_) | ___) | |_) | (_| | (_| __/_____| |_| || |
|
||||
|_| |_/_/ \_\_| |_| |_|\___/ |____/| .__/ \__,_|\___\___| |____/ |_|
|
||||
|_|
|
||||
${AnsiColor.BRIGHT_GREEN}
|
||||
Spring Boot Version: ${spring-boot.version}
|
||||
Spring Cloud Version: Hoxton.SR9
|
||||
Spring Cloud Alibaba Version: 2.2.2.RELEASE
|
||||
${AnsiColor.BLACK}
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,62 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<configuration debug="false" scan="false">
|
||||
<springProperty scop="context" name="spring.application.name" source="spring.application.name" defaultValue=""/>
|
||||
<property name="log.path" value="logs/"/>
|
||||
<!-- 彩色日志格式 -->
|
||||
<property name="CONSOLE_LOG_PATTERN"
|
||||
value="${CONSOLE_LOG_PATTERN:-%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(${LOG_LEVEL_PATTERN:-%5p}) %clr(${PID:- }){magenta} %clr(---){faint} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}}"/>
|
||||
<!-- 彩色日志依赖的渲染类 -->
|
||||
<conversionRule conversionWord="clr" converterClass="org.springframework.boot.logging.logback.ColorConverter"/>
|
||||
<conversionRule conversionWord="wex"
|
||||
converterClass="org.springframework.boot.logging.logback.WhitespaceThrowableProxyConverter"/>
|
||||
<conversionRule conversionWord="wEx"
|
||||
converterClass="org.springframework.boot.logging.logback.ExtendedWhitespaceThrowableProxyConverter"/>
|
||||
<!-- Console log output -->
|
||||
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder>
|
||||
<pattern>${CONSOLE_LOG_PATTERN}</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<!-- Log file debug output -->
|
||||
<appender name="debug" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<file>${log.path}/java/${spring.application.name}/syslogTodayDebug.log</file>
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
|
||||
<fileNamePattern>${log.path}/%d{yyyy-MM-dd}/java/${spring.application.name}/syslogYesterdayDebug.%i.log</fileNamePattern>
|
||||
<maxFileSize>50MB</maxFileSize>
|
||||
<maxHistory>30</maxHistory>
|
||||
</rollingPolicy>
|
||||
<encoder>
|
||||
<pattern>%date [%thread] %-5level [%logger{50}] %file:%line - %msg%n</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<!-- Log file error output -->
|
||||
<appender name="error" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<file>${log.path}/java/${spring.application.name}/syslogTodayError.log</file>
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
|
||||
<fileNamePattern>${log.path}/%d{yyyy-MM-dd}/java/${spring.application.name}/syslogYesterdayError.%i.log</fileNamePattern>
|
||||
<maxFileSize>50MB</maxFileSize>
|
||||
<maxHistory>30</maxHistory>
|
||||
</rollingPolicy>
|
||||
<encoder>
|
||||
<pattern>%date [%thread] %-5level [%logger{50}] %file:%line - %msg%n</pattern>
|
||||
</encoder>
|
||||
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
|
||||
<level>ERROR</level>
|
||||
</filter>
|
||||
</appender>
|
||||
|
||||
<!--nacos 心跳 INFO 屏蔽-->
|
||||
<logger name="com.alibaba.nacos" level="OFF">
|
||||
<appender-ref ref="error"/>
|
||||
</logger>
|
||||
|
||||
<!-- Level: FATAL 0 ERROR 3 WARN 4 INFO 6 DEBUG 7 -->
|
||||
<root level="INFO">
|
||||
<appender-ref ref="console"/>
|
||||
<appender-ref ref="debug"/>
|
||||
<appender-ref ref="error"/>
|
||||
</root>
|
||||
</configuration>
|
||||
@ -0,0 +1,3 @@
|
||||
artifactId=skyeye-common
|
||||
groupId=com.zhangy
|
||||
version=1.0.0.RELEASE
|
||||
@ -0,0 +1,12 @@
|
||||
com\zhangy\skyeye\common\utils\SpringUtil.class
|
||||
com\zhangy\skyeye\common\utils\IPUtil.class
|
||||
com\zhangy\skyeye\common\pojo\result\ResultConstant.class
|
||||
com\zhangy\skyeye\common\pojo\tree\TreeNode.class
|
||||
com\zhangy\skyeye\common\pojo\param\IdParam.class
|
||||
com\zhangy\skyeye\common\pojo\result\Result.class
|
||||
com\zhangy\skyeye\common\utils\WebUtil.class
|
||||
com\zhangy\skyeye\common\utils\CommonUtil.class
|
||||
com\zhangy\skyeye\common\utils\JwtUtil.class
|
||||
com\zhangy\skyeye\common\pojo\SecurityConstants.class
|
||||
com\zhangy\skyeye\common\pojo\CommonConstant.class
|
||||
com\zhangy\skyeye\common\utils\CookieUtil.class
|
||||
@ -0,0 +1,12 @@
|
||||
D:\logisen\ddd\skyeye-dev\skyeye-common\src\main\java\com\zhangy\skyeye\common\pojo\CommonConstant.java
|
||||
D:\logisen\ddd\skyeye-dev\skyeye-common\src\main\java\com\zhangy\skyeye\common\pojo\param\IdParam.java
|
||||
D:\logisen\ddd\skyeye-dev\skyeye-common\src\main\java\com\zhangy\skyeye\common\pojo\SecurityConstants.java
|
||||
D:\logisen\ddd\skyeye-dev\skyeye-common\src\main\java\com\zhangy\skyeye\common\utils\CookieUtil.java
|
||||
D:\logisen\ddd\skyeye-dev\skyeye-common\src\main\java\com\zhangy\skyeye\common\utils\SpringUtil.java
|
||||
D:\logisen\ddd\skyeye-dev\skyeye-common\src\main\java\com\zhangy\skyeye\common\pojo\result\ResultConstant.java
|
||||
D:\logisen\ddd\skyeye-dev\skyeye-common\src\main\java\com\zhangy\skyeye\common\pojo\tree\TreeNode.java
|
||||
D:\logisen\ddd\skyeye-dev\skyeye-common\src\main\java\com\zhangy\skyeye\common\utils\WebUtil.java
|
||||
D:\logisen\ddd\skyeye-dev\skyeye-common\src\main\java\com\zhangy\skyeye\common\pojo\result\Result.java
|
||||
D:\logisen\ddd\skyeye-dev\skyeye-common\src\main\java\com\zhangy\skyeye\common\utils\CommonUtil.java
|
||||
D:\logisen\ddd\skyeye-dev\skyeye-common\src\main\java\com\zhangy\skyeye\common\utils\JwtUtil.java
|
||||
D:\logisen\ddd\skyeye-dev\skyeye-common\src\main\java\com\zhangy\skyeye\common\utils\IPUtil.java
|
||||
Binary file not shown.
53
library/skyeye-dev/skyeye-db/pom.xml
Normal file
53
library/skyeye-dev/skyeye-db/pom.xml
Normal file
@ -0,0 +1,53 @@
|
||||
<?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>skyeye-dev</artifactId>
|
||||
<groupId>com.zhangy</groupId>
|
||||
<version>1.0.0.RELEASE</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>skyeye-db</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<description>skyeye db library</description>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<!-- SpringBoot Web -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- mybatis-plus -->
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-boot-starter</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- druid -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>druid-spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- tiamo-dev-common -->
|
||||
<dependency>
|
||||
<groupId>com.zhangy</groupId>
|
||||
<artifactId>skyeye-common</artifactId>
|
||||
<version>${skyeye.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- knife4j -->
|
||||
<dependency>
|
||||
<groupId>com.github.xiaoymin</groupId>
|
||||
<artifactId>knife4j-micro-spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
||||
</project>
|
||||
BIN
library/skyeye-dev/skyeye-db/src/main/java/com/zhangy/skyeye/.DS_Store
vendored
Normal file
BIN
library/skyeye-dev/skyeye-db/src/main/java/com/zhangy/skyeye/.DS_Store
vendored
Normal file
Binary file not shown.
@ -0,0 +1,39 @@
|
||||
package com.zhangy.skyeye.db.config;
|
||||
|
||||
import com.alibaba.druid.support.http.StatViewServlet;
|
||||
import com.alibaba.druid.support.http.WebStatFilter;
|
||||
import org.springframework.boot.web.servlet.FilterRegistrationBean;
|
||||
import org.springframework.boot.web.servlet.ServletRegistrationBean;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
public class DTDruidConfig {
|
||||
|
||||
@Bean
|
||||
public ServletRegistrationBean<StatViewServlet> statViewServletRegistrationBean() {
|
||||
ServletRegistrationBean<StatViewServlet> registrationBean = new ServletRegistrationBean();
|
||||
registrationBean.setServlet(new StatViewServlet());
|
||||
registrationBean.addUrlMappings(new String[] { "/druid/*" });
|
||||
registrationBean.addInitParameter("loginUsername", "admin");
|
||||
registrationBean.addInitParameter("loginPassword", "123456");
|
||||
registrationBean.addInitParameter("resetEnable", "false");
|
||||
return registrationBean;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public FilterRegistrationBean<WebStatFilter> webStatFilterRegistrationBean() {
|
||||
FilterRegistrationBean<WebStatFilter> registrationBean = new FilterRegistrationBean();
|
||||
WebStatFilter filter = new WebStatFilter();
|
||||
registrationBean.setFilter(filter);
|
||||
registrationBean.addUrlPatterns(new String[] { "/*" });
|
||||
registrationBean.addInitParameter("exclusions", "*.js,*.gif,*.jpg,*.png,*.css,*.ico,/druid/*");
|
||||
registrationBean.addInitParameter("sessionStatEnable", "false");
|
||||
registrationBean.addInitParameter("sessionStatMaxCount", "1000");
|
||||
registrationBean.addInitParameter("principalSessionName", "");
|
||||
registrationBean.addInitParameter("principalCookieName", "");
|
||||
registrationBean.addInitParameter("profileEnable", "true");
|
||||
return registrationBean;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,47 @@
|
||||
package com.zhangy.skyeye.db.config;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.DbType;
|
||||
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
|
||||
import com.baomidou.mybatisplus.extension.plugins.handler.TableNameHandler;
|
||||
import com.baomidou.mybatisplus.extension.plugins.inner.DynamicTableNameInnerInterceptor;
|
||||
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
@MapperScan("com.tiamo.dt.**.mapper")
|
||||
@Configuration
|
||||
public class DTMybatisPlusConfig {
|
||||
|
||||
/**
|
||||
* 分页插件
|
||||
*/
|
||||
@Bean
|
||||
public MybatisPlusInterceptor mybatisPlusInterceptor() {
|
||||
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
|
||||
|
||||
//分页插件
|
||||
interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
|
||||
|
||||
//动态表名插件
|
||||
DynamicTableNameInnerInterceptor dynamicTableNameInnerInterceptor = new DynamicTableNameInnerInterceptor();
|
||||
HashMap<String, TableNameHandler> map = new HashMap<>();
|
||||
map.put("res_pos_vel", (sql, tableName) -> tableName + "_" + DynamicTableNameHelper.getTableNameSuffix());
|
||||
map.put("env_sat_risk", (sql, tableName) -> getTableName(tableName, DynamicTableNameHelper.getTableNameSuffix()));
|
||||
map.put("env_goes_proton", (sql, tableName) -> getTableName(tableName, DynamicTableNameHelper.getTableNameSuffix()));
|
||||
map.put("env_goes_electron", (sql, tableName) -> getTableName(tableName, DynamicTableNameHelper.getTableNameSuffix()));
|
||||
map.put("env_goes_xray", (sql, tableName) -> getTableName(tableName, DynamicTableNameHelper.getTableNameSuffix()));
|
||||
map.put("env_goes_geomagnetic", (sql, tableName) -> getTableName(tableName, DynamicTableNameHelper.getTableNameSuffix()));
|
||||
map.put("env_poes_data", (sql, tableName) -> getTableName(tableName, DynamicTableNameHelper.getTableNameSuffix()));
|
||||
dynamicTableNameInnerInterceptor.setTableNameHandlerMap(map);
|
||||
interceptor.addInnerInterceptor(dynamicTableNameInnerInterceptor);
|
||||
|
||||
return interceptor;
|
||||
}
|
||||
|
||||
private String getTableName(String tableName, String suffix) {
|
||||
return suffix != null ? tableName + suffix : tableName;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,20 @@
|
||||
package com.zhangy.skyeye.db.config;
|
||||
|
||||
/**
|
||||
* 动态表名参数类
|
||||
*/
|
||||
public class DynamicTableNameHelper {
|
||||
|
||||
/**
|
||||
* 动态表名参数保存
|
||||
*/
|
||||
private static final ThreadLocal<String> TABLE_NAME_SUFFIX = new ThreadLocal<>();
|
||||
|
||||
public static void setTableNameSuffix(String tableNameSuffix){
|
||||
TABLE_NAME_SUFFIX.set(tableNameSuffix);
|
||||
}
|
||||
|
||||
public static String getTableNameSuffix() {
|
||||
return TABLE_NAME_SUFFIX.get();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,26 @@
|
||||
package com.zhangy.skyeye.db.pojo.page;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 分页参数
|
||||
*/
|
||||
@Data
|
||||
@ApiModel(value="PageParam对象", description="分页参数")
|
||||
public class PageParam {
|
||||
|
||||
@ApiModelProperty(value = "当前页", position = 1)
|
||||
private Integer pageCurrent = 1;
|
||||
|
||||
@ApiModelProperty(value = "每页数量", position = 2)
|
||||
private Integer pageSize = 10;
|
||||
|
||||
@ApiModelProperty(value = "排序字段", position = 3)
|
||||
private String orderBy;
|
||||
|
||||
@ApiModelProperty(value = "正序or倒序", position = 4)
|
||||
private Boolean isAsc = true;
|
||||
|
||||
}
|
||||
@ -0,0 +1,22 @@
|
||||
package com.zhangy.skyeye.db.pojo.props;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* knife4j配置配置信息
|
||||
*/
|
||||
@Data
|
||||
public class Knife4jProperties {
|
||||
|
||||
/**
|
||||
* Controller包根路径
|
||||
*/
|
||||
private String basePackage;
|
||||
|
||||
private String title;
|
||||
|
||||
private String description;
|
||||
|
||||
private String version;
|
||||
|
||||
}
|
||||
@ -0,0 +1,81 @@
|
||||
package com.zhangy.skyeye.db.config;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.OrderItem;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.zhangy.skyeye.common.utils.CommonUtil;
|
||||
import com.zhangy.skyeye.db.pojo.page.PageParam;
|
||||
|
||||
/**
|
||||
* MybatisPlus工具类
|
||||
*/
|
||||
public class MPUtil {
|
||||
|
||||
/**
|
||||
* 通过PageParam获取分页对象
|
||||
* @param pageParam
|
||||
* @return
|
||||
*/
|
||||
public static Page getPage(PageParam pageParam){
|
||||
if(pageParam == null){
|
||||
pageParam = new PageParam();
|
||||
}
|
||||
|
||||
Page page = new Page(pageParam.getPageCurrent(), pageParam.getPageSize());
|
||||
if(pageParam.getOrderBy() != null && !pageParam.getOrderBy().isEmpty()){
|
||||
String[] orderColumnArr = pageParam.getOrderBy().split(",");
|
||||
|
||||
//驼峰转下划线,数据库中字段为下划线
|
||||
for (int i = 0; i < orderColumnArr.length; i++) {
|
||||
orderColumnArr[i] = CommonUtil.camelToUnderline(orderColumnArr[i]);
|
||||
}
|
||||
|
||||
if(pageParam.getIsAsc()){
|
||||
page.addOrder(OrderItem.ascs(orderColumnArr));
|
||||
}else{
|
||||
page.addOrder(OrderItem.descs(orderColumnArr));
|
||||
}
|
||||
}
|
||||
return page;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取QueryWrapper
|
||||
* @return
|
||||
*/
|
||||
public static QueryWrapper getQueryWrapper(){
|
||||
return new QueryWrapper<>();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取QueryWrapper
|
||||
* @param pageParam
|
||||
* @return
|
||||
*/
|
||||
public static QueryWrapper getQueryWrapper(PageParam pageParam){
|
||||
if(pageParam == null){
|
||||
return new QueryWrapper<>();
|
||||
}
|
||||
|
||||
QueryWrapper queryWrapper = new QueryWrapper<>();
|
||||
|
||||
if(pageParam.getOrderBy() != null && !pageParam.getOrderBy().isEmpty()){
|
||||
String[] orderColumnArr = pageParam.getOrderBy().split(",");
|
||||
|
||||
//驼峰转下划线,数据库中字段为下划线
|
||||
for (int i = 0; i < orderColumnArr.length; i++) {
|
||||
orderColumnArr[i] = CommonUtil.camelToUnderline(orderColumnArr[i]);
|
||||
}
|
||||
|
||||
if(pageParam.getIsAsc()){
|
||||
queryWrapper.orderByAsc(orderColumnArr);
|
||||
}else{
|
||||
queryWrapper.orderByDesc(orderColumnArr);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return queryWrapper;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,3 @@
|
||||
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
|
||||
com.tiamo.dt.dev.db.config.DTDruidConfig,\
|
||||
com.tiamo.dt.dev.db.config.DTMybatisPlusConfig
|
||||
@ -0,0 +1,3 @@
|
||||
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
|
||||
com.tiamo.dt.dev.db.config.DTDruidConfig,\
|
||||
com.tiamo.dt.dev.db.config.DTMybatisPlusConfig
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,3 @@
|
||||
artifactId=skyeye-db
|
||||
groupId=com.zhangy
|
||||
version=1.0.0.RELEASE
|
||||
@ -0,0 +1,6 @@
|
||||
com\zhangy\skyeye\db\config\DTDruidConfig.class
|
||||
com\zhangy\skyeye\db\config\DTMybatisPlusConfig.class
|
||||
com\zhangy\skyeye\db\pojo\page\PageParam.class
|
||||
com\zhangy\skyeye\db\config\DynamicTableNameHelper.class
|
||||
com\zhangy\skyeye\db\config\MPUtil.class
|
||||
com\zhangy\skyeye\db\pojo\props\Knife4jProperties.class
|
||||
@ -0,0 +1,6 @@
|
||||
D:\logisen\ddd\skyeye-dev\skyeye-db\src\main\java\com\zhangy\skyeye\db\utils\MPUtil.java
|
||||
D:\logisen\ddd\skyeye-dev\skyeye-db\src\main\java\com\zhangy\skyeye\db\config\DynamicTableNameHelper.java
|
||||
D:\logisen\ddd\skyeye-dev\skyeye-db\src\main\java\com\zhangy\skyeye\db\config\DTDruidConfig.java
|
||||
D:\logisen\ddd\skyeye-dev\skyeye-db\src\main\java\com\zhangy\skyeye\db\pojo\props\Knife4jProperties.java
|
||||
D:\logisen\ddd\skyeye-dev\skyeye-db\src\main\java\com\zhangy\skyeye\db\pojo\page\PageParam.java
|
||||
D:\logisen\ddd\skyeye-dev\skyeye-db\src\main\java\com\zhangy\skyeye\db\config\DTMybatisPlusConfig.java
|
||||
BIN
library/skyeye-dev/skyeye-db/target/skyeye-db-1.0.0.RELEASE.jar
Normal file
BIN
library/skyeye-dev/skyeye-db/target/skyeye-db-1.0.0.RELEASE.jar
Normal file
Binary file not shown.
BIN
library/skyeye-dev/skyeye-generator/.DS_Store
vendored
Normal file
BIN
library/skyeye-dev/skyeye-generator/.DS_Store
vendored
Normal file
Binary file not shown.
45
library/skyeye-dev/skyeye-generator/pom.xml
Normal file
45
library/skyeye-dev/skyeye-generator/pom.xml
Normal file
@ -0,0 +1,45 @@
|
||||
<?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>skyeye-dev</artifactId>
|
||||
<groupId>com.zhangy</groupId>
|
||||
<version>1.0.0.RELEASE</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>skyeye-generator</artifactId>
|
||||
<description>skyeye code generator lib</description>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<!--generator-->
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-generator</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!--logging-->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-logging</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!--Velocity-->
|
||||
<dependency>
|
||||
<groupId>org.apache.velocity</groupId>
|
||||
<artifactId>velocity</artifactId>
|
||||
<version>1.7</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Lombok -->
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
BIN
library/skyeye-dev/skyeye-generator/src/.DS_Store
vendored
Normal file
BIN
library/skyeye-dev/skyeye-generator/src/.DS_Store
vendored
Normal file
Binary file not shown.
BIN
library/skyeye-dev/skyeye-generator/src/main/.DS_Store
vendored
Normal file
BIN
library/skyeye-dev/skyeye-generator/src/main/.DS_Store
vendored
Normal file
Binary file not shown.
@ -0,0 +1,194 @@
|
||||
package com.zhangy.skyeye.generator;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.DbType;
|
||||
import com.baomidou.mybatisplus.core.toolkit.StringPool;
|
||||
import com.baomidou.mybatisplus.generator.AutoGenerator;
|
||||
import com.baomidou.mybatisplus.generator.InjectionConfig;
|
||||
import com.baomidou.mybatisplus.generator.config.*;
|
||||
import com.baomidou.mybatisplus.generator.config.converts.MySqlTypeConvert;
|
||||
import com.baomidou.mybatisplus.generator.config.converts.OracleTypeConvert;
|
||||
import com.baomidou.mybatisplus.generator.config.converts.PostgreSqlTypeConvert;
|
||||
import com.baomidou.mybatisplus.generator.config.converts.SqlServerTypeConvert;
|
||||
import com.baomidou.mybatisplus.generator.config.po.TableInfo;
|
||||
import com.baomidou.mybatisplus.generator.config.rules.NamingStrategy;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 代码生成器配置类
|
||||
*/
|
||||
@Data
|
||||
public class GeneratorApi {
|
||||
/**
|
||||
* 数据库驱动名
|
||||
*/
|
||||
private String driverName;
|
||||
/**
|
||||
* 数据库链接地址
|
||||
*/
|
||||
private String url;
|
||||
/**
|
||||
* 数据库用户名
|
||||
*/
|
||||
private String username;
|
||||
/**
|
||||
* 数据库密码
|
||||
*/
|
||||
private String password;
|
||||
/**
|
||||
* 输出文件目录
|
||||
*/
|
||||
private String outputDir;
|
||||
/**
|
||||
* 作者
|
||||
*/
|
||||
private String author = "Tiamo";
|
||||
/**
|
||||
* 代码生成的包名
|
||||
*/
|
||||
private String packageName;
|
||||
/**
|
||||
* 需要生成的表名(两者只能取其一)
|
||||
*/
|
||||
private String[] includeTables;
|
||||
/**
|
||||
* 需要排除的表名(两者只能取其一)
|
||||
*/
|
||||
private String[] excludeTables;
|
||||
/**
|
||||
* 是否启用swagger
|
||||
*/
|
||||
private Boolean isSwagger2 = Boolean.TRUE;
|
||||
|
||||
public void run() {
|
||||
AutoGenerator mpg = new AutoGenerator();
|
||||
|
||||
//全局配置
|
||||
GlobalConfig gc = new GlobalConfig();
|
||||
//代码输出目录
|
||||
gc.setOutputDir(outputDir + "/src/main/java");
|
||||
//开发人员
|
||||
gc.setAuthor(author);
|
||||
|
||||
gc.setFileOverride(true);
|
||||
//是否打开输出目录
|
||||
gc.setOpen(false);
|
||||
gc.setActiveRecord(false);
|
||||
gc.setEnableCache(false);
|
||||
//Mybatis Mapping.xml中增加BaseResult和BaseColumn
|
||||
gc.setBaseResultMap(true);
|
||||
gc.setBaseColumnList(true);
|
||||
/*gc.setMapperName("%sMapper");
|
||||
gc.setXmlName("%sMapping");
|
||||
gc.setServiceName("I%sService");
|
||||
gc.setServiceImplName("%sServiceImpl");
|
||||
gc.setControllerName("%sController");*/
|
||||
gc.setSwagger2(isSwagger2);
|
||||
mpg.setGlobalConfig(gc);
|
||||
|
||||
//数据源配置
|
||||
DataSourceConfig dsc = new DataSourceConfig();
|
||||
dsc.setDriverName(this.driverName);
|
||||
dsc.setUrl(this.url);
|
||||
dsc.setUsername(this.username);
|
||||
dsc.setPassword(this.password);
|
||||
if (this.driverName.contains(DbType.MYSQL.getDb())) {
|
||||
dsc.setDbType(DbType.MYSQL);
|
||||
dsc.setTypeConvert(new MySqlTypeConvert());
|
||||
} else if (this.driverName.contains(DbType.POSTGRE_SQL.getDb())) {
|
||||
dsc.setDbType(DbType.POSTGRE_SQL);
|
||||
dsc.setTypeConvert(new PostgreSqlTypeConvert());
|
||||
} else if (this.driverName.contains(DbType.SQL_SERVER.getDb())) {
|
||||
dsc.setDbType(DbType.SQL_SERVER);
|
||||
dsc.setTypeConvert(new SqlServerTypeConvert());
|
||||
} else if (this.driverName.contains(DbType.ORACLE.getDb())) {
|
||||
dsc.setDbType(DbType.ORACLE);
|
||||
dsc.setTypeConvert(new OracleTypeConvert());
|
||||
} else {
|
||||
System.out.println("数据库类型异常,代码生成失败!");
|
||||
return;
|
||||
}
|
||||
mpg.setDataSource(dsc);
|
||||
|
||||
// 策略配置
|
||||
StrategyConfig strategy = new StrategyConfig();
|
||||
// strategy.setCapitalMode(true);// 全局大写命名
|
||||
// strategy.setDbColumnUnderline(true);//全局下划线命名
|
||||
strategy.setNaming(NamingStrategy.underline_to_camel);
|
||||
strategy.setColumnNaming(NamingStrategy.underline_to_camel);
|
||||
// strategy.setTablePrefix(tablePrefix);
|
||||
if (includeTables.length > 0) {
|
||||
strategy.setInclude(includeTables);
|
||||
}
|
||||
if (excludeTables.length > 0) {
|
||||
strategy.setExclude(excludeTables);
|
||||
}
|
||||
|
||||
// 自定义 controller 父类
|
||||
// strategy.setSuperControllerClass("com.tiamo.dev.db.controller.BaseController");
|
||||
strategy.setEntityBuilderModel(false);
|
||||
strategy.setEntityLombokModel(true);
|
||||
strategy.setRestControllerStyle(true);
|
||||
strategy.setControllerMappingHyphenStyle(true);
|
||||
mpg.setStrategy(strategy);
|
||||
|
||||
// 包配置
|
||||
PackageConfig pc = new PackageConfig();
|
||||
// 控制台扫描
|
||||
pc.setModuleName(null);
|
||||
//父包名
|
||||
pc.setParent(packageName);
|
||||
//controller包名
|
||||
pc.setController("controller");
|
||||
//entity包名
|
||||
pc.setEntity("entity");
|
||||
//mapping包名
|
||||
pc.setXml("mapping");
|
||||
mpg.setPackageInfo(pc);
|
||||
|
||||
//自定义配置
|
||||
InjectionConfig injectionConfig = new InjectionConfig() {
|
||||
@Override
|
||||
public void initMap() {
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
//如果模板引擎是 freemarker
|
||||
//String templatePath = "/templates/mapping.xml.ftl";
|
||||
// 如果模板引擎是 velocity
|
||||
String templatePath = "/templates/mapping.xml.vm";
|
||||
|
||||
// 自定义输出配置
|
||||
List<FileOutConfig> focList = new ArrayList<>();
|
||||
// 自定义配置会被优先输出
|
||||
focList.add(new FileOutConfig(templatePath) {
|
||||
@Override
|
||||
public String outputFile(TableInfo tableInfo) {
|
||||
// 自定义输出文件名 , 如果你 Entity 设置了前后缀、此处注意 xml 的名称会跟着发生变化!!
|
||||
return outputDir + "/src/main/resources/mapping/"
|
||||
+ tableInfo.getEntityName() + "Mapping" + StringPool.DOT_XML;
|
||||
}
|
||||
});
|
||||
|
||||
injectionConfig.setFileOutConfigList(focList);
|
||||
mpg.setCfg(injectionConfig);
|
||||
|
||||
// 配置模板
|
||||
TemplateConfig templateConfig = new TemplateConfig();
|
||||
|
||||
// 配置自定义输出模板
|
||||
//指定自定义模板路径,注意不要带上.ftl/.vm, 会根据使用的模板引擎自动识别
|
||||
// templateConfig.setEntity("templates/entity2.java");
|
||||
// templateConfig.setService();
|
||||
// templateConfig.setController();
|
||||
|
||||
templateConfig.setXml(null);
|
||||
mpg.setTemplate(templateConfig);
|
||||
|
||||
mpg.execute();
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,134 @@
|
||||
package ${package.Controller};
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
#if(${restControllerStyle})
|
||||
#else
|
||||
import org.springframework.stereotype.Controller;
|
||||
#end
|
||||
|
||||
#if(${superControllerClassPackage})
|
||||
import ${superControllerClassPackage};
|
||||
#end
|
||||
#if(${swagger2})
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
||||
#end
|
||||
#if(${entityLombokModel})
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
#end
|
||||
|
||||
import $!{package.Entity}.$!{entity};
|
||||
import $!{package.Service}.$!{table.serviceName};
|
||||
import result.pojo.com.zhangy.skyeye.common.Result;
|
||||
import param.pojo.com.zhangy.skyeye.common.IdParam;
|
||||
import com.tiamo.dt.dev.db.utils.MPUtil;
|
||||
import com.tiamo.dt.dev.db.pojo.page.PageParam;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* $!{table.comment} 前端控制器
|
||||
*
|
||||
* @author ${author}
|
||||
* @since ${date}
|
||||
*/
|
||||
#if(${restControllerStyle})
|
||||
@RestController
|
||||
#else
|
||||
@Controller
|
||||
#end
|
||||
@AllArgsConstructor
|
||||
@Slf4j
|
||||
@Api(value = "$!{table.comment}", tags = "$!{table.comment}接口")
|
||||
@RequestMapping("#if(${controllerMappingHyphenStyle})${controllerMappingHyphen}#else${table.entityPath}#end")
|
||||
#if(${superControllerClass})
|
||||
public class ${table.controllerName} extends ${superControllerClass} {
|
||||
#else
|
||||
public class ${table.controllerName} {
|
||||
#end
|
||||
|
||||
private $!{table.serviceName} $!{table.entityPath}Service;
|
||||
|
||||
/**
|
||||
* 新增
|
||||
*/
|
||||
@PostMapping("/save")
|
||||
@ApiOperationSupport(order = 1)
|
||||
@ApiOperation(value = "新增", notes = "传入$!{table.entityPath}")
|
||||
public Result save(@RequestBody $!{entity} $!{table.entityPath}) {
|
||||
if($!{table.entityPath} == null){
|
||||
return Result.error("参数异常");
|
||||
}
|
||||
return Result.status($!{table.entityPath}Service.save($!{table.entityPath}));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改 $!{table.comment}
|
||||
*/
|
||||
@PostMapping("/update")
|
||||
@ApiOperationSupport(order = 2)
|
||||
@ApiOperation(value = "修改", notes = "传入$!{table.entityPath}")
|
||||
public Result update(@RequestBody $!{entity} $!{table.entityPath}) {
|
||||
if($!{table.entityPath} == null){
|
||||
return Result.error("参数异常");
|
||||
}
|
||||
return Result.status($!{table.entityPath}Service.updateById($!{table.entityPath}));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除 $!{table.comment}
|
||||
*/
|
||||
@PostMapping("/remove")
|
||||
@ApiOperationSupport(order = 3)
|
||||
@ApiOperation(value = "删除", notes = "传入ids")
|
||||
public Result remove(@RequestBody IdParam<Long> idParam) {
|
||||
if(idParam == null){
|
||||
return Result.error("参数异常!");
|
||||
}
|
||||
|
||||
return Result.status($!{table.entityPath}Service.removeByIds(idParam.getIds()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 详情
|
||||
*/
|
||||
@GetMapping("/detail")
|
||||
@ApiOperationSupport(order = 4)
|
||||
@ApiOperation(value = "详情", notes = "传入id")
|
||||
public Result<$!{entity}> detail(Long id) {
|
||||
if(id == null){
|
||||
return Result.error("参数异常");
|
||||
}
|
||||
$!{entity} detail = $!{table.entityPath}Service.getById(id);
|
||||
return Result.successData(detail);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询 $!{table.comment}
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
@ApiOperationSupport(order = 5)
|
||||
@ApiOperation(value = "查询", notes = "传入$!{table.entityPath}")
|
||||
public Result<List<$!{entity}>> list(PageParam pageParam, $!{entity} $!{table.entityPath}) {
|
||||
List<$!{entity}> list = $!{table.entityPath}Service.list($!{table.entityPath}Service.getQueryWrapper(pageParam, $!{table.entityPath}));
|
||||
return Result.successData(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页 $!{table.comment}
|
||||
*/
|
||||
@GetMapping("/page")
|
||||
@ApiOperationSupport(order = 6)
|
||||
@ApiOperation(value = "分页", notes = "传入$!{table.entityPath}")
|
||||
public Result<IPage<$!{entity}>> page(PageParam pageParam, $!{entity} $!{table.entityPath}) {
|
||||
IPage<$!{entity}> pages = $!{table.entityPath}Service.page(
|
||||
MPUtil.getPage(pageParam),
|
||||
$!{table.entityPath}Service.getQueryWrapper(null, $!{table.entityPath})
|
||||
);
|
||||
return Result.successData(pages);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,158 @@
|
||||
package ${package.Entity};
|
||||
|
||||
#foreach($pkg in ${table.importPackages})
|
||||
import ${pkg};
|
||||
#end
|
||||
#if(${swagger2})
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
#end
|
||||
#if(${entityLombokModel})
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.NoArgsConstructor;
|
||||
#if(${chainModel})
|
||||
import lombok.experimental.Accessors;
|
||||
#end
|
||||
#end
|
||||
|
||||
/**
|
||||
* $!{table.comment}
|
||||
*
|
||||
* @author ${author}
|
||||
* @since ${date}
|
||||
*/
|
||||
#if(${entityLombokModel})
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
#if(${superEntityClass})
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
#else
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
#end
|
||||
#if(${chainModel})
|
||||
@Accessors(chain = true)
|
||||
#end
|
||||
#end
|
||||
#if(${table.convert})
|
||||
@TableName("${table.name}")
|
||||
#end
|
||||
#if(${swagger2})
|
||||
@ApiModel(value="${entity}对象", description="$!{table.comment}")
|
||||
#end
|
||||
#if(${superEntityClass})
|
||||
public class ${entity} extends ${superEntityClass}#if(${activeRecord})<${entity}>#end {
|
||||
#elseif(${activeRecord})
|
||||
public class ${entity} extends Model<${entity}> {
|
||||
#else
|
||||
public class ${entity} implements Serializable {
|
||||
#end
|
||||
|
||||
#if(${entitySerialVersionUID})
|
||||
private static final long serialVersionUID = 1L;
|
||||
#end
|
||||
## ---------- BEGIN 字段循环遍历 ----------
|
||||
#foreach($field in ${table.fields})
|
||||
|
||||
#if(${field.keyFlag})
|
||||
#set($keyPropertyName=${field.propertyName})
|
||||
#end
|
||||
#if("$!field.comment" != "")
|
||||
#if(${swagger2})
|
||||
@ApiModelProperty(value = "${field.comment}", position = ${foreach.index})
|
||||
#else
|
||||
/**
|
||||
* ${field.comment}
|
||||
*/
|
||||
#end
|
||||
#end
|
||||
#if(${field.keyFlag})
|
||||
## 主键
|
||||
#if(${field.keyIdentityFlag})
|
||||
@TableId(value = "${field.annotationColumnName}", type = IdType.AUTO)
|
||||
#elseif(!$null.isNull(${idType}) && "$!idType" != "")
|
||||
@TableId(value = "${field.annotationColumnName}", type = IdType.${idType})
|
||||
#elseif(${field.convert})
|
||||
@TableId("${field.annotationColumnName}")
|
||||
#end
|
||||
## 普通字段
|
||||
#elseif(${field.fill})
|
||||
## ----- 存在字段填充设置 -----
|
||||
#if(${field.convert})
|
||||
@TableField(value = "${field.annotationColumnName}", fill = FieldFill.${field.fill})
|
||||
#else
|
||||
@TableField(fill = FieldFill.${field.fill})
|
||||
#end
|
||||
#elseif(${field.convert})
|
||||
@TableField("${field.annotationColumnName}")
|
||||
#end
|
||||
## 乐观锁注解
|
||||
#if(${versionFieldName}==${field.name})
|
||||
@Version
|
||||
#end
|
||||
## 逻辑删除注解
|
||||
#if(${logicDeleteFieldName}==${field.name})
|
||||
@TableLogic
|
||||
#end
|
||||
private ${field.propertyType} ${field.propertyName};
|
||||
#end
|
||||
## ---------- END 字段循环遍历 ----------
|
||||
#if(!${entityLombokModel})
|
||||
#foreach($field in ${table.fields})
|
||||
#if(${field.propertyType.equals("boolean")})
|
||||
#set($getprefix="is")
|
||||
#else
|
||||
#set($getprefix="get")
|
||||
#end
|
||||
public ${field.propertyType} ${getprefix}${field.capitalName}() {
|
||||
return ${field.propertyName};
|
||||
}
|
||||
#if(${chainModel})
|
||||
public ${entity} set${field.capitalName}(${field.propertyType} ${field.propertyName}) {
|
||||
#else
|
||||
public void set${field.capitalName}(${field.propertyType} ${field.propertyName}) {
|
||||
#end
|
||||
this.${field.propertyName} = ${field.propertyName};
|
||||
#if(${chainModel})
|
||||
return this;
|
||||
#end
|
||||
}
|
||||
#end
|
||||
## --foreach end---
|
||||
#end
|
||||
## --end of #if(!${entityLombokModel})--
|
||||
#if(${entityColumnConstant})
|
||||
#foreach($field in ${table.fields})
|
||||
public static final String ${field.name.toUpperCase()} = "${field.name}";
|
||||
|
||||
#end
|
||||
#end
|
||||
#if(${activeRecord})
|
||||
@Override
|
||||
protected Serializable pkVal() {
|
||||
#if(${keyPropertyName})
|
||||
return this.${keyPropertyName};
|
||||
#else
|
||||
return null;
|
||||
#end
|
||||
}
|
||||
|
||||
#end
|
||||
#if(!${entityLombokModel})
|
||||
@Override
|
||||
public String toString() {
|
||||
return "${entity}{" +
|
||||
#foreach($field in ${table.fields})
|
||||
#if($!{foreach.index}==0)
|
||||
"${field.propertyName}=" + ${field.propertyName} +
|
||||
#else
|
||||
", ${field.propertyName}=" + ${field.propertyName} +
|
||||
#end
|
||||
#end
|
||||
"}";
|
||||
}
|
||||
#end
|
||||
|
||||
}
|
||||
@ -0,0 +1,14 @@
|
||||
package ${package.Mapper};
|
||||
|
||||
import ${package.Entity}.${entity};
|
||||
import ${superMapperClassPackage};
|
||||
|
||||
/**
|
||||
* $!{table.comment} Mapper 接口
|
||||
*
|
||||
* @author ${author}
|
||||
* @since ${date}
|
||||
*/
|
||||
public interface ${table.mapperName} extends ${superMapperClass}<${entity}> {
|
||||
|
||||
}
|
||||
@ -0,0 +1,38 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="${package.Mapper}.${table.mapperName}">
|
||||
#if(${enableCache})
|
||||
<!-- 开启二级缓存 -->
|
||||
<cache type="org.mybatis.caches.ehcache.LoggingEhcache"/>
|
||||
#end
|
||||
|
||||
#if(${baseResultMap})
|
||||
<!-- 通用查询映射结果 -->
|
||||
<resultMap id="BaseResultMap" type="${package.Entity}.${entity}">
|
||||
#foreach($field in ${table.fields})
|
||||
#if(${field.keyFlag})##生成主键排在第一位
|
||||
<id column="${field.name}" property="${field.propertyName}" />
|
||||
#end
|
||||
#end
|
||||
#foreach($field in ${table.commonFields})##生成公共字段
|
||||
<result column="${field.name}" property="${field.propertyName}" />
|
||||
#end
|
||||
#foreach($field in ${table.fields})
|
||||
#if(!${field.keyFlag})##生成普通字段
|
||||
<result column="${field.name}" property="${field.propertyName}" />
|
||||
#end
|
||||
#end
|
||||
</resultMap>
|
||||
|
||||
#end
|
||||
#if(${baseColumnList})
|
||||
<!-- 通用查询结果列 -->
|
||||
<sql id="Base_Column_List">
|
||||
#foreach($field in ${table.commonFields})
|
||||
${field.columnName},
|
||||
#end
|
||||
${table.fieldNames}
|
||||
</sql>
|
||||
|
||||
#end
|
||||
</mapper>
|
||||
@ -0,0 +1,24 @@
|
||||
package ${package.Service};
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.tiamo.dt.dev.db.pojo.page.PageParam;
|
||||
import ${package.Entity}.${entity};
|
||||
import ${superServiceClassPackage};
|
||||
|
||||
/**
|
||||
* $!{table.comment} 服务类
|
||||
*
|
||||
* @author ${author}
|
||||
* @since ${date}
|
||||
*/
|
||||
public interface ${table.serviceName} extends ${superServiceClass}<${entity}> {
|
||||
|
||||
/**
|
||||
* 通过实体类获取QueryWrapper
|
||||
* @param pageParam 分页参数
|
||||
* @param $!{table.entityPath} 实体信息
|
||||
* @return
|
||||
*/
|
||||
QueryWrapper<$!{entity}> getQueryWrapper(PageParam pageParam, $!{entity} $!{table.entityPath});
|
||||
|
||||
}
|
||||
@ -0,0 +1,60 @@
|
||||
package ${package.ServiceImpl};
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.tiamo.dt.dev.db.pojo.page.PageParam;
|
||||
import com.tiamo.dt.dev.db.utils.MPUtil;
|
||||
import ${package.Entity}.${entity};
|
||||
import ${package.Mapper}.${table.mapperName};
|
||||
import ${package.Service}.${table.serviceName};
|
||||
import ${superServiceImplClassPackage};
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* $!{table.comment} 服务实现类
|
||||
*
|
||||
* @author ${author}
|
||||
* @since ${date}
|
||||
*/
|
||||
@Service
|
||||
public class ${table.serviceImplName} extends ${superServiceImplClass}<${table.mapperName}, ${entity}> implements ${table.serviceName} {
|
||||
|
||||
/**
|
||||
* 通过实体类获取QueryWrapper
|
||||
* @param pageParam 分页参数
|
||||
* @param $!{table.entityPath} 实体信息
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public QueryWrapper<$!{entity}> getQueryWrapper(PageParam pageParam, $!{entity} $!{table.entityPath}){
|
||||
QueryWrapper<$!{entity}> queryWrapper = MPUtil.getQueryWrapper(pageParam);
|
||||
|
||||
if($!{table.entityPath} == null){
|
||||
return queryWrapper;
|
||||
}
|
||||
|
||||
#foreach($field in ${table.fields})
|
||||
## 主键
|
||||
#if(${field.keyIdentityFlag})
|
||||
//主键
|
||||
if($!{table.entityPath}.get${field.capitalName}() != null){
|
||||
queryWrapper.lambda()
|
||||
.eq($!{entity}::get${field.capitalName}, $!{table.entityPath}.get${field.capitalName}());
|
||||
return queryWrapper;
|
||||
}
|
||||
#end
|
||||
#end
|
||||
|
||||
//TODO 此处可以根据各字段查询需求修改查询条件,eq、like、ge、gt、le、lt、ne...等等等
|
||||
queryWrapper.lambda()
|
||||
#foreach($field in ${table.fields})
|
||||
#if(!${field.keyIdentityFlag})
|
||||
#if($!{foreach.last})
|
||||
.eq($!{table.entityPath}.get${field.capitalName}() != null, $!{entity}::get${field.capitalName}, $!{table.entityPath}.get${field.capitalName}());
|
||||
#else
|
||||
.eq($!{table.entityPath}.get${field.capitalName}() != null, $!{entity}::get${field.capitalName}, $!{table.entityPath}.get${field.capitalName}())
|
||||
#end
|
||||
#end
|
||||
#end
|
||||
return queryWrapper;
|
||||
}
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,134 @@
|
||||
package ${package.Controller};
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
#if(${restControllerStyle})
|
||||
#else
|
||||
import org.springframework.stereotype.Controller;
|
||||
#end
|
||||
|
||||
#if(${superControllerClassPackage})
|
||||
import ${superControllerClassPackage};
|
||||
#end
|
||||
#if(${swagger2})
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
||||
#end
|
||||
#if(${entityLombokModel})
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
#end
|
||||
|
||||
import $!{package.Entity}.$!{entity};
|
||||
import $!{package.Service}.$!{table.serviceName};
|
||||
import result.pojo.com.zhangy.skyeye.common.Result;
|
||||
import param.pojo.com.zhangy.skyeye.common.IdParam;
|
||||
import com.tiamo.dt.dev.db.utils.MPUtil;
|
||||
import com.tiamo.dt.dev.db.pojo.page.PageParam;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* $!{table.comment} 前端控制器
|
||||
*
|
||||
* @author ${author}
|
||||
* @since ${date}
|
||||
*/
|
||||
#if(${restControllerStyle})
|
||||
@RestController
|
||||
#else
|
||||
@Controller
|
||||
#end
|
||||
@AllArgsConstructor
|
||||
@Slf4j
|
||||
@Api(value = "$!{table.comment}", tags = "$!{table.comment}接口")
|
||||
@RequestMapping("#if(${controllerMappingHyphenStyle})${controllerMappingHyphen}#else${table.entityPath}#end")
|
||||
#if(${superControllerClass})
|
||||
public class ${table.controllerName} extends ${superControllerClass} {
|
||||
#else
|
||||
public class ${table.controllerName} {
|
||||
#end
|
||||
|
||||
private $!{table.serviceName} $!{table.entityPath}Service;
|
||||
|
||||
/**
|
||||
* 新增
|
||||
*/
|
||||
@PostMapping("/save")
|
||||
@ApiOperationSupport(order = 1)
|
||||
@ApiOperation(value = "新增", notes = "传入$!{table.entityPath}")
|
||||
public Result save(@RequestBody $!{entity} $!{table.entityPath}) {
|
||||
if($!{table.entityPath} == null){
|
||||
return Result.error("参数异常");
|
||||
}
|
||||
return Result.status($!{table.entityPath}Service.save($!{table.entityPath}));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改 $!{table.comment}
|
||||
*/
|
||||
@PostMapping("/update")
|
||||
@ApiOperationSupport(order = 2)
|
||||
@ApiOperation(value = "修改", notes = "传入$!{table.entityPath}")
|
||||
public Result update(@RequestBody $!{entity} $!{table.entityPath}) {
|
||||
if($!{table.entityPath} == null){
|
||||
return Result.error("参数异常");
|
||||
}
|
||||
return Result.status($!{table.entityPath}Service.updateById($!{table.entityPath}));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除 $!{table.comment}
|
||||
*/
|
||||
@PostMapping("/remove")
|
||||
@ApiOperationSupport(order = 3)
|
||||
@ApiOperation(value = "删除", notes = "传入ids")
|
||||
public Result remove(@RequestBody IdParam<Long> idParam) {
|
||||
if(idParam == null){
|
||||
return Result.error("参数异常!");
|
||||
}
|
||||
|
||||
return Result.status($!{table.entityPath}Service.removeByIds(idParam.getIds()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 详情
|
||||
*/
|
||||
@GetMapping("/detail")
|
||||
@ApiOperationSupport(order = 4)
|
||||
@ApiOperation(value = "详情", notes = "传入id")
|
||||
public Result<$!{entity}> detail(Long id) {
|
||||
if(id == null){
|
||||
return Result.error("参数异常");
|
||||
}
|
||||
$!{entity} detail = $!{table.entityPath}Service.getById(id);
|
||||
return Result.successData(detail);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询 $!{table.comment}
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
@ApiOperationSupport(order = 5)
|
||||
@ApiOperation(value = "查询", notes = "传入$!{table.entityPath}")
|
||||
public Result<List<$!{entity}>> list(PageParam pageParam, $!{entity} $!{table.entityPath}) {
|
||||
List<$!{entity}> list = $!{table.entityPath}Service.list($!{table.entityPath}Service.getQueryWrapper(pageParam, $!{table.entityPath}));
|
||||
return Result.successData(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页 $!{table.comment}
|
||||
*/
|
||||
@GetMapping("/page")
|
||||
@ApiOperationSupport(order = 6)
|
||||
@ApiOperation(value = "分页", notes = "传入$!{table.entityPath}")
|
||||
public Result<IPage<$!{entity}>> page(PageParam pageParam, $!{entity} $!{table.entityPath}) {
|
||||
IPage<$!{entity}> pages = $!{table.entityPath}Service.page(
|
||||
MPUtil.getPage(pageParam),
|
||||
$!{table.entityPath}Service.getQueryWrapper(null, $!{table.entityPath})
|
||||
);
|
||||
return Result.successData(pages);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,158 @@
|
||||
package ${package.Entity};
|
||||
|
||||
#foreach($pkg in ${table.importPackages})
|
||||
import ${pkg};
|
||||
#end
|
||||
#if(${swagger2})
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
#end
|
||||
#if(${entityLombokModel})
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.NoArgsConstructor;
|
||||
#if(${chainModel})
|
||||
import lombok.experimental.Accessors;
|
||||
#end
|
||||
#end
|
||||
|
||||
/**
|
||||
* $!{table.comment}
|
||||
*
|
||||
* @author ${author}
|
||||
* @since ${date}
|
||||
*/
|
||||
#if(${entityLombokModel})
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
#if(${superEntityClass})
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
#else
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
#end
|
||||
#if(${chainModel})
|
||||
@Accessors(chain = true)
|
||||
#end
|
||||
#end
|
||||
#if(${table.convert})
|
||||
@TableName("${table.name}")
|
||||
#end
|
||||
#if(${swagger2})
|
||||
@ApiModel(value="${entity}对象", description="$!{table.comment}")
|
||||
#end
|
||||
#if(${superEntityClass})
|
||||
public class ${entity} extends ${superEntityClass}#if(${activeRecord})<${entity}>#end {
|
||||
#elseif(${activeRecord})
|
||||
public class ${entity} extends Model<${entity}> {
|
||||
#else
|
||||
public class ${entity} implements Serializable {
|
||||
#end
|
||||
|
||||
#if(${entitySerialVersionUID})
|
||||
private static final long serialVersionUID = 1L;
|
||||
#end
|
||||
## ---------- BEGIN 字段循环遍历 ----------
|
||||
#foreach($field in ${table.fields})
|
||||
|
||||
#if(${field.keyFlag})
|
||||
#set($keyPropertyName=${field.propertyName})
|
||||
#end
|
||||
#if("$!field.comment" != "")
|
||||
#if(${swagger2})
|
||||
@ApiModelProperty(value = "${field.comment}", position = ${foreach.index})
|
||||
#else
|
||||
/**
|
||||
* ${field.comment}
|
||||
*/
|
||||
#end
|
||||
#end
|
||||
#if(${field.keyFlag})
|
||||
## 主键
|
||||
#if(${field.keyIdentityFlag})
|
||||
@TableId(value = "${field.annotationColumnName}", type = IdType.AUTO)
|
||||
#elseif(!$null.isNull(${idType}) && "$!idType" != "")
|
||||
@TableId(value = "${field.annotationColumnName}", type = IdType.${idType})
|
||||
#elseif(${field.convert})
|
||||
@TableId("${field.annotationColumnName}")
|
||||
#end
|
||||
## 普通字段
|
||||
#elseif(${field.fill})
|
||||
## ----- 存在字段填充设置 -----
|
||||
#if(${field.convert})
|
||||
@TableField(value = "${field.annotationColumnName}", fill = FieldFill.${field.fill})
|
||||
#else
|
||||
@TableField(fill = FieldFill.${field.fill})
|
||||
#end
|
||||
#elseif(${field.convert})
|
||||
@TableField("${field.annotationColumnName}")
|
||||
#end
|
||||
## 乐观锁注解
|
||||
#if(${versionFieldName}==${field.name})
|
||||
@Version
|
||||
#end
|
||||
## 逻辑删除注解
|
||||
#if(${logicDeleteFieldName}==${field.name})
|
||||
@TableLogic
|
||||
#end
|
||||
private ${field.propertyType} ${field.propertyName};
|
||||
#end
|
||||
## ---------- END 字段循环遍历 ----------
|
||||
#if(!${entityLombokModel})
|
||||
#foreach($field in ${table.fields})
|
||||
#if(${field.propertyType.equals("boolean")})
|
||||
#set($getprefix="is")
|
||||
#else
|
||||
#set($getprefix="get")
|
||||
#end
|
||||
public ${field.propertyType} ${getprefix}${field.capitalName}() {
|
||||
return ${field.propertyName};
|
||||
}
|
||||
#if(${chainModel})
|
||||
public ${entity} set${field.capitalName}(${field.propertyType} ${field.propertyName}) {
|
||||
#else
|
||||
public void set${field.capitalName}(${field.propertyType} ${field.propertyName}) {
|
||||
#end
|
||||
this.${field.propertyName} = ${field.propertyName};
|
||||
#if(${chainModel})
|
||||
return this;
|
||||
#end
|
||||
}
|
||||
#end
|
||||
## --foreach end---
|
||||
#end
|
||||
## --end of #if(!${entityLombokModel})--
|
||||
#if(${entityColumnConstant})
|
||||
#foreach($field in ${table.fields})
|
||||
public static final String ${field.name.toUpperCase()} = "${field.name}";
|
||||
|
||||
#end
|
||||
#end
|
||||
#if(${activeRecord})
|
||||
@Override
|
||||
protected Serializable pkVal() {
|
||||
#if(${keyPropertyName})
|
||||
return this.${keyPropertyName};
|
||||
#else
|
||||
return null;
|
||||
#end
|
||||
}
|
||||
|
||||
#end
|
||||
#if(!${entityLombokModel})
|
||||
@Override
|
||||
public String toString() {
|
||||
return "${entity}{" +
|
||||
#foreach($field in ${table.fields})
|
||||
#if($!{foreach.index}==0)
|
||||
"${field.propertyName}=" + ${field.propertyName} +
|
||||
#else
|
||||
", ${field.propertyName}=" + ${field.propertyName} +
|
||||
#end
|
||||
#end
|
||||
"}";
|
||||
}
|
||||
#end
|
||||
|
||||
}
|
||||
@ -0,0 +1,14 @@
|
||||
package ${package.Mapper};
|
||||
|
||||
import ${package.Entity}.${entity};
|
||||
import ${superMapperClassPackage};
|
||||
|
||||
/**
|
||||
* $!{table.comment} Mapper 接口
|
||||
*
|
||||
* @author ${author}
|
||||
* @since ${date}
|
||||
*/
|
||||
public interface ${table.mapperName} extends ${superMapperClass}<${entity}> {
|
||||
|
||||
}
|
||||
@ -0,0 +1,38 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="${package.Mapper}.${table.mapperName}">
|
||||
#if(${enableCache})
|
||||
<!-- 开启二级缓存 -->
|
||||
<cache type="org.mybatis.caches.ehcache.LoggingEhcache"/>
|
||||
#end
|
||||
|
||||
#if(${baseResultMap})
|
||||
<!-- 通用查询映射结果 -->
|
||||
<resultMap id="BaseResultMap" type="${package.Entity}.${entity}">
|
||||
#foreach($field in ${table.fields})
|
||||
#if(${field.keyFlag})##生成主键排在第一位
|
||||
<id column="${field.name}" property="${field.propertyName}" />
|
||||
#end
|
||||
#end
|
||||
#foreach($field in ${table.commonFields})##生成公共字段
|
||||
<result column="${field.name}" property="${field.propertyName}" />
|
||||
#end
|
||||
#foreach($field in ${table.fields})
|
||||
#if(!${field.keyFlag})##生成普通字段
|
||||
<result column="${field.name}" property="${field.propertyName}" />
|
||||
#end
|
||||
#end
|
||||
</resultMap>
|
||||
|
||||
#end
|
||||
#if(${baseColumnList})
|
||||
<!-- 通用查询结果列 -->
|
||||
<sql id="Base_Column_List">
|
||||
#foreach($field in ${table.commonFields})
|
||||
${field.columnName},
|
||||
#end
|
||||
${table.fieldNames}
|
||||
</sql>
|
||||
|
||||
#end
|
||||
</mapper>
|
||||
@ -0,0 +1,24 @@
|
||||
package ${package.Service};
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.tiamo.dt.dev.db.pojo.page.PageParam;
|
||||
import ${package.Entity}.${entity};
|
||||
import ${superServiceClassPackage};
|
||||
|
||||
/**
|
||||
* $!{table.comment} 服务类
|
||||
*
|
||||
* @author ${author}
|
||||
* @since ${date}
|
||||
*/
|
||||
public interface ${table.serviceName} extends ${superServiceClass}<${entity}> {
|
||||
|
||||
/**
|
||||
* 通过实体类获取QueryWrapper
|
||||
* @param pageParam 分页参数
|
||||
* @param $!{table.entityPath} 实体信息
|
||||
* @return
|
||||
*/
|
||||
QueryWrapper<$!{entity}> getQueryWrapper(PageParam pageParam, $!{entity} $!{table.entityPath});
|
||||
|
||||
}
|
||||
@ -0,0 +1,60 @@
|
||||
package ${package.ServiceImpl};
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.tiamo.dt.dev.db.pojo.page.PageParam;
|
||||
import com.tiamo.dt.dev.db.utils.MPUtil;
|
||||
import ${package.Entity}.${entity};
|
||||
import ${package.Mapper}.${table.mapperName};
|
||||
import ${package.Service}.${table.serviceName};
|
||||
import ${superServiceImplClassPackage};
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* $!{table.comment} 服务实现类
|
||||
*
|
||||
* @author ${author}
|
||||
* @since ${date}
|
||||
*/
|
||||
@Service
|
||||
public class ${table.serviceImplName} extends ${superServiceImplClass}<${table.mapperName}, ${entity}> implements ${table.serviceName} {
|
||||
|
||||
/**
|
||||
* 通过实体类获取QueryWrapper
|
||||
* @param pageParam 分页参数
|
||||
* @param $!{table.entityPath} 实体信息
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public QueryWrapper<$!{entity}> getQueryWrapper(PageParam pageParam, $!{entity} $!{table.entityPath}){
|
||||
QueryWrapper<$!{entity}> queryWrapper = MPUtil.getQueryWrapper(pageParam);
|
||||
|
||||
if($!{table.entityPath} == null){
|
||||
return queryWrapper;
|
||||
}
|
||||
|
||||
#foreach($field in ${table.fields})
|
||||
## 主键
|
||||
#if(${field.keyIdentityFlag})
|
||||
//主键
|
||||
if($!{table.entityPath}.get${field.capitalName}() != null){
|
||||
queryWrapper.lambda()
|
||||
.eq($!{entity}::get${field.capitalName}, $!{table.entityPath}.get${field.capitalName}());
|
||||
return queryWrapper;
|
||||
}
|
||||
#end
|
||||
#end
|
||||
|
||||
//TODO 此处可以根据各字段查询需求修改查询条件,eq、like、ge、gt、le、lt、ne...等等等
|
||||
queryWrapper.lambda()
|
||||
#foreach($field in ${table.fields})
|
||||
#if(!${field.keyIdentityFlag})
|
||||
#if($!{foreach.last})
|
||||
.eq($!{table.entityPath}.get${field.capitalName}() != null, $!{entity}::get${field.capitalName}, $!{table.entityPath}.get${field.capitalName}());
|
||||
#else
|
||||
.eq($!{table.entityPath}.get${field.capitalName}() != null, $!{entity}::get${field.capitalName}, $!{table.entityPath}.get${field.capitalName}())
|
||||
#end
|
||||
#end
|
||||
#end
|
||||
return queryWrapper;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,3 @@
|
||||
artifactId=skyeye-generator
|
||||
groupId=com.zhangy
|
||||
version=1.0.0.RELEASE
|
||||
@ -0,0 +1,3 @@
|
||||
com\zhangy\skyeye\generator\GeneratorApi.class
|
||||
com\zhangy\skyeye\generator\GeneratorApi$2.class
|
||||
com\zhangy\skyeye\generator\GeneratorApi$1.class
|
||||
@ -0,0 +1 @@
|
||||
D:\logisen\ddd\skyeye-dev\skyeye-generator\src\main\java\com\zhangy\skyeye\generator\GeneratorApi.java
|
||||
Binary file not shown.
42
library/skyeye-dev/skyeye-job/pom.xml
Normal file
42
library/skyeye-dev/skyeye-job/pom.xml
Normal file
@ -0,0 +1,42 @@
|
||||
<?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>skyeye-dev</artifactId>
|
||||
<groupId>com.zhangy</groupId>
|
||||
<version>1.0.0.RELEASE</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>skyeye-job</artifactId>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<!-- Lombok -->
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- SpringBoot -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!--xxl job-->
|
||||
<dependency>
|
||||
<groupId>com.xuxueli</groupId>
|
||||
<artifactId>xxl-job-core</artifactId>
|
||||
<version>2.3.1</version>
|
||||
</dependency>
|
||||
|
||||
<!--提供服务发现能力-->
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-commons</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
@ -0,0 +1,68 @@
|
||||
package com.zhangy.skyeye.job;
|
||||
|
||||
import com.zhangy.skyeye.job.properties.XxlExecutorProperties;
|
||||
import com.zhangy.skyeye.job.properties.XxlJobProperties;
|
||||
import com.xxl.job.core.executor.impl.XxlJobSpringExecutor;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.cloud.client.discovery.DiscoveryClient;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* xxl-job自动装配
|
||||
*/
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
@EnableAutoConfiguration
|
||||
@EnableConfigurationProperties(XxlJobProperties.class)
|
||||
public class XxlJobAutoConfiguration {
|
||||
|
||||
/**
|
||||
* 服务名称 包含 XXL_JOB_ADMIN 则说明是 Admin
|
||||
*/
|
||||
private static final String XXL_JOB_ADMIN = "xxl-job-admin";
|
||||
|
||||
/**
|
||||
* 配置xxl-job 执行器,提供自动发现 xxl-job-admin 能力
|
||||
*
|
||||
* @param xxlJobProperties xxl 配置
|
||||
* @param environment 环境变量
|
||||
* @param discoveryClient 注册发现客户端
|
||||
* @return
|
||||
*/
|
||||
@Bean
|
||||
public XxlJobSpringExecutor xxlJobSpringExecutor(XxlJobProperties xxlJobProperties, Environment environment,
|
||||
DiscoveryClient discoveryClient) {
|
||||
XxlJobSpringExecutor xxlJobSpringExecutor = new XxlJobSpringExecutor();
|
||||
XxlExecutorProperties executor = xxlJobProperties.getExecutor();
|
||||
// 应用名默认为服务名
|
||||
String appName = executor.getAppname();
|
||||
if (!StringUtils.hasText(appName)) {
|
||||
appName = environment.getProperty("spring.application.name");
|
||||
}
|
||||
xxlJobSpringExecutor.setAppname(appName);
|
||||
xxlJobSpringExecutor.setAddress(executor.getAddress());
|
||||
xxlJobSpringExecutor.setIp(executor.getIp());
|
||||
xxlJobSpringExecutor.setPort(executor.getPort());
|
||||
xxlJobSpringExecutor.setAccessToken(executor.getAccessToken());
|
||||
xxlJobSpringExecutor.setLogPath(executor.getLogPath());
|
||||
xxlJobSpringExecutor.setLogRetentionDays(executor.getLogRetentionDays());
|
||||
|
||||
if (!StringUtils.hasText(xxlJobProperties.getAdmin().getAddresses())) {
|
||||
String serverList = discoveryClient.getServices().stream().filter(s -> s.contains(XXL_JOB_ADMIN))
|
||||
.flatMap(s -> discoveryClient.getInstances(s).stream()).map(instance -> String
|
||||
.format("http://%s:%s/%s", instance.getHost(), instance.getPort(), XXL_JOB_ADMIN))
|
||||
.collect(Collectors.joining(","));
|
||||
xxlJobSpringExecutor.setAdminAddresses(serverList);
|
||||
} else {
|
||||
xxlJobSpringExecutor.setAdminAddresses(xxlJobProperties.getAdmin().getAddresses());
|
||||
}
|
||||
|
||||
return xxlJobSpringExecutor;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,15 @@
|
||||
package com.zhangy.skyeye.job.annotation;
|
||||
|
||||
import com.zhangy.skyeye.job.XxlJobAutoConfiguration;
|
||||
import org.springframework.context.annotation.Import;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
@Target({ElementType.TYPE})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
@Inherited
|
||||
@Import({XxlJobAutoConfiguration.class})
|
||||
public @interface EnableDtXxlJob {
|
||||
|
||||
}
|
||||
@ -0,0 +1,16 @@
|
||||
package com.zhangy.skyeye.job.properties;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* xxl-job管理平台配置
|
||||
*/
|
||||
@Data
|
||||
public class XxlAdminProperties {
|
||||
|
||||
/**
|
||||
* 调度中心部署跟地址 [选填]:如调度中心集群部署存在多个地址则用逗号分隔。 执行器将会使用该地址进行"执行器心跳注册"和"任务结果回调";为空则关闭自动注册;
|
||||
*/
|
||||
private String addresses;
|
||||
|
||||
}
|
||||
@ -0,0 +1,47 @@
|
||||
package com.zhangy.skyeye.job.properties;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* xxl-job执行器配置
|
||||
*/
|
||||
@Data
|
||||
public class XxlExecutorProperties {
|
||||
|
||||
/**
|
||||
* 执行器AppName [选填]:执行器心跳注册分组依据;为空则关闭自动注册
|
||||
*/
|
||||
private String appname;
|
||||
|
||||
/**
|
||||
* 服务注册地址,优先使用该配置作为注册地址 为空时使用内嵌服务 ”IP:PORT“ 作为注册地址 从而更灵活的支持容器类型执行器动态IP和动态映射端口问题
|
||||
*/
|
||||
private String address;
|
||||
|
||||
/**
|
||||
* 执行器IP [选填]:默认为空表示自动获取IP,多网卡时可手动设置指定IP ,该IP不会绑定Host仅作为通讯实用;地址信息用于 "执行器注册" 和
|
||||
* "调度中心请求并触发任务"
|
||||
*/
|
||||
private String ip;
|
||||
|
||||
/**
|
||||
* 执行器端口号 [选填]:小于等于0则自动获取;默认端口为9099,单机部署多个执行器时,注意要配置不同执行器端口;
|
||||
*/
|
||||
private Integer port = 9099;
|
||||
|
||||
/**
|
||||
* 执行器通讯TOKEN [选填]:非空时启用;
|
||||
*/
|
||||
private String accessToken;
|
||||
|
||||
/**
|
||||
* 执行器运行日志文件存储磁盘路径 [选填] :需要对该路径拥有读写权限;为空则使用默认路径;
|
||||
*/
|
||||
private String logPath = "logs/applogs/xxl-job/jobhandler";
|
||||
|
||||
/**
|
||||
* 执行器日志保存天数 [选填] :值大于3时生效,启用执行器Log文件定期清理功能,否则不生效;
|
||||
*/
|
||||
private Integer logRetentionDays = 30;
|
||||
|
||||
}
|
||||
@ -0,0 +1,20 @@
|
||||
package com.zhangy.skyeye.job.properties;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.boot.context.properties.NestedConfigurationProperty;
|
||||
|
||||
/**
|
||||
* xxl-job配置
|
||||
*/
|
||||
@Data
|
||||
@ConfigurationProperties(prefix = "xxl.job")
|
||||
public class XxlJobProperties {
|
||||
|
||||
@NestedConfigurationProperty
|
||||
private XxlAdminProperties admin = new XxlAdminProperties();
|
||||
|
||||
@NestedConfigurationProperty
|
||||
private XxlExecutorProperties executor = new XxlExecutorProperties();
|
||||
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user