Compare commits
45 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cf6d05c2b4 | ||
|
|
57f0e2ab82 | ||
|
|
cce180806b | ||
|
|
2a8a4ff337 | ||
|
|
e8cc8cf8f7 | ||
|
|
bb0e5098af | ||
|
|
6d91cc7c13 | ||
|
|
94f93f8a80 | ||
|
|
9363d08308 | ||
|
|
3797c0edd2 | ||
|
|
1cf97feabf | ||
|
|
bce848af7e | ||
|
|
a6b0062f8d | ||
| 885303e555 | |||
| 0cf30770f1 | |||
| 6a66f41925 | |||
|
|
2d8208e4dc | ||
|
|
c4ba637de7 | ||
|
|
7b0b9e0925 | ||
|
|
463ddf1b1e | ||
|
|
6fdc69fc2d | ||
|
|
fde73e57b9 | ||
|
|
8a517b09fd | ||
|
|
217d044940 | ||
|
|
9ecf58d75e | ||
|
|
5c0d47a011 | ||
|
|
08066f1367 | ||
|
|
9e7ed69d37 | ||
|
|
2793b2a634 | ||
|
|
9885e640e9 | ||
|
|
9b285db5bd | ||
|
|
abbfac2f08 | ||
|
|
fba88da506 | ||
|
|
cb6e1c85b2 | ||
|
|
2649070850 | ||
|
|
48a9d46d20 | ||
|
|
f8d7e49290 | ||
|
|
2cf88cefa7 | ||
|
|
9a56994342 | ||
|
|
a987689bd6 | ||
|
|
690dffa779 | ||
|
|
3ccbd6cd8e | ||
|
|
89e0c5d1d5 | ||
|
|
b15dbc6d4c | ||
|
|
2f6b5b0b05 |
21
CHANGELOG.md
21
CHANGELOG.md
@@ -1,21 +1,2 @@
|
||||
## 2.0.12
|
||||
|
||||
- 调整OkHttp日志
|
||||
|
||||
|
||||
## 2.0.0.rc46
|
||||
|
||||
现在导入导出都接入底层流程,无需新增接口,只需要实现接口即可。
|
||||
|
||||
- 过程日志不再和操作日志同时存在
|
||||
- 过程日志新增params参数
|
||||
- 通过实现*TsImportHandler*接口编写导入逻辑
|
||||
- 通过实现*TsExportHandler*接口编写导出逻辑
|
||||
|
||||
## 2.0.0.rc4
|
||||
|
||||
- perf:TsTokenConfig不在提供静态方法
|
||||
- perf:移除TsTokenAspect,由TokenWebMvcConfigurer替代,并实现TokenBean参数注入
|
||||
|
||||
|
||||
## 4.0.0
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>kepai-repo</id>
|
||||
<url>http://git.kepai365.com/tiesheng/repository/raw/master</url>
|
||||
<url>https://git.tieshengkeji.com/api/packages/tieshengkeji/maven</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
```
|
||||
|
||||
21
CHANGELOG_v2.md
Normal file
21
CHANGELOG_v2.md
Normal file
@@ -0,0 +1,21 @@
|
||||
## 2.0.12
|
||||
|
||||
- 调整OkHttp日志
|
||||
|
||||
|
||||
## 2.0.0.rc46
|
||||
|
||||
现在导入导出都接入底层流程,无需新增接口,只需要实现接口即可。
|
||||
|
||||
- 过程日志不再和操作日志同时存在
|
||||
- 过程日志新增params参数
|
||||
- 通过实现*TsImportHandler*接口编写导入逻辑
|
||||
- 通过实现*TsExportHandler*接口编写导出逻辑
|
||||
|
||||
## 2.0.0.rc4
|
||||
|
||||
- perf:TsTokenConfig不在提供静态方法
|
||||
- perf:移除TsTokenAspect,由TokenWebMvcConfigurer替代,并实现TokenBean参数注入
|
||||
|
||||
|
||||
|
||||
31
pom.xml
31
pom.xml
@@ -6,7 +6,7 @@
|
||||
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-parent</artifactId>
|
||||
<version>2.0.13</version>
|
||||
<version>4.0.0.alpha1</version>
|
||||
<packaging>pom</packaging>
|
||||
<name>springboot-parent</name>
|
||||
<description>杭州铁晟科技有限公司基础依赖</description>
|
||||
@@ -14,7 +14,7 @@
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>2.6.4</version>
|
||||
<version>4.0.0</version>
|
||||
</parent>
|
||||
|
||||
<modules>
|
||||
@@ -27,14 +27,15 @@
|
||||
<module>springboot-message</module>
|
||||
<module>springboot-annotation</module>
|
||||
<module>springboot-role</module>
|
||||
<module>springboot-chart</module>
|
||||
</modules>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
<maven.compiler.target>8</maven.compiler.target>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
|
||||
<hutool.version>5.8.31</hutool.version>
|
||||
<hutool.version>5.8.42</hutool.version>
|
||||
</properties>
|
||||
|
||||
<developers>
|
||||
@@ -58,49 +59,49 @@
|
||||
<dependency>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-database</artifactId>
|
||||
<version>2.0.13</version>
|
||||
<version>4.0.0.alpha1</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-login</artifactId>
|
||||
<version>2.0.13</version>
|
||||
<version>4.0.0.alpha1</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-web</artifactId>
|
||||
<version>2.0.13</version>
|
||||
<version>4.0.0.alpha1</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-util</artifactId>
|
||||
<version>2.0.13</version>
|
||||
<version>4.0.0.alpha1</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-platform</artifactId>
|
||||
<version>2.0.13</version>
|
||||
<version>4.0.0.alpha1</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-message</artifactId>
|
||||
<version>2.0.13</version>
|
||||
<version>4.0.0.alpha1</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-role</artifactId>
|
||||
<version>2.0.13</version>
|
||||
<version>4.0.0.alpha1</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-annotation</artifactId>
|
||||
<version>2.0.13</version>
|
||||
<version>4.0.0.alpha1</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
@@ -120,8 +121,8 @@
|
||||
|
||||
<pluginRepositories>
|
||||
<pluginRepository>
|
||||
<id>kepai-repo-plugin</id>
|
||||
<url>http://git.kepai365.com/tiesheng/repository/raw/master</url>
|
||||
<id>tiesheng-repo-plugin</id>
|
||||
<url>https://git.tieshengkeji.com/api/packages/tieshengkeji/maven</url>
|
||||
</pluginRepository>
|
||||
</pluginRepositories>
|
||||
|
||||
|
||||
31
qodana.yaml
31
qodana.yaml
@@ -1,31 +0,0 @@
|
||||
#-------------------------------------------------------------------------------#
|
||||
# Qodana analysis is configured by qodana.yaml file #
|
||||
# https://www.jetbrains.com/help/qodana/qodana-yaml.html #
|
||||
#-------------------------------------------------------------------------------#
|
||||
version: "1.0"
|
||||
|
||||
#Specify inspection profile for code analysis
|
||||
profile:
|
||||
name: qodana.starter
|
||||
|
||||
#Enable inspections
|
||||
#include:
|
||||
# - name: <SomeEnabledInspectionId>
|
||||
|
||||
#Disable inspections
|
||||
#exclude:
|
||||
# - name: <SomeDisabledInspectionId>
|
||||
# paths:
|
||||
# - <path/where/not/run/inspection>
|
||||
|
||||
projectJDK: 17 #(Applied in CI/CD pipeline)
|
||||
|
||||
#Execute shell command before Qodana execution (Applied in CI/CD pipeline)
|
||||
#bootstrap: sh ./prepare-qodana.sh
|
||||
|
||||
#Install IDE plugins before Qodana execution (Applied in CI/CD pipeline)
|
||||
#plugins:
|
||||
# - id: <plugin.id> #(plugin id can be found at https://plugins.jetbrains.com)
|
||||
|
||||
#Specify Qodana linter for analysis (Applied in CI/CD pipeline)
|
||||
linter: jetbrains/qodana-jvm:latest
|
||||
BIN
springboot-ademo/.DS_Store
vendored
BIN
springboot-ademo/.DS_Store
vendored
Binary file not shown.
@@ -6,15 +6,15 @@
|
||||
<parent>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-parent</artifactId>
|
||||
<version>2.0.13</version>
|
||||
<version>4.0.0.alpha1</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>springboot-ademo</artifactId>
|
||||
<version>2.0.13</version>
|
||||
<version>4.0.0.alpha1</version>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
<maven.compiler.target>8</maven.compiler.target>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<!-- 该模块不发布到maven仓库 -->
|
||||
<maven.deploy.skip>true</maven.deploy.skip>
|
||||
@@ -46,8 +46,8 @@
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>kepai-repo</id>
|
||||
<url>http://git.kepai365.com/tiesheng/repository/raw/master</url>
|
||||
<id>tiesheng-repo</id>
|
||||
<url>https://git.tieshengkeji.com/api/packages/tieshengkeji/maven</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ import com.tiesheng.web.service.TieshengWebConfigurer;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import java.util.Objects;
|
||||
|
||||
@Component
|
||||
|
||||
@@ -12,6 +12,7 @@ import com.alibaba.fastjson.JSONObject;
|
||||
import com.tiesheng.annotation.role.RoleAuthority;
|
||||
import com.tiesheng.annotation.token.TokenIgnore;
|
||||
import com.tiesheng.database.config.DbBackupConfig;
|
||||
import com.tiesheng.demo.pojos.CustTokenBean;
|
||||
import com.tiesheng.demo.pojos.JsonTest;
|
||||
import com.tiesheng.demo.pojos.PoiBean;
|
||||
import com.tiesheng.platform.config.ding.PlatformDingConfig;
|
||||
@@ -34,7 +35,7 @@ import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import java.io.File;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
@@ -43,7 +44,6 @@ import java.util.function.Consumer;
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/test")
|
||||
@RoleAuthority(value = "test", group = "test")
|
||||
public class TestController {
|
||||
|
||||
@Autowired
|
||||
@@ -65,9 +65,8 @@ public class TestController {
|
||||
|
||||
|
||||
@RequestMapping("/index")
|
||||
@TokenIgnore
|
||||
public void index(HttpServletResponse response) {
|
||||
globalConfig.redirect("mobile", "/test", response);
|
||||
globalConfig.redirectWithVer("mobile", "/test", response);
|
||||
}
|
||||
|
||||
@RequestMapping("/redirect")
|
||||
@@ -75,7 +74,8 @@ public class TestController {
|
||||
@RoleAuthority("redirect")
|
||||
public ApiResp<JsonTest> redirect(HttpServletResponse response) {
|
||||
|
||||
encryptConfig.passwdCreate("111111@Zz", "");
|
||||
String s1 = encryptConfig.passwdCreate("qU3?wE3{bX", "");
|
||||
LogFactory.get().info(s1);
|
||||
|
||||
JsonTest jsonTest = new JsonTest();
|
||||
jsonTest.setNow(DateUtil.date());
|
||||
@@ -112,8 +112,9 @@ public class TestController {
|
||||
|
||||
|
||||
@GetMapping("/send")
|
||||
@TokenIgnore
|
||||
public ApiResp<String> sendMessage() {
|
||||
public ApiResp<String> sendMessage(CustTokenBean tokenBean) {
|
||||
|
||||
tokenBean.test();
|
||||
|
||||
// MessageReqResp reqResp = coreMessageService.send(new UserChannel("13567116463", "sms"),
|
||||
// JSONUtil.createObj().putOpt("action", "sms-visitor-invite"));
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.tiesheng.demo.pojos;
|
||||
|
||||
import com.tiesheng.util.pojos.TokenBean;
|
||||
|
||||
public class CustTokenBean extends TokenBean {
|
||||
|
||||
|
||||
public void test() {
|
||||
System.out.println("test: " + getId());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -6,14 +6,14 @@
|
||||
<parent>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-parent</artifactId>
|
||||
<version>2.0.13</version>
|
||||
<version>4.0.0.alpha1</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>springboot-annotation</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
<maven.compiler.target>8</maven.compiler.target>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
|
||||
38
springboot-chart/pom.xml
Normal file
38
springboot-chart/pom.xml
Normal file
@@ -0,0 +1,38 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-parent</artifactId>
|
||||
<version>4.0.0.alpha1</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>springboot-chart</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>1.18.22</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>easyexcel</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-util</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1,111 @@
|
||||
package com.tiesheng.role.controller;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.excel.EasyExcel;
|
||||
import com.alibaba.excel.write.style.row.SimpleRowHeightStyleStrategy;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.tiesheng.annotation.operation.OperationIgnore;
|
||||
import com.tiesheng.annotation.role.RoleAuthority;
|
||||
import com.tiesheng.role.pojos.dto.ChartTemplateCheck;
|
||||
import com.tiesheng.role.pojos.vo.TsTableVO;
|
||||
import com.tiesheng.role.service.ChartService;
|
||||
import com.tiesheng.role.util.AliExcelUtil;
|
||||
import com.tiesheng.util.config.GlobalConfig;
|
||||
import com.tiesheng.util.exception.ApiException;
|
||||
import com.tiesheng.util.pojos.ApiResp;
|
||||
import com.tiesheng.util.pojos.FileUploadPath;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.validation.Valid;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/chart/record")
|
||||
@RoleAuthority(value = "template", group = "chart")
|
||||
public class ChartRecordController {
|
||||
|
||||
@Resource
|
||||
ChartService chartService;
|
||||
@Resource
|
||||
GlobalConfig globalConfig;
|
||||
|
||||
/**
|
||||
* 获取列表
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/check")
|
||||
@OperationIgnore
|
||||
public ApiResp<TsTableVO> check(@RequestBody @Valid ChartTemplateCheck dto) {
|
||||
|
||||
if (dto.getTemplate() == null) {
|
||||
dto.setTemplate(chartService.getById(dto.getTemplateId()));
|
||||
}
|
||||
if (dto.getTemplate() == null) {
|
||||
throw new ApiException("请选择或创建一个模版");
|
||||
}
|
||||
|
||||
try {
|
||||
List<JSONObject> chartRecordVOS = chartService.getBaseMapper()
|
||||
.recordCheck(dto.getTemplate().getTableName(), dto.getCountType(),
|
||||
dto.getTableXField(), dto.getWhere(),
|
||||
dto.getTemplate().getSField(),
|
||||
dto.getTableGroupBy());
|
||||
chartRecordVOS.forEach(it -> {
|
||||
it.put("xField", StrUtil.emptyToDefault(it.getString("xField"), "未分类"));
|
||||
});
|
||||
|
||||
return ApiResp.respOK(TsTableVO.of(dto.getTemplate(), chartRecordVOS));
|
||||
} catch (Exception e) {
|
||||
throw new ApiException("表或字段配置有误,请检查");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出数据
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/export")
|
||||
@OperationIgnore
|
||||
public ApiResp<String> export(@RequestBody @Valid ChartTemplateCheck dto) {
|
||||
TsTableVO tsTableVO = check(dto).getData();
|
||||
if (tsTableVO.getDataSource().isEmpty()) {
|
||||
return ApiResp.respOK("");
|
||||
}
|
||||
|
||||
List<List<String>> headers = new ArrayList<>();
|
||||
for (TsTableVO.TableColumn column : tsTableVO.getColumns()) {
|
||||
headers.add(CollUtil.newArrayList(column.getTitle()));
|
||||
}
|
||||
|
||||
List<List<String>> contents = new ArrayList<>();
|
||||
|
||||
for (JSONObject obj : tsTableVO.getDataSource()) {
|
||||
List<String> data = new ArrayList<>();
|
||||
|
||||
for (TsTableVO.TableColumn column : tsTableVO.getColumns()) {
|
||||
data.add(obj.getString(column.getDataIndex()));
|
||||
}
|
||||
contents.add(data);
|
||||
}
|
||||
|
||||
FileUploadPath xls = FileUploadPath.random("xls");
|
||||
EasyExcel.write(xls.getAbsolutePath())
|
||||
.sheet("数据统计")
|
||||
.registerWriteHandler(new AliExcelUtil.ChatColumnWidthStyleStrategy())
|
||||
.registerWriteHandler(new SimpleRowHeightStyleStrategy((short) 24, null))
|
||||
.registerWriteHandler(AliExcelUtil.getCustomStyle())
|
||||
.head(headers)
|
||||
.doWrite(contents);
|
||||
|
||||
return ApiResp.respOK(globalConfig.buildPath(xls.getHttpPath()));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,162 @@
|
||||
package com.tiesheng.role.controller;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.tiesheng.annotation.role.RoleAuthority;
|
||||
import com.tiesheng.annotation.token.TokenIgnore;
|
||||
import com.tiesheng.role.pojos.dao.CoreChartTable;
|
||||
import com.tiesheng.role.pojos.dao.CoreChartTemplate;
|
||||
import com.tiesheng.role.pojos.dto.ChartTableEditDTO;
|
||||
import com.tiesheng.role.pojos.dto.ChartTemplateEditDTO;
|
||||
import com.tiesheng.role.service.ChartService;
|
||||
import com.tiesheng.util.exception.ApiException;
|
||||
import com.tiesheng.util.pojos.ApiResp;
|
||||
import com.tiesheng.util.pojos.IdDTO;
|
||||
import com.tiesheng.util.pojos.PageDTO;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.validation.Valid;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/chart/template")
|
||||
@RoleAuthority(value = "template", group = "chart")
|
||||
public class ChartTemplateController {
|
||||
|
||||
@Resource
|
||||
ChartService chartService;
|
||||
|
||||
|
||||
/**
|
||||
* 获取模版列表
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/page")
|
||||
public ApiResp<List<CoreChartTemplate>> page(PageDTO dto) {
|
||||
|
||||
QueryWrapper<CoreChartTemplate> queryWrapper = new QueryWrapper<CoreChartTemplate>()
|
||||
.eq("is_deleted", 0)
|
||||
.like(StrUtil.isNotEmpty(dto.getKeyword()), "table_name", dto.getKeyword())
|
||||
.orderByAsc("sort");
|
||||
dto.likeColumns(queryWrapper, "name", "table_name", "table_title");
|
||||
|
||||
Page<CoreChartTemplate> page = dto.pageObj();
|
||||
chartService.page(page, queryWrapper);
|
||||
return ApiResp.respOK(page.getRecords(), page.getTotal());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取模版列表
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/edit")
|
||||
public ApiResp<String> edit(@RequestBody @Valid ChartTemplateEditDTO dto) {
|
||||
dto.setSField(StrUtil.emptyToDefault(dto.getSField(), ""));
|
||||
CoreChartTemplate template = BeanUtil.copyProperties(dto, CoreChartTemplate.class);
|
||||
template.setExts(JSON.toJSONString(dto.getExts()));
|
||||
chartService.saveOrUpdate(template);
|
||||
return ApiResp.respOK("");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取模版列表
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/del")
|
||||
public ApiResp<String> del(@RequestBody @Valid IdDTO dto) {
|
||||
chartService.update(null, new UpdateWrapper<CoreChartTemplate>()
|
||||
.set("is_deleted", 1)
|
||||
.eq("id", dto.getId())
|
||||
.eq("is_deleted", 0)
|
||||
);
|
||||
return ApiResp.respOK("");
|
||||
}
|
||||
|
||||
///////////////////////////// 表信息
|
||||
|
||||
|
||||
/**
|
||||
* 获取模版列表
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/table/list")
|
||||
public ApiResp<List<CoreChartTable>> tableList(PageDTO dto) {
|
||||
List<CoreChartTable> list = chartService.getCoreChartTableMapper()
|
||||
.selectList(new QueryWrapper<CoreChartTable>()
|
||||
.eq("is_deleted", 0)
|
||||
.like(StrUtil.isNotEmpty(dto.getKeyword()), "table_name", dto.getKeyword())
|
||||
);
|
||||
return ApiResp.respOK(list, list.size());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取模版列表
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/table/edit")
|
||||
public ApiResp<String> tableEdit(@RequestBody @Valid ChartTableEditDTO dto) {
|
||||
|
||||
CoreChartTable exist = chartService.getCoreChartTableMapper().selectOne(
|
||||
new QueryWrapper<CoreChartTable>()
|
||||
.eq("table_name", dto.getTableName())
|
||||
.ne(StrUtil.isNotEmpty(dto.getId()), "id", dto.getId())
|
||||
.last("limit 1")
|
||||
);
|
||||
if (exist != null) {
|
||||
throw new ApiException("不可添加重复的表名");
|
||||
}
|
||||
|
||||
CoreChartTable template = BeanUtil.copyProperties(dto, CoreChartTable.class);
|
||||
template.setIsDeleted(0);
|
||||
template.setColumns(JSON.toJSONString(dto.getColumns()));
|
||||
if (StrUtil.isNotEmpty(dto.getId())) {
|
||||
chartService.getCoreChartTableMapper().updateById(template);
|
||||
} else {
|
||||
chartService.getCoreChartTableMapper().insert(template);
|
||||
}
|
||||
return ApiResp.respOK("");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取模版列表
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/table/del")
|
||||
public ApiResp<String> tableDel(@RequestBody @Valid IdDTO dto) {
|
||||
chartService.getCoreChartTableMapper().update(null, new UpdateWrapper<CoreChartTable>()
|
||||
.set("is_deleted", 1)
|
||||
.eq("id", dto.getId())
|
||||
.eq("is_deleted", 0)
|
||||
);
|
||||
return ApiResp.respOK("");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取table详情
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/table/info")
|
||||
@TokenIgnore
|
||||
public ApiResp<CoreChartTable> getTableInfo(String tableName) {
|
||||
return ApiResp.respOK(chartService.getCoreChartTableMapper().selectOne(new QueryWrapper<CoreChartTable>()
|
||||
.eq("is_deleted", 0)
|
||||
.eq("table_name", tableName)
|
||||
.last("limit 1")
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.tiesheng.role.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.tiesheng.role.pojos.dao.CoreChartTable;
|
||||
|
||||
public interface CoreChartTableMapper extends BaseMapper<CoreChartTable> {
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.tiesheng.role.mapper;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.tiesheng.role.pojos.dao.CoreChartTemplate;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface CoreChartTemplateMapper extends BaseMapper<CoreChartTemplate> {
|
||||
/**
|
||||
* 根据字段查询数据
|
||||
*
|
||||
* @param table
|
||||
* @param xField
|
||||
* @param where
|
||||
* @param sField
|
||||
* @return
|
||||
*/
|
||||
List<JSONObject> recordCheck(@Param("table") String table,
|
||||
@Param("type") String type,
|
||||
@Param("xField") String xField,
|
||||
@Param("where") String where,
|
||||
@Param("sField") String sField,
|
||||
@Param("groupBy") String groupBy
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package com.tiesheng.role.pojos.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.tiesheng.util.pojos.DaoBase;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* 图表-表信息
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName(value = "core_chart_table")
|
||||
public class CoreChartTable extends DaoBase {
|
||||
/**
|
||||
* 表名
|
||||
*/
|
||||
@TableField(value = "`table_name`")
|
||||
private String tableName;
|
||||
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
@TableField(value = "table_title")
|
||||
private String tableTitle;
|
||||
|
||||
/**
|
||||
* 所有字段
|
||||
*/
|
||||
@TableField(value = "`columns`")
|
||||
private String columns;
|
||||
|
||||
/**
|
||||
* 其他说明
|
||||
*/
|
||||
@TableField(value = "remark")
|
||||
private String remark;
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
package com.tiesheng.role.pojos.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.tiesheng.util.pojos.DaoBase;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* 图表-表信息
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName(value = "core_chart_template")
|
||||
public class CoreChartTemplate extends DaoBase {
|
||||
/**
|
||||
* 模版名称
|
||||
*/
|
||||
@TableField(value = "`name`")
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 表名
|
||||
*/
|
||||
@TableField(value = "`table_name`")
|
||||
private String tableName;
|
||||
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
@TableField(value = "table_title")
|
||||
private String tableTitle;
|
||||
|
||||
/**
|
||||
* 统计方式
|
||||
*/
|
||||
@TableField(value = "`type`")
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* X轴字段
|
||||
*/
|
||||
@TableField(value = "x_field")
|
||||
private String xField;
|
||||
|
||||
@TableField(value = "x_field_name")
|
||||
private String xFieldName;
|
||||
|
||||
/**
|
||||
* X轴格式化,只有X轴字段为date时有效
|
||||
*/
|
||||
@TableField(value = "x_format")
|
||||
private String xFormat;
|
||||
|
||||
/**
|
||||
* S轴字段
|
||||
*/
|
||||
@TableField(value = "s_field")
|
||||
private String sField;
|
||||
|
||||
@TableField(value = "s_field_name")
|
||||
private String sFieldName;
|
||||
|
||||
/**
|
||||
* 附件条件
|
||||
*/
|
||||
@TableField(value = "exts")
|
||||
private String exts;
|
||||
|
||||
/**
|
||||
* 其他说明
|
||||
*/
|
||||
@TableField(value = "remark")
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
@TableField(value = "sort")
|
||||
private Integer sort;
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.tiesheng.role.pojos.dto;
|
||||
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.Size;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class ChartTableEditDTO {
|
||||
|
||||
private String id;
|
||||
|
||||
@NotEmpty(message = "请输入【表名】")
|
||||
private String tableName;
|
||||
|
||||
@NotEmpty(message = "请输入【名称】")
|
||||
private String tableTitle;
|
||||
|
||||
@Size(min = 1, message = "请配置【表字段】")
|
||||
private List<TableColumn> columns;
|
||||
private String remark;
|
||||
|
||||
|
||||
@Data
|
||||
public static class TableColumn {
|
||||
private String key;
|
||||
private String type;
|
||||
private String remark;
|
||||
private String enums;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
package com.tiesheng.role.pojos.dto;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import com.tiesheng.role.pojos.dao.CoreChartTemplate;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Data
|
||||
public class ChartTemplateCheck {
|
||||
|
||||
private String templateId;
|
||||
private CoreChartTemplate template;
|
||||
private String xFormat;
|
||||
private List<ChartTemplateEditDTO.TemplateExt> exts;
|
||||
|
||||
|
||||
@JSONField(serialize = false)
|
||||
public String getTableXField() {
|
||||
String tmpXFormat = StrUtil.emptyToDefault(getXFormat(), getTemplate().getXFormat());
|
||||
if (StrUtil.isNotEmpty(tmpXFormat)) {
|
||||
return StrUtil.format("DATE_FORMAT({},'{}')", getTemplate().getXField(), tmpXFormat);
|
||||
}
|
||||
return getTemplate().getXField();
|
||||
}
|
||||
|
||||
@JSONField(serialize = false)
|
||||
public String getTableGroupBy() {
|
||||
if (StrUtil.isNotEmpty(getTemplate().getSField())) {
|
||||
return StrUtil.format("{},{}", getTableXField(), getTemplate().getSField());
|
||||
}
|
||||
return getTableXField();
|
||||
}
|
||||
|
||||
public String getCountType() {
|
||||
if (Objects.equals(getTemplate().getType(), "count_1")) {
|
||||
return "count(1)";
|
||||
}
|
||||
return "sum(" + getTemplate().getType() + ")";
|
||||
}
|
||||
|
||||
|
||||
@JSONField(serialize = false)
|
||||
public String getWhere() {
|
||||
if (CollUtil.isEmpty(getExts())) {
|
||||
setExts(JSON.parseArray(getTemplate().getExts(), ChartTemplateEditDTO.TemplateExt.class));
|
||||
}
|
||||
if (CollUtil.isEmpty(getExts())) {
|
||||
return "";
|
||||
}
|
||||
|
||||
List<String> list = new ArrayList<>();
|
||||
for (ChartTemplateEditDTO.TemplateExt templateExt : getExts()) {
|
||||
if (templateExt.isErrorExt()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (Objects.equals(templateExt.getAction(), "eq")) {
|
||||
list.add(StrUtil.format("{} = '{}'", templateExt.getKey(), templateExt.getValue()));
|
||||
} else if (Objects.equals(templateExt.getAction(), "ne")) {
|
||||
list.add(StrUtil.format("{} != '{}'", templateExt.getKey(), templateExt.getValue()));
|
||||
} else if (Objects.equals(templateExt.getAction(), "btw")) {
|
||||
List<String> split = StrUtil.split(templateExt.getValue(), ",");
|
||||
if (split.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
if (split.size() == 1) {
|
||||
list.add(StrUtil.format("{} > '{}'", templateExt.getKey(), split.get(0)));
|
||||
} else {
|
||||
list.add(StrUtil.format("{} between '{}' and '{}'", templateExt.getKey(), split.get(0), split.get(1)));
|
||||
}
|
||||
} else if (Objects.equals(templateExt.getAction(), "nbtw")) {
|
||||
List<String> split = StrUtil.split(templateExt.getValue(), ",");
|
||||
if (split.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
if (split.size() == 1) {
|
||||
list.add(StrUtil.format("{} < '{}'", templateExt.getKey(), split.get(0)));
|
||||
} else {
|
||||
list.add(StrUtil.format("{} not between '{}' and '{}'", templateExt.getKey(), split.get(0), split.get(1)));
|
||||
}
|
||||
} else if (Objects.equals(templateExt.getAction(), "in")) {
|
||||
List<String> split = StrUtil.split(templateExt.getValue(), ",");
|
||||
if (split.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
list.add(StrUtil.format("{} in ({})", templateExt.getKey(), split.stream().map(it -> "'" + it + "'")
|
||||
.collect(Collectors.joining(","))));
|
||||
} else if (Objects.equals(templateExt.getAction(), "nin")) {
|
||||
List<String> split = StrUtil.split(templateExt.getValue(), ",");
|
||||
if (split.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
list.add(StrUtil.format("{} not in ({})", templateExt.getKey(), split.stream().map(it -> "'" + it + "'")
|
||||
.collect(Collectors.joining(","))));
|
||||
}
|
||||
}
|
||||
|
||||
return StrUtil.join(" and ", list);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package com.tiesheng.role.pojos.dto;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class ChartTemplateEditDTO {
|
||||
|
||||
private String id;
|
||||
|
||||
@NotEmpty(message = "请输入【模版名称】")
|
||||
private String name;
|
||||
|
||||
@NotEmpty(message = "请选择【表名】")
|
||||
private String tableName;
|
||||
private String tableTitle;
|
||||
|
||||
@NotEmpty(message = "请选择【X轴字段】")
|
||||
private String xField;
|
||||
private String xFieldName;
|
||||
private String xFormat;
|
||||
|
||||
private String sField;
|
||||
private String sFieldName;
|
||||
private String type;
|
||||
private List<TemplateExt> exts;
|
||||
private String remark;
|
||||
private Integer sort;
|
||||
|
||||
|
||||
@Data
|
||||
public static class TemplateExt {
|
||||
private String key;
|
||||
private String action;
|
||||
private String value;
|
||||
|
||||
|
||||
/**
|
||||
* 该数据是否有效
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@JSONField(serialize = false)
|
||||
public boolean isErrorExt() {
|
||||
return StrUtil.isEmpty(getKey()) || StrUtil.isEmpty(getAction()) || StrUtil.isEmpty(getValue());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
package com.tiesheng.role.pojos.vo;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.tiesheng.role.pojos.dao.CoreChartTemplate;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class TsTableVO {
|
||||
|
||||
private List<TableColumn> columns;
|
||||
private List<JSONObject> dataSource;
|
||||
|
||||
|
||||
@Data
|
||||
public static class TableColumn {
|
||||
private String title;
|
||||
private String dataIndex;
|
||||
private String width;
|
||||
|
||||
public TableColumn(String title, String dataIndex) {
|
||||
this.title = title;
|
||||
this.dataIndex = dataIndex;
|
||||
}
|
||||
}
|
||||
|
||||
public TsTableVO addHeader(String title, String dataIndex) {
|
||||
if (getColumns() == null) {
|
||||
setColumns(CollUtil.newArrayList());
|
||||
}
|
||||
getColumns().add(new TableColumn(title, dataIndex));
|
||||
return this;
|
||||
}
|
||||
|
||||
public TsTableVO addData(JSONObject obj) {
|
||||
if (getDataSource() == null) {
|
||||
setDataSource(CollUtil.newArrayList());
|
||||
}
|
||||
getDataSource().add(obj);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public static TsTableVO of(CoreChartTemplate template, List<JSONObject> originData) {
|
||||
|
||||
TsTableVO tsTableVO = new TsTableVO();
|
||||
tsTableVO.addHeader(template.getXFieldName(), "xField");
|
||||
List<String> split = StrUtil.split(template.getSField(), ",");
|
||||
List<String> sFieldNameList = StrUtil.split(template.getSFieldName(), ",");
|
||||
if (!split.isEmpty() && split.size() == sFieldNameList.size()) {
|
||||
int idx = 0;
|
||||
for (String dataIndex : split) {
|
||||
tsTableVO.addHeader(CollUtil.get(sFieldNameList, idx), StrUtil.toCamelCase(dataIndex));
|
||||
idx++;
|
||||
}
|
||||
}
|
||||
tsTableVO.addHeader("统计", "yField");
|
||||
tsTableVO.setDataSource(originData);
|
||||
return tsTableVO;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.tiesheng.role.service;
|
||||
|
||||
import com.tiesheng.role.mapper.CoreChartTableMapper;
|
||||
import com.tiesheng.role.mapper.CoreChartTemplateMapper;
|
||||
import com.tiesheng.role.pojos.dao.CoreChartTemplate;
|
||||
import com.tiesheng.util.service.TsServiceBase;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.Getter;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class ChartService extends TsServiceBase<CoreChartTemplateMapper, CoreChartTemplate> {
|
||||
|
||||
@Getter
|
||||
@Resource
|
||||
CoreChartTableMapper coreChartTableMapper;
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
package com.tiesheng.role.util;
|
||||
|
||||
import com.alibaba.excel.metadata.Head;
|
||||
import com.alibaba.excel.write.metadata.style.WriteCellStyle;
|
||||
import com.alibaba.excel.write.metadata.style.WriteFont;
|
||||
import com.alibaba.excel.write.style.HorizontalCellStyleStrategy;
|
||||
import com.alibaba.excel.write.style.column.AbstractHeadColumnWidthStyleStrategy;
|
||||
import org.apache.poi.ss.usermodel.FillPatternType;
|
||||
import org.apache.poi.ss.usermodel.HorizontalAlignment;
|
||||
import org.apache.poi.ss.usermodel.IndexedColors;
|
||||
import org.apache.poi.ss.usermodel.VerticalAlignment;
|
||||
|
||||
/**
|
||||
* @author Administrator
|
||||
*/
|
||||
public class AliExcelUtil {
|
||||
|
||||
|
||||
/**
|
||||
* 导出数据
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static HorizontalCellStyleStrategy getCustomStyle() {
|
||||
|
||||
// 头的策略
|
||||
WriteCellStyle headWriteCellStyle = new WriteCellStyle();
|
||||
WriteFont headWriteFont = new WriteFont();
|
||||
headWriteFont.setBold(true);
|
||||
headWriteFont.setFontHeightInPoints((short) 12);
|
||||
headWriteCellStyle.setWriteFont(headWriteFont);
|
||||
headWriteCellStyle.setFillBackgroundColor(IndexedColors.ROYAL_BLUE.getIndex());
|
||||
headWriteCellStyle.setFillPatternType(FillPatternType.SOLID_FOREGROUND);
|
||||
|
||||
// 内容的策略
|
||||
WriteCellStyle contentWriteCellStyle = new WriteCellStyle();
|
||||
WriteFont contentWriteFont = new WriteFont();
|
||||
contentWriteFont.setFontHeightInPoints((short) 11);
|
||||
contentWriteCellStyle.setWriteFont(contentWriteFont);
|
||||
contentWriteCellStyle.setWrapped(true);
|
||||
contentWriteCellStyle.setVerticalAlignment(VerticalAlignment.CENTER);
|
||||
contentWriteCellStyle.setHorizontalAlignment(HorizontalAlignment.CENTER);
|
||||
|
||||
return new HorizontalCellStyleStrategy(headWriteCellStyle, contentWriteCellStyle);
|
||||
}
|
||||
|
||||
public static class ChatColumnWidthStyleStrategy extends AbstractHeadColumnWidthStyleStrategy {
|
||||
|
||||
@Override
|
||||
protected Integer columnWidth(Head head, Integer integer) {
|
||||
if (head.getColumnIndex() == 0) {
|
||||
return 20;
|
||||
}
|
||||
return (head.getHeadNameList().get(0).length()) * 2 + 10;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
create table core_chart_table
|
||||
(
|
||||
id varchar(50) not null
|
||||
primary key,
|
||||
create_time datetime not null,
|
||||
update_time datetime not null,
|
||||
is_deleted int default 0 not null,
|
||||
table_name varchar(100) not null comment '表名',
|
||||
table_title varchar(500) not null comment '名称',
|
||||
columns text not null comment '所有字段',
|
||||
remark text null comment '其他说明'
|
||||
)
|
||||
ENGINE = InnoDB
|
||||
CHARACTER SET = utf8mb4
|
||||
COLLATE = utf8mb4_general_ci
|
||||
comment '图表-表信息'
|
||||
row_format = DYNAMIC;
|
||||
|
||||
create table core_chart_template
|
||||
(
|
||||
id varchar(50) not null
|
||||
primary key,
|
||||
create_time datetime not null,
|
||||
update_time datetime not null,
|
||||
is_deleted int default 0 not null,
|
||||
name varchar(100) not null comment '模版名称',
|
||||
table_name varchar(100) not null comment '表名',
|
||||
table_title varchar(100) not null comment '名称',
|
||||
type varchar(50) default 'count_1' null comment '统计方式',
|
||||
x_field varchar(100) not null comment 'X轴字段',
|
||||
x_field_name varchar(500) not null comment 'X轴字段',
|
||||
x_format varchar(100) null comment 'X轴格式化,只有X轴字段为date时有效',
|
||||
s_field varchar(100) null comment 'S轴字段',
|
||||
s_field_name varchar(500) null comment 'S轴字段',
|
||||
exts text null comment '附件条件',
|
||||
remark text null comment '其他说明',
|
||||
sort int default 0 null comment '排序'
|
||||
)
|
||||
ENGINE = InnoDB
|
||||
CHARACTER SET = utf8mb4
|
||||
COLLATE = utf8mb4_general_ci
|
||||
comment '图表-表信息'
|
||||
row_format = DYNAMIC;
|
||||
@@ -0,0 +1,20 @@
|
||||
<?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="com.tiesheng.zaxy.alarm.mapper.CoreChartTableMapper">
|
||||
<resultMap id="BaseResultMap" type="com.tiesheng.zaxy.alarm.pojos.dao.CoreChartTable">
|
||||
<!--@mbg.generated-->
|
||||
<!--@Table core_chart_table-->
|
||||
<id column="id" jdbcType="VARCHAR" property="id" />
|
||||
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
|
||||
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
|
||||
<result column="is_deleted" jdbcType="INTEGER" property="isDeleted" />
|
||||
<result column="table_name" jdbcType="VARCHAR" property="tableName" />
|
||||
<result column="table_title" jdbcType="VARCHAR" property="tableTitle" />
|
||||
<result column="columns" jdbcType="LONGVARCHAR" property="columns" />
|
||||
<result column="remark" jdbcType="LONGVARCHAR" property="remark" />
|
||||
</resultMap>
|
||||
<sql id="Base_Column_List">
|
||||
<!--@mbg.generated-->
|
||||
id, create_time, update_time, is_deleted, `table_name`, table_title, `columns`, remark
|
||||
</sql>
|
||||
</mapper>
|
||||
@@ -0,0 +1,46 @@
|
||||
<?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="com.tiesheng.zaxy.alarm.mapper.CoreChartTemplateMapper">
|
||||
<resultMap id="BaseResultMap" type="com.tiesheng.zaxy.alarm.pojos.dao.CoreChartTemplate">
|
||||
<!--@mbg.generated-->
|
||||
<!--@Table core_chart_template-->
|
||||
<id column="id" jdbcType="VARCHAR" property="id" />
|
||||
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
|
||||
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
|
||||
<result column="is_deleted" jdbcType="INTEGER" property="isDeleted" />
|
||||
<result column="name" jdbcType="VARCHAR" property="name" />
|
||||
<result column="table_name" jdbcType="VARCHAR" property="tableName" />
|
||||
<result column="table_title" jdbcType="VARCHAR" property="tableTitle" />
|
||||
<result column="type" jdbcType="VARCHAR" property="type" />
|
||||
<result column="x_field" jdbcType="VARCHAR" property="xField" />
|
||||
<result column="x_field_name" jdbcType="VARCHAR" property="xFieldName" />
|
||||
<result column="x_format" jdbcType="VARCHAR" property="xFormat" />
|
||||
<result column="s_field" jdbcType="VARCHAR" property="sField" />
|
||||
<result column="s_field_name" jdbcType="VARCHAR" property="sFieldName" />
|
||||
<result column="exts" jdbcType="LONGVARCHAR" property="exts" />
|
||||
<result column="remark" jdbcType="LONGVARCHAR" property="remark" />
|
||||
<result column="sort" jdbcType="INTEGER" property="sort" />
|
||||
</resultMap>
|
||||
<sql id="Base_Column_List">
|
||||
<!--@mbg.generated-->
|
||||
id, create_time, update_time, is_deleted, `name`, `table_name`, table_title, `type`,
|
||||
x_field, x_field_name, x_format, s_field, s_field_name, exts, remark, sort
|
||||
</sql>
|
||||
|
||||
<select id="recordCheck" resultType="com.alibaba.fastjson.JSONObject">
|
||||
select ${xField} x_field,
|
||||
<if test="sField != null and sField != ''">
|
||||
${sField},
|
||||
</if>
|
||||
${type} y_field
|
||||
from ${table}
|
||||
where 1 = 1
|
||||
<if test="where != null and where != ''">
|
||||
and ${where}
|
||||
</if>
|
||||
<if test="groupBy != null and groupBy != ''">
|
||||
group by ${groupBy}
|
||||
</if>
|
||||
order by ${groupBy} asc
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -6,14 +6,14 @@
|
||||
<parent>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-parent</artifactId>
|
||||
<version>2.0.13</version>
|
||||
<version>4.0.0.alpha1</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>springboot-database</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
<maven.compiler.target>8</maven.compiler.target>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
|
||||
@@ -9,13 +9,13 @@ import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.db.Db;
|
||||
import cn.hutool.db.Entity;
|
||||
import com.tiesheng.database.config.DbMigrationConfig;
|
||||
import jakarta.servlet.ServletContext;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.web.servlet.ServletContextInitializer;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.sql.DataSource;
|
||||
import java.io.InputStream;
|
||||
import java.sql.SQLException;
|
||||
|
||||
@@ -6,14 +6,14 @@
|
||||
<parent>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-parent</artifactId>
|
||||
<version>2.0.13</version>
|
||||
<version>4.0.0.alpha1</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>springboot-login</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
<maven.compiler.target>8</maven.compiler.target>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.tiesheng.login.config;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.util.ObjUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.tiesheng.annotation.token.TokenIgnore;
|
||||
@@ -22,7 +23,7 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.List;
|
||||
|
||||
@@ -40,7 +41,7 @@ public class TokenWebMvcConfigurer implements WebMvcConfigurer {
|
||||
resolvers.add(new HandlerMethodArgumentResolver() {
|
||||
@Override
|
||||
public boolean supportsParameter(MethodParameter parameter) {
|
||||
return parameter.getParameterType().isAssignableFrom(TokenBean.class);
|
||||
return TokenBean.class.isAssignableFrom(parameter.getParameterType());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -54,7 +55,9 @@ public class TokenWebMvcConfigurer implements WebMvcConfigurer {
|
||||
TokenIgnore annotation = method.getAnnotation(TokenIgnore.class);
|
||||
thrExp = annotation == null;
|
||||
}
|
||||
return tsTokenConfig.validToken(header, thrExp);
|
||||
|
||||
TokenBean tokenBean = tsTokenConfig.validToken(header, thrExp);
|
||||
return BeanUtil.copyProperties(tokenBean, parameter.getParameterType());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ import com.tiesheng.util.pojos.TokenBean;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.Map;
|
||||
@@ -170,7 +170,7 @@ public class LoginController {
|
||||
extra = "";
|
||||
}
|
||||
String configUrl = globalConfig.buildPath("/login/wxmp/oauth2/" + service + "?extra=" + extra);
|
||||
String authorizationUrl = platformWxmpConfig.buildAuthorizationUrl(service, configUrl, "snsapi_userinfo");
|
||||
String authorizationUrl = platformWxmpConfig.buildAuthorizationUrl(service, configUrl);
|
||||
response.sendRedirect(authorizationUrl);
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ import com.tiesheng.util.service.role.TsAuthorityHandler;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
@@ -43,9 +43,12 @@ public class CorePlatformUniqueService extends TsServiceBase<CorePlatformUniqueM
|
||||
*/
|
||||
public TokenBean login(DoLoginInfo loginInfo) {
|
||||
|
||||
int loginErrorTimes = coreLogLoginMapper.getLoginErrorTimes(loginInfo.getLoginIp());
|
||||
if (loginErrorTimes > 4) {
|
||||
throw new ApiException("登录失败已达5次,请10分钟后再试");
|
||||
int loginErrorTimes = tsLoginConfigurer.getLoginErrorTimes();
|
||||
if (loginErrorTimes > 0) {
|
||||
int currentErrorTimes = coreLogLoginMapper.getLoginErrorTimes(loginInfo.getLoginIp());
|
||||
if (currentErrorTimes >= loginErrorTimes) {
|
||||
throw new ApiException("登录失败已达" + loginErrorTimes + "次,请10分钟后再试");
|
||||
}
|
||||
}
|
||||
|
||||
CorePlatformUnique platformUnique = getOneByColumn("unique_id", loginInfo.getUnique());
|
||||
|
||||
@@ -9,7 +9,7 @@ import com.tiesheng.util.pojos.TokenBean;
|
||||
import com.tiesheng.util.service.TsCacheService;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* @author hao
|
||||
@@ -66,4 +66,14 @@ public interface TsLoginConfigurer {
|
||||
*/
|
||||
RequestUserInfo getCurrentUserName(TokenBean userId);
|
||||
|
||||
|
||||
/**
|
||||
* 获取登录失败的次数,默认0次,不校验
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
default int getLoginErrorTimes() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -17,7 +17,8 @@ CREATE TABLE `core_log_login`
|
||||
`address` varchar(255) DEFAULT NULL COMMENT 'ip地址',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE = InnoDB
|
||||
DEFAULT CHARSET = utf8mb4 COMMENT ='日志-登录';
|
||||
DEFAULT CHARSET = utf8mb4
|
||||
COLLATE = utf8mb4_general_ci COMMENT ='日志-登录';
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for core_platform_unique
|
||||
@@ -35,6 +36,7 @@ CREATE TABLE `core_platform_unique`
|
||||
`info` text COMMENT '其他参数',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE = InnoDB
|
||||
DEFAULT CHARSET = utf8mb4 COMMENT ='平台-唯一值';
|
||||
DEFAULT CHARSET = utf8mb4
|
||||
COLLATE = utf8mb4_general_ci COMMENT ='平台-唯一值';
|
||||
|
||||
SET FOREIGN_KEY_CHECKS = 1;
|
||||
|
||||
@@ -6,14 +6,14 @@
|
||||
<parent>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-parent</artifactId>
|
||||
<version>2.0.13</version>
|
||||
<version>4.0.0.alpha1</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>springboot-message</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
<maven.compiler.target>8</maven.compiler.target>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
|
||||
@@ -6,14 +6,14 @@
|
||||
<parent>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-parent</artifactId>
|
||||
<version>2.0.13</version>
|
||||
<version>4.0.0.alpha1</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>springboot-platform</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
<maven.compiler.target>8</maven.compiler.target>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
|
||||
@@ -122,12 +122,12 @@ public class PlatformWxmpConfig {
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String buildAuthorizationUrl(String service, String redirectUrl, String scope) {
|
||||
public String buildAuthorizationUrl(String service, String redirectUrl) {
|
||||
WxConfigBean configBean = getConfigBean(service);
|
||||
return "https://open.weixin.qq.com/connect/oauth2/authorize"
|
||||
+ "?appid=" + configBean.getAppId()
|
||||
+ "&redirect_uri=" + URLUtil.encodeAll(redirectUrl)
|
||||
+ "&response_type=code&scope=" + scope
|
||||
+ "&response_type=code&scope=" + configBean.getScope()
|
||||
+ "&state=STATE#wechat_redirect";
|
||||
}
|
||||
|
||||
@@ -141,7 +141,13 @@ public class PlatformWxmpConfig {
|
||||
public WxUserInfo getOAuth2AccessToken(String service, String code) {
|
||||
WxConfigBean configBean = getConfigBean(service);
|
||||
WxOAuth2AccessToken wxOAuth2AccessToken = WxOAuth2AccessToken.create(configBean.getAppId(), configBean.getAppSecret(), code);
|
||||
WxUserInfo wxUserInfo = WxUserInfo.create(wxOAuth2AccessToken);
|
||||
WxUserInfo wxUserInfo;
|
||||
if (configBean.canUserInfo()) {
|
||||
wxUserInfo = WxUserInfo.create(wxOAuth2AccessToken);
|
||||
} else {
|
||||
wxUserInfo = new WxUserInfo();
|
||||
wxUserInfo.setOpenid(wxOAuth2AccessToken.getOpenid());
|
||||
}
|
||||
wxUserInfo.setAppId(configBean.getAppId());
|
||||
return wxUserInfo;
|
||||
}
|
||||
@@ -162,6 +168,7 @@ public class PlatformWxmpConfig {
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// setter\getter
|
||||
|
||||
/// ////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public Map<String, WxConfigBean> getConfigs() {
|
||||
|
||||
@@ -7,9 +7,20 @@ public class WxConfigBean {
|
||||
|
||||
private String appId;
|
||||
private String appSecret;
|
||||
private String scope = "snsapi_base";
|
||||
|
||||
/**
|
||||
* 是否可以获取用户信息
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public boolean canUserInfo() {
|
||||
return !"snsapi_base".equals(scope);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// setter\getter
|
||||
|
||||
/// ////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public String getAppId() {
|
||||
@@ -27,4 +38,12 @@ public class WxConfigBean {
|
||||
public void setAppSecret(String appSecret) {
|
||||
this.appSecret = appSecret;
|
||||
}
|
||||
|
||||
public String getScope() {
|
||||
return scope;
|
||||
}
|
||||
|
||||
public void setScope(String scope) {
|
||||
this.scope = scope;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,14 +6,14 @@
|
||||
<parent>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-parent</artifactId>
|
||||
<version>2.0.13</version>
|
||||
<version>4.0.0.alpha1</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>springboot-role</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
<maven.compiler.target>8</maven.compiler.target>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ import com.tiesheng.role.pojos.vo.GroupTypeDTO;
|
||||
import com.tiesheng.role.pojos.vo.ServiceMenuVO;
|
||||
import com.tiesheng.role.service.CoreRoleService;
|
||||
import com.tiesheng.util.pojos.ApiResp;
|
||||
import com.tiesheng.util.pojos.DaoBase;
|
||||
import com.tiesheng.util.pojos.TokenBean;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
@@ -43,6 +44,14 @@ public class CommRoleController {
|
||||
List<CoreRoleAuthority> allOwnerMenus = coreRoleService.getOwnerAuthorityLeafList(tokenBean.getId(), tokenBean.getRoleId());
|
||||
List<String> list = allOwnerMenus.stream().map(CoreRoleAuthority::getService).collect(Collectors.toList());
|
||||
|
||||
// 添加公开服务
|
||||
list.addAll(coreRoleService.getServerMapper().selectList(new QueryWrapper<CoreRoleServer>()
|
||||
.eq("is_public", 1).eq("is_deleted", 0).eq("is_open", 1)
|
||||
).stream().map(DaoBase::getId).collect(Collectors.toList()));
|
||||
|
||||
// 去除重复
|
||||
list = CollUtil.distinct(list);
|
||||
|
||||
List<CoreRoleServer> roleServerList = new ArrayList<>();
|
||||
if (CollUtil.isNotEmpty(list)) {
|
||||
roleServerList = coreRoleService.getServerMapper().selectList(new QueryWrapper<CoreRoleServer>()
|
||||
|
||||
@@ -66,6 +66,12 @@ public class CoreRoleServer extends DaoBase {
|
||||
@TableField(value = "ext3")
|
||||
private String ext3;
|
||||
|
||||
/**
|
||||
* 是否公开
|
||||
*/
|
||||
@TableField(value = "is_public")
|
||||
private Integer isPublic;
|
||||
|
||||
/**
|
||||
* 获取名称
|
||||
*
|
||||
@@ -227,4 +233,22 @@ public class CoreRoleServer extends DaoBase {
|
||||
public void setExt3(String ext3) {
|
||||
this.ext3 = ext3;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取是否公开
|
||||
*
|
||||
* @return is_public - 是否公开
|
||||
*/
|
||||
public Integer getIsPublic() {
|
||||
return isPublic;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置是否公开
|
||||
*
|
||||
* @param isPublic 是否公开
|
||||
*/
|
||||
public void setIsPublic(Integer isPublic) {
|
||||
this.isPublic = isPublic;
|
||||
}
|
||||
}
|
||||
@@ -24,6 +24,7 @@ create table core_role_authority
|
||||
ext3 varchar(500) null comment '扩展3'
|
||||
) ENGINE = InnoDB
|
||||
DEFAULT CHARSET = utf8mb4
|
||||
COLLATE = utf8mb4_general_ci
|
||||
comment '角色-权限';
|
||||
|
||||
create table core_role_group
|
||||
@@ -43,6 +44,7 @@ create table core_role_group
|
||||
ext3 varchar(500) null comment '扩展3'
|
||||
) ENGINE = InnoDB
|
||||
DEFAULT CHARSET = utf8mb4
|
||||
COLLATE = utf8mb4_general_ci
|
||||
comment '角色-分组';
|
||||
|
||||
create table core_role_group_rx
|
||||
@@ -56,6 +58,7 @@ create table core_role_group_rx
|
||||
menu_id varchar(50) not null comment '菜单id'
|
||||
) ENGINE = InnoDB
|
||||
DEFAULT CHARSET = utf8mb4
|
||||
COLLATE = utf8mb4_general_ci
|
||||
comment '角色-分组-关系';
|
||||
|
||||
create table core_role_server
|
||||
@@ -76,6 +79,7 @@ create table core_role_server
|
||||
ext3 varchar(500) null comment '扩展3'
|
||||
) ENGINE = InnoDB
|
||||
DEFAULT CHARSET = utf8mb4
|
||||
COLLATE = utf8mb4_general_ci
|
||||
comment '角色-服务';
|
||||
|
||||
create table core_role_user
|
||||
@@ -94,6 +98,7 @@ create table core_role_user
|
||||
ext3 varchar(500) null comment '扩展3'
|
||||
) ENGINE = InnoDB
|
||||
DEFAULT CHARSET = utf8mb4
|
||||
COLLATE = utf8mb4_general_ci
|
||||
comment '角色-用户';
|
||||
|
||||
alter table core_role_authority
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
alter table core_role_server
|
||||
add is_public int default 0 null comment '是否公开';
|
||||
|
||||
@@ -17,10 +17,11 @@
|
||||
<result column="ext1" jdbcType="VARCHAR" property="ext1" />
|
||||
<result column="ext2" jdbcType="VARCHAR" property="ext2" />
|
||||
<result column="ext3" jdbcType="VARCHAR" property="ext3" />
|
||||
<result column="is_public" jdbcType="INTEGER" property="isPublic" />
|
||||
</resultMap>
|
||||
<sql id="Base_Column_List">
|
||||
<!--@mbg.generated-->
|
||||
id, create_time, update_time, is_deleted, `name`, remark, logo, sort, is_open, link,
|
||||
ext1, ext2, ext3
|
||||
ext1, ext2, ext3, is_public
|
||||
</sql>
|
||||
</mapper>
|
||||
BIN
springboot-util/.DS_Store
vendored
BIN
springboot-util/.DS_Store
vendored
Binary file not shown.
@@ -6,14 +6,14 @@
|
||||
<parent>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-parent</artifactId>
|
||||
<version>2.0.13</version>
|
||||
<version>4.0.0.alpha1</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>springboot-util</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
<maven.compiler.target>8</maven.compiler.target>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
@@ -82,7 +82,7 @@
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
<version>8.0.30</version>
|
||||
<version>8.0.33</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
@@ -107,7 +107,7 @@
|
||||
<dependency>
|
||||
<groupId>org.bouncycastle</groupId>
|
||||
<artifactId>bcprov-jdk15to18</artifactId>
|
||||
<version>1.68</version>
|
||||
<version>1.80</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
|
||||
@@ -1,12 +1,337 @@
|
||||
package com.tiesheng.util;
|
||||
|
||||
import cn.hutool.extra.servlet.ServletUtil;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.bean.copier.CopyOptions;
|
||||
import cn.hutool.core.bean.copier.ValueProvider;
|
||||
import cn.hutool.core.collection.ArrayIter;
|
||||
import cn.hutool.core.collection.IterUtil;
|
||||
import cn.hutool.core.collection.ListUtil;
|
||||
import cn.hutool.core.exceptions.UtilException;
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.io.IORuntimeException;
|
||||
import cn.hutool.core.io.IoUtil;
|
||||
import cn.hutool.core.map.CaseInsensitiveMap;
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import cn.hutool.core.net.NetUtil;
|
||||
import cn.hutool.core.net.multipart.MultipartFormData;
|
||||
import cn.hutool.core.net.multipart.UploadSetting;
|
||||
import cn.hutool.core.util.*;
|
||||
import jakarta.servlet.ServletOutputStream;
|
||||
import jakarta.servlet.ServletRequest;
|
||||
import jakarta.servlet.http.Cookie;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import org.springframework.web.context.request.RequestContextHolder;
|
||||
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.io.*;
|
||||
import java.lang.reflect.Type;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.*;
|
||||
|
||||
public class ServletKit extends ServletUtil {
|
||||
public class ServletKit {
|
||||
|
||||
public static final String METHOD_DELETE = "DELETE";
|
||||
public static final String METHOD_HEAD = "HEAD";
|
||||
public static final String METHOD_GET = "GET";
|
||||
public static final String METHOD_OPTIONS = "OPTIONS";
|
||||
public static final String METHOD_POST = "POST";
|
||||
public static final String METHOD_PUT = "PUT";
|
||||
public static final String METHOD_TRACE = "TRACE";
|
||||
|
||||
public static Map<String, String[]> getParams(ServletRequest request) {
|
||||
Map<String, String[]> map = request.getParameterMap();
|
||||
return Collections.unmodifiableMap(map);
|
||||
}
|
||||
|
||||
public static Map<String, String> getParamMap(ServletRequest request) {
|
||||
Map<String, String> params = new HashMap();
|
||||
|
||||
for (Map.Entry<String, String[]> entry : getParams(request).entrySet()) {
|
||||
params.put(entry.getKey(), ArrayUtil.join(entry.getValue(), ","));
|
||||
}
|
||||
|
||||
return params;
|
||||
}
|
||||
|
||||
public static String getBody(ServletRequest request) {
|
||||
try (BufferedReader reader = request.getReader()) {
|
||||
String var3 = IoUtil.read(reader);
|
||||
return var3;
|
||||
} catch (IOException e) {
|
||||
throw new IORuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static byte[] getBodyBytes(ServletRequest request) {
|
||||
try {
|
||||
return IoUtil.readBytes(request.getInputStream());
|
||||
} catch (IOException e) {
|
||||
throw new IORuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static <T> T fillBean(final ServletRequest request, T bean, CopyOptions copyOptions) {
|
||||
final String beanName = StrUtil.lowerFirst(bean.getClass().getSimpleName());
|
||||
return (T) BeanUtil.fillBean(bean, new ValueProvider<String>() {
|
||||
public Object value(String key, Type valueType) {
|
||||
String[] values = request.getParameterValues(key);
|
||||
if (ArrayUtil.isEmpty(values)) {
|
||||
values = request.getParameterValues(beanName + "." + key);
|
||||
if (ArrayUtil.isEmpty(values)) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
return 1 == values.length ? values[0] : values;
|
||||
}
|
||||
|
||||
public boolean containsKey(String key) {
|
||||
return null != request.getParameter(key) || null != request.getParameter(beanName + "." + key);
|
||||
}
|
||||
}, copyOptions);
|
||||
}
|
||||
|
||||
public static <T> T fillBean(ServletRequest request, T bean, boolean isIgnoreError) {
|
||||
return (T) fillBean(request, bean, CopyOptions.create().setIgnoreError(isIgnoreError));
|
||||
}
|
||||
|
||||
public static <T> T toBean(ServletRequest request, Class<T> beanClass, boolean isIgnoreError) {
|
||||
return (T) fillBean(request, ReflectUtil.newInstanceIfPossible(beanClass), isIgnoreError);
|
||||
}
|
||||
|
||||
public static String getClientIP(HttpServletRequest request, String... otherHeaderNames) {
|
||||
String[] headers = new String[]{"X-Forwarded-For", "X-Real-IP", "Proxy-Client-IP", "WL-Proxy-Client-IP", "HTTP_CLIENT_IP", "HTTP_X_FORWARDED_FOR"};
|
||||
if (ArrayUtil.isNotEmpty(otherHeaderNames)) {
|
||||
headers = (String[]) ArrayUtil.addAll(new String[][]{otherHeaderNames, headers});
|
||||
}
|
||||
|
||||
return getClientIPByHeader(request, headers);
|
||||
}
|
||||
|
||||
public static String getClientIPByHeader(HttpServletRequest request, String... headerNames) {
|
||||
for (String header : headerNames) {
|
||||
String ip = request.getHeader(header);
|
||||
if (!NetUtil.isUnknown(ip)) {
|
||||
return NetUtil.getMultistageReverseProxyIp(ip);
|
||||
}
|
||||
}
|
||||
|
||||
String ip = request.getRemoteAddr();
|
||||
return NetUtil.getMultistageReverseProxyIp(ip);
|
||||
}
|
||||
|
||||
public static MultipartFormData getMultipart(ServletRequest request) throws IORuntimeException {
|
||||
return getMultipart(request, new UploadSetting());
|
||||
}
|
||||
|
||||
public static MultipartFormData getMultipart(ServletRequest request, UploadSetting uploadSetting) throws IORuntimeException {
|
||||
MultipartFormData formData = new MultipartFormData(uploadSetting);
|
||||
|
||||
try {
|
||||
formData.parseRequestStream(request.getInputStream(), CharsetUtil.charset(request.getCharacterEncoding()));
|
||||
return formData;
|
||||
} catch (IOException e) {
|
||||
throw new IORuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static Map<String, String> getHeaderMap(HttpServletRequest request) {
|
||||
Map<String, String> headerMap = new HashMap();
|
||||
Enumeration<String> names = request.getHeaderNames();
|
||||
|
||||
while (names.hasMoreElements()) {
|
||||
String name = (String) names.nextElement();
|
||||
headerMap.put(name, request.getHeader(name));
|
||||
}
|
||||
|
||||
return headerMap;
|
||||
}
|
||||
|
||||
public static Map<String, List<String>> getHeadersMap(HttpServletRequest request) {
|
||||
Map<String, List<String>> headerMap = new LinkedHashMap();
|
||||
Enumeration<String> names = request.getHeaderNames();
|
||||
|
||||
while (names.hasMoreElements()) {
|
||||
String name = (String) names.nextElement();
|
||||
headerMap.put(name, ListUtil.list(false, request.getHeaders(name)));
|
||||
}
|
||||
|
||||
return headerMap;
|
||||
}
|
||||
|
||||
public static Map<String, Collection<String>> getHeadersMap(HttpServletResponse response) {
|
||||
Map<String, Collection<String>> headerMap = new HashMap();
|
||||
|
||||
for (String name : response.getHeaderNames()) {
|
||||
headerMap.put(name, response.getHeaders(name));
|
||||
}
|
||||
|
||||
return headerMap;
|
||||
}
|
||||
|
||||
public static String getHeaderIgnoreCase(HttpServletRequest request, String nameIgnoreCase) {
|
||||
Enumeration<String> names = request.getHeaderNames();
|
||||
|
||||
while (names.hasMoreElements()) {
|
||||
String name = (String) names.nextElement();
|
||||
if (name != null && name.equalsIgnoreCase(nameIgnoreCase)) {
|
||||
return request.getHeader(name);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static String getHeader(HttpServletRequest request, String name, String charsetName) {
|
||||
return getHeader(request, name, CharsetUtil.charset(charsetName));
|
||||
}
|
||||
|
||||
public static String getHeader(HttpServletRequest request, String name, Charset charset) {
|
||||
String header = request.getHeader(name);
|
||||
return null != header ? CharsetUtil.convert(header, CharsetUtil.CHARSET_ISO_8859_1, charset) : null;
|
||||
}
|
||||
|
||||
public static boolean isIE(HttpServletRequest request) {
|
||||
String userAgent = getHeaderIgnoreCase(request, "User-Agent");
|
||||
if (!StrUtil.isNotBlank(userAgent)) {
|
||||
return false;
|
||||
} else {
|
||||
userAgent = userAgent.toUpperCase();
|
||||
return userAgent.contains("MSIE") || userAgent.contains("TRIDENT");
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isGetMethod(HttpServletRequest request) {
|
||||
return "GET".equalsIgnoreCase(request.getMethod());
|
||||
}
|
||||
|
||||
public static boolean isPostMethod(HttpServletRequest request) {
|
||||
return "POST".equalsIgnoreCase(request.getMethod());
|
||||
}
|
||||
|
||||
public static boolean isMultipart(HttpServletRequest request) {
|
||||
if (!isPostMethod(request)) {
|
||||
return false;
|
||||
} else {
|
||||
String contentType = request.getContentType();
|
||||
return StrUtil.isBlank(contentType) ? false : contentType.toLowerCase().startsWith("multipart/");
|
||||
}
|
||||
}
|
||||
|
||||
public static Cookie getCookie(HttpServletRequest httpServletRequest, String name) {
|
||||
return readCookieMap(httpServletRequest).get(name);
|
||||
}
|
||||
|
||||
public static Map<String, Cookie> readCookieMap(HttpServletRequest httpServletRequest) {
|
||||
Cookie[] cookies = httpServletRequest.getCookies();
|
||||
return ArrayUtil.isEmpty(cookies) ? MapUtil.empty() : IterUtil.toMap(new ArrayIter(httpServletRequest.getCookies()), new CaseInsensitiveMap(), Cookie::getName);
|
||||
}
|
||||
|
||||
public static void addCookie(HttpServletResponse response, Cookie cookie) {
|
||||
response.addCookie(cookie);
|
||||
}
|
||||
|
||||
public static void addCookie(HttpServletResponse response, String name, String value) {
|
||||
response.addCookie(new Cookie(name, value));
|
||||
}
|
||||
|
||||
public static void addCookie(HttpServletResponse response, String name, String value, int maxAgeInSeconds, String path, String domain) {
|
||||
Cookie cookie = new Cookie(name, value);
|
||||
if (domain != null) {
|
||||
cookie.setDomain(domain);
|
||||
}
|
||||
|
||||
cookie.setMaxAge(maxAgeInSeconds);
|
||||
cookie.setPath(path);
|
||||
addCookie(response, cookie);
|
||||
}
|
||||
|
||||
public static void addCookie(HttpServletResponse response, String name, String value, int maxAgeInSeconds) {
|
||||
addCookie(response, name, value, maxAgeInSeconds, "/", (String) null);
|
||||
}
|
||||
|
||||
public static PrintWriter getWriter(HttpServletResponse response) throws IORuntimeException {
|
||||
try {
|
||||
return response.getWriter();
|
||||
} catch (IOException e) {
|
||||
throw new IORuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static void write(HttpServletResponse response, String text, String contentType) {
|
||||
response.setContentType(contentType);
|
||||
Writer writer = null;
|
||||
|
||||
try {
|
||||
writer = response.getWriter();
|
||||
writer.write(text);
|
||||
writer.flush();
|
||||
} catch (IOException e) {
|
||||
throw new UtilException(e);
|
||||
} finally {
|
||||
IoUtil.close(writer);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void write(HttpServletResponse response, File file) {
|
||||
String fileName = file.getName();
|
||||
String contentType = (String) ObjectUtil.defaultIfNull(FileUtil.getMimeType(fileName), "application/octet-stream");
|
||||
BufferedInputStream in = null;
|
||||
|
||||
try {
|
||||
in = FileUtil.getInputStream(file);
|
||||
write(response, in, contentType, fileName);
|
||||
} finally {
|
||||
IoUtil.close(in);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void write(HttpServletResponse response, InputStream in, String contentType, String fileName) {
|
||||
String charset = (String) ObjectUtil.defaultIfNull(response.getCharacterEncoding(), "UTF-8");
|
||||
String encodeText = URLUtil.encodeAll(fileName, CharsetUtil.charset(charset));
|
||||
response.setHeader("Content-Disposition", StrUtil.format("attachment;filename=\"{}\";filename*={}''{}", new Object[]{encodeText, charset, encodeText}));
|
||||
response.setContentType(contentType);
|
||||
write(response, in);
|
||||
}
|
||||
|
||||
public static void write(HttpServletResponse response, InputStream in, String contentType) {
|
||||
response.setContentType(contentType);
|
||||
write(response, in);
|
||||
}
|
||||
|
||||
public static void write(HttpServletResponse response, InputStream in) {
|
||||
write(response, in, 8192);
|
||||
}
|
||||
|
||||
public static void write(HttpServletResponse response, InputStream in, int bufferSize) {
|
||||
ServletOutputStream out = null;
|
||||
|
||||
try {
|
||||
out = response.getOutputStream();
|
||||
IoUtil.copy(in, out, bufferSize);
|
||||
} catch (IOException e) {
|
||||
throw new UtilException(e);
|
||||
} finally {
|
||||
IoUtil.close(out);
|
||||
IoUtil.close(in);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void setHeader(HttpServletResponse response, String name, Object value) {
|
||||
if (value instanceof String) {
|
||||
response.setHeader(name, (String) value);
|
||||
} else if (Date.class.isAssignableFrom(value.getClass())) {
|
||||
response.setDateHeader(name, ((Date) value).getTime());
|
||||
} else if (!(value instanceof Integer) && !"int".equalsIgnoreCase(value.getClass().getSimpleName())) {
|
||||
response.setHeader(name, value.toString());
|
||||
} else {
|
||||
response.setIntHeader(name, (Integer) value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -9,12 +9,12 @@ import cn.hutool.log.LogFactory;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.serializer.SerializerFeature;
|
||||
import com.tiesheng.util.exception.ApiException;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
@@ -95,12 +95,13 @@ public class GlobalConfig {
|
||||
|
||||
|
||||
/**
|
||||
* 重定向
|
||||
* 构建待版本号的路径
|
||||
*
|
||||
* @param htmlDir 资源目录
|
||||
* @param htmlDir
|
||||
* @param route
|
||||
* @return
|
||||
*/
|
||||
public void redirect(String htmlDir, String route, HttpServletResponse response) {
|
||||
public String buildByVersion(String htmlDir, String route) {
|
||||
if (!StrUtil.endWith(htmlDir, "/")) {
|
||||
htmlDir = htmlDir + "/";
|
||||
}
|
||||
@@ -129,15 +130,31 @@ public class GlobalConfig {
|
||||
throw new ApiException("无法重定向,请检查资源");
|
||||
}
|
||||
CollUtil.sort(versions, (o1, o2) -> -VersionComparator.INSTANCE.compare(o1, o2));
|
||||
String path = buildPath(String.format("/%s%s/index.html#%s", htmlDir, versions.get(0), route));
|
||||
response.sendRedirect(path);
|
||||
return buildPath(String.format("/%s%s/index.html#%s", htmlDir, versions.get(0), route));
|
||||
} catch (IOException e) {
|
||||
LogFactory.get().info(e);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 重定向
|
||||
*
|
||||
* @param htmlDir 资源目录
|
||||
* @param route
|
||||
*/
|
||||
public void redirectWithVer(String htmlDir, String route, HttpServletResponse response) {
|
||||
try {
|
||||
response.sendRedirect(buildByVersion(htmlDir, route));
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// setter\getter
|
||||
|
||||
/// ////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
@@ -4,11 +4,10 @@ import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.log.LogFactory;
|
||||
import com.tiesheng.util.ip2region.Searcher;
|
||||
import com.tiesheng.util.service.http.OkHttpUtil;
|
||||
import jakarta.annotation.PostConstruct;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
|
||||
/**
|
||||
* @author hao
|
||||
*/
|
||||
@@ -16,7 +15,7 @@ import javax.annotation.PostConstruct;
|
||||
@ConfigurationProperties(prefix = "tiesheng.ip2region")
|
||||
public class Ip2regionConfig {
|
||||
|
||||
private String dbUrl = "http://git.kepai365.com/tiesheng/repository/raw/master/ipdb/ip2region.xdb";
|
||||
private String dbUrl = "https://git.tieshengkeji.com/tieshengkeji/Ip2region/raw/branch/main/ip2region.xdb";
|
||||
private String dbPath = System.getProperty("user.dir") + "/runtime/ip2region/ip2region.xdb";
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -3,16 +3,16 @@ package com.tiesheng.util.config;
|
||||
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.extra.servlet.ServletUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.tiesheng.util.ServletKit;
|
||||
import com.tiesheng.util.exception.ApiException;
|
||||
import com.tiesheng.util.jwt.JWT;
|
||||
import com.tiesheng.util.jwt.JWTValidator;
|
||||
import com.tiesheng.util.pojos.TokenBean;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
@@ -62,7 +62,7 @@ public class TsTokenConfig {
|
||||
* @return
|
||||
*/
|
||||
public TokenBean validToken(HttpServletRequest request, boolean thrExp) {
|
||||
String token = ServletUtil.getHeader(request, TOKEN_KEY, "utf-8");
|
||||
String token = ServletKit.getHeader(request, TOKEN_KEY, "utf-8");
|
||||
return validToken(token, thrExp);
|
||||
}
|
||||
|
||||
@@ -110,6 +110,7 @@ public class TsTokenConfig {
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// setter\getter
|
||||
|
||||
/// ////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public Map<String, TokenBean> getTestMap() {
|
||||
@@ -151,4 +152,5 @@ public class TsTokenConfig {
|
||||
public void setValidLoginSign(boolean validLoginSign) {
|
||||
this.validLoginSign = validLoginSign;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.tiesheng.util.pojos;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
|
||||
public class IdDTO {
|
||||
|
||||
@@ -9,6 +10,7 @@ public class IdDTO {
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// setter\getter
|
||||
|
||||
/// ////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public String getId() {
|
||||
|
||||
@@ -6,8 +6,20 @@ public class IdName {
|
||||
private String name;
|
||||
private String extra;
|
||||
|
||||
public IdName(String id, String name) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public IdName(String id, String name, String extra) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.extra = extra;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// setter\getter
|
||||
|
||||
/// ////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public String getId() {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.tiesheng.util.service;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.extra.servlet.ServletUtil;
|
||||
import cn.hutool.extra.spring.SpringUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.tiesheng.util.ServletKit;
|
||||
@@ -10,6 +9,7 @@ import com.tiesheng.util.service.cache.TsCacheHandler;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
|
||||
@Service
|
||||
@@ -92,4 +92,20 @@ public class TsCacheService {
|
||||
remove(captchaKey);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 验证是否重复操作
|
||||
*
|
||||
* @param key
|
||||
* @param value
|
||||
* @param seconds
|
||||
*/
|
||||
public void checkRepeat(String key, String value, int seconds) {
|
||||
String s = get(key);
|
||||
if (StrUtil.isNotEmpty(s) && Objects.equals(s, value)) {
|
||||
throw new ApiException("操作频繁,请稍后再试");
|
||||
}
|
||||
put(key, value, seconds);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -5,8 +5,6 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
|
||||
@@ -23,7 +23,8 @@ public class OkHttpUtil {
|
||||
public static OkHttpClient.Builder ofHttpClient() {
|
||||
OkHttpClient.Builder builder = new OkHttpClient.Builder()
|
||||
.connectTimeout(OkHttpConfig.GLOBAL_TIMEOUT, TimeUnit.MILLISECONDS)
|
||||
.readTimeout(OkHttpConfig.GLOBAL_TIMEOUT, TimeUnit.MILLISECONDS);
|
||||
.readTimeout(OkHttpConfig.GLOBAL_TIMEOUT, TimeUnit.MILLISECONDS)
|
||||
.writeTimeout(OkHttpConfig.GLOBAL_TIMEOUT, TimeUnit.MILLISECONDS);
|
||||
|
||||
for (Interceptor interceptor : OkHttpConfig.INTERCEPTORS) {
|
||||
builder.addInterceptor(interceptor);
|
||||
@@ -32,6 +33,7 @@ public class OkHttpUtil {
|
||||
return builder;
|
||||
}
|
||||
|
||||
|
||||
public static Request ofRequest(String method, String url, RequestBody body) {
|
||||
return new Request.Builder()
|
||||
.url(url).method(method, body).build();
|
||||
@@ -74,6 +76,7 @@ public class OkHttpUtil {
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// get请求
|
||||
|
||||
/// ////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public static String get(String urlString) {
|
||||
@@ -92,6 +95,8 @@ public class OkHttpUtil {
|
||||
|
||||
public static String get(String urlString, int timeout) {
|
||||
try (Response execute = ofHttpClient().connectTimeout(timeout, TimeUnit.MILLISECONDS)
|
||||
.readTimeout(timeout, TimeUnit.MILLISECONDS)
|
||||
.writeTimeout(timeout, TimeUnit.MILLISECONDS)
|
||||
.build().newCall(ofGet(urlString)).execute()) {
|
||||
if (execute.body() != null) {
|
||||
return execute.body().string();
|
||||
@@ -104,6 +109,7 @@ public class OkHttpUtil {
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// Post请求
|
||||
|
||||
/// ////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public static String post(String urlString, Map<String, String> formMap) {
|
||||
@@ -124,6 +130,8 @@ public class OkHttpUtil {
|
||||
|
||||
public static String post(String urlString, RequestBody body, int timeout) {
|
||||
try (Response response = ofHttpClient().connectTimeout(timeout, TimeUnit.MILLISECONDS)
|
||||
.readTimeout(timeout, TimeUnit.MILLISECONDS)
|
||||
.writeTimeout(timeout, TimeUnit.MILLISECONDS)
|
||||
.build().newCall(ofPost(urlString, body)).execute()) {
|
||||
if (response.body() != null) {
|
||||
return response.body().string();
|
||||
@@ -136,6 +144,7 @@ public class OkHttpUtil {
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// Download下载文件
|
||||
|
||||
/// ////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public static File downloadFile(String url, String destFile) {
|
||||
@@ -146,6 +155,7 @@ public class OkHttpUtil {
|
||||
try (Response response = ofHttpClient()
|
||||
.connectTimeout(0, TimeUnit.MILLISECONDS)
|
||||
.readTimeout(0, TimeUnit.MILLISECONDS)
|
||||
.writeTimeout(0, TimeUnit.MILLISECONDS)
|
||||
.build().newCall(ofGet(url)).execute()) {
|
||||
if (response.isSuccessful() && response.body() != null) {
|
||||
FileUtil.writeFromStream(response.body().byteStream(), destFile);
|
||||
@@ -160,6 +170,7 @@ public class OkHttpUtil {
|
||||
try (Response response = ofHttpClient()
|
||||
.connectTimeout(0, TimeUnit.MILLISECONDS)
|
||||
.readTimeout(0, TimeUnit.MILLISECONDS)
|
||||
.writeTimeout(0, TimeUnit.MILLISECONDS)
|
||||
.build().newCall(ofGet(url)).execute()) {
|
||||
if (response.isSuccessful() && response.body() != null) {
|
||||
return response.body().bytes();
|
||||
|
||||
@@ -6,14 +6,14 @@
|
||||
<parent>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-parent</artifactId>
|
||||
<version>2.0.13</version>
|
||||
<version>4.0.0.alpha1</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>springboot-web</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
<maven.compiler.target>8</maven.compiler.target>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
@@ -30,15 +30,44 @@
|
||||
<artifactId>spring-boot-starter-json</artifactId>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.apache.tomcat.embed</groupId>
|
||||
<artifactId>tomcat-embed-core</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.apache.tomcat.embed</groupId>
|
||||
<artifactId>tomcat-embed-el</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.apache.tomcat.embed</groupId>
|
||||
<artifactId>tomcat-embed-websocket</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<!-- aspect -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-aop</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.tomcat.embed</groupId>
|
||||
<artifactId>tomcat-embed-core</artifactId>
|
||||
<version>9.0.104</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.tomcat.embed</groupId>
|
||||
<artifactId>tomcat-embed-el</artifactId>
|
||||
<version>9.0.104</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.tomcat.embed</groupId>
|
||||
<artifactId>tomcat-embed-websocket</artifactId>
|
||||
<version>9.0.104</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-util</artifactId>
|
||||
|
||||
@@ -27,7 +27,8 @@ public class EncryptResponseBodyAdvice implements ResponseBodyAdvice<ApiResp> {
|
||||
|
||||
@Override
|
||||
public boolean supports(MethodParameter returnType, Class<? extends HttpMessageConverter<?>> converterType) {
|
||||
return AnnotationUtil.getAnnotation(returnType.getContainingClass(), RestController.class) != null;
|
||||
return AnnotationUtil.getAnnotation(returnType.getContainingClass(), RestController.class) != null
|
||||
&& returnType.getParameterType() == ApiResp.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -7,7 +7,7 @@ import com.tiesheng.util.exception.ApiRespEnum;
|
||||
import com.tiesheng.util.pojos.ApiResp;
|
||||
import com.tiesheng.web.service.TieshengWebConfigurer;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.web.servlet.MultipartProperties;
|
||||
import org.springframework.boot.servlet.autoconfigure.MultipartProperties;
|
||||
import org.springframework.http.converter.HttpMessageNotReadableException;
|
||||
import org.springframework.validation.BindException;
|
||||
import org.springframework.validation.FieldError;
|
||||
|
||||
@@ -3,10 +3,10 @@ package com.tiesheng.web.config.json;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.support.config.FastJsonConfig;
|
||||
import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter;
|
||||
import org.springframework.boot.autoconfigure.http.HttpMessageConverters;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.converter.HttpMessageConverters;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
@@ -16,16 +16,11 @@ import java.util.List;
|
||||
* @author hao
|
||||
*/
|
||||
@Configuration
|
||||
public class FastJsonMessageConverter {
|
||||
public class FastJsonMessageConverter implements WebMvcConfigurer {
|
||||
|
||||
/**
|
||||
* 配置FastJson
|
||||
*
|
||||
* @return HttpMessageConverters
|
||||
*/
|
||||
@Bean
|
||||
public HttpMessageConverters fastJsonHttpMessageConverters() {
|
||||
|
||||
@Override
|
||||
public void configureMessageConverters(HttpMessageConverters.ServerBuilder builder) {
|
||||
FastJsonConfig config = new FastJsonConfig();
|
||||
config.setDateFormat(JSON.DEFFAULT_DATE_FORMAT);
|
||||
|
||||
@@ -37,7 +32,7 @@ public class FastJsonMessageConverter {
|
||||
fastConverter.setDefaultCharset(StandardCharsets.UTF_8);
|
||||
fastConverter.setSupportedMediaTypes(mediaTypes);
|
||||
|
||||
return new HttpMessageConverters(fastConverter);
|
||||
builder.addCustomConverter(fastConverter);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package com.tiesheng.web.config.operation;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
@@ -9,11 +11,6 @@ import com.tiesheng.annotation.operation.OperationLog;
|
||||
import com.tiesheng.util.ServletKit;
|
||||
import com.tiesheng.util.config.TsTokenConfig;
|
||||
import com.tiesheng.web.service.CoreLogService;
|
||||
import org.aspectj.lang.ProceedingJoinPoint;
|
||||
import org.aspectj.lang.annotation.Around;
|
||||
import org.aspectj.lang.annotation.Aspect;
|
||||
import org.aspectj.lang.annotation.Pointcut;
|
||||
import org.aspectj.lang.reflect.MethodSignature;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@@ -56,6 +53,8 @@ public class OperationAspect {
|
||||
@Around("methodArgs()")
|
||||
public Object around(ProceedingJoinPoint joinPoint) throws Throwable {
|
||||
|
||||
DateTime crateTime = DateUtil.date();
|
||||
|
||||
HttpServletRequest request = ServletKit.getRequest();
|
||||
if (request == null) {
|
||||
return joinPoint.proceed();
|
||||
@@ -115,7 +114,7 @@ public class OperationAspect {
|
||||
}
|
||||
}
|
||||
|
||||
coreLogService.addOperationLog(
|
||||
coreLogService.addOperationLog(crateTime,
|
||||
tsTokenConfig.validToken(request, false), title, subject, reqMaps);
|
||||
|
||||
return response;
|
||||
|
||||
@@ -17,9 +17,9 @@ import org.aspectj.lang.annotation.Before;
|
||||
import org.aspectj.lang.reflect.MethodSignature;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
|
||||
import org.springframework.stereotype.Component;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ import cn.hutool.core.annotation.AnnotationUtil;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.tiesheng.annotation.role.RoleAuthority;
|
||||
import com.tiesheng.util.service.role.TsAuthorityHandler;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.aop.support.AopUtils;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
@@ -11,7 +12,6 @@ import org.springframework.context.ApplicationListener;
|
||||
import org.springframework.context.event.ContextRefreshedEvent;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
|
||||
@@ -12,12 +12,12 @@ import com.tiesheng.web.pojos.dto.config.EnumTypeDTO;
|
||||
import com.tiesheng.web.pojos.vo.ProcessDetailVo;
|
||||
import com.tiesheng.web.service.CoreConfigService;
|
||||
import com.tiesheng.web.service.CoreLogService;
|
||||
import jakarta.validation.Valid;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
|
||||
@@ -26,11 +26,11 @@ import com.tiesheng.web.service.CoreLogService;
|
||||
import com.tiesheng.web.service.FileUploadService;
|
||||
import com.tiesheng.web.service.imex.TsExportHandler;
|
||||
import com.tiesheng.web.service.imex.TsImportHandler;
|
||||
import jakarta.validation.Valid;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -4,7 +4,6 @@ package com.tiesheng.web.controller.system;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.tiesheng.annotation.role.RoleAuthority;
|
||||
import com.tiesheng.util.exception.ApiException;
|
||||
import com.tiesheng.util.pojos.ApiResp;
|
||||
import com.tiesheng.util.pojos.PageDTO;
|
||||
import com.tiesheng.web.pojos.dao.CoreConfigSystem;
|
||||
@@ -57,21 +56,8 @@ public class ConfigSystemController {
|
||||
*/
|
||||
@PostMapping("/system/update")
|
||||
public ApiResp<String> systemUpdate(@RequestBody ConfigSystemDTO dto) {
|
||||
|
||||
CoreConfigSystem configKey = coreConfigService.getOneByColumn("config_key", dto.getConfigKey());
|
||||
if (configKey == null) {
|
||||
throw new ApiException("该配置不存在,请检查");
|
||||
}
|
||||
if (configKey.getReadOnly() == 1) {
|
||||
throw new ApiException("该配置只读,不可修改");
|
||||
}
|
||||
configKey.setConfigVal(dto.getConfigVal());
|
||||
configKey.setRemark(dto.getRemark());
|
||||
configKey.setExtra(dto.getExtra());
|
||||
|
||||
tieshengWebConfigurer.configSystemCheck(configKey);
|
||||
coreConfigService.updateById(configKey);
|
||||
|
||||
tieshengWebConfigurer.configSystemCheck(dto);
|
||||
coreConfigService.updateConfigSystem(dto);
|
||||
return ApiResp.respOK("");
|
||||
}
|
||||
|
||||
|
||||
@@ -8,12 +8,12 @@ import com.tiesheng.util.pojos.ApiResp;
|
||||
import com.tiesheng.util.pojos.PageDTO;
|
||||
import com.tiesheng.web.pojos.dao.CoreLogApi;
|
||||
import com.tiesheng.web.service.CoreLogService;
|
||||
import jakarta.validation.Valid;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
||||
@@ -7,12 +7,12 @@ import com.tiesheng.login.pojos.dao.CoreLogLogin;
|
||||
import com.tiesheng.util.pojos.ApiResp;
|
||||
import com.tiesheng.util.pojos.PageDTO;
|
||||
import com.tiesheng.web.service.CoreLogService;
|
||||
import jakarta.validation.Valid;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
||||
@@ -7,12 +7,12 @@ import com.tiesheng.util.pojos.ApiResp;
|
||||
import com.tiesheng.util.pojos.PageDTO;
|
||||
import com.tiesheng.web.pojos.dao.CoreLogOperation;
|
||||
import com.tiesheng.web.service.CoreLogService;
|
||||
import jakarta.validation.Valid;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
||||
@@ -8,12 +8,12 @@ import com.tiesheng.util.pojos.ApiResp;
|
||||
import com.tiesheng.util.pojos.PageDTO;
|
||||
import com.tiesheng.web.pojos.dao.CoreLogProcess;
|
||||
import com.tiesheng.web.service.CoreLogService;
|
||||
import jakarta.validation.Valid;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.tiesheng.web.pojos.dto.config;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
|
||||
public class ConfigSystemDTO {
|
||||
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
package com.tiesheng.web.pojos.imex;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
|
||||
public class ExportDealDTO {
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.tiesheng.web.pojos.imex;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
|
||||
public class ImportDealDTO {
|
||||
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
package com.tiesheng.web.pojos.imex;
|
||||
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
|
||||
public class ImportInfoDTO {
|
||||
|
||||
@NotEmpty(message = "操作必须存在")
|
||||
@@ -13,6 +11,7 @@ public class ImportInfoDTO {
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// setter\getter
|
||||
|
||||
/// ////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public String getAction() {
|
||||
|
||||
@@ -1,9 +1,14 @@
|
||||
package com.tiesheng.web.service;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.tiesheng.util.exception.ApiException;
|
||||
import com.tiesheng.util.service.TsCacheService;
|
||||
import com.tiesheng.util.service.TsServiceBase;
|
||||
import com.tiesheng.web.mapper.CoreConfigEnumMapper;
|
||||
import com.tiesheng.web.mapper.CoreConfigSystemMapper;
|
||||
import com.tiesheng.web.pojos.dao.CoreConfigSystem;
|
||||
import com.tiesheng.util.service.TsServiceBase;
|
||||
import com.tiesheng.web.pojos.dto.config.ConfigSystemDTO;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@@ -15,6 +20,11 @@ public class CoreConfigService extends TsServiceBase<CoreConfigSystemMapper, Cor
|
||||
|
||||
@Autowired
|
||||
CoreConfigEnumMapper coreConfigEnumMapper;
|
||||
@Resource
|
||||
TsCacheService tsCacheService;
|
||||
|
||||
|
||||
private static final String CONFIG_SYSTEM_PREFIX = "CONFIG:SYSTEM:";
|
||||
|
||||
public CoreConfigEnumMapper getEnumMapper() {
|
||||
return coreConfigEnumMapper;
|
||||
@@ -28,17 +38,51 @@ public class CoreConfigService extends TsServiceBase<CoreConfigSystemMapper, Cor
|
||||
* @return
|
||||
*/
|
||||
public CoreConfigSystem getTextOrCreate(String configKey, String defaultValue) {
|
||||
CoreConfigSystem oneByColumn = getOneByColumn("config_key", configKey);
|
||||
CoreConfigSystem oneByColumn = tsCacheService.getObj(CONFIG_SYSTEM_PREFIX + configKey,
|
||||
CoreConfigSystem.class, -1);
|
||||
|
||||
if (oneByColumn != null && StrUtil.isNotEmpty(oneByColumn.getConfigVal())) {
|
||||
return oneByColumn;
|
||||
}
|
||||
|
||||
oneByColumn = getOneByColumn("config_key", configKey);
|
||||
if (oneByColumn == null) {
|
||||
oneByColumn = new CoreConfigSystem();
|
||||
oneByColumn.setId(configKey);
|
||||
oneByColumn.setConfigKey(configKey);
|
||||
oneByColumn.setConfigVal(defaultValue);
|
||||
oneByColumn.setRemark(defaultValue);
|
||||
oneByColumn.setRemark(configKey);
|
||||
oneByColumn.setConfigType(0);
|
||||
save(oneByColumn);
|
||||
}
|
||||
|
||||
tsCacheService.putObj(CONFIG_SYSTEM_PREFIX + configKey, oneByColumn, 10 * 60);
|
||||
|
||||
return oneByColumn;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 更新数据
|
||||
*
|
||||
* @param dto
|
||||
*/
|
||||
public void updateConfigSystem(ConfigSystemDTO dto) {
|
||||
CoreConfigSystem coreConfigSystem = getOneByColumn("config_key", dto.getConfigKey());
|
||||
if (coreConfigSystem == null) {
|
||||
throw new ApiException("该配置不存在,请检查");
|
||||
}
|
||||
if (coreConfigSystem.getReadOnly() == 1) {
|
||||
throw new ApiException("该配置只读,不可修改");
|
||||
}
|
||||
coreConfigSystem.setConfigVal(dto.getConfigVal());
|
||||
coreConfigSystem.setRemark(dto.getRemark());
|
||||
coreConfigSystem.setExtra(dto.getExtra());
|
||||
updateById(coreConfigSystem);
|
||||
|
||||
tsCacheService.putObj(CONFIG_SYSTEM_PREFIX + coreConfigSystem.getConfigKey(),
|
||||
coreConfigSystem, 10 * 60);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ import com.tiesheng.web.util.ProcessSyncConsumer;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -154,7 +155,7 @@ public class CoreLogService extends TsServiceBase<CoreLogOperationMapper, CoreLo
|
||||
/**
|
||||
* 添加操作日志
|
||||
*/
|
||||
public void addOperationLog(TokenBean tokenBean, String title, String subject, Object params) {
|
||||
public void addOperationLog(Date createTime, TokenBean tokenBean, String title, String subject, Object params) {
|
||||
|
||||
if (tokenBean == null || StrUtil.isEmpty(tokenBean.getId())) {
|
||||
return;
|
||||
@@ -165,7 +166,7 @@ public class CoreLogService extends TsServiceBase<CoreLogOperationMapper, CoreLo
|
||||
}
|
||||
|
||||
CoreLogOperation operation = new CoreLogOperation();
|
||||
operation.setCreateTime(DateUtil.date());
|
||||
operation.setCreateTime(createTime);
|
||||
operation.setUpdateTime(DateUtil.date());
|
||||
operation.setUserId(requestUserInfo.getId());
|
||||
operation.setUserName(requestUserInfo.getName());
|
||||
|
||||
@@ -2,16 +2,17 @@ package com.tiesheng.web.service;
|
||||
|
||||
import cn.hutool.core.thread.ThreadUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.tiesheng.web.mapper.CoreLogApiMapper;
|
||||
import com.tiesheng.web.pojos.dao.CoreLogApi;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import okhttp3.*;
|
||||
import okio.Buffer;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.io.IOException;
|
||||
import java.util.Objects;
|
||||
|
||||
@Component
|
||||
public class OkHttpLogInterceptor implements Interceptor {
|
||||
@@ -22,11 +23,14 @@ public class OkHttpLogInterceptor implements Interceptor {
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Response intercept(@NotNull Chain chain) {
|
||||
|
||||
CoreLogApi logApi = new CoreLogApi();
|
||||
public Response intercept(@NotNull Chain chain) throws IOException {
|
||||
|
||||
Request request = chain.request();
|
||||
if (Objects.equals(request.header("skipApiLog"), "true")) {
|
||||
return chain.proceed(request);
|
||||
}
|
||||
|
||||
CoreLogApi logApi = new CoreLogApi();
|
||||
logApi.setUrl(request.url().toString());
|
||||
logApi.setContent(requestBody2String(request));
|
||||
|
||||
@@ -47,10 +51,29 @@ public class OkHttpLogInterceptor implements Interceptor {
|
||||
}
|
||||
} catch (Exception e) {
|
||||
JSONObject object = new JSONObject();
|
||||
object.put("code", -1);
|
||||
object.put("message", JSON.toJSONString(e));
|
||||
object.put("code", 500);
|
||||
object.put("message", e.getMessage());
|
||||
object.put("exception", e);
|
||||
logApi.setRespBody(object.toJSONString());
|
||||
|
||||
response = new Response.Builder()
|
||||
|
||||
// 必须设置请求对象
|
||||
.request(chain.request())
|
||||
|
||||
// 指定协议版本
|
||||
.protocol(Protocol.HTTP_1_1)
|
||||
|
||||
// 设置HTTP状态码
|
||||
.code(object.getInteger("code"))
|
||||
|
||||
// 状态信息
|
||||
.message(object.getString("message"))
|
||||
|
||||
// 设置响应体
|
||||
.body(ResponseBody.create(MediaType.parse("application/json"), object.toJSONString()))
|
||||
.headers(new Headers.Builder().build()) // 可选:设置响应头
|
||||
.build();
|
||||
}
|
||||
|
||||
ThreadUtil.execute(() -> coreLogApiMapper.insert(logApi));
|
||||
|
||||
@@ -4,7 +4,7 @@ import cn.hutool.log.LogFactory;
|
||||
import com.tiesheng.login.service.TsLoginConfigurer;
|
||||
import com.tiesheng.util.exception.ApiRespEnum;
|
||||
import com.tiesheng.util.pojos.ApiResp;
|
||||
import com.tiesheng.web.pojos.dao.CoreConfigSystem;
|
||||
import com.tiesheng.web.pojos.dto.config.ConfigSystemDTO;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
/**
|
||||
@@ -58,7 +58,7 @@ public interface TieshengWebConfigurer {
|
||||
* 系统配置验证
|
||||
* 如果不符合规则,可以抛出异常
|
||||
*/
|
||||
default void configSystemCheck(CoreConfigSystem configSystem) {
|
||||
default void configSystemCheck(ConfigSystemDTO dto) {
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -13,7 +13,8 @@ CREATE TABLE `core_config_enum`
|
||||
`ext` varchar(255) DEFAULT NULL COMMENT '扩展字段',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE = InnoDB
|
||||
DEFAULT CHARSET = utf8mb4 COMMENT ='配置-枚举';
|
||||
DEFAULT CHARSET = utf8mb4
|
||||
COLLATE = utf8mb4_general_ci COMMENT ='配置-枚举';
|
||||
|
||||
|
||||
CREATE TABLE `core_config_system`
|
||||
@@ -31,7 +32,8 @@ CREATE TABLE `core_config_system`
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `uni_key` (`config_key`(50)) USING BTREE
|
||||
) ENGINE = InnoDB
|
||||
DEFAULT CHARSET = utf8mb4 COMMENT ='配置-系统';
|
||||
DEFAULT CHARSET = utf8mb4
|
||||
COLLATE = utf8mb4_general_ci COMMENT ='配置-系统';
|
||||
|
||||
alter table core_config_enum
|
||||
add sort int(10) not null default 0 comment '排序' after name;
|
||||
|
||||
@@ -18,6 +18,7 @@ CREATE TABLE `core_log_api`
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE = InnoDB
|
||||
DEFAULT CHARSET = utf8mb4
|
||||
COLLATE = utf8mb4_general_ci
|
||||
ROW_FORMAT = DYNAMIC COMMENT ='日志-调用';
|
||||
|
||||
-- ----------------------------
|
||||
@@ -69,7 +70,8 @@ CREATE TABLE `core_log_operation`
|
||||
`params` longtext COMMENT '其他参数',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE = InnoDB
|
||||
DEFAULT CHARSET = utf8mb4 COMMENT ='日志-操作';
|
||||
DEFAULT CHARSET = utf8mb4
|
||||
COLLATE = utf8mb4_general_ci COMMENT ='日志-操作';
|
||||
|
||||
|
||||
alter table core_log_process
|
||||
|
||||
Reference in New Issue
Block a user