第一次提交。
This commit is contained in:
commit
3294cc04bb
|
|
@ -0,0 +1,40 @@
|
|||
target/
|
||||
!.mvn/wrapper/maven-wrapper.jar
|
||||
!**/src/main/**/target/
|
||||
!**/src/test/**/target/
|
||||
|
||||
### IntelliJ IDEA ###
|
||||
.idea/modules.xml
|
||||
.idea/jarRepositories.xml
|
||||
.idea/compiler.xml
|
||||
.idea/libraries/
|
||||
*.iws
|
||||
*.iml
|
||||
*.ipr
|
||||
|
||||
### Eclipse ###
|
||||
.apt_generated
|
||||
.classpath
|
||||
.factorypath
|
||||
.project
|
||||
.settings
|
||||
.springBeans
|
||||
.sts4-cache
|
||||
|
||||
### NetBeans ###
|
||||
/nbproject/private/
|
||||
/nbbuild/
|
||||
/dist/
|
||||
/nbdist/
|
||||
/.nb-gradle/
|
||||
build/
|
||||
!**/src/main/**/build/
|
||||
!**/src/test/**/build/
|
||||
|
||||
### VS Code ###
|
||||
.vscode/
|
||||
|
||||
### Mac OS ###
|
||||
.DS_Store
|
||||
.idea/
|
||||
logs/
|
||||
|
|
@ -0,0 +1,169 @@
|
|||
<?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.electromagnetic.data</groupId>
|
||||
<artifactId>electromagnetic-data-new</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>electrmangnetic</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
<maven.compiler.target>8</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<mapstruct.version>1.4.1.Final</mapstruct.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>ch.qos.logback</groupId>
|
||||
<artifactId>logback-classic</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-log4j12</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.apache.logging.log4j</groupId>
|
||||
<artifactId>log4j-to-slf4j</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-all</artifactId>
|
||||
<version>5.8.22</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-boot-starter</artifactId>
|
||||
<version>3.5.3.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>1.18.34</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.springfox</groupId>
|
||||
<artifactId>springfox-swagger2</artifactId>
|
||||
<version>2.7.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.springfox</groupId>
|
||||
<artifactId>springfox-swagger-ui</artifactId>
|
||||
<version>2.7.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.electromagnetic.data</groupId>
|
||||
<artifactId>electromagnetic-common</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.pagehelper</groupId>
|
||||
<artifactId>pagehelper</artifactId>
|
||||
<version>5.1.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
<version>3.8.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>druid</artifactId>
|
||||
<version>1.1.10</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.logging.log4j</groupId>
|
||||
<artifactId>log4j-api</artifactId>
|
||||
<version>2.11.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.logging.log4j</groupId>
|
||||
<artifactId>log4j-core</artifactId>
|
||||
<version>2.11.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.logging.log4j</groupId>
|
||||
<artifactId>log4j-jcl</artifactId>
|
||||
<version>2.11.2</version>
|
||||
</dependency>
|
||||
<!--使⽤log4j2的AsyncLogger,包含disruptor-->
|
||||
<dependency>
|
||||
<groupId>com.lmax</groupId>
|
||||
<artifactId>disruptor</artifactId>
|
||||
<version>3.4.2</version>
|
||||
</dependency>
|
||||
<!-- slf4j依赖-->
|
||||
<!--与slf4j保持桥接-->
|
||||
<dependency>
|
||||
<groupId>org.apache.logging.log4j</groupId>
|
||||
<artifactId>log4j-slf4j-impl</artifactId>
|
||||
<version>2.11.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mapstruct</groupId>
|
||||
<artifactId>mapstruct-processor</artifactId>
|
||||
<version>${mapstruct.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mapstruct</groupId>
|
||||
<artifactId>mapstruct</artifactId>
|
||||
<version>${mapstruct.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.aspectj</groupId>
|
||||
<artifactId>aspectjweaver</artifactId>
|
||||
<version>1.9.7</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<finalName>electromagnetic</finalName>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<version>2.6.12</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<configuration>
|
||||
<mainClass>com.electromagnetic.industry.software.manage.Application</mainClass>
|
||||
</configuration>
|
||||
<goals>
|
||||
<goal>repackage</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
|
||||
</project>
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
package com.electromagnetic.industry.software.manage;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
public class Application {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(Application.class, args);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,72 @@
|
|||
package com.electromagnetic.industry.software.manage.aop;
|
||||
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.catalina.connector.ResponseFacade;
|
||||
import org.aspectj.lang.ProceedingJoinPoint;
|
||||
import org.aspectj.lang.annotation.Around;
|
||||
import org.aspectj.lang.annotation.Aspect;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.StopWatch;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.ServletRequest;
|
||||
import javax.servlet.ServletResponse;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Aspect
|
||||
@Component
|
||||
@Slf4j
|
||||
public class ServiceAspect {
|
||||
|
||||
/**
|
||||
* 日志切面
|
||||
*/
|
||||
@Around("execution(* com.electromagnetic.industry.software.manage.controller..*.*(..)))")
|
||||
public Object process(ProceedingJoinPoint jp) throws Throwable {
|
||||
String methodInfo = jp.getTarget().getClass().getSimpleName() + "."
|
||||
+ jp.getSignature().getName();
|
||||
Object[] args = jp.getArgs();
|
||||
String paramInfo = "";
|
||||
if (args != null && args.length > 0) {
|
||||
if (args[0] != null && args[0].getClass() != ResponseFacade.class) {
|
||||
try {
|
||||
List<Object> list = new ArrayList<>();
|
||||
for (Object obj : jp.getArgs()) {
|
||||
|
||||
if (obj instanceof ServletResponse) {
|
||||
log.info("参数中有response");
|
||||
} else if (obj instanceof ServletRequest) {
|
||||
log.info("参数中有request");
|
||||
} else if (obj instanceof MultipartFile) {
|
||||
//文件不输出
|
||||
MultipartFile obj1 = (MultipartFile) obj;
|
||||
log.info("参数中文件;文件名:{},文件大小:{}", obj1.getName(), obj1.getSize());
|
||||
break;
|
||||
} else {
|
||||
list.add(obj);
|
||||
}
|
||||
}
|
||||
paramInfo = JSONUtil.toJsonStr(list);
|
||||
} catch (Exception e) {
|
||||
log.warn("切面异常", e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
log.info("请求接口开始:{},参数:{}", methodInfo, paramInfo);
|
||||
long startTime = System.currentTimeMillis();
|
||||
StopWatch stopwatch = new StopWatch();
|
||||
stopwatch.start("接口:" + methodInfo);
|
||||
Object rvt = jp.proceed();
|
||||
if (rvt instanceof ResponseEntity) {
|
||||
return rvt;
|
||||
}
|
||||
String returnInfo = JSONUtil.toJsonStr(rvt);
|
||||
log.info("请求接口结束:{},返回参数:{},接口耗时:{}", methodInfo, returnInfo, (System.currentTimeMillis() - startTime) + "毫秒");
|
||||
stopwatch.stop();
|
||||
log.debug(stopwatch.prettyPrint());
|
||||
return rvt;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,76 @@
|
|||
package com.electromagnetic.industry.software.manage.config;
|
||||
|
||||
import cn.hutool.core.date.SystemClock;
|
||||
import com.electromagnetic.industry.software.common.cons.UserConstants;
|
||||
import com.electromagnetic.industry.software.common.pojo.UserLoginInfo;
|
||||
import com.electromagnetic.industry.software.common.util.TokenUtil;
|
||||
import com.electromagnetic.industry.software.common.util.UserThreadLocal;
|
||||
import com.electromagnetic.industry.software.manage.mapper.TokenMapper;
|
||||
import com.electromagnetic.industry.software.manage.pojo.models.Token;
|
||||
import io.jsonwebtoken.Claims;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.servlet.HandlerInterceptor;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.Date;
|
||||
|
||||
@Component
|
||||
@Slf4j
|
||||
public class LoginInterceptor implements HandlerInterceptor {
|
||||
|
||||
@Resource
|
||||
private TokenMapper tokenMapper;
|
||||
|
||||
@Override
|
||||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
|
||||
|
||||
String token = request.getHeader("Authorization");
|
||||
if (token==null) {
|
||||
log.error("Authorization header is null");
|
||||
response.setStatus(401);
|
||||
return false;
|
||||
} else {
|
||||
token = token.substring(7);
|
||||
}
|
||||
boolean result = isTokenValid(token);
|
||||
if (!result) {
|
||||
log.error("Invalid token");
|
||||
response.setStatus(401);
|
||||
return false;
|
||||
} else {
|
||||
Claims claims = TokenUtil.getLoginInfo(token);
|
||||
if (claims==null) {
|
||||
log.error("User info is missing");
|
||||
response.setStatus(401);
|
||||
return false;
|
||||
} else {
|
||||
UserLoginInfo userLoginInfo = new UserLoginInfo();
|
||||
userLoginInfo.setUserId(claims.get(UserConstants.LOGIN_USER_ID, String.class));
|
||||
userLoginInfo.setUsername(claims.get(UserConstants.LOGIN_USER_NAME, String.class));
|
||||
userLoginInfo.setWorkNumber(claims.get(UserConstants.LOGIN_WORK_NUMBER, String.class));
|
||||
UserThreadLocal.set(userLoginInfo);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
|
||||
UserThreadLocal.remove();
|
||||
}
|
||||
|
||||
public Boolean isTokenValid(String tokenStr){
|
||||
Token token = tokenMapper.selectToken(tokenStr);
|
||||
Date now = new Date(SystemClock.now());
|
||||
return token != null && now.before(token.getExpireAt());
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
package com.electromagnetic.industry.software.manage.config;
|
||||
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* @author
|
||||
* @version $Id: d.java, v 0.1 2021-01-05 19:33 Exp $$
|
||||
*/
|
||||
@Configuration
|
||||
public class WebMvcConfig implements WebMvcConfigurer {
|
||||
|
||||
@Resource
|
||||
private LoginInterceptor loginInterceptor;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param registry registry
|
||||
*/
|
||||
@Override
|
||||
public void addResourceHandlers(ResourceHandlerRegistry registry) {
|
||||
registry.addResourceHandler("swagger-ui.html")
|
||||
.addResourceLocations("classpath:/META-INF/resources/");
|
||||
|
||||
registry.addResourceHandler("/webjars/**")
|
||||
.addResourceLocations("classpath:/META-INF/resources/webjars/");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInterceptors(InterceptorRegistry registry) {
|
||||
registry.addInterceptor(loginInterceptor)
|
||||
.addPathPatterns("/**")
|
||||
.excludePathPatterns("/data/ed/user/login");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
package com.electromagnetic.industry.software.manage.controller;
|
||||
|
||||
import com.electromagnetic.industry.software.common.resp.ElectromagneticResult;
|
||||
import com.electromagnetic.industry.software.manage.service.CategoryService;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
@RequestMapping("/data/ed/category")
|
||||
@RestController
|
||||
public class CategoryController {
|
||||
|
||||
@Resource
|
||||
private CategoryService categoryService;
|
||||
|
||||
/**
|
||||
* 目录树查询
|
||||
*/
|
||||
@ApiOperation(value = "目录树查询", notes = "")
|
||||
@RequestMapping(value = "/tree", method = RequestMethod.GET)
|
||||
public ElectromagneticResult<?> categoryTree() {
|
||||
return categoryService.getAllCategories();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,106 @@
|
|||
package com.electromagnetic.industry.software.manage.controller;
|
||||
|
||||
import com.electromagnetic.industry.software.common.resp.*;
|
||||
import com.electromagnetic.industry.software.manage.pojo.req.EDDataRequest;
|
||||
import com.electromagnetic.industry.software.manage.pojo.req.FileChunkDTO;
|
||||
import com.electromagnetic.industry.software.manage.service.EDDataService;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.core.io.InputStreamResource;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.Date;
|
||||
|
||||
@RequestMapping("/data/ed/file")
|
||||
@RestController
|
||||
public class EDDataController {
|
||||
|
||||
|
||||
@Resource
|
||||
private EDDataService edDataService;
|
||||
|
||||
@ApiOperation(value = "新建文件夹",notes = "")
|
||||
@RequestMapping(value = "/createFolder",method = RequestMethod.POST)
|
||||
public ElectromagneticResult<?> createFolder(@RequestBody EDDataRequest request){
|
||||
return edDataService.createFolder(request);
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation(value = "获取文件信息列表",notes = "")
|
||||
@RequestMapping(value = "/getFileInfoList",method = RequestMethod.POST)
|
||||
public ElectromagneticResult<?> getFileInfoList(@RequestBody EDDataRequest request){
|
||||
return edDataService.getDataInfoList(request);
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation(value = "更新文件信息",notes = "")
|
||||
@RequestMapping(value = "/updateFileInfo",method = RequestMethod.POST)
|
||||
public ElectromagneticResult<?> updateFileInfo(@RequestBody EDDataRequest request){
|
||||
return edDataService.updateFileInfo(request);
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation(value = "获取子文件数量",notes = "")
|
||||
@RequestMapping(value = "/getChildFileCount",method = RequestMethod.POST)
|
||||
public ElectromagneticResult<?> getChildFileCount(@RequestBody EDDataRequest request){
|
||||
return edDataService.getChildFileCount(request);
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation(value = "上传",notes = "")
|
||||
@RequestMapping(value = "/upload", consumes = "multipart/form-data",method = RequestMethod.POST)
|
||||
public ElectromagneticResult<?> upload(@RequestParam("parentId") String parentId,
|
||||
@RequestParam("file") MultipartFile file,
|
||||
@RequestParam("gmtBatchUpload") Long gmtBatchUpload){
|
||||
EDDataRequest request = new EDDataRequest();
|
||||
request.setParentId(parentId);
|
||||
request.setFileData(file);
|
||||
request.setGmtBatchUpload(new Date(gmtBatchUpload));
|
||||
return edDataService.uploadFile(request);
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation(value = "下载",notes = "")
|
||||
@RequestMapping(value = "/download",method = RequestMethod.GET)
|
||||
public ResponseEntity<InputStreamResource> download(@RequestParam String dataId, HttpServletResponse response) throws IOException {
|
||||
return edDataService.download(dataId, response);
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation(value = "数据导出",notes = "")
|
||||
@RequestMapping(value = "/batchExport",method = RequestMethod.GET)
|
||||
public ResponseEntity<InputStreamResource> batchExport(@RequestParam String dataIdArr, HttpServletResponse response) throws IOException {
|
||||
return edDataService.batchExport(dataIdArr, response);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取已经上传的分片",notes = "")
|
||||
@RequestMapping(value = "/getUploadedChunkNums",method = RequestMethod.GET)
|
||||
public ElectromagneticResult<?> getUploadedChunkNums(@RequestParam String identifier) {
|
||||
return edDataService.getUploadedChunkNums(identifier);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "合并分片",notes = "")
|
||||
@RequestMapping(value = "/mergeChunks",method = RequestMethod.GET)
|
||||
public ElectromagneticResult<?> mergeChunks(@RequestParam String identifier,
|
||||
@RequestParam String fileName,
|
||||
@RequestParam Integer totalChunks) {
|
||||
return edDataService.mergeChunks(identifier, fileName, totalChunks);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "分片上传",notes = "")
|
||||
@RequestMapping(value = "/batchImport",method = RequestMethod.POST)
|
||||
public ElectromagneticResult<?> batchImport(FileChunkDTO fileChunkDTO) {
|
||||
return edDataService.batchImport(fileChunkDTO);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "检查分片是否存在",notes = "")
|
||||
@RequestMapping(value = "/batchImport",method = RequestMethod.GET)
|
||||
public ElectromagneticResult<?> checkChunkExist(FileChunkDTO fileChunkDTO) {
|
||||
return edDataService.checkChunkExist(fileChunkDTO);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,71 @@
|
|||
package com.electromagnetic.industry.software.manage.controller;
|
||||
|
||||
import com.electromagnetic.industry.software.common.resp.ElectromagneticResult;
|
||||
import com.electromagnetic.industry.software.manage.pojo.req.*;
|
||||
import com.electromagnetic.industry.software.manage.service.UserService;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
@RequestMapping("/data/ed/user")
|
||||
@RestController
|
||||
public class UserController {
|
||||
|
||||
@Resource
|
||||
private UserService userService;
|
||||
|
||||
@ApiOperation(value = "登录", notes = "")
|
||||
@PostMapping("/login")
|
||||
public ElectromagneticResult<?> login(@RequestBody UserLoginRequest loginRequest) {
|
||||
return userService.login(loginRequest);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "新增用户信息", notes = "")
|
||||
@PostMapping("/createUser")
|
||||
public ElectromagneticResult<?> createUser(@RequestBody UserRequest userRequest) {
|
||||
return userService.createUser(userRequest);
|
||||
}
|
||||
|
||||
@ApiOperation(value="编辑用户信息",notes = "")
|
||||
@PutMapping("/updateUser")
|
||||
public ElectromagneticResult<?> updateUser(@RequestBody UserModiRequest userModiRequest){
|
||||
return userService.modifyUser(userModiRequest);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "发布用户信息", notes = "")
|
||||
@RequestMapping(value = "/publish", method = RequestMethod.POST)
|
||||
public ElectromagneticResult<?> publishUser(@RequestBody UserPublishRequest userPublishRequest) {
|
||||
return userService.publishUser(userPublishRequest);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取单条用户信息", notes = "")
|
||||
@RequestMapping(value = "/getInfo", method = RequestMethod.GET)
|
||||
public ElectromagneticResult<?> getSingleUser(GetSingleUserRequest getSingleUserRequest) {
|
||||
return userService.getSingleUser(getSingleUserRequest);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "查询用户信息", notes = "")
|
||||
@RequestMapping(value = "/list", method = RequestMethod.POST)
|
||||
public ElectromagneticResult<?> searchUser(@RequestBody SearchUserRequest searchUserRequest) {
|
||||
return userService.searchUser(searchUserRequest);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "校验工号唯一性", notes = "")
|
||||
@RequestMapping(value = "/validateWorkNumber", method = RequestMethod.POST)
|
||||
public ElectromagneticResult<?> validateWorkNum(@RequestBody UserWorkNumRequest userWorkNumRequest) {
|
||||
return userService.validateWorkNum(userWorkNumRequest);
|
||||
}
|
||||
|
||||
@ApiOperation(value="删除用户信息",notes="")
|
||||
@PostMapping(value = "/deleteUser")
|
||||
public ElectromagneticResult<?> deleteUser(@RequestBody UserDeleteRequest userDeleteRequest) {
|
||||
return userService.deleteUser(userDeleteRequest);
|
||||
}
|
||||
|
||||
@ApiOperation(value="登出", notes = "")
|
||||
@RequestMapping(value = "/logout", method = RequestMethod.POST)
|
||||
public ElectromagneticResult<?> logout(@RequestHeader("Authorization") String token) {
|
||||
return userService.logout(token);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
package com.electromagnetic.industry.software.manage.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.electromagnetic.industry.software.manage.pojo.models.Category;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface CategoryMapper extends BaseMapper<Category> {
|
||||
|
||||
/**
|
||||
* 获取顶级节点
|
||||
* @return
|
||||
*/
|
||||
List<Category> selectTopCategories();
|
||||
|
||||
/**
|
||||
* 获取所有节点
|
||||
* @return
|
||||
*/
|
||||
List<Category> selectAllCategories();
|
||||
|
||||
/**
|
||||
* 获取节点通过编码ID
|
||||
* @return
|
||||
*/
|
||||
List<Category> selectCategories(Category category);
|
||||
|
||||
/**
|
||||
* 获取子节点通过父ID
|
||||
* @return
|
||||
*/
|
||||
List<Category> selectChildCategories(Category category);
|
||||
|
||||
/**
|
||||
* 创建目录树节点数据
|
||||
* @return
|
||||
*/
|
||||
Boolean createCategory(Category category);
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
package com.electromagnetic.industry.software.manage.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.electromagnetic.industry.software.manage.pojo.models.EDDataInfo;
|
||||
import com.electromagnetic.industry.software.manage.pojo.other.EDDataParams;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@Mapper
|
||||
public interface EDDataMapper extends BaseMapper<EDDataInfo> {
|
||||
/**
|
||||
* 创建文件/文件夹数据信息
|
||||
* @param edDataInfo
|
||||
* @return
|
||||
*/
|
||||
Boolean createDataInfo(EDDataInfo edDataInfo);
|
||||
|
||||
/**
|
||||
* 获取文件信息列表
|
||||
* @param parames
|
||||
* @return
|
||||
*/
|
||||
List<EDDataInfo> getDataInfoList(EDDataParams parames);
|
||||
|
||||
/**
|
||||
* 更新文件信息
|
||||
* @param parames
|
||||
* @return
|
||||
*/
|
||||
Boolean updateFileInfo(EDDataParams parames);
|
||||
}
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
package com.electromagnetic.industry.software.manage.mapper;
|
||||
|
||||
import com.electromagnetic.industry.software.manage.pojo.models.EDDataInfo;
|
||||
import com.electromagnetic.industry.software.manage.pojo.other.EDDataPage;
|
||||
import com.electromagnetic.industry.software.manage.pojo.other.EDDataParams;
|
||||
import com.electromagnetic.industry.software.manage.pojo.req.EDDataRequest;
|
||||
import com.electromagnetic.industry.software.manage.pojo.resp.EDDataPageResponse;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
@Mapper
|
||||
public interface EDDataMappers {
|
||||
|
||||
EDDataMappers INSTANCE= Mappers.getMapper(EDDataMappers.class);
|
||||
|
||||
/**
|
||||
* 文件数据扩展模型入参转换
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
EDDataParams getEDDataParames(EDDataRequest request);
|
||||
/**
|
||||
* 文件数据扩展模型入参转换
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
EDDataInfo getEDDataInfo(EDDataRequest request);
|
||||
/**
|
||||
* 指标卡扩展模型返回
|
||||
* @param edDataPage
|
||||
* @return
|
||||
*/
|
||||
EDDataPageResponse getEDDataInfoToModel(EDDataPage edDataPage);
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
package com.electromagnetic.industry.software.manage.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.electromagnetic.industry.software.manage.pojo.models.Token;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface TokenMapper extends BaseMapper<Token> {
|
||||
|
||||
/**
|
||||
* 插入
|
||||
* @param token
|
||||
* @return
|
||||
*/
|
||||
int insert(Token token);
|
||||
|
||||
/**
|
||||
* 查询
|
||||
* @param token
|
||||
* @return Token
|
||||
*/
|
||||
Token selectToken(String token);
|
||||
|
||||
/**
|
||||
* 删除token
|
||||
* @param token
|
||||
* @return
|
||||
*/
|
||||
int deleteToken(String token);
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,70 @@
|
|||
package com.electromagnetic.industry.software.manage.mapper;
|
||||
|
||||
import com.electromagnetic.industry.software.manage.pojo.models.User;
|
||||
import com.electromagnetic.industry.software.manage.pojo.other.PublishParam;
|
||||
import com.electromagnetic.industry.software.manage.pojo.other.SearchKeyWords;
|
||||
import com.electromagnetic.industry.software.manage.pojo.other.UserDeleteKeyWords;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface UserMapper {
|
||||
|
||||
/**
|
||||
* 插入
|
||||
* @param user
|
||||
* @return
|
||||
*/
|
||||
int insert(User user);
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
* @param user
|
||||
* @return
|
||||
*/
|
||||
int modify(User user);
|
||||
|
||||
/**
|
||||
* 发布
|
||||
* @param publishParam
|
||||
* @return
|
||||
*/
|
||||
int publish(PublishParam publishParam);
|
||||
|
||||
/**
|
||||
* 通过工号查询用户
|
||||
* @param workNumber
|
||||
* @return
|
||||
*/
|
||||
User selectUserByWorkNumber(String workNumber);
|
||||
|
||||
/**
|
||||
* 通过用户编码查询用户
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
User getSingleUser(String userId);
|
||||
|
||||
/**
|
||||
* 通过用户编码查询用户
|
||||
* @param searchKeywords
|
||||
* @return
|
||||
*/
|
||||
List<User> search(SearchKeyWords searchKeywords);
|
||||
|
||||
/**
|
||||
* 查询数据总条目数
|
||||
* @param searchKeywords
|
||||
* @return
|
||||
*/
|
||||
int getTotalCount (SearchKeyWords searchKeywords);
|
||||
|
||||
/**
|
||||
* 通过用户ID删除用户
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
int deleteUser(UserDeleteKeyWords userDeleteKeyWords);
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,82 @@
|
|||
package com.electromagnetic.industry.software.manage.mapper;
|
||||
|
||||
import com.electromagnetic.industry.software.common.pojo.UserLoginInfo;
|
||||
import com.electromagnetic.industry.software.manage.pojo.models.User;
|
||||
import com.electromagnetic.industry.software.manage.pojo.other.PublishParam;
|
||||
import com.electromagnetic.industry.software.manage.pojo.other.SearchKeyWords;
|
||||
import com.electromagnetic.industry.software.manage.pojo.other.SingleUserResponse;
|
||||
import com.electromagnetic.industry.software.manage.pojo.other.UserDeleteKeyWords;
|
||||
import com.electromagnetic.industry.software.manage.pojo.req.*;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface UserMappers {
|
||||
UserMappers INSTANCE= Mappers.getMapper(UserMappers.class);
|
||||
|
||||
/**
|
||||
* 用户Request转用户模型
|
||||
* @param userRequest
|
||||
* @return
|
||||
*/
|
||||
User getUserRequestToModel(UserRequest userRequest);
|
||||
|
||||
/**
|
||||
* 用户登录Request转用户登录模型
|
||||
* @param loginRequest
|
||||
* @return
|
||||
*/
|
||||
UserLoginInfo getUserLoginRequestToModel(UserLoginRequest loginRequest);
|
||||
|
||||
/**
|
||||
* 获取单条用户信息Request转用户模型
|
||||
* @param user
|
||||
* @return
|
||||
*/
|
||||
SingleUserResponse getSingleUserToResponse(User user);
|
||||
|
||||
|
||||
/**
|
||||
* 用户发布request转用户发布参数模型
|
||||
* @param userPublishRequest
|
||||
* @return
|
||||
*/
|
||||
PublishParam getUserPublishRequestToModel(UserPublishRequest userPublishRequest);
|
||||
|
||||
/**
|
||||
* 获取单条用户信息Request转用户模型
|
||||
* @param searchUserRequest
|
||||
* @return
|
||||
*/
|
||||
SearchKeyWords getSearchKeywordsRequestToModel(SearchUserRequest searchUserRequest);
|
||||
|
||||
/**
|
||||
* 获取用户列表转response列表
|
||||
* @param users
|
||||
* @return
|
||||
*/
|
||||
List<SingleUserResponse> userListToResponseList(List<User> users);
|
||||
|
||||
/**
|
||||
* 编辑用户Request转用户模型
|
||||
* @param userModiRequest
|
||||
* @return
|
||||
*/
|
||||
User getUserModiRequestToModel(UserModiRequest userModiRequest);
|
||||
|
||||
/**
|
||||
* 校验工号唯一性Request转用户模型
|
||||
* @param userWorkNumRequest
|
||||
* @return
|
||||
*/
|
||||
User getUserWorkNumRequestToModel(UserWorkNumRequest userWorkNumRequest);
|
||||
|
||||
/**
|
||||
* 删除单条用户信息Request转用户模型
|
||||
* @param userDeleteRequest
|
||||
* @return
|
||||
*/
|
||||
UserDeleteKeyWords getUserDeleteRequestToModel(UserDeleteRequest userDeleteRequest);
|
||||
}
|
||||
|
|
@ -0,0 +1,84 @@
|
|||
package com.electromagnetic.industry.software.manage.pojo.models;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@TableName("ed_category")
|
||||
public class Category {
|
||||
/**
|
||||
* 主键ID
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 目录类型ID
|
||||
*/
|
||||
private String categoryTypeId;
|
||||
|
||||
/**
|
||||
* 上级编码,为空则为一级
|
||||
*/
|
||||
private String parentId;
|
||||
|
||||
/**
|
||||
* 目录编码
|
||||
*/
|
||||
private String categoryId;
|
||||
|
||||
/**
|
||||
* 目录名称
|
||||
*/
|
||||
private String categoryName;
|
||||
|
||||
/**
|
||||
* 目录状态
|
||||
*/
|
||||
private String categoryStatus;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
private String creator;
|
||||
|
||||
/**
|
||||
* 创建人姓名
|
||||
*/
|
||||
private String creatorName;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date gmtCreate;
|
||||
|
||||
/**
|
||||
* 编辑人
|
||||
*/
|
||||
private String modifier;
|
||||
|
||||
/**
|
||||
* 编辑人姓名
|
||||
*/
|
||||
private String modifierName;
|
||||
|
||||
/**
|
||||
* 编辑时间
|
||||
*/
|
||||
private Date gmtModified;
|
||||
|
||||
/**
|
||||
* 是否有效:0-无效 1-有效
|
||||
*/
|
||||
private int effectFlag;
|
||||
|
||||
/**
|
||||
* 子目录
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private List<Category> children = new ArrayList<>();
|
||||
}
|
||||
|
|
@ -0,0 +1,99 @@
|
|||
package com.electromagnetic.industry.software.manage.pojo.models;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@TableName("ed_data_info")
|
||||
@Data
|
||||
public class EDDataInfo {
|
||||
/**
|
||||
* 主键ID
|
||||
*/
|
||||
private Long id;
|
||||
/**
|
||||
* 目录编码
|
||||
*/
|
||||
private String categoryId;
|
||||
/**
|
||||
* 数据编码
|
||||
*/
|
||||
private String dataId;
|
||||
/**
|
||||
* 数据可视化码
|
||||
*/
|
||||
private String dataNo;
|
||||
/**
|
||||
* 数据名称
|
||||
*/
|
||||
private String dataName;
|
||||
/**
|
||||
* 数据类型:folder文件夹;file文件
|
||||
*/
|
||||
private String dataType;
|
||||
/**
|
||||
* 文件类型
|
||||
*/
|
||||
private String fileType;
|
||||
/**
|
||||
* 当前版本
|
||||
*/
|
||||
private String version;
|
||||
/**
|
||||
* 富文本内容
|
||||
*/
|
||||
private String content;
|
||||
/**
|
||||
* 文件地址JSON
|
||||
*/
|
||||
private String implantJson;
|
||||
/**
|
||||
* 状态:publish:发布,occupy:占用
|
||||
*/
|
||||
private String dataStatus;
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String note;
|
||||
/**
|
||||
* 编辑人
|
||||
*/
|
||||
private String editor;
|
||||
/**
|
||||
* 批量上传时间
|
||||
*/
|
||||
private Date gmtBatchUpload;
|
||||
/**
|
||||
* 保存状态
|
||||
*/
|
||||
private String saveStatus;
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
private String creator;
|
||||
/**
|
||||
* 创建人姓名
|
||||
*/
|
||||
private String creatorName;
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date gmtCreate;
|
||||
/**
|
||||
* 更新人
|
||||
*/
|
||||
private String modifier;
|
||||
/**
|
||||
* 更新人姓名
|
||||
*/
|
||||
private String modifierName;
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
private Date gmtModified;
|
||||
/**
|
||||
* 是否有效:0-无效 1-有效
|
||||
*/
|
||||
private Integer effectFlag;
|
||||
}
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
package com.electromagnetic.industry.software.manage.pojo.models;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
@TableName("tokens")
|
||||
public class Token {
|
||||
|
||||
/**
|
||||
* 主键ID
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 用户编码
|
||||
*/
|
||||
private String userId;
|
||||
|
||||
/**
|
||||
* 令牌
|
||||
*/
|
||||
private String token;
|
||||
|
||||
/**
|
||||
* 是否是长期令牌
|
||||
*/
|
||||
private int isLongTerm;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createdAt;
|
||||
|
||||
/**
|
||||
* 过期时间
|
||||
*/
|
||||
private Date expireAt;
|
||||
}
|
||||
|
|
@ -0,0 +1,107 @@
|
|||
package com.electromagnetic.industry.software.manage.pojo.models;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@TableName("ed_users")
|
||||
@Data
|
||||
public class User {
|
||||
|
||||
/**
|
||||
* 主键ID
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 用户编码
|
||||
*/
|
||||
private String userId;
|
||||
|
||||
/**
|
||||
* 用户姓名
|
||||
*/
|
||||
private String userName;
|
||||
|
||||
/**
|
||||
* 工号
|
||||
*/
|
||||
private String workNumber;
|
||||
|
||||
/**
|
||||
* 手机号
|
||||
*/
|
||||
private String mobile;
|
||||
|
||||
/**
|
||||
* 所属部门
|
||||
*/
|
||||
private String userDept;
|
||||
|
||||
/**
|
||||
* 职称
|
||||
*/
|
||||
private String userTitle;
|
||||
|
||||
/**
|
||||
* 登录密码
|
||||
*/
|
||||
private String userPwd;
|
||||
|
||||
/**
|
||||
* 入职日期
|
||||
*/
|
||||
private Date joinTime;
|
||||
|
||||
/**
|
||||
* 工作状态
|
||||
*/
|
||||
private String userStatus;
|
||||
|
||||
/**
|
||||
* 实习截止日期
|
||||
*/
|
||||
private Date internshipEndDate;
|
||||
|
||||
/**
|
||||
* 是否已发布
|
||||
*/
|
||||
private Integer isPublished;
|
||||
|
||||
/**
|
||||
* 盐
|
||||
*/
|
||||
private String salt;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
private String creator;
|
||||
|
||||
/**
|
||||
* 创建人姓名
|
||||
*/
|
||||
private String creatorName;
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date gmtCreate;
|
||||
/**
|
||||
* 更新人
|
||||
*/
|
||||
private String modifier;
|
||||
/**
|
||||
* 更新人姓名
|
||||
*/
|
||||
private String modifierName;
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
private Date gmtModified;
|
||||
|
||||
/**
|
||||
* 是否有效:0-无效 1-有效
|
||||
*/
|
||||
private Integer effectFlag;
|
||||
}
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
package com.electromagnetic.industry.software.manage.pojo.other;
|
||||
|
||||
import com.electromagnetic.industry.software.manage.pojo.models.EDDataInfo;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 分页综合返回
|
||||
* @author
|
||||
* @version $Id: IndicatorCardPage.java, v 0.1 2024-08-14 17:30
|
||||
*/
|
||||
@Data
|
||||
public class EDDataPage implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -6207631048120337133L;
|
||||
/**
|
||||
* 电磁数据-文件数据列表
|
||||
*/
|
||||
private PageInfo<EDDataInfo> edDataInfo;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,80 @@
|
|||
package com.electromagnetic.industry.software.manage.pojo.other;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
public class EDDataParams implements Serializable {
|
||||
private static final long serialVersionUID = -4835122199589863011L;
|
||||
/**
|
||||
* 当前页
|
||||
*/
|
||||
private Integer pageIndex = 1;
|
||||
/**
|
||||
* 每页数据
|
||||
*/
|
||||
private Integer pageSize = 10;
|
||||
/**
|
||||
* 操作用户id
|
||||
*/
|
||||
private String userId;
|
||||
/**
|
||||
* 用户名
|
||||
*/
|
||||
private String userName;
|
||||
/**
|
||||
* 上级文件夹数据码,为空是顶级
|
||||
*/
|
||||
private String parentId;
|
||||
/**
|
||||
* 文件数据编码
|
||||
*/
|
||||
private String dataId;
|
||||
/**
|
||||
* 文件夹名称
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
* 文件类型
|
||||
*/
|
||||
private String dataType;
|
||||
/**
|
||||
* 创建日期排序
|
||||
*/
|
||||
private String gmtCreate;
|
||||
/**
|
||||
* 文件数据状态
|
||||
*/
|
||||
private String dataStatus;
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String note;
|
||||
/**
|
||||
* 是否有效
|
||||
*/
|
||||
private String effectFlag;
|
||||
/**
|
||||
* 关键词
|
||||
*/
|
||||
private String keyWord;
|
||||
/**
|
||||
* 批量上传时间
|
||||
*/
|
||||
private Date gmtBatchUpload;
|
||||
/**
|
||||
* 保存状态
|
||||
*/
|
||||
private String saveStatus;
|
||||
/**
|
||||
* 文件数据编码数组
|
||||
*/
|
||||
private String[] dataIdArr;
|
||||
/**
|
||||
* 文件数据
|
||||
*/
|
||||
private MultipartFile fileData;
|
||||
}
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
package com.electromagnetic.industry.software.manage.pojo.other;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class PublishParam {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 用户编码
|
||||
*/
|
||||
private List<String> userIds;
|
||||
|
||||
/**
|
||||
* 编辑者
|
||||
*/
|
||||
private String modifier;
|
||||
|
||||
/**
|
||||
* 编辑者姓名
|
||||
*/
|
||||
private String modifierName;
|
||||
}
|
||||
|
|
@ -0,0 +1,46 @@
|
|||
package com.electromagnetic.industry.software.manage.pojo.other;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class SearchKeyWords {
|
||||
/**
|
||||
* 搜索关键词
|
||||
*/
|
||||
private String keyWord;
|
||||
|
||||
/**
|
||||
* 用户状态
|
||||
*/
|
||||
private String userStatus;
|
||||
|
||||
/**
|
||||
* 用户发布状态
|
||||
*/
|
||||
private String isPublished;
|
||||
|
||||
/**
|
||||
* 排序方式: "asc" 或 "desc" 或 “”
|
||||
*/
|
||||
private String gmtCreate;
|
||||
|
||||
/**
|
||||
* 排序方式: "asc" 或 "desc" 或 “”
|
||||
*/
|
||||
private String joinTime;
|
||||
|
||||
/**
|
||||
* 排序方式: "asc" 或 "desc" 或 “”
|
||||
*/
|
||||
private String internEndDate;
|
||||
|
||||
/**
|
||||
* 页码
|
||||
*/
|
||||
private int pageIndex;
|
||||
|
||||
/**
|
||||
* 单页条目数量
|
||||
*/
|
||||
private int pageSize;
|
||||
}
|
||||
|
|
@ -0,0 +1,110 @@
|
|||
package com.electromagnetic.industry.software.manage.pojo.other;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
public class SingleUserResponse {
|
||||
|
||||
private static final long serialVersionUID = -7475233976453471059L;
|
||||
|
||||
/**
|
||||
* 主键ID
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 用户编码
|
||||
*/
|
||||
private String userId;
|
||||
|
||||
/**
|
||||
* 用户姓名
|
||||
*/
|
||||
private String userName;
|
||||
|
||||
/**
|
||||
* 工号
|
||||
*/
|
||||
private String workNumber;
|
||||
|
||||
/**
|
||||
* 手机号
|
||||
*/
|
||||
private String mobile;
|
||||
|
||||
/**
|
||||
* 所属部门
|
||||
*/
|
||||
private String userDept;
|
||||
|
||||
/**
|
||||
* 职称
|
||||
*/
|
||||
private String userTitle;
|
||||
|
||||
/**
|
||||
* 登录密码
|
||||
*/
|
||||
private String userPwd;
|
||||
|
||||
/**
|
||||
* 入职日期
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
private Date joinTime;
|
||||
|
||||
/**
|
||||
* 工作状态
|
||||
*/
|
||||
private String userStatus;
|
||||
|
||||
/**
|
||||
* 实习截止日期
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
private Date internshipEndDate;
|
||||
|
||||
/**
|
||||
* 是否已发布
|
||||
*/
|
||||
private Integer isPublished;
|
||||
|
||||
/**
|
||||
* 盐
|
||||
*/
|
||||
private String salt;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
private String creator;
|
||||
|
||||
/**
|
||||
* 创建人姓名
|
||||
*/
|
||||
private String creatorName;
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date gmtCreate;
|
||||
/**
|
||||
* 更新人
|
||||
*/
|
||||
private String modifier;
|
||||
/**
|
||||
* 更新人姓名
|
||||
*/
|
||||
private String modifierName;
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
private Date gmtModified;
|
||||
|
||||
/**
|
||||
* 是否有效:0-无效 1-有效
|
||||
*/
|
||||
private Integer effectFlag;
|
||||
}
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
package com.electromagnetic.industry.software.manage.pojo.other;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class UserDeleteKeyWords {
|
||||
|
||||
/**
|
||||
* 主键ID
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 用户编码
|
||||
*/
|
||||
private String userId;
|
||||
|
||||
/**
|
||||
* 更新人
|
||||
*/
|
||||
private String modifier;
|
||||
/**
|
||||
* 更新人姓名
|
||||
*/
|
||||
private String modifierName;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,49 @@
|
|||
package com.electromagnetic.industry.software.manage.pojo.req;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
public class BaseRequest implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -9017146892952264211L;
|
||||
|
||||
/**
|
||||
* 操作用户id
|
||||
*/
|
||||
private String userId;
|
||||
|
||||
/**
|
||||
* 用户部门
|
||||
*/
|
||||
private String department;
|
||||
|
||||
/**
|
||||
* 用户名
|
||||
*/
|
||||
private String userName;
|
||||
|
||||
/**
|
||||
* 调用服务ip
|
||||
*/
|
||||
private String ip;
|
||||
|
||||
/**
|
||||
* 调用服务app name
|
||||
*/
|
||||
private String appName;
|
||||
/**
|
||||
*人员编码
|
||||
*/
|
||||
private String personNo;
|
||||
/**
|
||||
*人员姓名
|
||||
*/
|
||||
private String personName;
|
||||
/**
|
||||
* 权限码
|
||||
*/
|
||||
private String permissionCode;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,72 @@
|
|||
package com.electromagnetic.industry.software.manage.pojo.req;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
public class EDDataRequest extends BaseRequest implements Serializable {
|
||||
|
||||
/**
|
||||
* 当前页
|
||||
*/
|
||||
private Integer pageIndex = 1;
|
||||
/**
|
||||
* 每页数据
|
||||
*/
|
||||
private Integer pageSize = 10;
|
||||
/**
|
||||
* 上级文件夹数据码,为空是顶级
|
||||
*/
|
||||
private String parentId;
|
||||
/**
|
||||
* 文件数据编码
|
||||
*/
|
||||
private String dataId;
|
||||
/**
|
||||
* 文件夹名称
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
* 文件类型
|
||||
*/
|
||||
private String dataType;
|
||||
/**
|
||||
* 创建日期排序
|
||||
*/
|
||||
private String gmtCreate;
|
||||
/**
|
||||
* 文件数据状态
|
||||
*/
|
||||
private String dataStatus;
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String note;
|
||||
/**
|
||||
* 是否有效
|
||||
*/
|
||||
private String effectFlag;
|
||||
/**
|
||||
* 关键词
|
||||
*/
|
||||
private String keyWord;
|
||||
/**
|
||||
* 批量上传时间
|
||||
*/
|
||||
private Date gmtBatchUpload;
|
||||
/**
|
||||
* 保存状态
|
||||
*/
|
||||
private String saveStatus;
|
||||
/**
|
||||
* 文件数据编码数组
|
||||
*/
|
||||
private String[] dataIdArr;
|
||||
/**
|
||||
* 文件数据
|
||||
*/
|
||||
private MultipartFile fileData;
|
||||
}
|
||||
|
|
@ -0,0 +1,100 @@
|
|||
package com.electromagnetic.industry.software.manage.pojo.req;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
public class EDDataResponse implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -4835122199589863011L;
|
||||
/**
|
||||
* 主键ID
|
||||
*/
|
||||
private Long id;
|
||||
/**
|
||||
* 目录编码
|
||||
*/
|
||||
private String categoryId;
|
||||
/**
|
||||
* 数据编码
|
||||
*/
|
||||
private String dataId;
|
||||
/**
|
||||
* 数据可视化码
|
||||
*/
|
||||
private String dataNo;
|
||||
/**
|
||||
* 数据名称
|
||||
*/
|
||||
private String dataName;
|
||||
/**
|
||||
* 数据类型:folder文件夹;file文件
|
||||
*/
|
||||
private String dataType;
|
||||
/**
|
||||
* 文件类型
|
||||
*/
|
||||
private String fileType;
|
||||
/**
|
||||
* 当前版本
|
||||
*/
|
||||
private String version;
|
||||
/**
|
||||
* 富文本内容
|
||||
*/
|
||||
private String content;
|
||||
/**
|
||||
* 文件地址JSON
|
||||
*/
|
||||
private String implantJson;
|
||||
/**
|
||||
* 状态:publish:发布,occupy:占用
|
||||
*/
|
||||
private String dataStatus;
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String note;
|
||||
/**
|
||||
* 编辑人
|
||||
*/
|
||||
private String editor;
|
||||
/**
|
||||
* 批量上传时间
|
||||
*/
|
||||
private Date gmtBatchUpload;
|
||||
/**
|
||||
* 保存状态
|
||||
*/
|
||||
private String saveStatus;
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
private String creator;
|
||||
/**
|
||||
* 创建人姓名
|
||||
*/
|
||||
private String creatorName;
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date gmtCreate;
|
||||
/**
|
||||
* 更新人
|
||||
*/
|
||||
private String modifier;
|
||||
/**
|
||||
* 更新人姓名
|
||||
*/
|
||||
private String modifierName;
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
private Date gmtModified;
|
||||
/**
|
||||
* 是否有效:0-无效 1-有效
|
||||
*/
|
||||
private Integer effectFlag;
|
||||
}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
package com.electromagnetic.industry.software.manage.pojo.req;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
@Data
|
||||
public class FileChunkDTO {
|
||||
|
||||
private String identifier;
|
||||
private long totalSize;
|
||||
private MultipartFile file;
|
||||
private String fileName;
|
||||
private Integer chunkNumber;
|
||||
private Long chunkSize;
|
||||
private Long currentChunkSize;
|
||||
private Integer totalChunks;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
package com.electromagnetic.industry.software.manage.pojo.req;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class FileChunkResultDTO {
|
||||
private Boolean skipUpload;
|
||||
private Set<Integer> uploaded;
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
package com.electromagnetic.industry.software.manage.pojo.req;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
public class GetSingleUserRequest extends BaseRequest implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 用户编码
|
||||
*/
|
||||
private String userId;
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,51 @@
|
|||
package com.electromagnetic.industry.software.manage.pojo.req;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
public class SearchUserRequest extends BaseRequest implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 搜索关键词
|
||||
*/
|
||||
private String keyWord;
|
||||
|
||||
/**
|
||||
* 用户状态
|
||||
*/
|
||||
private String userStatus;
|
||||
|
||||
/**
|
||||
* 用户发布状态,1已发布,0未发布
|
||||
*/
|
||||
private String isPublished;
|
||||
|
||||
/**
|
||||
* 排序方式: "asc" 或 "desc" 或 “”
|
||||
*/
|
||||
private String gmtCreate;
|
||||
|
||||
/**
|
||||
* 排序方式: "asc" 或 "desc" 或 “”
|
||||
*/
|
||||
private String joinTime;
|
||||
|
||||
/**
|
||||
* 排序方式: "asc" 或 "desc" 或 “”
|
||||
*/
|
||||
private String internEndDate;
|
||||
|
||||
/**
|
||||
* 页码
|
||||
*/
|
||||
private int pageIndex;
|
||||
|
||||
/**
|
||||
* 单页条目数量
|
||||
*/
|
||||
private int pageSize;
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
package com.electromagnetic.industry.software.manage.pojo.req;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
public class UserDeleteRequest extends BaseRequest implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 用户编码
|
||||
*/
|
||||
private String userId;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
package com.electromagnetic.industry.software.manage.pojo.req;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
public class UserLoginRequest extends BaseRequest implements Serializable {
|
||||
|
||||
/**
|
||||
* 工号
|
||||
*/
|
||||
private String workNumber;
|
||||
|
||||
/**
|
||||
* 用户密码
|
||||
*/
|
||||
private String userPwd;
|
||||
}
|
||||
|
|
@ -0,0 +1,60 @@
|
|||
package com.electromagnetic.industry.software.manage.pojo.req;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
public class UserModiRequest extends BaseRequest implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 用户Id
|
||||
*/
|
||||
private String userId;
|
||||
|
||||
/**
|
||||
* 用户姓名
|
||||
*/
|
||||
private String userName;
|
||||
|
||||
/**
|
||||
* 工号
|
||||
*/
|
||||
private String workNumber;
|
||||
|
||||
/**
|
||||
* 手机号
|
||||
*/
|
||||
private String mobile;
|
||||
|
||||
/**
|
||||
* 所属部门
|
||||
*/
|
||||
private String userDept;
|
||||
|
||||
/**
|
||||
* 职称
|
||||
*/
|
||||
private String userTitle;
|
||||
|
||||
/**
|
||||
* 入职日期
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
private Date joinTime;
|
||||
|
||||
/**
|
||||
* 工作状态
|
||||
*/
|
||||
private String userStatus;
|
||||
|
||||
/**
|
||||
* 实习截止日期
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
private Date internshipEndDate;
|
||||
}
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
package com.electromagnetic.industry.software.manage.pojo.req;
|
||||
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class UserPublishRequest extends BaseRequest implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 用户编码
|
||||
*/
|
||||
private List<String> userIds;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
package com.electromagnetic.industry.software.manage.pojo.req;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
public class UserRequest extends BaseRequest implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 用户姓名
|
||||
*/
|
||||
private String userName;
|
||||
|
||||
/**
|
||||
* 工号
|
||||
*/
|
||||
private String workNumber;
|
||||
|
||||
/**
|
||||
* 手机号
|
||||
*/
|
||||
private String mobile;
|
||||
|
||||
/**
|
||||
* 所属部门
|
||||
*/
|
||||
private String userDept;
|
||||
|
||||
/**
|
||||
* 职称
|
||||
*/
|
||||
private String userTitle;
|
||||
|
||||
/**
|
||||
* 入职日期
|
||||
*/
|
||||
@JsonFormat(pattern="yyyy-MM-dd")
|
||||
private Date joinTime;
|
||||
|
||||
/**
|
||||
* 工作状态
|
||||
*/
|
||||
private String userStatus;
|
||||
|
||||
/**
|
||||
* 实习截止日期
|
||||
*/
|
||||
@JsonFormat(pattern="yyyy-MM-dd")
|
||||
private Date internshipEndDate;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
package com.electromagnetic.industry.software.manage.pojo.req;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
public class UserWorkNumRequest extends BaseRequest implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
/**
|
||||
* 工号
|
||||
*/
|
||||
private String workNumber;
|
||||
|
||||
/**
|
||||
* 用户编号
|
||||
*/
|
||||
private String userID;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
package com.electromagnetic.industry.software.manage.pojo.resp;
|
||||
|
||||
import com.electromagnetic.industry.software.manage.pojo.req.EDDataResponse;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
public class EDDataPageResponse implements Serializable {
|
||||
private static final long serialVersionUID = 3464355768912308150L;
|
||||
/**
|
||||
* 指电磁数据-文件信息数据
|
||||
*/
|
||||
private PageInfo<EDDataResponse> edDataInfo;
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
package com.electromagnetic.industry.software.manage.pojo.resp;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
public class UserLoginResponse implements Serializable {
|
||||
|
||||
private String token;
|
||||
|
||||
private String userId;
|
||||
}
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
package com.electromagnetic.industry.software.manage.pojo.resp;
|
||||
|
||||
import com.electromagnetic.industry.software.manage.pojo.other.SingleUserResponse;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class UserSearchResponse implements Serializable {
|
||||
private static final long serialVersionUID = -7475233976453471059L;
|
||||
|
||||
/**
|
||||
* 用户列表
|
||||
*/
|
||||
private List<SingleUserResponse> userList;
|
||||
|
||||
|
||||
/**
|
||||
* 总数据数
|
||||
*/
|
||||
private long totalCount;
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
package com.electromagnetic.industry.software.manage.service;
|
||||
|
||||
import com.electromagnetic.industry.software.common.resp.ElectromagneticResult;
|
||||
|
||||
public interface CategoryService {
|
||||
|
||||
ElectromagneticResult<?> getAllCategories();
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,99 @@
|
|||
package com.electromagnetic.industry.software.manage.service;
|
||||
|
||||
import com.electromagnetic.industry.software.common.resp.ElectromagneticResult;
|
||||
import com.electromagnetic.industry.software.manage.pojo.req.EDDataRequest;
|
||||
import com.electromagnetic.industry.software.manage.pojo.req.FileChunkDTO;
|
||||
import com.electromagnetic.industry.software.manage.pojo.req.FileChunkResultDTO;
|
||||
import com.electromagnetic.industry.software.manage.pojo.resp.EDDataPageResponse;
|
||||
import org.springframework.core.io.InputStreamResource;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface EDDataService {
|
||||
/**
|
||||
* 创建文件夹
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
ElectromagneticResult<Boolean> createFolder(EDDataRequest request);
|
||||
|
||||
|
||||
/**
|
||||
* 获取文件信息列表
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
ElectromagneticResult<EDDataPageResponse> getDataInfoList(EDDataRequest request);
|
||||
|
||||
/**
|
||||
* 更新文件信息
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
ElectromagneticResult<Boolean> updateFileInfo(EDDataRequest request);
|
||||
|
||||
/**
|
||||
* 获取子文件数量
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
ElectromagneticResult<Map<String, Integer>> getChildFileCount(EDDataRequest request);
|
||||
|
||||
/**
|
||||
* 上传
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
ElectromagneticResult<Boolean> uploadFile(EDDataRequest request);
|
||||
|
||||
/**
|
||||
* 下载
|
||||
*
|
||||
* @param dataId
|
||||
* @return
|
||||
*/
|
||||
ResponseEntity<InputStreamResource> download(String dataId, HttpServletResponse response) throws IOException;
|
||||
|
||||
/**
|
||||
* 导出数据
|
||||
* @param dataIdArr
|
||||
* @return
|
||||
*/
|
||||
ResponseEntity<InputStreamResource> batchExport(String dataIdArr, HttpServletResponse response) throws IOException;
|
||||
|
||||
/**
|
||||
* 导入数据
|
||||
* @param fileChunkDTO
|
||||
* @return
|
||||
*/
|
||||
ElectromagneticResult<?> batchImport(FileChunkDTO fileChunkDTO);
|
||||
|
||||
/**
|
||||
* 获取已经上传的分片
|
||||
* @param identifier
|
||||
* @return
|
||||
*/
|
||||
ElectromagneticResult<List<Integer>> getUploadedChunkNums(String identifier);
|
||||
|
||||
|
||||
/**
|
||||
* 合并分片
|
||||
* @param identifier
|
||||
* @param fileName
|
||||
* @param totalChunks
|
||||
* @return
|
||||
*/
|
||||
ElectromagneticResult<?> mergeChunks(String identifier, String fileName, Integer totalChunks);
|
||||
|
||||
|
||||
/**
|
||||
* 检查分片是否存在
|
||||
* @param fileChunkDTO
|
||||
* @return
|
||||
*/
|
||||
ElectromagneticResult<FileChunkResultDTO> checkChunkExist(FileChunkDTO fileChunkDTO);
|
||||
}
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
package com.electromagnetic.industry.software.manage.service;
|
||||
|
||||
|
||||
import com.electromagnetic.industry.software.common.pojo.UserLoginInfo;
|
||||
import com.electromagnetic.industry.software.manage.pojo.models.User;
|
||||
|
||||
public interface TokenService {
|
||||
|
||||
/**
|
||||
* 创建令牌
|
||||
* @param loginInfo
|
||||
* @return 令牌
|
||||
*/
|
||||
String createToken(UserLoginInfo loginInfo);
|
||||
|
||||
/**
|
||||
* 创建用户令牌
|
||||
* @param user
|
||||
* @param tokenStr
|
||||
* @return
|
||||
*/
|
||||
Boolean createUserToken(User user, String tokenStr);
|
||||
|
||||
/**
|
||||
* 查看token是否有效
|
||||
*/
|
||||
Boolean isTokenValid(String tokenStr);
|
||||
|
||||
/**
|
||||
* 删除token
|
||||
*/
|
||||
int deleteToken(String tokenStr);
|
||||
}
|
||||
|
|
@ -0,0 +1,72 @@
|
|||
package com.electromagnetic.industry.software.manage.service;
|
||||
|
||||
import com.electromagnetic.industry.software.common.resp.ElectromagneticResult;
|
||||
import com.electromagnetic.industry.software.manage.pojo.req.*;
|
||||
|
||||
public interface UserService {
|
||||
|
||||
/**
|
||||
* 用户登录
|
||||
* @param loginRequest
|
||||
* @return
|
||||
*/
|
||||
ElectromagneticResult<?> login(UserLoginRequest loginRequest);
|
||||
|
||||
/**
|
||||
* 新增用户信息
|
||||
* @param userRequest
|
||||
* @return
|
||||
*/
|
||||
ElectromagneticResult<?> createUser(UserRequest userRequest);
|
||||
|
||||
/**
|
||||
* 编辑用户信息
|
||||
* @param userModiRequest
|
||||
* @return
|
||||
*/
|
||||
ElectromagneticResult<?> modifyUser(UserModiRequest userModiRequest);
|
||||
|
||||
|
||||
/**
|
||||
* 发布用户
|
||||
* @param userPublishRequest
|
||||
* @return
|
||||
*/
|
||||
ElectromagneticResult<?> publishUser(UserPublishRequest userPublishRequest);
|
||||
|
||||
/**
|
||||
* 校验工号唯一性
|
||||
* @param workNumberRequest
|
||||
* @return
|
||||
*/
|
||||
ElectromagneticResult<?> validateWorkNum(UserWorkNumRequest workNumberRequest);
|
||||
|
||||
/**
|
||||
* 通过用户编码获取单条用户信息
|
||||
* @param getSingleUserRequest
|
||||
* @return
|
||||
*/
|
||||
ElectromagneticResult<?> getSingleUser(GetSingleUserRequest getSingleUserRequest);
|
||||
|
||||
/**
|
||||
* 查询用户信息
|
||||
* @param searchUserRequest
|
||||
* @return
|
||||
*/
|
||||
ElectromagneticResult<?> searchUser(SearchUserRequest searchUserRequest);
|
||||
|
||||
/**
|
||||
* 刪除用戶(逻辑删除)
|
||||
* @param userDeleteRequest
|
||||
* @return
|
||||
*/
|
||||
ElectromagneticResult<?> deleteUser(UserDeleteRequest userDeleteRequest);
|
||||
|
||||
/**
|
||||
* 用户登出
|
||||
* @param token
|
||||
* @return
|
||||
*/
|
||||
ElectromagneticResult<?> logout(String token);
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,82 @@
|
|||
package com.electromagnetic.industry.software.manage.service.serviceimpl;
|
||||
|
||||
import com.electromagnetic.industry.software.common.resp.ElectromagneticResult;
|
||||
import com.electromagnetic.industry.software.common.util.ElectromagneticResultUtil;
|
||||
import com.electromagnetic.industry.software.manage.mapper.CategoryMapper;
|
||||
import com.electromagnetic.industry.software.manage.pojo.models.Category;
|
||||
import com.electromagnetic.industry.software.manage.service.CategoryService;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
public class CategoryServiceImpl implements CategoryService {
|
||||
|
||||
@Resource
|
||||
private CategoryMapper categoryMapper;
|
||||
|
||||
@Override
|
||||
public ElectromagneticResult<?> getAllCategories() {
|
||||
List<Category> categories = categoryMapper.selectAllCategories();
|
||||
List<Category> returnList = new ArrayList<>();
|
||||
List<String> tempList = categories.stream().map(Category::getCategoryId).collect(Collectors.toList());
|
||||
for (Category category : categories) {
|
||||
if (!tempList.contains(category.getParentId())) {
|
||||
recursionFn(categories, category);
|
||||
returnList.add(category);
|
||||
}
|
||||
}
|
||||
if (returnList.isEmpty()) {
|
||||
returnList = categories;
|
||||
}
|
||||
return ElectromagneticResultUtil.success(returnList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 递归列表
|
||||
* @param list
|
||||
* @param category
|
||||
*/
|
||||
private void recursionFn (List<Category> list, Category category) {
|
||||
List<Category> childList = getChildList(list, category);
|
||||
category.setChildren(childList);
|
||||
for (Category child : childList) {
|
||||
if (hasChild(list, child)) {
|
||||
recursionFn(list, child);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 得到子节点列表
|
||||
* @param list
|
||||
* @param category
|
||||
* @return
|
||||
*/
|
||||
private List<Category> getChildList(List<Category> list, Category category) {
|
||||
List<Category> childList = new ArrayList<>();
|
||||
Iterator<Category> it = list.iterator();
|
||||
while (it.hasNext()) {
|
||||
Category child = it.next();
|
||||
if (!StringUtils.isEmpty(child.getParentId()) && child.getParentId().equals(category.getCategoryId())) {
|
||||
childList.add(child);
|
||||
}
|
||||
}
|
||||
return childList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断是否有子节点
|
||||
* @param list
|
||||
* @param category
|
||||
* @return
|
||||
*/
|
||||
private boolean hasChild(List<Category> list, Category category) {
|
||||
return !getChildList(list, category).isEmpty();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,923 @@
|
|||
package com.electromagnetic.industry.software.manage.service.serviceimpl;
|
||||
|
||||
import cn.hutool.core.codec.Base64;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.io.IoUtil;
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.core.util.ZipUtil;
|
||||
import cn.hutool.crypto.SecureUtil;
|
||||
import cn.hutool.crypto.symmetric.AES;
|
||||
import cn.hutool.json.JSONArray;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.electromagnetic.industry.software.common.cons.ElectromagneticConstants;
|
||||
import com.electromagnetic.industry.software.common.resp.ElectromagneticResult;
|
||||
import com.electromagnetic.industry.software.common.util.EleCommonUtil;
|
||||
import com.electromagnetic.industry.software.common.util.ElectromagneticResultUtil;
|
||||
import com.electromagnetic.industry.software.common.util.IdWorker;
|
||||
import com.electromagnetic.industry.software.common.util.UserThreadLocal;
|
||||
import com.electromagnetic.industry.software.manage.mapper.CategoryMapper;
|
||||
import com.electromagnetic.industry.software.manage.mapper.EDDataMapper;
|
||||
import com.electromagnetic.industry.software.manage.mapper.EDDataMappers;
|
||||
import com.electromagnetic.industry.software.manage.pojo.models.Category;
|
||||
import com.electromagnetic.industry.software.manage.pojo.models.EDDataInfo;
|
||||
import com.electromagnetic.industry.software.manage.pojo.other.EDDataPage;
|
||||
import com.electromagnetic.industry.software.manage.pojo.other.EDDataParams;
|
||||
import com.electromagnetic.industry.software.manage.pojo.req.EDDataRequest;
|
||||
import com.electromagnetic.industry.software.manage.pojo.req.FileChunkDTO;
|
||||
import com.electromagnetic.industry.software.manage.pojo.req.FileChunkResultDTO;
|
||||
import com.electromagnetic.industry.software.manage.pojo.resp.EDDataPageResponse;
|
||||
import com.electromagnetic.industry.software.manage.service.EDDataService;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.core.io.FileSystemResource;
|
||||
import org.springframework.core.io.InputStreamResource;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.*;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
public class EDDataServiceImpl implements EDDataService {
|
||||
|
||||
@Resource
|
||||
private EDDataMapper edDataMapper;
|
||||
@Resource
|
||||
private CategoryMapper categoryMapper;
|
||||
|
||||
|
||||
@Value("${data.windows.path}")
|
||||
private String uploadFilePath;
|
||||
|
||||
@Value("${data.file.storage.dir}")
|
||||
private String fileStorageDir;
|
||||
|
||||
@Value("${data.import.cache.dir}")
|
||||
private String importCacheDir;
|
||||
|
||||
@Value("${file.encode.passwd}")
|
||||
private String encodePasswd;
|
||||
|
||||
@Value("${data.type.folder}")
|
||||
private String dataTypeFolder;
|
||||
|
||||
@Value("${data.windows.path}")
|
||||
private String windowsDir;
|
||||
@Value("${data.file.cache.dir}")
|
||||
private String fileCacheDir;
|
||||
@Value("${data.upload.cache.dir}")
|
||||
private String uploadCacheDir;
|
||||
@Value("${data.export.cache.dir}")
|
||||
private String exportCacheDir;
|
||||
@Value("${data.type.file}")
|
||||
private String dataTypeFile;
|
||||
|
||||
private static final String UPLOAD_FILE_CHUNK_SUFFIX = ".part";
|
||||
// 文件夹名称分隔符
|
||||
private static final String FOLDER_NAME_SEPARATOR = "_";
|
||||
|
||||
|
||||
@Override
|
||||
public ElectromagneticResult<Boolean> createFolder(EDDataRequest request) {
|
||||
|
||||
EDDataInfo edDataInfo = EDDataMappers.INSTANCE.getEDDataInfo(request);
|
||||
|
||||
edDataInfo.setCreator(UserThreadLocal.getUserId());
|
||||
edDataInfo.setCreatorName(UserThreadLocal.getUsername());
|
||||
edDataInfo.setModifier(UserThreadLocal.getUserId());
|
||||
edDataInfo.setModifierName(UserThreadLocal.getUsername());
|
||||
edDataInfo.setCategoryId(request.getParentId());
|
||||
edDataInfo.setDataName(request.getName());
|
||||
edDataInfo.setNote(request.getNote());
|
||||
edDataInfo.setGmtBatchUpload(new Date());
|
||||
|
||||
edDataInfo.setDataId(IdWorker.getSnowFlakeIdString());
|
||||
edDataInfo.setDataNo(edDataInfo.getDataId());
|
||||
edDataInfo.setDataType(dataTypeFolder);
|
||||
edDataInfo.setVersion("1.0.0");
|
||||
edDataInfo.setDataStatus("publish");
|
||||
edDataInfo.setSaveStatus("success");
|
||||
|
||||
try {
|
||||
return ElectromagneticResultUtil.success(createDataInfo(edDataInfo));
|
||||
} catch (Exception e) {
|
||||
log.error("创建文件夹失败。。。", e);
|
||||
return ElectromagneticResultUtil.fail("500", e.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public Boolean createDataInfo(EDDataInfo edDataInfo) throws Exception
|
||||
{
|
||||
// 获取上级目录的名称
|
||||
String fileName = edDataInfo.getDataName();
|
||||
Assert.isTrue(EleCommonUtil.isFileNameValid(fileName), "文件名不符合规范,只能包含中文字符、下划线、连字符、加号、数字和英文字符且长度小于32。");
|
||||
|
||||
Category categoryParent = new Category();
|
||||
categoryParent.setCategoryId(edDataInfo.getCategoryId());
|
||||
List<Category> categoryParentList = categoryMapper.selectCategories(categoryParent);
|
||||
|
||||
if(categoryParentList.size() < 1) {
|
||||
throw new Exception("上级文件夹不存在");
|
||||
}
|
||||
else
|
||||
{
|
||||
// 获取新文件夹路径信息
|
||||
categoryParent = categoryParentList.get(0);
|
||||
|
||||
String dataStoragePath = getDataStoragePath();
|
||||
String folderParent = categoryParent.getCategoryId() + FOLDER_NAME_SEPARATOR + categoryParent.getCategoryName() ;
|
||||
String folderNew = dataStoragePath + File.separator + folderParent + File.separator + edDataInfo.getDataName();
|
||||
|
||||
// 判断文件夹名称是否存在
|
||||
EDDataParams folderParames = new EDDataParams();
|
||||
folderParames.setParentId(edDataInfo.getCategoryId());
|
||||
List<EDDataInfo> childFileInfoList = edDataMapper.getDataInfoList(folderParames);
|
||||
for(EDDataInfo fileInfo : childFileInfoList)
|
||||
{
|
||||
if(fileInfo.getDataName().equals(edDataInfo.getDataName())){
|
||||
throw new Exception("文件夹已存在");
|
||||
}
|
||||
}
|
||||
|
||||
// 将文件夹数据写到数据库中
|
||||
if(edDataMapper.createDataInfo(edDataInfo)) {
|
||||
if (!FileUtil.exist(folderNew)){
|
||||
FileUtil.mkdir(folderNew);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取数据存储目录
|
||||
* @return
|
||||
*/
|
||||
public String getDataStoragePath() {
|
||||
String osName = System.getProperty("os.name").toLowerCase();
|
||||
return osName.startsWith("win") ? windowsDir + fileStorageDir : fileStorageDir;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ElectromagneticResult<EDDataPageResponse> getDataInfoList(EDDataRequest request) {
|
||||
EDDataParams parames= EDDataMappers.INSTANCE.getEDDataParames(request);
|
||||
//获取中支指标配置列表
|
||||
PageHelper.startPage(parames.getPageIndex(), parames.getPageSize());
|
||||
List<EDDataInfo> edDataInfoList = edDataMapper.getDataInfoList(parames);
|
||||
PageInfo<EDDataInfo> pageInfo = new PageInfo<>(edDataInfoList);
|
||||
EDDataPage edDataPage = new EDDataPage();
|
||||
edDataPage.setEdDataInfo(pageInfo);
|
||||
//模型转换
|
||||
EDDataPageResponse edDataPageResponse = EDDataMappers.INSTANCE.getEDDataInfoToModel(edDataPage);
|
||||
return ElectromagneticResultUtil.success(edDataPageResponse);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ElectromagneticResult<Boolean> updateFileInfo(EDDataRequest request) {
|
||||
|
||||
try {
|
||||
EDDataParams parames = EDDataMappers.INSTANCE.getEDDataParames(request);
|
||||
parames.setUserId(UserThreadLocal.getUserId());
|
||||
parames.setUserName(UserThreadLocal.getUsername());
|
||||
return ElectromagneticResultUtil.success(updateFileInfo(parames));
|
||||
} catch (Exception e) {
|
||||
log.error("文件信息更新失败。。。", e);
|
||||
return ElectromagneticResultUtil.fail("500", e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public Boolean updateFileInfo(EDDataParams parames) throws Exception {
|
||||
|
||||
String dataStoragePath = getDataStoragePath();
|
||||
if (!FileUtil.exist(dataStoragePath)){
|
||||
throw new Exception("数据存储文件夹不存在");
|
||||
}
|
||||
|
||||
EDDataParams paramesFind = new EDDataParams();
|
||||
paramesFind.setDataId(parames.getDataId());
|
||||
List<EDDataInfo> edDataInfoList = edDataMapper.getDataInfoList(paramesFind);
|
||||
if(edDataInfoList.size() < 1) {
|
||||
throw new Exception("文件信息不存在");
|
||||
}
|
||||
|
||||
EDDataInfo edDataInfo = edDataInfoList.get(0);
|
||||
String filePathOfFolder = getFilePathOfFolder(edDataInfo.getCategoryId());
|
||||
String fileType = StrUtil.isEmpty(edDataInfo.getFileType()) ? "" : "." + edDataInfo.getFileType();
|
||||
String fileStorageFullPath = dataStoragePath + filePathOfFolder + File.separator + edDataInfo.getDataName() + fileType;
|
||||
|
||||
if (!FileUtil.exist(fileStorageFullPath)){
|
||||
throw new Exception("文件不存在");
|
||||
}
|
||||
|
||||
String fileNameNew = parames.getName() + fileType;
|
||||
if(fileNameNew != null && fileNameNew != "" && !fileNameNew.equals(edDataInfo.getDataName())) {
|
||||
FileUtil.rename(Paths.get(fileStorageFullPath) ,fileNameNew,true);
|
||||
}
|
||||
|
||||
// 修改文件夹
|
||||
edDataMapper.updateFileInfo(parames);
|
||||
// 修改文件夹中的文件
|
||||
if(edDataInfo.getDataType().equals(dataTypeFolder) && parames.getEffectFlag() != null) {
|
||||
EDDataParams paramesChild = new EDDataParams();
|
||||
paramesChild.setParentId(edDataInfo.getDataId());
|
||||
paramesChild.setEffectFlag(parames.getEffectFlag());
|
||||
edDataMapper.updateFileInfo(paramesChild);
|
||||
}
|
||||
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
|
||||
public String getFilePathOfFolder(String categoryId) {
|
||||
String filePathOfFolder = ""; //文件存放在文件夹的路径
|
||||
|
||||
String categoryIdHighest = categoryId; //最高级的目录编码
|
||||
EDDataParams folderParames = new EDDataParams();
|
||||
folderParames.setDataId(categoryId);
|
||||
List<EDDataInfo> edDataInfoList = edDataMapper.getDataInfoList(folderParames);
|
||||
EDDataInfo edDataInfoParent = null;
|
||||
if(CollUtil.isNotEmpty(edDataInfoList)) {
|
||||
categoryIdHighest = edDataInfoList.get(0).getCategoryId();
|
||||
edDataInfoParent = edDataInfoList.get(0);
|
||||
}
|
||||
Category categoryParent = new Category();
|
||||
categoryParent.setCategoryId(categoryIdHighest);
|
||||
List<Category> categoryParentList = categoryMapper.selectCategories(categoryParent);
|
||||
if(categoryParentList.size() > 0){
|
||||
categoryParent = categoryParentList.get(0);
|
||||
filePathOfFolder = categoryParent.getCategoryId() + FOLDER_NAME_SEPARATOR + categoryParent.getCategoryName();
|
||||
if(edDataInfoParent != null) {
|
||||
String fileType = StrUtil.isEmpty(edDataInfoParent.getFileType()) ? "" : "." + edDataInfoParent.getFileType();
|
||||
filePathOfFolder = filePathOfFolder + File.separator + edDataInfoParent.getDataName() + fileType;
|
||||
}
|
||||
}
|
||||
|
||||
return filePathOfFolder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ElectromagneticResult<Map<String, Integer>> getChildFileCount(EDDataRequest request) {
|
||||
EDDataParams parames= EDDataMappers.INSTANCE.getEDDataParames(request);
|
||||
Integer fileCount = getChildFileCount(parames);
|
||||
Map<String, Integer> result = new HashMap<>();
|
||||
result.put("fileCount", fileCount);
|
||||
return ElectromagneticResultUtil.success(result);
|
||||
}
|
||||
|
||||
public Integer getChildFileCount(EDDataParams parames) {
|
||||
Integer childFileCount = 0;
|
||||
|
||||
List<EDDataInfo> edDataInfoList = edDataMapper.getDataInfoList(parames);
|
||||
parames.setDataId(null);
|
||||
for (EDDataInfo edDataInfo : edDataInfoList) {
|
||||
if(edDataInfo.getDataType().equals(dataTypeFolder))
|
||||
{
|
||||
parames.setParentId(edDataInfo.getDataId());
|
||||
childFileCount += getChildFileCount(parames);
|
||||
}
|
||||
else if(edDataInfo.getDataType().equals(dataTypeFile) && edDataInfo.getEffectFlag().equals(1))
|
||||
{
|
||||
++childFileCount;
|
||||
}
|
||||
}
|
||||
|
||||
return childFileCount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ElectromagneticResult<Boolean> uploadFile(EDDataRequest request) {
|
||||
try {
|
||||
EDDataParams parames= EDDataMappers.INSTANCE.getEDDataParames(request);
|
||||
parames.setUserId(UserThreadLocal.getUserId());
|
||||
parames.setUserName(UserThreadLocal.getUsername());
|
||||
return ElectromagneticResultUtil.success(upload(parames));
|
||||
} catch (Exception e) {
|
||||
log.error("上传文件失败。。。", e);
|
||||
return ElectromagneticResultUtil.fail("500", e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private Boolean upload(EDDataParams parames) throws Exception {
|
||||
// 获取目录编码ID
|
||||
String categoryId = parames.getParentId();
|
||||
|
||||
// 获取要上传的文件
|
||||
MultipartFile fileInput = parames.getFileData();
|
||||
|
||||
// 检查文件是否为空
|
||||
if (fileInput == null || fileInput.isEmpty()) {
|
||||
throw new Exception("上传的文件为空");
|
||||
}
|
||||
|
||||
// 获取文件名
|
||||
String fileFullName = fileInput.getOriginalFilename();
|
||||
// 获取文件类型
|
||||
String fileType = EleCommonUtil.getFileType(fileFullName);
|
||||
// 获取文件名称
|
||||
String fileName = EleCommonUtil.getFileName(fileFullName);
|
||||
Assert.isTrue(EleCommonUtil.isFileNameValid(fileName), "文件名不符合规范,只能包含中文字符、下划线、连字符、加号、数字和英文字符且长度小于32。");
|
||||
// 判断文件名称是否存在
|
||||
EDDataParams folderParames = new EDDataParams();
|
||||
folderParames.setParentId(categoryId);
|
||||
List<EDDataInfo> childFileInfoList = edDataMapper.getDataInfoList(folderParames);
|
||||
for(EDDataInfo fileInfo : childFileInfoList)
|
||||
{
|
||||
if(fileInfo.getDataName().equals(fileFullName)){
|
||||
throw new Exception("上传的文件已存在");
|
||||
}
|
||||
}
|
||||
|
||||
String dataStoragePath = getDataStoragePath();
|
||||
if (!FileUtil.exist(dataStoragePath)){
|
||||
FileUtil.mkdir(dataStoragePath);
|
||||
}
|
||||
|
||||
//获取文件存放在文件夹的路径
|
||||
String filePathOfFolder = getFilePathOfFolder(categoryId);
|
||||
|
||||
// 将文件数据信息写到数据库
|
||||
EDDataInfo edDataInfo = new EDDataInfo();
|
||||
|
||||
|
||||
// 创建新文件数据
|
||||
edDataInfo.setCreator(parames.getUserId());
|
||||
edDataInfo.setCreatorName(parames.getUserName());
|
||||
edDataInfo.setModifier(parames.getUserId());
|
||||
edDataInfo.setModifierName(parames.getUserName());
|
||||
edDataInfo.setCategoryId(parames.getParentId());
|
||||
edDataInfo.setDataName(fileName);
|
||||
edDataInfo.setNote(parames.getNote());
|
||||
edDataInfo.setFileType(fileType);
|
||||
edDataInfo.setGmtBatchUpload(parames.getGmtBatchUpload());
|
||||
|
||||
edDataInfo.setDataId(IdWorker.getSnowFlakeIdString());
|
||||
edDataInfo.setDataNo(edDataInfo.getDataId());
|
||||
edDataInfo.setDataType(dataTypeFile);
|
||||
edDataInfo.setVersion("1.0.0");
|
||||
edDataInfo.setDataStatus("publish");
|
||||
edDataInfo.setSaveStatus("saving");
|
||||
|
||||
boolean isSuccess = edDataMapper.createDataInfo(edDataInfo);
|
||||
log.info("文件开始保存.");
|
||||
|
||||
// 保存文件数据 到 文件存储目录
|
||||
|
||||
|
||||
// 文件保存目录路径
|
||||
String fileSavePath = dataStoragePath + File.separator + filePathOfFolder;
|
||||
String newFileName = edDataInfo.getDataId() + FOLDER_NAME_SEPARATOR + fileFullName;
|
||||
if (!FileUtil.exist(fileSavePath)){
|
||||
FileUtil.mkdir(fileSavePath);
|
||||
}
|
||||
|
||||
String dataCachePath = getDataCachePath();
|
||||
String uploadFileCachePath = dataCachePath + uploadCacheDir + FOLDER_NAME_SEPARATOR + getTimeStampString();
|
||||
if (!FileUtil.exist(uploadFileCachePath)){
|
||||
FileUtil.mkdir(uploadFileCachePath);
|
||||
}
|
||||
|
||||
String fileCacheFullPath = uploadFileCachePath + File.separator + newFileName;
|
||||
String fileSaveFullPath = fileSavePath + File.separator + fileFullName;
|
||||
log.info("文件缓存路径为: " + fileCacheFullPath);
|
||||
|
||||
|
||||
// 这里可以添加将文件保存到本地磁盘或其他存储介质的逻辑
|
||||
File saveFile = new File(fileCacheFullPath);
|
||||
|
||||
// 将文件保存到硬盘
|
||||
EDDataParams fileParames = new EDDataParams();
|
||||
try {
|
||||
fileInput.transferTo(saveFile);
|
||||
|
||||
|
||||
fileParames.setDataId(edDataInfo.getDataId());
|
||||
if(fileInput.getSize() == saveFile.length())
|
||||
{
|
||||
Path source = Paths.get(fileCacheFullPath);
|
||||
Path target = Paths.get(fileSaveFullPath);
|
||||
Files.move(source, target);
|
||||
fileParames.setSaveStatus("success");
|
||||
}
|
||||
else
|
||||
{
|
||||
saveFile.delete();
|
||||
fileParames.setSaveStatus("failure");
|
||||
}
|
||||
|
||||
isSuccess = edDataMapper.updateFileInfo(fileParames);
|
||||
|
||||
FileUtil.del(uploadFileCachePath);//删除临时目录
|
||||
|
||||
log.info("文件保存成功: " + fileSaveFullPath);
|
||||
|
||||
return Boolean.TRUE;
|
||||
|
||||
} catch (IOException e) {
|
||||
fileParames.setSaveStatus("failure");
|
||||
edDataMapper.updateFileInfo(fileParames);
|
||||
log.info("文件保存失败: " + fileSaveFullPath);
|
||||
throw new Exception(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取时间戳字符串
|
||||
* @return
|
||||
*/
|
||||
public String getTimeStampString() {
|
||||
long timestamp = System.currentTimeMillis();
|
||||
return String.valueOf(timestamp);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取数据缓存目录
|
||||
* @return
|
||||
*/
|
||||
public String getDataCachePath() {
|
||||
String osName = System.getProperty("os.name").toLowerCase();
|
||||
return osName.startsWith("win") ? windowsDir + fileCacheDir : fileCacheDir;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<InputStreamResource> download(String dataId, HttpServletResponse response) throws IOException {
|
||||
// 获取文件存储的文件夹路径
|
||||
String osName = System.getProperty("os.name").toLowerCase();
|
||||
String storageFilePath = osName.startsWith("win") ? uploadFilePath + fileStorageDir : fileStorageDir;
|
||||
EDDataParams parames = new EDDataParams();
|
||||
parames.setDataId(dataId);
|
||||
List<EDDataInfo> edDataInfos = edDataMapper.getDataInfoList(parames);
|
||||
Assert.isTrue(CollUtil.isNotEmpty(edDataInfos), "没有找到该下载文件");
|
||||
EDDataInfo edDataInfo = edDataInfos.get(0);
|
||||
String filePathOfFolder = getFilePathOfFolder1(edDataInfo.getCategoryId());
|
||||
String fileType = StrUtil.isEmpty(edDataInfo.getFileType()) ? "" : "." + edDataInfo.getFileType();
|
||||
String filePath = storageFilePath + "/" + filePathOfFolder + "/" + edDataInfo.getDataName() + fileType;
|
||||
|
||||
Assert.isTrue(FileUtil.exist(filePath), "下载文件不存在。");
|
||||
FileSystemResource fileSystemResource = new FileSystemResource(filePath);
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.add("Cache-Control", "no-cache, no-store, must-revalidate");
|
||||
headers.add("Pragma", "no-cache");
|
||||
headers.add("Expires", "0");
|
||||
String fileName = Base64.encode(fileSystemResource.getFilename());
|
||||
response.setHeader("content-disposition","attachment;filename=" + fileName);
|
||||
// 构建响应实体(可以返回<byte[]或Resource,返回类型取决body入参类型)
|
||||
return ResponseEntity
|
||||
.ok()
|
||||
.headers(headers)
|
||||
.contentLength(fileSystemResource.contentLength())
|
||||
.contentType(MediaType.parseMediaType("application/octet-stream;charset=UTF-8"))
|
||||
.body(new InputStreamResource(fileSystemResource.getInputStream()));
|
||||
}
|
||||
|
||||
private String getFilePathOfFolder1(String categoryId)
|
||||
{
|
||||
String filePathOfFolder = ""; //文件存放在文件夹的路径
|
||||
|
||||
String categoryIdHighest = categoryId; //最高级的目录编码
|
||||
EDDataParams folderParames = new EDDataParams();
|
||||
folderParames.setDataId(categoryId);
|
||||
List<EDDataInfo> edDataInfoList = edDataMapper.getDataInfoList(folderParames);
|
||||
EDDataInfo edDataInfoParent = null;
|
||||
if(CollUtil.isNotEmpty(edDataInfoList)) {
|
||||
categoryIdHighest = edDataInfoList.get(0).getCategoryId();
|
||||
edDataInfoParent = edDataInfoList.get(0);
|
||||
}
|
||||
Category categoryParent = new Category();
|
||||
categoryParent.setCategoryId(categoryIdHighest);
|
||||
List<Category> categoryParentList = categoryMapper.selectCategories(categoryParent);
|
||||
if(categoryParentList.size() > 0){
|
||||
categoryParent = categoryParentList.get(0);
|
||||
filePathOfFolder = categoryParent.getCategoryId() + FOLDER_NAME_SEPARATOR + categoryParent.getCategoryName();
|
||||
if(edDataInfoParent != null) {
|
||||
String fileType = StrUtil.isEmpty(edDataInfoParent.getFileType()) ? "" : "." + edDataInfoParent.getFileType();
|
||||
filePathOfFolder = filePathOfFolder + File.separator + edDataInfoParent.getDataName() + fileType;
|
||||
}
|
||||
}
|
||||
return filePathOfFolder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<InputStreamResource> batchExport(String dataIdArr, HttpServletResponse response) throws IOException {
|
||||
//1、根据用户选择层级树编码查出所有文件和文件夹list
|
||||
//2、循环list将每个文件复制到新建目录并进行重命名,命名规则:目录树编码+,+文件夹编码(有则填写无则为空)+,+文件编码
|
||||
//3、打包新建为zip,并根据生产下载地址(域名+文件路径+文件)
|
||||
//4、返回前端下载的地址
|
||||
|
||||
// **********在导出的过程中可能会出现有用户上传文件的情况
|
||||
|
||||
Map<String, String> result = new HashMap<>();
|
||||
List<String> dataIdList = Arrays.asList(dataIdArr.split(","));
|
||||
if(!dataIdList.isEmpty()) {
|
||||
String filePath = exportData(dataIdList);
|
||||
|
||||
Assert.isTrue(FileUtil.exist(filePath), "下载文件不存在。");
|
||||
File file = new File(filePath);
|
||||
FileSystemResource fileSystemResource = new FileSystemResource(file);
|
||||
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.add("Cache-Control", "no-cache, no-store, must-revalidate");
|
||||
String fileName = Base64.encode(fileSystemResource.getFilename());
|
||||
headers.add("Pragma", "no-cache");
|
||||
headers.add("Expires", "0");
|
||||
response.setHeader("content-disposition","attachment;filename=" + fileName);
|
||||
|
||||
// 构建响应实体(可以返回<byte[]或Resource,返回类型取决body入参类型)
|
||||
return ResponseEntity
|
||||
.ok()
|
||||
.headers(headers)
|
||||
.contentLength(fileSystemResource.contentLength())
|
||||
.contentType(MediaType.parseMediaType("application/octet-stream"))
|
||||
.body(new InputStreamResource(fileSystemResource.getInputStream()));
|
||||
|
||||
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public String exportData(List<String> dataIdList) {
|
||||
String zipPathFileName = "";
|
||||
String exportDataCachePath = "";
|
||||
String enCodeZipPathFileName = "";
|
||||
|
||||
try {
|
||||
// 获取文件夹编码ID数组
|
||||
List<String> categoryIdInputList = dataIdList;
|
||||
|
||||
String dataCachePath = getDataCachePath();
|
||||
|
||||
// 导出数据时的临时存放目录
|
||||
exportDataCachePath = dataCachePath + exportCacheDir + FOLDER_NAME_SEPARATOR + getTimeStampString();
|
||||
if (!FileUtil.exist(exportDataCachePath)) {
|
||||
FileUtil.mkdir(exportDataCachePath);
|
||||
}
|
||||
|
||||
List<Category> categoryAllList = categoryMapper.selectAllCategories();
|
||||
Map<String, Category> categoryAllMap = new HashMap(); //所有目录数组map
|
||||
for (Category category : categoryAllList) {
|
||||
categoryAllMap.put(category.getCategoryId(), category);
|
||||
}
|
||||
|
||||
EDDataParams folderParames = new EDDataParams();
|
||||
List<EDDataInfo> fileAllList = edDataMapper.getDataInfoList(folderParames); //获取所有文件信息数据
|
||||
Map<String, EDDataInfo> fileAllMap = new HashMap(); //所有文件数组map
|
||||
for (EDDataInfo fileFinfo : fileAllList) {
|
||||
fileAllMap.put(fileFinfo.getDataId(), fileFinfo);
|
||||
}
|
||||
|
||||
List<Category> categoryInputList = new ArrayList(); //客户端输入的目录数组
|
||||
Map<String, Category> categoryInputMap = new HashMap(); //客户端输入的目录数组map
|
||||
for (String categoryId : categoryIdInputList) {
|
||||
Category category = categoryAllMap.get(categoryId);
|
||||
if (category != null) {
|
||||
categoryInputList.add(category);
|
||||
categoryInputMap.put(categoryId, category);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 将List<Category>转换为JSON字符串
|
||||
String jsonStringCategory = JSONUtil.toJsonStr(categoryInputList);
|
||||
String categoryListFileFullPath = exportDataCachePath + "/categoryList.json";
|
||||
FileUtil.writeString(jsonStringCategory, categoryListFileFullPath, "utf-8");
|
||||
log.info("目录树数据已成功导出为JSON文件。" + categoryListFileFullPath);
|
||||
|
||||
|
||||
// 导出文件信息数据和文件数据
|
||||
|
||||
List<EDDataInfo> fileExportList = new ArrayList(); //需要导出的文件信息数据数组
|
||||
Map<String, EDDataInfo> fileExportMap = new HashMap(); //需要导出的文件信息数据数组map
|
||||
for (EDDataInfo fileFinfo : fileAllList) {
|
||||
if (categoryInputMap.get(fileFinfo.getCategoryId()) != null) {
|
||||
fileExportList.add(fileFinfo);
|
||||
fileExportMap.put(fileFinfo.getDataId(), fileFinfo);
|
||||
}
|
||||
}
|
||||
// 找出子文件夹下的文件
|
||||
for (EDDataInfo fileFinfo : fileAllList) {
|
||||
if (fileExportMap.get(fileFinfo.getCategoryId()) != null) {
|
||||
fileExportList.add(fileFinfo);
|
||||
}
|
||||
}
|
||||
|
||||
// 将文件信息数据导出为json文件
|
||||
String jsonStringFile = JSONUtil.toJsonStr(fileExportList);
|
||||
String fileListFileFullPath = exportDataCachePath + "/fileInfoList.json";
|
||||
FileUtil.writeString(jsonStringFile, fileListFileFullPath, "utf-8");
|
||||
log.info("文件数据已成功导出为JSON文件。" + fileListFileFullPath);
|
||||
|
||||
|
||||
// 将文件 复制到 数据导出的缓存目录中
|
||||
String dataStoragePath = getDataStoragePath();
|
||||
String needExportfolder = "";
|
||||
for (Category category : categoryInputList) {
|
||||
needExportfolder = dataStoragePath + category.getCategoryId() + FOLDER_NAME_SEPARATOR + category.getCategoryName();
|
||||
if (FileUtil.exist(needExportfolder)) {
|
||||
Path source = Paths.get(needExportfolder);
|
||||
Path target = Paths.get(exportDataCachePath);
|
||||
FileUtil.copy(source, target); // StandardCopyOption.REPLACE_EXISTING
|
||||
}
|
||||
}
|
||||
|
||||
log.info("文件数据已成功复制到目标目录。");
|
||||
|
||||
// 将目录树数据 和 文件夹及文件夹内数据 进行压缩打包
|
||||
Date date = new Date();
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd-HHmmss");
|
||||
String dateString = sdf.format(date);
|
||||
|
||||
zipPathFileName = dataCachePath + "/exportData_" + dateString;
|
||||
enCodeZipPathFileName = dataCachePath + "/exportData_" + dateString + ElectromagneticConstants.EXPORT_FILE_SUFFIX;
|
||||
|
||||
ZipUtil.zip(exportDataCachePath, zipPathFileName);
|
||||
|
||||
AES aes = SecureUtil.aes(encodePasswd.getBytes()); // aesKey是加密密钥
|
||||
try (
|
||||
InputStream inputStream = new FileInputStream(zipPathFileName);
|
||||
OutputStream outputStream = new FileOutputStream(enCodeZipPathFileName);
|
||||
) {
|
||||
aes.encrypt(inputStream, outputStream, true);
|
||||
} catch (Exception e) {
|
||||
log.error("文件加密错误..", e);
|
||||
}
|
||||
|
||||
log.info("目录树数据+文件数据已成功复制到目标目录。" + enCodeZipPathFileName);
|
||||
}
|
||||
catch (Exception e) {
|
||||
log.error("导出数据异常..", e);
|
||||
}
|
||||
finally {
|
||||
// 删除 导出数据的 缓存目录
|
||||
FileUtil.del(exportDataCachePath);
|
||||
}
|
||||
|
||||
return enCodeZipPathFileName;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ElectromagneticResult<?> batchImport(FileChunkDTO fileChunkDTO) {
|
||||
String identifier = fileChunkDTO.getIdentifier();
|
||||
String fileName = fileChunkDTO.getFileName();
|
||||
|
||||
String dataCachePath = getDataCachePath();
|
||||
String importDataCachePath = dataCachePath + importCacheDir;
|
||||
|
||||
// 首先检查文件是否存在,如果存在则不允许重复上传。
|
||||
String destZipPath = importDataCachePath + identifier + File.separator + fileName;
|
||||
boolean existFile = FileUtil.exist(new File(destZipPath));
|
||||
if (existFile) {
|
||||
return ElectromagneticResultUtil.fail("-1", "文件已经存在,请勿重复上传。");
|
||||
}
|
||||
|
||||
// 检查该分片有没被上传过
|
||||
String destChunkPath = importDataCachePath + identifier + File.separator + fileChunkDTO.getChunkNumber() + UPLOAD_FILE_CHUNK_SUFFIX;
|
||||
boolean existChunk = FileUtil.exist(new File(destChunkPath));
|
||||
if (existChunk) {
|
||||
return ElectromagneticResultUtil.success(true);
|
||||
}
|
||||
|
||||
File dir = new File(importDataCachePath + identifier + File.separator);
|
||||
if (!dir.exists()) {
|
||||
dir.mkdir();
|
||||
}
|
||||
|
||||
try (
|
||||
InputStream inputStream = fileChunkDTO.getFile().getInputStream();
|
||||
FileOutputStream fileOutputStream = new FileOutputStream(destChunkPath);
|
||||
) {
|
||||
IoUtil.copy(inputStream, fileOutputStream);
|
||||
} catch (IOException ioException) {
|
||||
log.error("上传文件错误...", ioException);
|
||||
}
|
||||
return ElectromagneticResultUtil.success(fileChunkDTO.getIdentifier());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ElectromagneticResult<List<Integer>> getUploadedChunkNums(String identifier) {
|
||||
return ElectromagneticResultUtil.success(getUploadedChunks(identifier));
|
||||
}
|
||||
|
||||
private List<Integer> getUploadedChunks(String identifier) {
|
||||
String dataCachePath = getDataCachePath();
|
||||
String importDataCachePath = dataCachePath + importCacheDir;
|
||||
String destPath = importDataCachePath + identifier;
|
||||
if (!FileUtil.exist(new File(destPath))) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
return FileUtil.listFileNames(destPath)
|
||||
.stream()
|
||||
.filter(e -> !e.endsWith(ElectromagneticConstants.EXPORT_FILE_SUFFIX))
|
||||
.map(e -> e.replace(UPLOAD_FILE_CHUNK_SUFFIX, ""))
|
||||
.map(Integer::parseInt)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ElectromagneticResult<?> mergeChunks(String identifier, String fileName, Integer totalChunks) {
|
||||
String dataCachePath = getDataCachePath();
|
||||
String importDataCachePath = dataCachePath + importCacheDir;
|
||||
|
||||
// 检查所有分片是否已经上传完成,分片编号从1开始
|
||||
for (int i = 1; i <= totalChunks; i++) {
|
||||
String tmpPath = importDataCachePath + identifier + File.separator + i + UPLOAD_FILE_CHUNK_SUFFIX;
|
||||
if (!FileUtil.exist(new File(tmpPath))) {
|
||||
log.error("第{}个分片没有上传完成,请上传完成后再合并。", i);
|
||||
ElectromagneticResultUtil.fail("-1", "文件尚未上传完成。");
|
||||
}
|
||||
}
|
||||
|
||||
// 合并分片
|
||||
String destZipPath = importDataCachePath + identifier + File.separator + fileName;
|
||||
File mergedFile = new File(destZipPath);
|
||||
try {
|
||||
RandomAccessFile targetFile = new RandomAccessFile(mergedFile, "rw");
|
||||
byte[] buffer = new byte[1024];
|
||||
for (int i = 1; i <= totalChunks; i++) {
|
||||
String tmpPath = importDataCachePath + identifier + File.separator + i + UPLOAD_FILE_CHUNK_SUFFIX;
|
||||
RandomAccessFile tmp = new RandomAccessFile(new File(tmpPath), "r");
|
||||
int len;
|
||||
while ((len = tmp.read(buffer)) != -1) {
|
||||
targetFile.write(buffer, 0, len);
|
||||
}
|
||||
tmp.close();
|
||||
}
|
||||
targetFile.close();
|
||||
} catch (IOException ioException) {
|
||||
ElectromagneticResultUtil.fail("-1", "文件合并失败");
|
||||
}
|
||||
|
||||
// 删除分片
|
||||
for (int i = 1; i <= totalChunks; i++) {
|
||||
String tmpPath = importDataCachePath + identifier + File.separator + i + UPLOAD_FILE_CHUNK_SUFFIX;
|
||||
FileUtil.del(tmpPath);
|
||||
}
|
||||
|
||||
// 检验文件的MD5值
|
||||
|
||||
// 解密文件
|
||||
String decryptFilePath = destZipPath + "_decrypted";
|
||||
AES aes = SecureUtil.aes(encodePasswd.getBytes()); // aesKey是加密密钥
|
||||
try(
|
||||
InputStream inputStream = new FileInputStream(destZipPath);
|
||||
OutputStream outputStream = new FileOutputStream(decryptFilePath);
|
||||
) {
|
||||
aes.decrypt(inputStream, outputStream, true);
|
||||
} catch (Exception e) {
|
||||
log.error("文件加密错误..", e);
|
||||
}
|
||||
|
||||
// 解压文件
|
||||
String unzipFileOutputPath = importDataCachePath + identifier + File.separator;
|
||||
ZipUtil.unzip(decryptFilePath, unzipFileOutputPath);
|
||||
|
||||
// 文件信息存入数据库
|
||||
Map<String, List<String>> result = importData(importDataCachePath + identifier);
|
||||
|
||||
// 删除 解压数据的 缓存目录
|
||||
FileUtil.del(unzipFileOutputPath);
|
||||
|
||||
return ElectromagneticResultUtil.success(result);
|
||||
}
|
||||
|
||||
public Map<String, List<String>> importData(String folderPath) {
|
||||
// 获取所有目录树节点数据
|
||||
List<Category> categoryAllList = categoryMapper.selectAllCategories();
|
||||
Map<String, Category> categoryAllMap = new HashMap(); //所有目录数组map
|
||||
for (Category category : categoryAllList) {
|
||||
categoryAllMap.put(category.getCategoryId(), category);
|
||||
}
|
||||
|
||||
// 获取所有文件信息数据
|
||||
EDDataParams parames = new EDDataParams();
|
||||
List<EDDataInfo> fileInfoAllList = edDataMapper.getDataInfoList(parames);
|
||||
Map<String, EDDataInfo> fileInfoAllMap = new HashMap(); //所有文件数组map
|
||||
for (EDDataInfo fileInfo : fileInfoAllList) {
|
||||
fileInfoAllMap.put(fileInfo.getDataId(), fileInfo);
|
||||
}
|
||||
|
||||
|
||||
// 读取并反序列化目录树的JSON文件数据为List<Category>;然后写入到数据库中。
|
||||
String jsonStringCategory = FileUtil.readString(folderPath + "/categoryList.json", StandardCharsets.UTF_8);
|
||||
JSONArray jsonArrayCategory = JSONUtil.parseArray(jsonStringCategory);
|
||||
List<Category> categoryImportList = JSONUtil.toList(jsonArrayCategory, Category.class);
|
||||
if (categoryImportList == null) {
|
||||
log.error("读取并反序列化JSON文件数据为List<Category>失败!");
|
||||
return null;
|
||||
}
|
||||
// 将目录树数据写入到数据库中
|
||||
for (Category category : categoryImportList) {
|
||||
if (categoryAllMap.get(category.getCategoryId()) == null) {
|
||||
categoryMapper.createCategory(category);
|
||||
}
|
||||
}
|
||||
|
||||
// 读取并反序列化文件信息的JSON文件数据为List<EDDataInfo>;然后写入到数据库中。
|
||||
String jsonStringFile = FileUtil.readString(folderPath + "/fileInfoList.json", StandardCharsets.UTF_8);
|
||||
JSONArray jsonArrayFile = JSONUtil.parseArray(jsonStringFile);
|
||||
List<EDDataInfo> fileInfoImportList = JSONUtil.toList(jsonArrayFile, EDDataInfo.class);
|
||||
if (fileInfoImportList == null) {
|
||||
log.error("读取并反序列化JSON文件数据为List<EDDataInfo>失败!");
|
||||
return null;
|
||||
}
|
||||
// 将文件信息数据写入到数据库中
|
||||
for (EDDataInfo fileInfo : fileInfoImportList) {
|
||||
if (fileInfoAllMap.get(fileInfo.getDataId()) == null) {
|
||||
edDataMapper.createDataInfo(fileInfo);
|
||||
}
|
||||
}
|
||||
|
||||
// 将解压后的文件夹和文件 移动到 上传文件的存储目录中
|
||||
List<String> importFileSuccess = new ArrayList();
|
||||
List<String> importFileFail = new ArrayList();
|
||||
|
||||
String dataStoragePath = getDataStoragePath();
|
||||
if (!FileUtil.exist(dataStoragePath)){
|
||||
FileUtil.mkdir(dataStoragePath);
|
||||
}
|
||||
|
||||
String importDataCachePath = folderPath; //导入数据时 数据文件解压后的目录
|
||||
String importFileCachePath = ""; //需要导入的文件的缓存路径
|
||||
String importFileCacheFullPath = ""; //需要导入的文件的全路径
|
||||
String fileStorageFolder = ""; //文件存储的文件夹
|
||||
String fileStoragePath = ""; //文件存储的文件夹路径
|
||||
String fileStorageFullPath = ""; //文件存储的文件全路径
|
||||
|
||||
for (EDDataInfo fileInfo : fileInfoImportList) {
|
||||
fileStorageFolder = getFilePathOfFolder(fileInfo.getCategoryId());
|
||||
importFileCachePath = importDataCachePath + File.separator + fileStorageFolder;
|
||||
importFileCacheFullPath = importFileCachePath + File.separator + fileInfo.getDataName();
|
||||
fileStoragePath = dataStoragePath + File.separator + fileStorageFolder;
|
||||
fileStorageFullPath = fileStoragePath + File.separator + fileInfo.getDataName();
|
||||
|
||||
if (fileInfoAllMap.get(fileInfo.getDataId()) == null
|
||||
&& !fileStorageFolder.isEmpty()
|
||||
&& FileUtil.exist(importFileCachePath)
|
||||
&& FileUtil.exist(importFileCacheFullPath)
|
||||
&& !FileUtil.exist(fileStorageFullPath)
|
||||
)
|
||||
{
|
||||
if(fileInfo.getDataType().equals(dataTypeFolder)) {
|
||||
if (!FileUtil.exist(fileStorageFullPath)) {
|
||||
FileUtil.mkdir(fileStorageFullPath);
|
||||
}
|
||||
} else if(fileInfo.getDataType().equals(dataTypeFile)) {
|
||||
Path source = Paths.get(importFileCacheFullPath);
|
||||
Path target = Paths.get(fileStorageFullPath);
|
||||
FileUtil.move(source,target,true);
|
||||
}
|
||||
|
||||
importFileSuccess.add(fileInfo.getDataId() + FOLDER_NAME_SEPARATOR + fileInfo.getDataName());
|
||||
}
|
||||
else
|
||||
{
|
||||
importFileFail.add(fileInfo.getDataId() + FOLDER_NAME_SEPARATOR + fileInfo.getDataName());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Map<String, List<String>> result = new HashMap<>();
|
||||
result.put("success", importFileSuccess);
|
||||
result.put("fail", importFileFail);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ElectromagneticResult<FileChunkResultDTO> checkChunkExist(FileChunkDTO fileChunkDTO) {
|
||||
String dataCachePath = getDataCachePath();
|
||||
String importDataCachePath = dataCachePath + importCacheDir;
|
||||
// 首先判断zip文件是否存在,如果不存在则表示还没有上传完成。
|
||||
String identifier = fileChunkDTO.getIdentifier();
|
||||
String fileName = fileChunkDTO.getFileName();
|
||||
String destZipPath = importDataCachePath + identifier + File.separator + fileName;
|
||||
boolean existFile = FileUtil.exist(new File(destZipPath));
|
||||
|
||||
if (existFile) {
|
||||
return ElectromagneticResultUtil.success(new FileChunkResultDTO(true, new HashSet<>()));
|
||||
}
|
||||
|
||||
List<Integer> uploadedChunks = getUploadedChunks(identifier);
|
||||
return ElectromagneticResultUtil.success(new FileChunkResultDTO(false, new HashSet<>(uploadedChunks)));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
package com.electromagnetic.industry.software.manage.service.serviceimpl;
|
||||
|
||||
import com.electromagnetic.industry.software.common.pojo.UserLoginInfo;
|
||||
import com.electromagnetic.industry.software.manage.pojo.models.User;
|
||||
import com.electromagnetic.industry.software.manage.service.TokenService;
|
||||
|
||||
public class TokenServiceImpl implements TokenService {
|
||||
@Override
|
||||
public String createToken(UserLoginInfo loginInfo) {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean createUserToken(User user, String tokenStr) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean isTokenValid(String tokenStr) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int deleteToken(String tokenStr) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,236 @@
|
|||
package com.electromagnetic.industry.software.manage.service.serviceimpl;
|
||||
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import cn.hutool.core.date.SystemClock;
|
||||
import com.electromagnetic.industry.software.common.cons.UserConstants;
|
||||
import com.electromagnetic.industry.software.common.enums.EffectFlagEnum;
|
||||
import com.electromagnetic.industry.software.common.enums.ElectromagneticErrorEnum;
|
||||
import com.electromagnetic.industry.software.common.enums.PublishEnum;
|
||||
import com.electromagnetic.industry.software.common.pojo.UserLoginInfo;
|
||||
import com.electromagnetic.industry.software.common.resp.ElectromagneticResult;
|
||||
import com.electromagnetic.industry.software.common.util.*;
|
||||
import com.electromagnetic.industry.software.manage.mapper.TokenMapper;
|
||||
import com.electromagnetic.industry.software.manage.mapper.UserMapper;
|
||||
import com.electromagnetic.industry.software.manage.mapper.UserMappers;
|
||||
import com.electromagnetic.industry.software.manage.pojo.models.Token;
|
||||
import com.electromagnetic.industry.software.manage.pojo.models.User;
|
||||
import com.electromagnetic.industry.software.manage.pojo.other.PublishParam;
|
||||
import com.electromagnetic.industry.software.manage.pojo.other.SearchKeyWords;
|
||||
import com.electromagnetic.industry.software.manage.pojo.other.SingleUserResponse;
|
||||
import com.electromagnetic.industry.software.manage.pojo.other.UserDeleteKeyWords;
|
||||
import com.electromagnetic.industry.software.manage.pojo.req.*;
|
||||
import com.electromagnetic.industry.software.manage.pojo.resp.UserLoginResponse;
|
||||
import com.electromagnetic.industry.software.manage.pojo.resp.UserSearchResponse;
|
||||
import com.electromagnetic.industry.software.manage.service.UserService;
|
||||
import io.jsonwebtoken.Jwts;
|
||||
import io.jsonwebtoken.SignatureAlgorithm;
|
||||
import org.apache.commons.lang3.RandomStringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static cn.hutool.core.date.DateTime.now;
|
||||
|
||||
@Service
|
||||
public class UserServiceImpl implements UserService {
|
||||
|
||||
@Resource
|
||||
private UserMapper userMapper;
|
||||
@Resource
|
||||
private TokenMapper tokenMapper;
|
||||
|
||||
/**
|
||||
* 用户登录
|
||||
* @param loginRequest
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public ElectromagneticResult<?> login(UserLoginRequest loginRequest) {
|
||||
UserLoginInfo info = UserMappers.INSTANCE.getUserLoginRequestToModel(loginRequest);
|
||||
String decodePwd = AESUtils.decrypt(info.getUserPwd(), UserConstants.SECRET_KEY);
|
||||
User user = userMapper.selectUserByWorkNumber(info.getWorkNumber());
|
||||
info.setUserId(user.getUserId());
|
||||
info.setUsername(user.getUserName());
|
||||
if ( checkUserValid(user) && matchPassword(user, decodePwd)) {
|
||||
String tokenStr = createToken(info);
|
||||
createUserToken(user, tokenStr);
|
||||
UserLoginResponse userLoginResponse = new UserLoginResponse();
|
||||
userLoginResponse.setToken(tokenStr);
|
||||
userLoginResponse.setUserId(user.getUserId());
|
||||
return ElectromagneticResultUtil.success(userLoginResponse);
|
||||
}
|
||||
return ElectromagneticResultUtil.fail("500","用户不存在/密码错误");
|
||||
}
|
||||
|
||||
public Boolean createUserToken (User user, String tokenStr){
|
||||
Token token = new Token();
|
||||
token.setUserId(user.getUserId());
|
||||
token.setToken(tokenStr);
|
||||
token.setExpireAt(new DateTime(SystemClock.now()+ UserConstants.DEFAULT_EXPIRE_TIME));
|
||||
return tokenMapper.insert(token)>0;
|
||||
}
|
||||
|
||||
public Boolean checkUserValid(User user){
|
||||
if ( user == null
|
||||
|| user.getIsPublished() == PublishEnum.UNPUBLISHED.getCode()
|
||||
|| user.getEffectFlag() == EffectFlagEnum.EFFECT_FLAG_0.getCode()
|
||||
) {
|
||||
return false;
|
||||
} else if( user.getInternshipEndDate()!=null && user.getInternshipEndDate().before(now())) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public String createToken(UserLoginInfo loginInfo){
|
||||
Map<String, Object> claims = new HashMap<>();
|
||||
claims.put(UserConstants.LOGIN_USER_ID, loginInfo.getUserId());
|
||||
claims.put(UserConstants.LOGIN_USER_NAME, loginInfo.getUsername());
|
||||
claims.put(UserConstants.LOGIN_WORK_NUMBER, loginInfo.getWorkNumber());
|
||||
return Jwts.builder()
|
||||
.addClaims(claims)
|
||||
.setIssuedAt(DateTime.now())
|
||||
.signWith(SignatureAlgorithm.HS512, UserConstants.SECRET_KEY)
|
||||
.compact();
|
||||
}
|
||||
|
||||
public Boolean matchPassword(User user, String password){
|
||||
String salt = user.getSalt();
|
||||
String encodePwd = SignUtils.MD5(password+salt);
|
||||
return user.getUserPwd().equals(encodePwd);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增用户信息
|
||||
* @param userRequest
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public ElectromagneticResult<?> createUser(UserRequest userRequest) {
|
||||
|
||||
User user = UserMappers.INSTANCE.getUserRequestToModel(userRequest);
|
||||
user.setSalt(RandomStringUtils.randomAlphanumeric(16));
|
||||
user.setUserId(IdWorker.getSnowFlakeIdString());
|
||||
user.setUserPwd(SignUtils.MD5(UserConstants.DEFAULT_PASSWORD+user.getSalt()));
|
||||
user.setIsPublished(UserConstants.DEFAULT_PUBLISH_STATUS);
|
||||
user.setCreator(UserThreadLocal.getUserId());
|
||||
user.setCreatorName(UserThreadLocal.getUsername());
|
||||
return ElectromagneticResultUtil.success(userMapper.insert(user) > 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改用户信息
|
||||
* @param userModiRequest
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public ElectromagneticResult<?> modifyUser(UserModiRequest userModiRequest) {
|
||||
User user = UserMappers.INSTANCE.getUserModiRequestToModel(userModiRequest);
|
||||
user.setModifier(UserThreadLocal.getUserId());
|
||||
user.setModifierName(UserThreadLocal.getUsername());
|
||||
return ElectromagneticResultUtil.success(userMapper.modify(user) > 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* 发布用户信息
|
||||
* @param userPublishRequest
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public ElectromagneticResult<?> publishUser(UserPublishRequest userPublishRequest) {
|
||||
PublishParam model = UserMappers.INSTANCE.getUserPublishRequestToModel(userPublishRequest);
|
||||
model.setModifier(UserThreadLocal.getUserId());
|
||||
model.setModifierName(UserThreadLocal.getUsername());
|
||||
return ElectromagneticResultUtil.success(userMapper.publish(model) > 0 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public ElectromagneticResult<?> validateWorkNum(UserWorkNumRequest workNumberRequest) {
|
||||
// 将前端请求对象转换为模型对象,包含userId和userWorkNum
|
||||
User user = UserMappers.INSTANCE.getUserWorkNumRequestToModel(workNumberRequest);
|
||||
|
||||
//根据请求对象的userId判断当前处于什么状态
|
||||
if(user.getUserId()==null){
|
||||
//userId为空,表示是新增用户阶段
|
||||
//判断数据库中有无该工号对应的用户
|
||||
User existingUser = userMapper.selectUserByWorkNumber(user.getWorkNumber());
|
||||
//如果有该用户就返回false,如果没有(==null)就返回true
|
||||
boolean isWorkNumberUnique = (existingUser == null);
|
||||
return ElectromagneticResultUtil.success(isWorkNumberUnique);
|
||||
}else{
|
||||
//userId不为空,表示是编辑用户阶段
|
||||
//请求对象的userWordNum在数据库中对应的user
|
||||
User existingUser = userMapper.selectUserByWorkNumber(user.getWorkNumber());
|
||||
//判断,请求对象的userId对应的user和请求对象的userWordNum在数据库中对应的user是否为用一个
|
||||
if(existingUser!=null){
|
||||
//请求对象的userWordNum在数据库中对应的user与请求对象的userId对应的user是否为同一个
|
||||
if(user.getUserId().equals(existingUser.getUserId())){
|
||||
// 如果获取到的用户ID与当前编辑的用户ID相同,说明工号未改变,直接返回true
|
||||
return ElectromagneticResultUtil.success(true);
|
||||
}else{
|
||||
// 如果获取到的用户ID与当前编辑的用户ID不同,说明工号已改变,需要判断新工号是否唯一
|
||||
// 如果根据新工号获取不到用户,说明新工号唯一
|
||||
boolean isWorkNumberUnique = (userMapper.selectUserByWorkNumber(user.getWorkNumber()) == null);
|
||||
return ElectromagneticResultUtil.success(isWorkNumberUnique);
|
||||
}
|
||||
}else{
|
||||
//请求对象的userWordNum在数据库中不存在对应的user
|
||||
return ElectromagneticResultUtil.success(true);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ElectromagneticResult<?> getSingleUser(GetSingleUserRequest getSingleUserRequest) {
|
||||
User user = userMapper.getSingleUser(getSingleUserRequest.getUserId());
|
||||
SingleUserResponse singleUserResponse = UserMappers.INSTANCE.getSingleUserToResponse(user);
|
||||
return ElectromagneticResultUtil.success(singleUserResponse);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ElectromagneticResult<?> searchUser(SearchUserRequest searchUserRequest) {
|
||||
searchUserRequest.setPageIndex((searchUserRequest.getPageIndex()-1)*searchUserRequest.getPageSize());
|
||||
SearchKeyWords model = UserMappers.INSTANCE.getSearchKeywordsRequestToModel(searchUserRequest);
|
||||
List<User> userList = userMapper.search(model);
|
||||
int totalCount = userMapper.getTotalCount(model);
|
||||
List<SingleUserResponse> singleUserResponseList = UserMappers.INSTANCE.userListToResponseList(userList);
|
||||
UserSearchResponse userSearchResponse = new UserSearchResponse();
|
||||
userSearchResponse.setUserList(singleUserResponseList);
|
||||
userSearchResponse.setTotalCount(totalCount);
|
||||
return ElectromagneticResultUtil.success(userSearchResponse);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ElectromagneticResult<?> deleteUser(UserDeleteRequest userDeleteRequest) {
|
||||
// 将请求对象转换为模型对象
|
||||
UserDeleteKeyWords userDeleteKeyWords = UserMappers.INSTANCE.getUserDeleteRequestToModel(userDeleteRequest);
|
||||
userDeleteKeyWords.setModifier(UserThreadLocal.getUserId());
|
||||
userDeleteKeyWords.setModifierName(UserThreadLocal.getUsername());
|
||||
|
||||
// 检查用户是否已经被逻辑删除
|
||||
User existingUser = userMapper.getSingleUser(userDeleteKeyWords.getUserId());
|
||||
|
||||
if(existingUser != null && existingUser.getEffectFlag()==0){
|
||||
// 如果用户已经被逻辑删除(在这个假设中,0 表示已删除),则不进行任何操作或返回错误
|
||||
return ElectromagneticResultUtil.fail(ElectromagneticErrorEnum. FINE_DELETE_USER_ERROR);
|
||||
}
|
||||
if(existingUser!=null && existingUser.getEffectFlag()==1){// 在这个假设中,1 表示未删除
|
||||
return ElectromagneticResultUtil.success(userMapper.deleteUser(userDeleteKeyWords));
|
||||
}else{
|
||||
// 如果用户不存在(理论上不应该发生,除非数据库状态不一致),则返回错误
|
||||
return ElectromagneticResultUtil.fail(ElectromagneticErrorEnum. FINE_DELETE_USER_ERROR);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ElectromagneticResult<?> logout(String token) {
|
||||
token = token.substring(7);
|
||||
return ElectromagneticResultUtil.success(tokenMapper.deleteToken(token));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
#required
|
||||
spring.application.name=electromagnetic-data
|
||||
# security
|
||||
run.mode=NORMAL
|
||||
com.alipay.env=shared
|
||||
#log
|
||||
logging.file.path=./logs
|
||||
loggerPath=electromagnetic-data
|
||||
logging.level.com.aliyun.fsi.insurance=${LOG_LEVEL:INFO}
|
||||
#日志配置
|
||||
logging.config=classpath:${LOG_CONFIG:log4j2-spring.xml}
|
||||
|
||||
|
||||
spring.datasource.typd=com.alibaba.druid.pool.DruidDataSource
|
||||
spring.datasource.url=jdbc:mysql://139.224.43.89:3306/em_data?serverTimezone=UTC&useUnicode=true&characterEncoding=utf-8&useSSL=true&serverTimezone=GMT%2B8&allowMultiQueries=true&rewriteBatchedStatements=true
|
||||
spring.datasource.username=comac
|
||||
spring.datasource.password=2024*Comac
|
||||
spring.servlet.multipart.max-file-size=500MB
|
||||
spring.servlet.multipart.max-request-size=10MB
|
||||
|
||||
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
|
||||
spring.datasource.type=com.alibaba.druid.pool.DruidDataSource
|
||||
mybatis-plus.mapper-locations=classpath:sqlmapper/*.xml
|
||||
mybatis-plus.configuration.log-impl=org.apache.ibatis.logging.stdout.StdOutImpl
|
||||
pagehelper.helperDialect=mysql
|
||||
pagehelper.reasonable=false
|
||||
server.port=12365
|
||||
|
||||
#windows文件存储目录
|
||||
data.windows.path=E:/comacFileStorage/
|
||||
#文件缓存路径
|
||||
data.file.cache.dir=/szsd/cache/
|
||||
#文件存储路径
|
||||
data.file.storage.dir=/szsd/fileStorage/
|
||||
#上传文件时文件的缓存文件夹名称
|
||||
data.upload.cache.dir=upload
|
||||
#导出数据时文件的缓存文件夹名称
|
||||
data.export.cache.dir=export
|
||||
#导入数据时文件的缓存文件夹名称
|
||||
data.import.cache.dir=import
|
||||
file.encode.passwd=adknfhkj87654knd
|
||||
#数据类型中的文件类型为file
|
||||
data.type.file=file
|
||||
#数据类型中的文件夹类型为folder
|
||||
data.type.folder=folder
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
log4j.rootLogger=DEBUG, stdout
|
||||
# Console output...
|
||||
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
|
||||
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
|
||||
log4j.appender.stdout.layout.ConversionPattern=%5p [%t] - %m%n
|
||||
|
|
@ -0,0 +1,205 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Configuration>
|
||||
<properties>
|
||||
<property name="LOG_LEVEL" value="INFO"/>
|
||||
<property name="APP_NAME" value="electromagnetic-data"/>
|
||||
<property name="LOG_HOME" value="./logs/${APP_NAME}"/>
|
||||
<property name="LOG_LAYOUT" value="%d{yyyy-MM-dd HH:mm:ss.SSS},%t,%r,%-5p,%X{SOFA-TraceId},%X{SOFA-SpanId},%c{2},%m%n%throwable"/>
|
||||
<property name="SIMPLE_LAYOUT" value="%d{yyyy-MM-dd HH:mm:ss.SSS} %m%n%"/>
|
||||
</properties>
|
||||
|
||||
<Appenders>
|
||||
<Console name="STDOUT-APPENDER" target="SYSTEM_OUT">
|
||||
<PatternLayout pattern="${LOG_LAYOUT}" charset="UTF-8"/>
|
||||
</Console>
|
||||
<Console name="STDERR-APPENDER" target="SYSTEM_ERR">
|
||||
<PatternLayout pattern="${LOG_LAYOUT}" charset="UTF-8"/>
|
||||
</Console>
|
||||
|
||||
<!-- 错误节点日志 -->
|
||||
<RollingFile name="ERROR-APPENDER" fileName="${LOG_HOME}/common-error.log"
|
||||
filePattern="${LOG_HOME}/common-error-%d{yyyy-MM-dd}_%i.log" append="true">
|
||||
<Filters>
|
||||
<ThresholdFilter level="ERROR" onMatch="ACCEPT" onMismatch="DENY"/>
|
||||
</Filters>
|
||||
<PatternLayout pattern="${LOG_LAYOUT}" charset="UTF-8"/>
|
||||
<Policies>
|
||||
<SizeBasedTriggeringPolicy size="500MB"/>
|
||||
<TimeBasedTriggeringPolicy interval="1" modulate="true"/>
|
||||
</Policies>
|
||||
<DefaultRolloverStrategy max="300">
|
||||
<Delete basePath="${LOG_HOME}" maxDepth="1">
|
||||
<IfLastModified age="15d"/>
|
||||
<IfFileName glob="${LOG_HOME}*.log"/>
|
||||
</Delete>
|
||||
</DefaultRolloverStrategy>
|
||||
</RollingFile>
|
||||
|
||||
<!-- 业务日常节点日志-->
|
||||
<RollingFile name="COMMON-APPENDER" fileName="${LOG_HOME}/common-default.log"
|
||||
filePattern="${LOG_HOME}/common-default-%d{yyyy-MM-dd}_%i.log" append="true">
|
||||
<PatternLayout pattern="${LOG_LAYOUT}" charset="UTF-8"/>
|
||||
<Policies>
|
||||
<SizeBasedTriggeringPolicy size="500MB"/>
|
||||
<TimeBasedTriggeringPolicy interval="1" modulate="true"/>
|
||||
</Policies>
|
||||
<DefaultRolloverStrategy max="300">
|
||||
<Delete basePath="${LOG_HOME}" maxDepth="1">
|
||||
<IfLastModified age="15d"/>
|
||||
<IfFileName glob="${LOG_HOME}*.log"/>
|
||||
</Delete>
|
||||
</DefaultRolloverStrategy>
|
||||
</RollingFile>
|
||||
<!-- 业务日常节点日志-->
|
||||
<RollingFile name="DOMAIN-CALL-APPENDER" fileName="${LOG_HOME}/domain-call.log"
|
||||
filePattern="${LOG_HOME}/domain-call-%d{yyyy-MM-dd}_%i.log" append="true">
|
||||
<PatternLayout pattern="${SIMPLE_LAYOUT}" charset="UTF-8"/>
|
||||
<Policies>
|
||||
<SizeBasedTriggeringPolicy size="500MB"/>
|
||||
<TimeBasedTriggeringPolicy interval="1" modulate="true"/>
|
||||
</Policies>
|
||||
<DefaultRolloverStrategy max="300">
|
||||
<Delete basePath="${LOG_HOME}" maxDepth="1">
|
||||
<IfLastModified age="15d"/>
|
||||
<IfFileName glob="${LOG_HOME}*.log"/>
|
||||
</Delete>
|
||||
</DefaultRolloverStrategy>
|
||||
</RollingFile>
|
||||
<!-- 消息监听日志 -->
|
||||
<RollingFile name="MSG-LISTEN-APPENDER" fileName="${LOG_HOME}/msg-listen.log"
|
||||
filePattern="${LOG_HOME}/msg-listen-%d{yyyy-MM-dd}_%i.log" append="true">
|
||||
<PatternLayout pattern="${LOG_LAYOUT}" charset="UTF-8"/>
|
||||
<Policies>
|
||||
<SizeBasedTriggeringPolicy size="500MB"/>
|
||||
<TimeBasedTriggeringPolicy interval="1" modulate="true"/>
|
||||
</Policies>
|
||||
<DefaultRolloverStrategy max="300">
|
||||
<Delete basePath="${LOG_HOME}" maxDepth="1">
|
||||
<IfLastModified age="15d"/>
|
||||
<IfFileName glob="${LOG_HOME}*.log"/>
|
||||
</Delete>
|
||||
</DefaultRolloverStrategy>
|
||||
</RollingFile>
|
||||
|
||||
<!-- 异步任务日志 -->
|
||||
<RollingFile name="TASK-SCHEDULER-APPENDER" fileName="${LOG_HOME}/task-scheduler.log"
|
||||
filePattern="${LOG_HOME}/task-scheduler-%d{yyyy-MM-dd}_%i.log" append="true">
|
||||
<PatternLayout pattern="${LOG_LAYOUT}" charset="UTF-8"/>
|
||||
<Policies>
|
||||
<SizeBasedTriggeringPolicy size="500MB"/>
|
||||
<TimeBasedTriggeringPolicy interval="1" modulate="true"/>
|
||||
</Policies>
|
||||
<DefaultRolloverStrategy max="300">
|
||||
<Delete basePath="${LOG_HOME}" maxDepth="1">
|
||||
<IfLastModified age="15d"/>
|
||||
<IfFileName glob="${LOG_HOME}*.log"/>
|
||||
</Delete>
|
||||
</DefaultRolloverStrategy>
|
||||
</RollingFile>
|
||||
|
||||
<!-- SOFA日常节点日志 -->
|
||||
<RollingFile name="SOFA-DEFAULT-APPENDER" fileName="${LOG_HOME}/sofa-default.log"
|
||||
filePattern="${LOG_HOME}/sofa-default-%d{yyyy-MM-dd}_%i.log" append="true">
|
||||
<PatternLayout pattern="${LOG_LAYOUT}" charset="UTF-8"/>
|
||||
<Policies>
|
||||
<SizeBasedTriggeringPolicy size="500MB"/>
|
||||
<TimeBasedTriggeringPolicy interval="1" modulate="true"/>
|
||||
</Policies>
|
||||
<DefaultRolloverStrategy max="300">
|
||||
<Delete basePath="${LOG_HOME}" maxDepth="1">
|
||||
<IfLastModified age="15d"/>
|
||||
<IfFileName glob="${LOG_HOME}*.log"/>
|
||||
</Delete>
|
||||
</DefaultRolloverStrategy>
|
||||
</RollingFile>
|
||||
|
||||
<!-- 调用外部系统日志 -->
|
||||
<RollingFile name="INTEGRATION-APPENDER" fileName="${LOG_HOME}/integration.log"
|
||||
filePattern="${LOG_HOME}/integration-%d{yyyy-MM-dd}_%i.log" append="true">
|
||||
<PatternLayout pattern="${LOG_LAYOUT}" charset="UTF-8"/>
|
||||
<Policies>
|
||||
<SizeBasedTriggeringPolicy size="500MB"/>
|
||||
<TimeBasedTriggeringPolicy interval="1" modulate="true"/>
|
||||
</Policies>
|
||||
<DefaultRolloverStrategy max="300">
|
||||
<Delete basePath="${LOG_HOME}" maxDepth="1">
|
||||
<IfLastModified age="15d"/>
|
||||
<IfFileName glob="${LOG_HOME}*.log"/>
|
||||
</Delete>
|
||||
</DefaultRolloverStrategy>
|
||||
</RollingFile>
|
||||
|
||||
<RollingFile name="COMMON-MONITOR-APPENDER" fileName="${LOG_HOME}/common-monitor.log"
|
||||
filePattern="${LOG_HOME}/common-monitor-%d{yyyy-MM-dd}_%i.log" append="true">
|
||||
<PatternLayout pattern="${LOG_LAYOUT}" charset="UTF-8"/>
|
||||
<Policies>
|
||||
<SizeBasedTriggeringPolicy size="500MB"/>
|
||||
<TimeBasedTriggeringPolicy interval="1" modulate="true"/>
|
||||
</Policies>
|
||||
<DefaultRolloverStrategy max="300">
|
||||
<Delete basePath="${LOG_HOME}" maxDepth="1">
|
||||
<IfLastModified age="15d"/>
|
||||
<IfFileName glob="${LOG_HOME}*.log"/>
|
||||
</Delete>
|
||||
</DefaultRolloverStrategy>
|
||||
</RollingFile>
|
||||
</Appenders>
|
||||
|
||||
<Loggers>
|
||||
<AsyncRoot includeLocation="true" level="${LOG_LEVEL}">
|
||||
<AppenderRef ref="ERROR-APPENDER"/>
|
||||
<AppenderRef ref="COMMON-APPENDER"/>
|
||||
</AsyncRoot>
|
||||
|
||||
<AsyncLogger name="com.alipay.sofa" additivity="false" level="${LOG_LEVEL}">
|
||||
<AppenderRef ref="ERROR-APPENDER"/>
|
||||
<AppenderRef ref="SOFA-DEFAULT-APPENDER"/>
|
||||
</AsyncLogger>
|
||||
<AsyncLogger name="com.aliyun.fsi.insurance" additivity="false" level="${LOG_LEVEL}">
|
||||
<AppenderRef ref="ERROR-APPENDER"/>
|
||||
<AppenderRef ref="COMMON-APPENDER"/>
|
||||
</AsyncLogger>
|
||||
|
||||
<Logger name="INTEGRATION" additivity="false" includeLocation="true" level="${LOG_LEVEL}">
|
||||
<AppenderRef ref="ERROR-APPENDER"/>
|
||||
<AppenderRef ref="INTEGRATION-APPENDER"/>
|
||||
</Logger>
|
||||
<Logger name="SERIOUS-ALERT" additivity="false" includeLocation="true" level="${LOG_LEVEL}">
|
||||
<AppenderRef ref="ERROR-APPENDER"/>
|
||||
<AppenderRef ref="COMMON-APPENDER"/>
|
||||
</Logger>
|
||||
<Logger name="DOMAIN-ERROR" additivity="false" includeLocation="true" level="${LOG_LEVEL}">
|
||||
<AppenderRef ref="ERROR-APPENDER"/>
|
||||
<AppenderRef ref="COMMON-APPENDER"/>
|
||||
</Logger>
|
||||
<Logger name="DOMAIN-DIGEST" additivity="false" includeLocation="true" level="${LOG_LEVEL}">
|
||||
<AppenderRef ref="ERROR-APPENDER"/>
|
||||
<AppenderRef ref="COMMON-APPENDER"/>
|
||||
</Logger>
|
||||
<Logger name="DOMAIN-CALL" additivity="false" includeLocation="true" level="${LOG_LEVEL}">
|
||||
<AppenderRef ref="DOMAIN-CALL-APPENDER"/>
|
||||
</Logger>
|
||||
<Logger name="DOMAIN-SERVICE" additivity="false" includeLocation="true" level="${LOG_LEVEL}">
|
||||
<AppenderRef ref="ERROR-APPENDER"/>
|
||||
<AppenderRef ref="COMMON-APPENDER"/>
|
||||
</Logger>
|
||||
<Logger name="TASK-SCHEDULER" additivity="false" includeLocation="true" level="${LOG_LEVEL}">
|
||||
<AppenderRef ref="ERROR-APPENDER"/>
|
||||
<AppenderRef ref="TASK-SCHEDULER-APPENDER"/>
|
||||
</Logger>
|
||||
|
||||
<Logger name="MSG-LISTEN" additivity="false" includeLocation="true" level="${LOG_LEVEL}">
|
||||
<AppenderRef ref="ERROR-APPENDER"/>
|
||||
<AppenderRef ref="MSG-LISTEN-APPENDER"/>
|
||||
</Logger>
|
||||
<Logger name="AbstractMessageListenerXFlush" additivity="false" includeLocation="true" level="${LOG_LEVEL}">
|
||||
<AppenderRef ref="ERROR-APPENDER"/>
|
||||
<AppenderRef ref="MSG-LISTEN-APPENDER"/>
|
||||
</Logger>
|
||||
<Logger name="COMMON-MONITOR" includeLocation="true" additivity="false" level="${LOG_LEVEL}">
|
||||
<AppenderRef ref="ERROR-APPENDER"/>
|
||||
<AppenderRef ref="COMMON-MONITOR-APPENDER"/>
|
||||
<AppenderRef ref="STDOUT-APPENDER"/>
|
||||
</Logger>
|
||||
</Loggers>
|
||||
</Configuration>
|
||||
|
|
@ -0,0 +1,217 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Configuration>
|
||||
<properties>
|
||||
<property name="LOG_LEVEL" value="DEBUG"/>
|
||||
<property name="APP_NAME" value="electromagnetic-data"/>
|
||||
<property name="LOG_HOME" value="./logs/${APP_NAME}"/>
|
||||
<property name="LOG_LAYOUT" value="%d{yyyy-MM-dd HH:mm:ss.SSS},%t,%r,%-5p,%X{SOFA-TraceId},%X{SOFA-SpanId},%c{2},%m%n%throwable"/>
|
||||
<property name="SIMPLE_LAYOUT" value="%d{yyyy-MM-dd HH:mm:ss.SSS} %m%n%"/>
|
||||
</properties>
|
||||
|
||||
<Appenders>
|
||||
<Console name="STDOUT-APPENDER" target="SYSTEM_OUT">
|
||||
<PatternLayout pattern="${LOG_LAYOUT}" charset="UTF-8"/>
|
||||
</Console>
|
||||
<Console name="STDERR-APPENDER" target="SYSTEM_ERR">
|
||||
<PatternLayout pattern="${LOG_LAYOUT}" charset="UTF-8"/>
|
||||
</Console>
|
||||
|
||||
<!-- 错误节点日志 -->
|
||||
<RollingFile name="ERROR-APPENDER" fileName="${LOG_HOME}/common-error.log"
|
||||
filePattern="${LOG_HOME}/common-error-%d{yyyy-MM-dd}_%i.log" append="true">
|
||||
<Filters>
|
||||
<ThresholdFilter level="ERROR" onMatch="ACCEPT" onMismatch="DENY"/>
|
||||
</Filters>
|
||||
<PatternLayout pattern="${LOG_LAYOUT}" charset="UTF-8"/>
|
||||
<Policies>
|
||||
<SizeBasedTriggeringPolicy size="500MB"/>
|
||||
<TimeBasedTriggeringPolicy interval="1" modulate="true"/>
|
||||
</Policies>
|
||||
<DefaultRolloverStrategy max="300">
|
||||
<Delete basePath="${LOG_HOME}" maxDepth="1">
|
||||
<IfLastModified age="15d"/>
|
||||
<IfFileName glob="${LOG_HOME}*.log"/>
|
||||
</Delete>
|
||||
</DefaultRolloverStrategy>
|
||||
</RollingFile>
|
||||
|
||||
<!-- 业务日常节点日志-->
|
||||
<RollingFile name="COMMON-APPENDER" fileName="${LOG_HOME}/common-default.log"
|
||||
filePattern="${LOG_HOME}/common-default-%d{yyyy-MM-dd}_%i.log" append="true">
|
||||
<PatternLayout pattern="${LOG_LAYOUT}" charset="UTF-8"/>
|
||||
<Policies>
|
||||
<SizeBasedTriggeringPolicy size="500MB"/>
|
||||
<TimeBasedTriggeringPolicy interval="1" modulate="true"/>
|
||||
</Policies>
|
||||
<DefaultRolloverStrategy max="300">
|
||||
<Delete basePath="${LOG_HOME}" maxDepth="1">
|
||||
<IfLastModified age="15d"/>
|
||||
<IfFileName glob="${LOG_HOME}*.log"/>
|
||||
</Delete>
|
||||
</DefaultRolloverStrategy>
|
||||
</RollingFile>
|
||||
<!-- 业务日常节点日志-->
|
||||
<RollingFile name="DOMAIN-CALL-APPENDER" fileName="${LOG_HOME}/domain-call.log"
|
||||
filePattern="${LOG_HOME}/domain-call-%d{yyyy-MM-dd}_%i.log" append="true">
|
||||
<PatternLayout pattern="${SIMPLE_LAYOUT}" charset="UTF-8"/>
|
||||
<Policies>
|
||||
<SizeBasedTriggeringPolicy size="500MB"/>
|
||||
<TimeBasedTriggeringPolicy interval="1" modulate="true"/>
|
||||
</Policies>
|
||||
<DefaultRolloverStrategy max="300">
|
||||
<Delete basePath="${LOG_HOME}" maxDepth="1">
|
||||
<IfLastModified age="15d"/>
|
||||
<IfFileName glob="${LOG_HOME}*.log"/>
|
||||
</Delete>
|
||||
</DefaultRolloverStrategy>
|
||||
</RollingFile>
|
||||
<!-- 消息监听日志 -->
|
||||
<RollingFile name="MSG-LISTEN-APPENDER" fileName="${LOG_HOME}/msg-listen.log"
|
||||
filePattern="${LOG_HOME}/msg-listen-%d{yyyy-MM-dd}_%i.log" append="true">
|
||||
<PatternLayout pattern="${LOG_LAYOUT}" charset="UTF-8"/>
|
||||
<Policies>
|
||||
<SizeBasedTriggeringPolicy size="500MB"/>
|
||||
<TimeBasedTriggeringPolicy interval="1" modulate="true"/>
|
||||
</Policies>
|
||||
<DefaultRolloverStrategy max="300">
|
||||
<Delete basePath="${LOG_HOME}" maxDepth="1">
|
||||
<IfLastModified age="15d"/>
|
||||
<IfFileName glob="${LOG_HOME}*.log"/>
|
||||
</Delete>
|
||||
</DefaultRolloverStrategy>
|
||||
</RollingFile>
|
||||
|
||||
<!-- 异步任务日志 -->
|
||||
<RollingFile name="TASK-SCHEDULER-APPENDER" fileName="${LOG_HOME}/task-scheduler.log"
|
||||
filePattern="${LOG_HOME}/task-scheduler-%d{yyyy-MM-dd}_%i.log" append="true">
|
||||
<PatternLayout pattern="${LOG_LAYOUT}" charset="UTF-8"/>
|
||||
<Policies>
|
||||
<SizeBasedTriggeringPolicy size="500MB"/>
|
||||
<TimeBasedTriggeringPolicy interval="1" modulate="true"/>
|
||||
</Policies>
|
||||
<DefaultRolloverStrategy max="300">
|
||||
<Delete basePath="${LOG_HOME}" maxDepth="1">
|
||||
<IfLastModified age="15d"/>
|
||||
<IfFileName glob="${LOG_HOME}*.log"/>
|
||||
</Delete>
|
||||
</DefaultRolloverStrategy>
|
||||
</RollingFile>
|
||||
|
||||
<!-- SOFA日常节点日志 -->
|
||||
<RollingFile name="SOFA-DEFAULT-APPENDER" fileName="${LOG_HOME}/sofa-default.log"
|
||||
filePattern="${LOG_HOME}/sofa-default-%d{yyyy-MM-dd}_%i.log" append="true">
|
||||
<PatternLayout pattern="${LOG_LAYOUT}" charset="UTF-8"/>
|
||||
<Policies>
|
||||
<SizeBasedTriggeringPolicy size="500MB"/>
|
||||
<TimeBasedTriggeringPolicy interval="1" modulate="true"/>
|
||||
</Policies>
|
||||
<DefaultRolloverStrategy max="300">
|
||||
<Delete basePath="${LOG_HOME}" maxDepth="1">
|
||||
<IfLastModified age="15d"/>
|
||||
<IfFileName glob="${LOG_HOME}*.log"/>
|
||||
</Delete>
|
||||
</DefaultRolloverStrategy>
|
||||
</RollingFile>
|
||||
|
||||
<!-- 调用外部系统日志 -->
|
||||
<RollingFile name="INTEGRATION-APPENDER" fileName="${LOG_HOME}/integration.log"
|
||||
filePattern="${LOG_HOME}/integration-%d{yyyy-MM-dd}_%i.log" append="true">
|
||||
<PatternLayout pattern="${LOG_LAYOUT}" charset="UTF-8"/>
|
||||
<Policies>
|
||||
<SizeBasedTriggeringPolicy size="500MB"/>
|
||||
<TimeBasedTriggeringPolicy interval="1" modulate="true"/>
|
||||
</Policies>
|
||||
<DefaultRolloverStrategy max="300">
|
||||
<Delete basePath="${LOG_HOME}" maxDepth="1">
|
||||
<IfLastModified age="15d"/>
|
||||
<IfFileName glob="${LOG_HOME}*.log"/>
|
||||
</Delete>
|
||||
</DefaultRolloverStrategy>
|
||||
</RollingFile>
|
||||
|
||||
<RollingFile name="COMMON-MONITOR-APPENDER" fileName="${LOG_HOME}/common-monitor.log"
|
||||
filePattern="${LOG_HOME}/common-monitor-%d{yyyy-MM-dd}_%i.log" append="true">
|
||||
<PatternLayout pattern="${LOG_LAYOUT}" charset="UTF-8"/>
|
||||
<Policies>
|
||||
<SizeBasedTriggeringPolicy size="500MB"/>
|
||||
<TimeBasedTriggeringPolicy interval="1" modulate="true"/>
|
||||
</Policies>
|
||||
<DefaultRolloverStrategy max="300">
|
||||
<Delete basePath="${LOG_HOME}" maxDepth="1">
|
||||
<IfLastModified age="15d"/>
|
||||
<IfFileName glob="${LOG_HOME}*.log"/>
|
||||
</Delete>
|
||||
</DefaultRolloverStrategy>
|
||||
</RollingFile>
|
||||
</Appenders>
|
||||
|
||||
<Loggers>
|
||||
<AsyncRoot includeLocation="true" level="INFO">
|
||||
<AppenderRef ref="ERROR-APPENDER"/>
|
||||
<AppenderRef ref="COMMON-APPENDER"/>
|
||||
<AppenderRef ref="STDOUT-APPENDER"/>
|
||||
</AsyncRoot>
|
||||
|
||||
<AsyncLogger name="com.alipay.sofa" additivity="false" level="${LOG_LEVEL}">
|
||||
<AppenderRef ref="ERROR-APPENDER"/>
|
||||
<AppenderRef ref="SOFA-DEFAULT-APPENDER"/>
|
||||
<AppenderRef ref="STDOUT-APPENDER"/>
|
||||
</AsyncLogger>
|
||||
<AsyncLogger name="com.aliyun.fsi.insurance" additivity="false" level="${LOG_LEVEL}">
|
||||
<AppenderRef ref="ERROR-APPENDER"/>
|
||||
<AppenderRef ref="COMMON-APPENDER"/>
|
||||
<AppenderRef ref="STDOUT-APPENDER"/>
|
||||
</AsyncLogger>
|
||||
|
||||
<Logger name="INTEGRATION" includeLocation="true" additivity="false" level="${LOG_LEVEL}">
|
||||
<AppenderRef ref="ERROR-APPENDER"/>
|
||||
<AppenderRef ref="INTEGRATION-APPENDER"/>
|
||||
<AppenderRef ref="STDOUT-APPENDER"/>
|
||||
</Logger>
|
||||
<Logger name="SERIOUS-ALERT" includeLocation="true" additivity="false" level="${LOG_LEVEL}">
|
||||
<AppenderRef ref="ERROR-APPENDER"/>
|
||||
<AppenderRef ref="COMMON-APPENDER"/>
|
||||
<AppenderRef ref="STDERR-APPENDER"/>
|
||||
</Logger>
|
||||
<Logger name="DOMAIN-CALL" additivity="false" includeLocation="true" level="${LOG_LEVEL}">
|
||||
<AppenderRef ref="DOMAIN-CALL-APPENDER"/>
|
||||
</Logger>
|
||||
<Logger name="DOMAIN-ERROR" includeLocation="true" additivity="false" level="${LOG_LEVEL}">
|
||||
<AppenderRef ref="ERROR-APPENDER"/>
|
||||
<AppenderRef ref="COMMON-APPENDER"/>
|
||||
<AppenderRef ref="STDERR-APPENDER"/>
|
||||
</Logger>
|
||||
<Logger name="DOMAIN-DIGEST" includeLocation="true" additivity="false" level="${LOG_LEVEL}">
|
||||
<AppenderRef ref="ERROR-APPENDER"/>
|
||||
<AppenderRef ref="COMMON-APPENDER"/>
|
||||
<AppenderRef ref="STDOUT-APPENDER"/>
|
||||
</Logger>
|
||||
<Logger name="DOMAIN-SERVICE" includeLocation="true" additivity="false" level="${LOG_LEVEL}">
|
||||
<AppenderRef ref="ERROR-APPENDER"/>
|
||||
<AppenderRef ref="COMMON-APPENDER"/>
|
||||
<AppenderRef ref="STDOUT-APPENDER"/>
|
||||
</Logger>
|
||||
|
||||
<Logger name="TASK-SCHEDULER" includeLocation="true" additivity="false" level="${LOG_LEVEL}">
|
||||
<AppenderRef ref="ERROR-APPENDER"/>
|
||||
<AppenderRef ref="TASK-SCHEDULER-APPENDER"/>
|
||||
<AppenderRef ref="STDOUT-APPENDER"/>
|
||||
</Logger>
|
||||
|
||||
<Logger name="MSG-LISTEN" includeLocation="true" additivity="false" level="${LOG_LEVEL}">
|
||||
<AppenderRef ref="ERROR-APPENDER"/>
|
||||
<AppenderRef ref="MSG-LISTEN-APPENDER"/>
|
||||
<AppenderRef ref="STDOUT-APPENDER"/>
|
||||
</Logger>
|
||||
<Logger name="AbstractMessageListenerXFlush" includeLocation="true" additivity="false" level="${LOG_LEVEL}">
|
||||
<AppenderRef ref="ERROR-APPENDER"/>
|
||||
<AppenderRef ref="MSG-LISTEN-APPENDER"/>
|
||||
<AppenderRef ref="STDOUT-APPENDER"/>
|
||||
</Logger>
|
||||
<Logger name="COMMON-MONITOR" includeLocation="true" additivity="false" level="${LOG_LEVEL}">
|
||||
<AppenderRef ref="ERROR-APPENDER"/>
|
||||
<AppenderRef ref="COMMON-MONITOR-APPENDER"/>
|
||||
<AppenderRef ref="STDOUT-APPENDER"/>
|
||||
</Logger>
|
||||
</Loggers>
|
||||
</Configuration>
|
||||
|
|
@ -0,0 +1,67 @@
|
|||
<?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.electromagnetic.industry.software.manage.mapper.CategoryMapper">
|
||||
<resultMap id="CategoryResultMap" type="com.electromagnetic.industry.software.manage.pojo.models.Category">
|
||||
<id column="id" jdbcType="BIGINT" property="id" />
|
||||
<result column="category_type_id" jdbcType="VARCHAR" property="categoryTypeId" />
|
||||
<result column="parent_id" jdbcType="VARCHAR" property="parentId" />
|
||||
<result column="category_id" jdbcType="VARCHAR" property="categoryId" />
|
||||
<result column="category_name" jdbcType="VARCHAR" property="categoryName" />
|
||||
<result column="category_status" jdbcType="VARCHAR" property="categoryStatus" />
|
||||
<result column="creator" jdbcType="VARCHAR" property="creator" />
|
||||
<result column="creator_name" jdbcType="VARCHAR" property="creatorName" />
|
||||
<result column="gmt_create" jdbcType="TIMESTAMP" property="gmtCreate" />
|
||||
<result column="modifier" jdbcType="VARCHAR" property="modifier" />
|
||||
<result column="modifier_name" jdbcType="VARCHAR" property="modifierName" />
|
||||
<result column="gmt_modified" jdbcType="TIMESTAMP" property="gmtModified" />
|
||||
<result column="effect_flag" jdbcType="TINYINT" property="effectFlag" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectUserVo">
|
||||
select category_type_id, parent_id, category_id, category_name, category_status,
|
||||
creator, creator_name, gmt_create, modifier, modifier_name, gmt_modified, effect_flag
|
||||
from ed_category
|
||||
</sql>
|
||||
|
||||
<select id="selectTopCategories" resultMap="CategoryResultMap">
|
||||
<include refid="selectUserVo" />
|
||||
where parent_id = 0 and category_status="available"
|
||||
</select>
|
||||
|
||||
<select id="selectAllCategories" resultMap="CategoryResultMap">
|
||||
<include refid="selectUserVo" />
|
||||
where category_status="available"
|
||||
</select>
|
||||
|
||||
<select id="selectCategories" resultMap="CategoryResultMap"
|
||||
parameterType="com.electromagnetic.industry.software.manage.pojo.models.Category">
|
||||
<include refid="selectUserVo" />
|
||||
where category_id = #{categoryId,jdbcType=VARCHAR} and category_status="available"
|
||||
</select>
|
||||
|
||||
<select id="selectChildCategories" resultMap="CategoryResultMap"
|
||||
parameterType="com.electromagnetic.industry.software.manage.pojo.models.Category">
|
||||
<include refid="selectUserVo" />
|
||||
where parent_id = #{parentId,jdbcType=VARCHAR} and category_status="available"
|
||||
</select>
|
||||
|
||||
<insert id="createCategory" parameterType="com.electromagnetic.industry.software.manage.pojo.models.Category">
|
||||
<selectKey keyProperty="id" order="AFTER" resultType="java.lang.Long">
|
||||
SELECT LAST_INSERT_ID()
|
||||
</selectKey>
|
||||
replace into ed_data_info (id,
|
||||
category_type_id, parent_id, category_id,
|
||||
category_name, category_status,
|
||||
creator, creator_name, gmt_create,
|
||||
modifier, modifier_name, gmt_modified,
|
||||
effect_flag
|
||||
)
|
||||
values (#{id,jdbcType=VARCHAR}, #{categoryTypeId,jdbcType=VARCHAR},
|
||||
#{parentId,jdbcType=VARCHAR}, #{categoryId,jdbcType=VARCHAR},
|
||||
#{categoryName,jdbcType=VARCHAR}, #{categoryStatus,jdbcType=VARCHAR},
|
||||
#{creator,jdbcType=VARCHAR}, #{creatorName,jdbcType=VARCHAR}, now(), #{modifier,jdbcType=VARCHAR},
|
||||
#{modifierName,jdbcType=VARCHAR},now(),1
|
||||
)
|
||||
</insert>
|
||||
|
||||
</mapper>
|
||||
|
|
@ -0,0 +1,132 @@
|
|||
<?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.electromagnetic.industry.software.manage.mapper.EDDataMapper">
|
||||
|
||||
<resultMap id="BaseResultMap" type="com.electromagnetic.industry.software.manage.pojo.models.EDDataInfo">
|
||||
<id column="id" jdbcType="BIGINT" property="id" />
|
||||
<result column="category_id" jdbcType="VARCHAR" property="categoryId" />
|
||||
<result column="data_id" jdbcType="VARCHAR" property="dataId" />
|
||||
<result column="data_no" jdbcType="VARCHAR" property="dataNo" />
|
||||
<result column="data_name" jdbcType="VARCHAR" property="dataName" />
|
||||
<result column="data_type" jdbcType="VARCHAR" property="dataType" />
|
||||
<result column="file_type" jdbcType="VARCHAR" property="fileType" />
|
||||
<result column="version" jdbcType="VARCHAR" property="version" />
|
||||
<result column="content" jdbcType="VARCHAR" property="content" />
|
||||
<result column="implant_json" jdbcType="VARCHAR" property="implantJson" />
|
||||
<result column="data_status" jdbcType="VARCHAR" property="dataStatus" />
|
||||
<result column="note" jdbcType="VARCHAR" property="note" />
|
||||
<result column="editor" jdbcType="VARCHAR" property="editor" />
|
||||
<result column="gmt_batch_upload" jdbcType="TIMESTAMP" property="gmtBatchUpload" />
|
||||
<result column="save_status" jdbcType="VARCHAR" property="saveStatus" />
|
||||
<result column="creator" jdbcType="VARCHAR" property="creator" />
|
||||
<result column="creator_name" jdbcType="VARCHAR" property="creatorName" />
|
||||
<result column="gmt_create" jdbcType="TIMESTAMP" property="gmtCreate" />
|
||||
<result column="modifier" jdbcType="VARCHAR" property="modifier" />
|
||||
<result column="modifier_name" jdbcType="VARCHAR" property="modifierName" />
|
||||
<result column="gmt_modified" jdbcType="TIMESTAMP" property="gmtModified" />
|
||||
<result column="effect_flag" jdbcType="TINYINT" property="effectFlag" />
|
||||
</resultMap>
|
||||
<sql id="Base_Column_list">
|
||||
id,category_id,data_id,data_no,data_name,data_type,file_type,version,content,
|
||||
implant_json,data_status,note,editor,gmt_batch_upload,save_status,creator,creator_name,gmt_create,modifier,modifier_name,
|
||||
gmt_modified,effect_flag
|
||||
</sql>
|
||||
|
||||
|
||||
<insert id="createDataInfo" parameterType="com.electromagnetic.industry.software.manage.pojo.models.EDDataInfo">
|
||||
<selectKey keyProperty="id" order="AFTER" resultType="java.lang.Long">
|
||||
SELECT LAST_INSERT_ID()
|
||||
</selectKey>
|
||||
replace into ed_data_info (category_id,
|
||||
data_id, data_no, data_name,
|
||||
data_type, file_type, version,
|
||||
content, implant_json, data_status,
|
||||
note, editor, gmt_batch_upload, save_status,
|
||||
creator, creator_name, gmt_create,
|
||||
modifier, modifier_name, gmt_modified,
|
||||
effect_flag
|
||||
)
|
||||
values (#{categoryId,jdbcType=VARCHAR},
|
||||
#{dataId,jdbcType=VARCHAR}, #{dataNo,jdbcType=VARCHAR}, #{dataName,jdbcType=VARCHAR},
|
||||
#{dataType,jdbcType=VARCHAR}, #{fileType,jdbcType=VARCHAR},#{version,jdbcType=VARCHAR},
|
||||
#{content,jdbcType=VARCHAR}, #{implantJson,jdbcType=VARCHAR}, #{dataStatus,jdbcType=VARCHAR},
|
||||
#{note,jdbcType=VARCHAR}, #{editor,jdbcType=VARCHAR}, #{gmtBatchUpload,jdbcType=TIMESTAMP}, #{saveStatus,jdbcType=VARCHAR},
|
||||
#{creator,jdbcType=VARCHAR}, #{creatorName,jdbcType=VARCHAR}, now(), #{modifier,jdbcType=VARCHAR},
|
||||
#{modifierName,jdbcType=VARCHAR},now(),1
|
||||
)
|
||||
</insert>
|
||||
|
||||
<select id="getDataInfoList" resultMap="BaseResultMap"
|
||||
parameterType="com.electromagnetic.industry.software.manage.pojo.other.EDDataParams">
|
||||
SELECT
|
||||
<include refid="Base_Column_list"/>
|
||||
FROM
|
||||
ed_data_info
|
||||
where
|
||||
effect_flag = 1
|
||||
<if test="parentId!=null and parentId!=''">
|
||||
and category_id='${parentId}'
|
||||
</if>
|
||||
<if test="dataId!=null and dataId!=''">
|
||||
and data_id='${dataId}'
|
||||
</if>
|
||||
<if test="keyWord!=null and keyWord!=''">
|
||||
and data_name LIKE '%${keyWord}%'
|
||||
</if>
|
||||
<if test="dataType != null and dataType!=''">
|
||||
and data_type = '${dataType}'
|
||||
</if>
|
||||
<if test="saveStatus!=null and saveStatus!=''">
|
||||
and save_status='${saveStatus}'
|
||||
</if>
|
||||
GROUP BY id
|
||||
<if test="gmtCreate == 'asc' or gmtCreate =='desc'">
|
||||
order by gmt_create ${gmtCreate}
|
||||
</if>
|
||||
<if test = "gmtCreate == null or gmtCreate == ''">
|
||||
order by gmt_create desc
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<update id="updateFileInfo" parameterType="com.electromagnetic.industry.software.manage.pojo.other.EDDataParams">
|
||||
update ed_data_info
|
||||
<set>
|
||||
<if test="name != null and name!=''">
|
||||
data_name = #{name,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="dataStatus != null and dataStatus!=''">
|
||||
data_status = #{dataStatus,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="note != null and note!=''">
|
||||
note = #{note,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="saveStatus != null and note!=''">
|
||||
save_status = #{saveStatus,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="effectFlag != null and effectFlag!=''">
|
||||
effect_flag = #{effectFlag,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="userId != null and userId!=''">
|
||||
modifier = #{userId,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="userName != null and userName!=''">
|
||||
modifier_name = #{userName,jdbcType=VARCHAR},
|
||||
</if>
|
||||
gmt_modified = now()
|
||||
</set>
|
||||
<where>
|
||||
<!-- 条件 1:按数据编码修改 -->
|
||||
<if test="dataId != null and dataId != ''">
|
||||
data_id = #{dataId,jdbcType=VARCHAR}
|
||||
</if>
|
||||
<!-- 条件 2:按目录编码修改 -->
|
||||
<if test="parentId != null and parentId != ''">
|
||||
category_id = #{parentId,jdbcType=VARCHAR}
|
||||
</if>
|
||||
</where>
|
||||
|
||||
</update>
|
||||
|
||||
</mapper>
|
||||
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
<?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.electromagnetic.industry.software.manage.mapper.TokenMapper">
|
||||
<resultMap id="TokenResultMap" type="com.electromagnetic.industry.software.manage.pojo.models.Token">
|
||||
<id column="id" jdbcType="BIGINT" property="id" />
|
||||
<result column="user_id" jdbcType="VARCHAR" property="userId" />
|
||||
<result column="token" jdbcType="VARCHAR" property="token" />
|
||||
<result column="is_long_term" jdbcType="TINYINT" property="isLongTerm" />
|
||||
<result column="created_at" jdbcType="TIMESTAMP" property="createdAt" />
|
||||
<result column="expire_at" jdbcType="TIMESTAMP" property="expireAt" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectTokenVo">
|
||||
select id, user_id, token, is_long_term, created_at, expire_at from tokens
|
||||
</sql>
|
||||
|
||||
<insert id="insert" parameterType="com.electromagnetic.industry.software.manage.pojo.models.Token">
|
||||
insert into tokens(
|
||||
<if test="userId != null and userId !='' ">user_id,</if>
|
||||
<if test="token != null and token !='' ">token,</if>
|
||||
is_long_term,
|
||||
created_at,
|
||||
<if test="expireAt != null">expire_at</if>
|
||||
)
|
||||
values (
|
||||
<if test="userId != null and userId !='' ">#{userId},</if>
|
||||
<if test="token != null and token !='' ">#{token},</if>
|
||||
0,
|
||||
now(),
|
||||
<if test="expireAt !=null">#{expireAt}</if>
|
||||
)
|
||||
</insert>
|
||||
|
||||
<select id="selectToken" parameterType="String" resultMap="TokenResultMap">
|
||||
<include refid="selectTokenVo" />
|
||||
where token=#{token}
|
||||
</select>
|
||||
|
||||
<delete id="deleteToken" parameterType="String">
|
||||
delete from tokens where token=#{token}
|
||||
</delete>
|
||||
|
||||
</mapper>
|
||||
|
|
@ -0,0 +1,212 @@
|
|||
<?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.electromagnetic.industry.software.manage.mapper.UserMapper">
|
||||
<resultMap id="UserResultMap" type="com.electromagnetic.industry.software.manage.pojo.models.User">
|
||||
<id column="id" jdbcType="BIGINT" property="id" />
|
||||
<result column="user_id" jdbcType="VARCHAR" property="userId" />
|
||||
<result column="user_name" jdbcType="VARCHAR" property="userName" />
|
||||
<result column="work_number" jdbcType="VARCHAR" property="workNumber" />
|
||||
<result column="mobile" jdbcType="VARCHAR" property="mobile" />
|
||||
<result column="user_dept" jdbcType="VARCHAR" property="userDept" />
|
||||
<result column="user_title" jdbcType="VARCHAR" property="userTitle" />
|
||||
<result column="user_pwd" jdbcType="VARCHAR" property="userPwd" />
|
||||
<result column="join_time" jdbcType="TIMESTAMP" property="joinTime" />
|
||||
<result column="is_published" jdbcType="TINYINT" property="isPublished" />
|
||||
<result column="salt" jdbcType="VARCHAR" property="salt" />
|
||||
<result column="user_status" jdbcType="VARCHAR" property="userStatus" />
|
||||
<result column="internship_end_date" jdbcType="DATE" property="internshipEndDate"/>
|
||||
<result column="creator" jdbcType="VARCHAR" property="creator" />
|
||||
<result column="creator_name" jdbcType="VARCHAR" property="creatorName" />
|
||||
<result column="gmt_create" jdbcType="TIMESTAMP" property="gmtCreate" />
|
||||
<result column="modifier" jdbcType="VARCHAR" property="modifier" />
|
||||
<result column="modifier_name" jdbcType="VARCHAR" property="modifierName" />
|
||||
<result column="gmt_modified" jdbcType="TIMESTAMP" property="gmtModified" />
|
||||
<result column="effect_flag" jdbcType="TINYINT" property="effectFlag" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectUserVo">
|
||||
select user_id, user_name, work_number, mobile, user_dept, user_title, user_pwd,
|
||||
join_time, is_published, salt, user_status, internship_end_date,
|
||||
creator, creator_name, gmt_create, modifier, modifier_name, gmt_modified, effect_flag
|
||||
from ed_users
|
||||
</sql>
|
||||
|
||||
<insert id="insert" parameterType="com.electromagnetic.industry.software.manage.pojo.models.User">
|
||||
insert into ed_users(
|
||||
<if test="userId != null and userId !='' ">user_id,</if>
|
||||
<if test="userName != null and userName !='' ">user_name,</if>
|
||||
<if test="workNumber != null and workNumber !='' ">work_number,</if>
|
||||
<if test="mobile != null and mobile !='' ">mobile,</if>
|
||||
<if test="userDept != null and userDept !='' ">user_dept,</if>
|
||||
<if test="userTitle != null and userTitle !='' ">user_title,</if>
|
||||
<if test="userPwd != null and userPwd !='' ">user_pwd,</if>
|
||||
<if test="joinTime != null">join_time,</if>
|
||||
<if test="isPublished != null">is_published,</if>
|
||||
<if test="salt != null and salt !='' ">salt,</if>
|
||||
<if test="userStatus != null and userStatus !='' ">user_status,</if>
|
||||
<if test="internshipEndDate != null">internship_end_date,</if>
|
||||
<if test="creator != null and creator !='' ">creator,</if>
|
||||
<if test="creatorName != null and creatorName !='' ">creator_name,</if>
|
||||
gmt_create,
|
||||
effect_flag)
|
||||
values (
|
||||
<if test="userId != null and userId !='' ">#{userId},</if>
|
||||
<if test="userName != null and userName !='' ">#{userName},</if>
|
||||
<if test="workNumber != null and workNumber !='' ">#{workNumber},</if>
|
||||
<if test="mobile != null and mobile !='' ">#{mobile},</if>
|
||||
<if test="userDept != null and userDept !='' ">#{userDept},</if>
|
||||
<if test="userTitle != null and userTitle !='' ">#{userTitle},</if>
|
||||
<if test="userPwd != null and userPwd !='' ">#{userPwd},</if>
|
||||
<if test="joinTime != null">#{joinTime},</if>
|
||||
<if test="isPublished != null">#{isPublished},</if>
|
||||
<if test="salt != null and salt !='' ">#{salt},</if>
|
||||
<if test="userStatus != null and userStatus !='' ">#{userStatus},</if>
|
||||
<if test="internshipEndDate != null">#{internshipEndDate},</if>
|
||||
<if test="creator != null and creator !='' ">#{creator},</if>
|
||||
<if test="creatorName != null and creatorName !='' ">#{creatorName},</if>
|
||||
now(),
|
||||
1
|
||||
)
|
||||
</insert>
|
||||
<update id="modify" parameterType="com.electromagnetic.industry.software.manage.pojo.models.User">
|
||||
update ed_users
|
||||
<set>
|
||||
<if test="userId != null and userId != ''">user_id = #{userId},</if>
|
||||
<if test="userName != null and userName != ''">user_name = #{userName},</if>
|
||||
<if test="workNumber != null and workNumber != ''">work_number = #{workNumber},</if>
|
||||
<if test="mobile != null and mobile != ''">mobile = #{mobile},</if>
|
||||
<if test="userDept != null and userDept != ''">user_dept = #{userDept},</if>
|
||||
<if test="userTitle != null and userTitle != ''">user_title = #{userTitle},</if>
|
||||
<if test="joinTime != null">join_time = #{joinTime},</if>
|
||||
<if test="userStatus != null and userStatus != ''">user_status = #{userStatus},</if>
|
||||
internship_end_date = #{internshipEndDate},
|
||||
<if test="modifier != null and modifier != ''">modifier = #{modifier},</if>
|
||||
<if test="modifierName != null and modifierName != ''">modifier_name = #{modifierName},</if>
|
||||
gmt_modified=now()
|
||||
</set>
|
||||
where user_id= #{userId}
|
||||
</update>
|
||||
|
||||
|
||||
<update id="publish" parameterType="com.electromagnetic.industry.software.manage.pojo.other.PublishParam">
|
||||
update ed_users
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
is_published = 1,
|
||||
<if test="modifier != null and modifier != ''">modifier = #{modifier},</if>
|
||||
<if test="modifierName != null and modifierName != ''">modifier_name = #{modifierName},</if>
|
||||
gmt_modified = now()
|
||||
</trim>
|
||||
where user_id IN
|
||||
<foreach collection="userIds" item="userId" open="(" separator="," close=")">
|
||||
#{userId}
|
||||
</foreach>
|
||||
</update>
|
||||
|
||||
<select id="search" parameterType="com.electromagnetic.industry.software.manage.pojo.other.SearchKeyWords" resultMap="UserResultMap">
|
||||
SELECT *
|
||||
FROM ed_users
|
||||
<where>
|
||||
<!-- 条件 1:按用户名或工号搜索 -->
|
||||
<if test="keyWord != null and keyWord != ''">
|
||||
(user_name LIKE CONCAT('%', #{keyWord}, '%') OR work_number LIKE CONCAT('%', #{keyWord}, '%'))
|
||||
</if>
|
||||
|
||||
<!-- 条件 2:按用户状态搜索 -->
|
||||
<if test="userStatus != null and userStatus != ''">
|
||||
<choose>
|
||||
<when test="userStatus != 'all'">
|
||||
AND user_status = #{userStatus}
|
||||
</when>
|
||||
</choose>
|
||||
</if>
|
||||
|
||||
<!-- 条件 3:按发布状态搜索 -->
|
||||
<if test="isPublished != null and isPublished != ''">
|
||||
<choose>
|
||||
<when test="isPublished != 'all'">
|
||||
AND is_published = CAST(#{isPublished} AS SIGNED)
|
||||
</when>
|
||||
</choose>
|
||||
</if>
|
||||
and effect_flag=1
|
||||
</where>
|
||||
|
||||
<!-- 动态排序条件 -->
|
||||
<choose>
|
||||
<when test="gmtCreate == 'asc' or gmtCreate == 'desc'">
|
||||
ORDER BY gmt_create ${gmtCreate}
|
||||
</when>
|
||||
<when test="joinTime == 'asc' or joinTime == 'desc'">
|
||||
ORDER BY join_time ${joinTime}
|
||||
</when>
|
||||
<when test="internEndDate == 'asc' or internEndDate == 'desc'">
|
||||
ORDER BY internship_end_date ${internEndDate}
|
||||
</when>
|
||||
</choose>
|
||||
LIMIT #{pageSize} OFFSET #{pageIndex}
|
||||
</select>
|
||||
|
||||
<select id="getTotalCount" parameterType="com.electromagnetic.industry.software.manage.pojo.other.SearchKeyWords" resultType="Integer">
|
||||
SELECT COUNT(*)
|
||||
FROM ed_users
|
||||
<where>
|
||||
<!-- 条件 1:按用户名或工号搜索 -->
|
||||
<if test="keyWord != null and keyWord != ''">
|
||||
(user_name LIKE CONCAT('%', #{keyWord}, '%') OR work_number LIKE CONCAT('%', #{keyWord}, '%'))
|
||||
</if>
|
||||
|
||||
<!-- 条件 2:按用户状态搜索 -->
|
||||
<if test="userStatus != null and userStatus != ''">
|
||||
<choose>
|
||||
<when test="userStatus != 'all'">
|
||||
AND user_status = #{userStatus}
|
||||
</when>
|
||||
</choose>
|
||||
</if>
|
||||
|
||||
<!-- 条件 3:按发布状态搜索 -->
|
||||
<if test="isPublished != null and isPublished != ''">
|
||||
<choose>
|
||||
<when test="isPublished != 'all'">
|
||||
AND is_published = #{isPublished}
|
||||
</when>
|
||||
</choose>
|
||||
</if>
|
||||
and effect_flag=1
|
||||
</where>
|
||||
|
||||
<!-- 动态排序条件 -->
|
||||
<choose>
|
||||
<when test="gmtCreate == 'asc' or gmtCreate == 'desc'">
|
||||
ORDER BY gmt_create ${gmtCreate}
|
||||
</when>
|
||||
<when test="joinTime == 'asc' or joinTime == 'desc'">
|
||||
ORDER BY join_time ${joinTime}
|
||||
</when>
|
||||
<when test="internEndDate == 'asc' or internEndDate == 'desc'">
|
||||
ORDER BY internship_end_date ${internEndDate}
|
||||
</when>
|
||||
</choose>
|
||||
</select>
|
||||
|
||||
<select id="selectUserByWorkNumber" parameterType="String" resultMap="UserResultMap">
|
||||
<include refid="selectUserVo" />
|
||||
where work_number = #{workNumber}
|
||||
</select>
|
||||
|
||||
<select id="getSingleUser" parameterType="String" resultMap="UserResultMap">
|
||||
<include refid="selectUserVo" />
|
||||
where user_id = #{userId}
|
||||
</select>
|
||||
|
||||
<update id="deleteUser" parameterType="com.electromagnetic.industry.software.manage.pojo.other.UserDeleteKeyWords">
|
||||
update ed_users
|
||||
<set>
|
||||
effect_flag=0,
|
||||
modifier=#{modifier},
|
||||
modifier_name=#{modifierName},
|
||||
gmt_modified = now()
|
||||
</set>
|
||||
where user_id = #{userId}
|
||||
</update>
|
||||
</mapper>
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
//import com.electromagnetic.industry.software.manage.Application;
|
||||
//import com.electromagnetic.industry.software.manage.mapper.CategoryMapper;
|
||||
//import com.electromagnetic.industry.software.manage.pojo.models.Category;
|
||||
//import org.junit.jupiter.api.Test;
|
||||
//import org.springframework.boot.test.context.SpringBootTest;
|
||||
//
|
||||
//import javax.annotation.Resource;
|
||||
//import java.util.List;
|
||||
//
|
||||
//@SpringBootTest(classes = Application.class)
|
||||
//public class Test1 {
|
||||
//
|
||||
// @Resource
|
||||
// private CategoryMapper categoryMapper;
|
||||
//
|
||||
// @Test
|
||||
// public void test() {
|
||||
// List<Category> categories = categoryMapper.selectAllCategories();
|
||||
// System.out.println("categories = " + categories);
|
||||
// }
|
||||
//
|
||||
//}
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
<?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.electromagnetic.data</groupId>
|
||||
<artifactId>electromagnetic-data-new</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>electromagnetic-common</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
<maven.compiler.target>8</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<jwt.version>0.9.0</jwt.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>1.18.34</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.jsonwebtoken</groupId>
|
||||
<artifactId>jjwt</artifactId>
|
||||
<version>${jwt.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.bouncycastle</groupId>
|
||||
<artifactId>bcprov-jdk16</artifactId>
|
||||
<version>1.46</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-all</artifactId>
|
||||
<version>5.8.22</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
package com.electromagnetic.industry.software.common.cons;
|
||||
|
||||
public interface ElectromagneticConstants {
|
||||
|
||||
String EXPORT_FILE_SUFFIX = ".colib";
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
package com.electromagnetic.industry.software.common.cons;
|
||||
|
||||
public interface UserConstants {
|
||||
|
||||
/**
|
||||
* 默认初始密码
|
||||
*/
|
||||
String DEFAULT_PASSWORD = "123456";
|
||||
|
||||
/**
|
||||
* 默认发布状态(未发布)
|
||||
*/
|
||||
int DEFAULT_PUBLISH_STATUS = 0;
|
||||
|
||||
/**
|
||||
* 默认令牌过期时间(7天)
|
||||
*/
|
||||
long DEFAULT_EXPIRE_TIME = 7*24*60*60*1000;
|
||||
|
||||
/**
|
||||
* 令牌密钥
|
||||
*/
|
||||
String SECRET_KEY = "5JKRGV0QO4WK1WCWVK55YEU0A1NPOXOP";
|
||||
|
||||
/**
|
||||
* 令牌前缀
|
||||
*/
|
||||
String LOGIN_USER_NAME = "userName";
|
||||
String LOGIN_WORK_NUMBER = "workNumber";
|
||||
String LOGIN_USER_ID = "userId";
|
||||
|
||||
/**
|
||||
* 管理员账号
|
||||
*/
|
||||
String ADMIN_WORK_NUMBER = "100000";
|
||||
}
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
package com.electromagnetic.industry.software.common.enums;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 是否删除枚举
|
||||
*
|
||||
* @author zhangxiong.pt
|
||||
* @version $Id: EffectFlagEnum.java, v 0.1 2024-08-01 18:18
|
||||
*/
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
public enum EffectFlagEnum {
|
||||
/**
|
||||
* 有效
|
||||
*/
|
||||
EFFECT_FLAG_1(1,"有效"),
|
||||
/**
|
||||
* 无效
|
||||
*/
|
||||
EFFECT_FLAG_0(0,"无效"),
|
||||
;
|
||||
private Integer code;
|
||||
private String desc;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,201 @@
|
|||
package com.electromagnetic.industry.software.common.enums;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
public enum ElectromagneticErrorEnum implements ErrorEnum {
|
||||
/**
|
||||
* 系统
|
||||
*/
|
||||
SYSTEM_ERROR(ErrorLevels.ERROR, ErrorTypes.BIZ, "000", "SYSTEM_ERROR", "系统异常"),
|
||||
PARAMS_ERROR(ErrorLevels.ERROR, ErrorTypes.BIZ, "001", "PARAMS_ERROR", "参数异常"),
|
||||
/*****************业务级*****************/
|
||||
|
||||
|
||||
//111
|
||||
INPUT_PARAMETER_IS_EMPTY(ErrorLevels.ERROR, ErrorTypes.BIZ, "53001", "INPUT_PARAMETER_IS_EMPTY", "入参为空"),
|
||||
NAME_IS_EMPTY(ErrorLevels.ERROR, ErrorTypes.BIZ, "53002", "NAME_IS_EMPTY", "名字为空"),
|
||||
CREATOR_IS_EMPTY(ErrorLevels.ERROR, ErrorTypes.BIZ, "53003", "CREATOR_IS_EMPTY", "创建人不能为空"),
|
||||
NAME_IS_REPEAT(ErrorLevels.ERROR, ErrorTypes.BIZ, "53004", "NAME_IS_REPEAT", "名字重复"),
|
||||
NAME_FORM_ERROR(ErrorLevels.ERROR, ErrorTypes.BIZ, "53005", "NAME_FORM_ERROR", "名字格式不正确"),
|
||||
PARENT_CATEGORY_NOT_EXIST(ErrorLevels.ERROR, ErrorTypes.BIZ, "53006", "PARENT_CATEGORY_NOT_EXIST", "父类目不存在"),
|
||||
DEPT_NOT_EXIST(ErrorLevels.ERROR, ErrorTypes.BIZ, "53007", "DEPT_NOT_EXIST", "属主部门不存在"),
|
||||
|
||||
CATEGORY_BUILD_ERROR(ErrorLevels.ERROR, ErrorTypes.BIZ, "53008", "CATEGORY_BUILD_ERROR", "类目代码生成失败"),
|
||||
CATEGORY_INSERT_ERROR(ErrorLevels.ERROR, ErrorTypes.BIZ, "53009", "CATEGORY_INSERT_ERROR", "类目新增异常"),
|
||||
CATEGORY_NOT_EXIST_ERROR(ErrorLevels.ERROR, ErrorTypes.BIZ, "53010", "CATEGORY_NOT_EXIST_ERROR", "类目不存在"),
|
||||
CATEGORY_DELETE_ERROR(ErrorLevels.ERROR, ErrorTypes.BIZ, "53011", "CATEGORY_DELETE_ERROR", "类目删除异常"),
|
||||
REPORT_STATUS_CREATE(ErrorLevels.ERROR, ErrorTypes.BIZ, "53012", "REPORT_STATUS_CREATE", "新建状态可以编辑"),
|
||||
REPORT_STATUS_DELETE(ErrorLevels.ERROR, ErrorTypes.BIZ, "53013", "REPORT_STATUS_CREATE", "新建状态可以删除"),
|
||||
REPORT_DELETE(ErrorLevels.ERROR, ErrorTypes.BIZ, "53014", "REPORT_DELETE", "删除失败"),
|
||||
REPORT_UPDATE(ErrorLevels.ERROR, ErrorTypes.BIZ, "53015", "REPORT_UPDATE", "更新失败"),
|
||||
REPORT_CREATE(ErrorLevels.ERROR, ErrorTypes.BIZ, "53016", "REPORT_CREATE", "创建失败"),
|
||||
REPORT_STATUS(ErrorLevels.ERROR, ErrorTypes.BIZ, "53017", "REPORT_STATUS",
|
||||
"传入对应更新状态:●状态为“新增”,可操作“上架:3”;●状态为“使用中”,可传入“下架:4”;●状态为“将下架”,可操作“取消下架:6”"),
|
||||
REPORT_GINSENG_NULL(ErrorLevels.ERROR, ErrorTypes.BIZ, "53018", "REPORT_GINSENG_NULL", "入参为空"),
|
||||
REPORT_CHECK_NAME(ErrorLevels.ERROR, ErrorTypes.BIZ, "53019", "REPORT_GINSENG_NULL", "名称重复,请重新输入"),
|
||||
GETSEQUENCEID_ERROR(ErrorLevels.ERROR, ErrorTypes.BIZ, "53020", "GETSEQUENCEID_ERROR", "序列化ID生成错误"),
|
||||
GET_DEPT_CODE_ERROR(ErrorLevels.ERROR, ErrorTypes.BIZ, "53020", "GET_DEPT_CODE_ERROR", "部门编码获取异常"),
|
||||
REPORT_NO_ERROR(ErrorLevels.ERROR, ErrorTypes.BIZ, "53021", "REPORT_NO_ERROR", "ID生成不能为空"),
|
||||
DEPT_INSERT_ERROR(ErrorLevels.ERROR, ErrorTypes.BIZ, "53022", "DEPT_INSERT_ERROR", "新增异常"),
|
||||
DEPT_EXIST(ErrorLevels.ERROR, ErrorTypes.BIZ, "53023", "DEPT_EXIST", "属主部门已存在"),
|
||||
DEPT_ENUM_NOT_EXIST(ErrorLevels.ERROR, ErrorTypes.BIZ, "53024", "DEPT_ENUM_NOT_EXIST", "属主部门枚举映射不存在"),
|
||||
DEPT_DELETE_ERROR(ErrorLevels.ERROR, ErrorTypes.BIZ, "53025", "DEPT_DELETE_ERROR", "部门删除异常"),
|
||||
REPORT_UN_SHELVE_ERROR(ErrorLevels.ERROR, ErrorTypes.BIZ, "53026", "REPORT_UN_SHELVE_ERROR", "下架數據为空"),
|
||||
|
||||
REPORT_ID_NULL(ErrorLevels.ERROR, ErrorTypes.BIZ, "53027", "REPORT_ID_NULL", "ID对应数据不存在"),
|
||||
REPORT_UN_SHELVE_NULL(ErrorLevels.ERROR, ErrorTypes.BIZ, "53028", "REPORT_ID_NULL", "沒有下架數據"),
|
||||
REPORT_CATEOGRYLV1_NULL(ErrorLevels.ERROR, ErrorTypes.BIZ, "53029", "REPORT_ID_NULL", "一級類目为空"),
|
||||
REPORT_CATEOGRYLV2_NULL(ErrorLevels.ERROR, ErrorTypes.BIZ, "53030", "REPORT_ID_NULL", "二級類目为空"),
|
||||
CATEGORY_EXIST(ErrorLevels.ERROR, ErrorTypes.BIZ, "53031", "CATEGORY_EXIST", "类目已存在"),
|
||||
CATEGORY_EXIST_REPORT(ErrorLevels.ERROR, ErrorTypes.BIZ, "53032", "CATEGORY_EXIST_REPORT", "类目下已挂在数据"),
|
||||
REPORT_URL_ERROR(ErrorLevels.ERROR, ErrorTypes.BIZ, "53033", "REPORT_URL_ERROR", "FR报表地址错误"),
|
||||
REPORT_OFF_DESC_NULL(ErrorLevels.ERROR, ErrorTypes.BIZ, "53034", "REPORT_URL_ERROR", "下架原因不能为空"),
|
||||
REPORT_CANCEL_OFF_DESC_NULL(ErrorLevels.ERROR, ErrorTypes.BIZ, "53035", "REPORT_URL_ERROR", "取消下架原因不能为空"),
|
||||
DEPT_EXIST_REPORT(ErrorLevels.ERROR, ErrorTypes.BIZ, "53036", "DEPT_EXIST_REPORT", "部门下已挂在数据"),
|
||||
FINE_CREATE_USER_ERROR(ErrorLevels.ERROR, ErrorTypes.BIZ, "53037", "FINE_CREATE_USER_ERROR", "创建用户失败"),
|
||||
FINE_CONNECT_LIST_ERROR(ErrorLevels.ERROR, ErrorTypes.BIZ, "53038", "FINE_CONNECT_LIST_ERROR", "获取finebi数据库连接列表错误"),
|
||||
FINE_CONNECT_TABLE_ERROR(ErrorLevels.ERROR, ErrorTypes.BIZ, "53039", "FINE_CONNECT_TABLE_ERROR", "获取finebi数据库对应表列表错误"),
|
||||
FINE_ADD_GROUP_ERROR(ErrorLevels.ERROR, ErrorTypes.BIZ, "53040", "FINE_ADD_GROUP_ERROR", "添加分组报错"),
|
||||
FINE_ADD_PACK_ERROR(ErrorLevels.ERROR, ErrorTypes.BIZ, "53041", "FINE_ADD_PACK_ERROR", "添加业务包报错"),
|
||||
FINE_DELETE_USER_ERROR(ErrorLevels.ERROR, ErrorTypes.BIZ, "53042", "FINE_DELETE_USER_ERROR", "删除用户失败"),
|
||||
FINE_ADD_DB_ERROR(ErrorLevels.ERROR, ErrorTypes.BIZ, "53043", "FINE_ADD_DB_ERROR", "数据集已存在,请不要重复添加"),
|
||||
FINE_GET_TABLE_INFO_ERROR(ErrorLevels.ERROR, ErrorTypes.BIZ, "53044", "FINE_GET_TABLE_INFO_ERROR", "数据集表信息错误"),
|
||||
LABEL_OBJNAME_IS_CHINESE(ErrorLevels.ERROR, ErrorTypes.BIZ, "53045", "LABEL_OSS_ANALYSIS_FAIL", "名称不能包含特殊字符(下划线,横杠,加号 除外)"),
|
||||
MEASURE_EXCEL_READ_ERROR(ErrorLevels.ERROR, ErrorTypes.BIZ, "53046", "MEASURE_EXCEL_READ_ERROR", "文件读取失败,请按照模板重新上传!(是否有空值或重复数据或数据超过指定长度)"),
|
||||
MEASURE_UPDATE_STATUS_ERROR(ErrorLevels.ERROR, ErrorTypes.BIZ, "53047", "MEASURE_UPDATE_STATUS_ERROR", "当前状态不允许更新指标"),
|
||||
FINE_ADD_TABLE_ROW_AUTHORITY_ERROR(ErrorLevels.ERROR, ErrorTypes.BIZ, "53048", "FINE_ADD_TABLE_ROW_AUTHORITY_ERROR", "数据集添加行权限错误"),
|
||||
FINE_GET_ENTRY_TREE_ERROR(ErrorLevels.ERROR, ErrorTypes.BIZ, "53049", "fine_get_entry_tree_error", "bi获取目录报错"),
|
||||
FINE_ENTRY_AUTH_ERROR(ErrorLevels.ERROR, ErrorTypes.BIZ, "53050", "FINE_ENTRY_AUTH_ERROR", "目录授权失败"),
|
||||
OAR_ORG_AUTH_LIST_REPEAT(ErrorLevels.ERROR, ErrorTypes.BIZ, "53051", "oar_org_auth_list_repeat", "适用机构重复"),
|
||||
|
||||
ACCOUNT_INFO_NULL(ErrorLevels.ERROR, ErrorTypes.BIZ, "630005", "ACCOUNT_INFO_BY_ACC_ID_NULL", "调用运营支撑域获取信息为空"),
|
||||
ROLE_CODE_NULL(ErrorLevels.ERROR, ErrorTypes.BIZ, "630005", "ACCOUNT_INFO_BY_ACC_ID_NULL", "用户对应角色为空"),
|
||||
ROLE_ORG_CODE_NULL(ErrorLevels.ERROR, ErrorTypes.BIZ, "630005", "ACCOUNT_INFO_BY_ACC_ID_NULL", "工作组对应組员为空"),
|
||||
USER_ROLE_ORG_CODE_NULL(ErrorLevels.ERROR, ErrorTypes.BIZ, "630008", "ACCOUNT_INFO_BY_ACC_ID_NULL", "角色对应机构为空"),
|
||||
OSS_ANALYSIS_FAIL(ErrorLevels.ERROR, ErrorTypes.BIZ, "50", "OSS_ANALYSIS_FAIL", "excel不能为空"),
|
||||
OAR_OFFLINE_CONFIG_NAME_REPEAT(ErrorLevels.ERROR, ErrorTypes.BIZ, "630009", "OAR_OFFLINE_CONFIG_NAME_REPEAT", "名称重复"),
|
||||
OAR_OFFLINE_CONFIG_DIMENSION_MEASURE_ERROR1(ErrorLevels.ERROR, ErrorTypes.BIZ, "630009", "OAR_OFFLINE_CONFIG_DIMENSION_MEASURE_ERROR1", "统计报表维度和度量不能为空"),
|
||||
OAR_OFFLINE_CONFIG_DIMENSION_MEASURE_ERROR2(ErrorLevels.ERROR, ErrorTypes.BIZ, "630009", "OAR_OFFLINE_CONFIG_DIMENSION_MEASURE_ERROR2", "清单报表维度和度量至少一个不能为空"),
|
||||
OAR_OFFLINE_CONFIG_CONDITION_VALUE_NULL(ErrorLevels.ERROR, ErrorTypes.BIZ, "6300010", "OAR_OFFLINE_CONFIG_CONDITION_VALUE_NULL", "筛选条件值不能为空"),
|
||||
OAR_OFFLINE_CONFIG_NAME_NOT_NULL(ErrorLevels.ERROR, ErrorTypes.BIZ, "630006", "OAR_OFFLINE_CONFIG_NAME_NOT_NULL", "任务名称不能为空"),
|
||||
OAR_OFFLINET_SQL_ERROR(ErrorLevels.ERROR, ErrorTypes.BIZ, "6300013", "OAR_OFFLINET_SQL_ERROR", "离线任务运行报错"),
|
||||
|
||||
OFFLINE_ERRORL(ErrorLevels.ERROR, ErrorTypes.BIZ, "630011", "OFFLINE_ERRORL", "更新失敗"),
|
||||
SEND_MESSAGE(ErrorLevels.ERROR, ErrorTypes.BIZ, "630012", "SEND_MESSAGE", "获取对应wrapper 异常"),
|
||||
OAR_OFFLINE_CONFIG_DETAIL_REPEAT(ErrorLevels.ERROR, ErrorTypes.BIZ, "630014", "oar_offline_config_detail_repeat", "该模板所选字段并无更改,请通过原模板 \"离线取数\" 功能提交离线任务!"),
|
||||
|
||||
EXCEL_TYPE_ERROR(ErrorLevels.ERROR, ErrorTypes.BIZ, "100", "EXCEL_TYPE_ERROR", "报表类型不正确"),
|
||||
EXCEL_DELETE(ErrorLevels.ERROR, ErrorTypes.BIZ, "101", "EXCEL_DELETE", "行业数据删除失败"),
|
||||
DATA_EXCEL_DELETE(ErrorLevels.ERROR, ErrorTypes.BIZ, "102", "DATA_EXCEL_DELETE", "业务数据删除失败"),
|
||||
IMPORT_DATA_EXCEL(ErrorLevels.ERROR, ErrorTypes.BIZ, "103", "IMPORT_DATA_EXCEL", "业务数据导入失败"),
|
||||
UPDATE_DATA_EXCEL(ErrorLevels.ERROR, ErrorTypes.BIZ, "104", "UPDATE_DATA_EXCEL", "业务数据更新失败"),
|
||||
INSTITUTION_CODE_ERROR(ErrorLevels.ERROR, ErrorTypes.BIZ, "105", "INSTITUTION_CODE_ERROR", "行机构编码错误!"),
|
||||
DATA_EMPTY(ErrorLevels.ERROR, ErrorTypes.BIZ, "106", "DATA_EMPTY", "模板存在空值,请检查并补充完整;"),
|
||||
NUMBER_EMPTY(ErrorLevels.ERROR, ErrorTypes.BIZ, "107", "NUMBER_EMPTY", "电融(万元)&网销(万元)&车商(万元)&线下(万元)&中介(万元)&重客(万元)总和不等于该行合计值"),
|
||||
DATA_EXIST(ErrorLevels.ERROR, ErrorTypes.BIZ, "108", "DATA_EXIST", "模板存在重复项,请检查更新!"),
|
||||
VELOCITY_ERROR(ErrorLevels.ERROR, ErrorTypes.BIZ, "109", "VELOCITY_ERROR", "模板转换失败"),
|
||||
PLAN_TYPE_DATE(ErrorLevels.ERROR, ErrorTypes.BIZ, "110", "PLAN_TYPE_DATE", "计划周期格式错误!"),
|
||||
WEEK_XUN_ERROR(ErrorLevels.ERROR, ErrorTypes.BIZ, "111", "WEEK_XUN_ERROR", "你所传的文件不是周旬报"),
|
||||
TOPIC_ERROR(ErrorLevels.ERROR, ErrorTypes.BIZ, "112", "TOPIC_ERROR", "主题不匹配"),
|
||||
CALIBER_ERROR(ErrorLevels.ERROR, ErrorTypes.BIZ, "113", "CALIBER_ERROR", "指标口径不匹配"),
|
||||
DATA_ERROR(ErrorLevels.ERROR, ErrorTypes.BIZ, "114", "DATA_ERROR", "报表缺失月份数据"),
|
||||
DATA_IS_EXIST(ErrorLevels.ERROR, ErrorTypes.BIZ, "115", "DATA_IS_EXIST", "数据已存在"),
|
||||
|
||||
DEPT_NULL(ErrorLevels.ERROR, ErrorTypes.BIZ, "53049", "DEPT_NULL", "当前该账户尚未授权,请联系管理员申请权限!"),
|
||||
MEMBER_NULL(ErrorLevels.ERROR, ErrorTypes.BIZ, "53050", "MEMBER_NULL", "对应组员为空"),
|
||||
ORG_NULL(ErrorLevels.ERROR, ErrorTypes.BIZ, "53050", "MEMBER_NULL", "用戶对应机构权限为空"),
|
||||
DATA_AUTHRIZATION(ErrorLevels.ERROR, ErrorTypes.BIZ, "53051", "DATA_AUTHRIZATION", "数据集授权"),
|
||||
GROUP_FLAG(ErrorLevels.ERROR, ErrorTypes.BIZ, "53052", "DATA_AUTHRIZATION", "工作组失效"),
|
||||
DATA_USER_NULL(ErrorLevels.ERROR, ErrorTypes.BIZ, "53053", "DATA_AUTHRIZATION", "数据为空"),
|
||||
DATA_UPDATE_NULL(ErrorLevels.ERROR, ErrorTypes.BIZ, "53054", "DATA_AUTHRIZATION", "数据为空。"),
|
||||
DATA_COLLECT_AUTH_IS(ErrorLevels.ERROR, ErrorTypes.BIZ, "53055", "DATA_COLLECT_AUTH_IS", "对应数据集和仪表板已经授权完成"),
|
||||
DATA_COLLECT_AUTH_IS_NULL(ErrorLevels.ERROR, ErrorTypes.BIZ, "53056", "DATA_COLLECT_AUTH_IS_NULL", "对应数据为空"),
|
||||
DATA_PRODUCT_NULL(ErrorLevels.ERROR, ErrorTypes.BIZ, "53057", "DATA_PRODUCT_NULL", "产品权限为空"),
|
||||
IMPORT_DATA_NULL(ErrorLevels.ERROR, ErrorTypes.BIZ, "53058", "IMPORT_DATA_NULL", "导入数据为空"),
|
||||
IMPORT_DATA_IS_NULL(ErrorLevels.ERROR, ErrorTypes.BIZ, "53059", "IMPORT_DATA_IS_NULL", "对应数据为空"),
|
||||
IMPORT_REPEAT_DATA(ErrorLevels.ERROR, ErrorTypes.BIZ, "53060", "IMPORT_REPEAT_DATA", "重复数据"),
|
||||
DATA_IS_INVALID(ErrorLevels.ERROR, ErrorTypes.BIZ, "53061", "DATA_IS_INVALID", "对应清单失效,请创建新的模板"),
|
||||
DATA_AUTH_USER_NULL(ErrorLevels.ERROR, ErrorTypes.BIZ, "53062", "data_auth_user_null", "用户组没有匹配到有权限的数据集"),
|
||||
FILE_NOT_EXIST(ErrorLevels.ERROR, ErrorTypes.BIZ, "53063", "FILE_NOT_EXIST", "字段文件下载失败"),
|
||||
EXCEL_FIELD_ANALYTICS_ERROR(ErrorLevels.ERROR, ErrorTypes.BIZ, "53066", "EXCEL_FIELD_ANALYTICS_ERROR", "excel解析异常,请检查内容"),
|
||||
TASK_TIME_ROLE(ErrorLevels.ERROR, ErrorTypes.BIZ, "53067", "TASK_TIME_ROLE", "请设置定时任务日期滚动规则后再提交"),
|
||||
TASK_TEMPLATE_CREATE(ErrorLevels.ERROR, ErrorTypes.BIZ, "53067", "TASK_TIME_ROLE", "支持1~50个字符!"),
|
||||
IMPORT_DATA_LENGTH(ErrorLevels.ERROR, ErrorTypes.BIZ, "53068", "IMPORT_DATA_LENGTH", "字段说明长度支持100个字符!"),
|
||||
FILE_NAME_ERROR(ErrorLevels.ERROR, ErrorTypes.BIZ, "53069", "FILE_NAME_ERROR", "文件命名错误"),
|
||||
FILE_NAME_REPEAT(ErrorLevels.ERROR, ErrorTypes.BIZ, "53070", "FILE_NAME_REPEAT", "存在相同命名的文件,请检查后重更新上传!"),
|
||||
INDICATORCARD_NULL(ErrorLevels.ERROR, ErrorTypes.BIZ, "53071", "INDICATORCARD_NULL", "指标卡为空!"),
|
||||
INDICATORCARD_DATA_ERROR(ErrorLevels.ERROR, ErrorTypes.BIZ, "53072", "INDICATORCARD_DATA_ERROR", "指标数据请求异常!"),
|
||||
ANALYSISITEMPLATE_ERROR(ErrorLevels.ERROR, ErrorTypes.BIZ, "53073", "ANALYSISITEMPLATE_ERROR", "模板创建DB失败!"),
|
||||
INDICATORCARD_DB_ERROR(ErrorLevels.ERROR, ErrorTypes.BIZ, "53074", "INDICATORCARD_DB_ERROR", "指标卡DB操作异常!"),
|
||||
INDICATORCARD_WARNING_NULL(ErrorLevels.ERROR, ErrorTypes.BIZ, "53075", "INDICATORCARD_WARNING_NULL", "预警已存在!"),
|
||||
RESOURCE_NO_GENERATE_ERROR(ErrorLevels.ERROR, ErrorTypes.BIZ, "53076", "RESOURCE_NO_GENERATE_ERROR", "业务编码生成异常,请联系管理员"),
|
||||
INDICATOR_DATASERVICE_NO_NULL(ErrorLevels.ERROR, ErrorTypes.BIZ, "53077", "INDICATOR_DATASERVICE_NO_NULL", "服务编码不能为空!"),
|
||||
INDICATOR_DT_NULL(ErrorLevels.ERROR, ErrorTypes.BIZ, "53078", "INDICATOR_DT_NULL", "指标数据DT时间为空!"),
|
||||
INDICATOR_HOST_NULL(ErrorLevels.ERROR, ErrorTypes.BIZ, "53079", "INDICATOR_HOST_NULL", "主指标不能为空!"),
|
||||
INDICATOR_CARD_NO_NULL(ErrorLevels.ERROR, ErrorTypes.BIZ, "53080", "INDICATOR_CARD_NO_NULL", "指标卡编码不能为空!"),
|
||||
INDICATOR_CARD_NULL(ErrorLevels.ERROR, ErrorTypes.BIZ, "53081", "INDICATOR_CARD_NULL", "无匹配的指标卡!"),
|
||||
INDICATOR_DATAFILE_NULL(ErrorLevels.ERROR, ErrorTypes.BIZ, "53082", "INDICATOR_DATAFILE_NULL", "返回数据中没有指标字段!"),
|
||||
INDICATOR_DT_ERROR(ErrorLevels.ERROR, ErrorTypes.BIZ, "53083", "INDICATOR_DT_ERROR", "请选择正确的DT或者服务编码!"),
|
||||
DRILLINGCONFIG_INDICATOR_NULL(ErrorLevels.ERROR, ErrorTypes.BIZ, "53084", "DRILLINGCONFIG_INDICATOR_NULL", "下钻配置字段未匹配到指标字段!"),
|
||||
DUTIES_UPDATE_IDS_ERROR(ErrorLevels.ERROR, ErrorTypes.BIZ, "53085", "DUTIES_UPDATE_IDS_ERROR", "入参ids不能为空"),
|
||||
DUTIES_MEASURES_UPDATE_LIST_ERROR(ErrorLevels.ERROR, ErrorTypes.BIZ, "53086", "DUTIES_MEASURES_UPDATE_LIST_ERROR", "举措信息不能为空"),
|
||||
INDICATOR_WARN_CREATE_ERROR(ErrorLevels.ERROR, ErrorTypes.BIZ, "53087", "INDICATOR_WARN_CREATE_ERROR", "保存指标预警规则失败"),
|
||||
INDICATOR_WARN_UPDATE_ERROR(ErrorLevels.ERROR, ErrorTypes.BIZ, "53088", "INDICATOR_WARN_UPDATE_ERROR", "指标预警规则更新失败"),
|
||||
INDICATOR_WARN_RESULT_ERROR(ErrorLevels.ERROR, ErrorTypes.BIZ, "53089", "INDICATOR_WARN_RESULT_ERROR", "指标预警结果查询失败"),
|
||||
INDICATOR_WARN_DEL_ERROR(ErrorLevels.ERROR, ErrorTypes.BIZ, "53090", "INDICATOR_WARN_DEL_ERROR", "指标预警删除失败"),
|
||||
INDICATOR_WARN_NULL_ERROR(ErrorLevels.ERROR, ErrorTypes.BIZ, "53091", "INDICATOR_WARN_NULL_ERROR", "请求预警中心参数为空"),
|
||||
MESSAGE_DING_PUSH_ERROR(ErrorLevels.ERROR, ErrorTypes.BIZ, "53092", "MESSAGE_DING_PUSH_ERROR", "钉钉消息推送失败"),
|
||||
INDICATORCARD_UPDATESTATUSOREFFECT_ERROR(ErrorLevels.ERROR, ErrorTypes.BIZ, "53093", "INDICATORCARD_UPDATESTATUSOREFFECT_ERROR", "指标卡状态更新或删除失败"),
|
||||
INDICATORCARD_INVALID_OPERATION(ErrorLevels.ERROR, ErrorTypes.BIZ, "53094", "INDICATORCARD_INVALID_OPERATION", "指标卡状态更新或删除无效的操作"),
|
||||
DUTIES_CREATE_ERROR(ErrorLevels.ERROR, ErrorTypes.BIZ, "53095", "DUTIES_CREATE_ERROR", "一键通知失败!"),
|
||||
DUTIES_MEASURES_SOLVETIME_ERROR(ErrorLevels.ERROR, ErrorTypes.BIZ, "53096", "DUTIES_MEASURES_SOLVETIME_ERROR", "请选择正确的举措时间"),
|
||||
USER_INFO_NULL(ErrorLevels.ERROR, ErrorTypes.BIZ, "53097", "USER_INFO_NULL", "用户信息不能为空!"),
|
||||
EXIST_GOAL_CONFIG(ErrorLevels.ERROR, ErrorTypes.BIZ, "53098", "EXIST_GOAL_CONFIG", "已存在该年度的目标计划!"),
|
||||
DATASERVICE_NULL(ErrorLevels.ERROR, ErrorTypes.BIZ, "53099", "DATASERVICE_NULL", "数据服务不存在!"),
|
||||
DATASERVICE_NO_NULL(ErrorLevels.ERROR, ErrorTypes.BIZ, "53100", "DATASERVICE_NO_NULL", "服务编码不存在!"),
|
||||
ANALYSISTEMPLATE_NO_NULL(ErrorLevels.ERROR, ErrorTypes.BIZ, "53101", "ANALYSISTEMPLATE_NO_NULL", "模板不存在!"),
|
||||
INDICATORCARWRAINGONE(ErrorLevels.ERROR, ErrorTypes.BIZ, "53102", "INDICATORCARWRAINGONE", "一个指标卡只支持一个预警指标!"),
|
||||
TESTDRILLINGDATA_ERROR(ErrorLevels.ERROR, ErrorTypes.BIZ, "53103", "TESTDRILLINGDATA_ERROR", "下钻服务测试失败!"),
|
||||
DRILLINGCONFIG_ORGLEVE_ERROR(ErrorLevels.ERROR, ErrorTypes.BIZ, "53104", " DRILLINGCONFIG_ORGLEVE_ERROR", "下钻机构权限勾选不正确!"),
|
||||
BRANCH_ORGANIZATION_ERROR(ErrorLevels.ERROR, ErrorTypes.BIZ, "53105", "BRANCH_ORGANIZATION_ERROR", "获取用户配置机构信息!"),
|
||||
;
|
||||
|
||||
|
||||
private String codeType;
|
||||
|
||||
private String codeLevel;
|
||||
|
||||
private String code;
|
||||
|
||||
private String errorMessage;
|
||||
|
||||
private String errorDesc;
|
||||
|
||||
/**
|
||||
* DataplatformLabelErrorEnum
|
||||
*
|
||||
* @param codeLevel
|
||||
* @param codeType
|
||||
* @param code
|
||||
* @param errorMessage
|
||||
* @param errorDesc
|
||||
*/
|
||||
ElectromagneticErrorEnum(String codeLevel, String codeType, String code, String errorMessage, String errorDesc) {
|
||||
|
||||
this.codeType = codeType;
|
||||
this.codeLevel = codeLevel;
|
||||
this.code = code;
|
||||
this.errorMessage = errorMessage;
|
||||
this.errorDesc = errorDesc;
|
||||
}
|
||||
|
||||
public void setErrorDesc(String errorDesc) {
|
||||
this.errorDesc = errorDesc;
|
||||
}
|
||||
|
||||
public ElectromagneticErrorEnum changeErrorDesc(String str) {
|
||||
this.setErrorDesc(str);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
package com.electromagnetic.industry.software.common.enums;
|
||||
|
||||
public interface ErrorEnum {
|
||||
|
||||
String getCodeType();
|
||||
|
||||
String getCodeLevel();
|
||||
|
||||
String getCode();
|
||||
|
||||
String getErrorMessage();
|
||||
|
||||
String getErrorDesc();
|
||||
}
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
package com.electromagnetic.industry.software.common.enums;
|
||||
|
||||
/**
|
||||
* @author wsk
|
||||
* @version $Id: ErrorLevels.java, v 0.1 2024-10-17 17:44 wsk
|
||||
*/
|
||||
public interface ErrorLevels {
|
||||
|
||||
/** INFO级别 */
|
||||
public static final String INFO = "1";
|
||||
|
||||
/** WARN级别 */
|
||||
public static final String WARN = "3";
|
||||
|
||||
/** ERROR级别 */
|
||||
public static final String ERROR = "5";
|
||||
|
||||
/** FATAL级别 */
|
||||
public static final String FATAL = "7";
|
||||
}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
package com.electromagnetic.industry.software.common.enums;
|
||||
|
||||
public interface ErrorTypes {
|
||||
|
||||
/** 系统错误 */
|
||||
public static final String SYSTEM = "0";
|
||||
|
||||
/** 业务错误 */
|
||||
@Deprecated
|
||||
public static final String BIZ = "1";
|
||||
|
||||
/** 第三方错误 */
|
||||
@Deprecated
|
||||
public static final String THIRD_PARTY = "2";
|
||||
|
||||
/** 业务错误,客户感知 */
|
||||
public static final String BIZ_CUSTOMER = "9";
|
||||
}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
package com.electromagnetic.industry.software.common.enums;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
public enum PublishEnum {
|
||||
/**
|
||||
* 已发布
|
||||
*/
|
||||
PUBLISHED(1,"已发布"),
|
||||
/**
|
||||
* 未发布
|
||||
*/
|
||||
UNPUBLISHED(0,"未发布"),
|
||||
;
|
||||
private Integer code;
|
||||
private String desc;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
package com.electromagnetic.industry.software.common.pojo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class UserLoginInfo {
|
||||
|
||||
/**
|
||||
* 工号
|
||||
*/
|
||||
private String workNumber;
|
||||
|
||||
/**
|
||||
* 用户名
|
||||
*/
|
||||
private String username;
|
||||
|
||||
/**
|
||||
* 用户编号
|
||||
*/
|
||||
private String userId;
|
||||
|
||||
/**
|
||||
* 用户密码
|
||||
*/
|
||||
private String userPwd;
|
||||
|
||||
/**
|
||||
* 令牌
|
||||
*/
|
||||
private String token;
|
||||
}
|
||||
|
|
@ -0,0 +1,124 @@
|
|||
package com.electromagnetic.industry.software.common.resp;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class ElectromagneticResult<T> implements Serializable, Result {
|
||||
|
||||
private static final long serialVersionUID = -6408526187818056594L;
|
||||
/**
|
||||
* 请求成功还是失败
|
||||
*/
|
||||
private Boolean success;
|
||||
|
||||
/**
|
||||
* 错误码
|
||||
*/
|
||||
private String errorCode;
|
||||
|
||||
/**
|
||||
* 错误消息
|
||||
*/
|
||||
private String errorMessage;
|
||||
|
||||
/**
|
||||
* 数据对象传给前台的json
|
||||
*/
|
||||
private T data;
|
||||
|
||||
public ElectromagneticResult() {
|
||||
|
||||
}
|
||||
|
||||
public ElectromagneticResult(Boolean success, String errorCode, String errorMessage, T data) {
|
||||
this.success = success;
|
||||
this.errorCode = errorCode;
|
||||
this.errorMessage = errorMessage;
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter method for property <tt>success</tt>.
|
||||
*
|
||||
* @return property value of success
|
||||
*/
|
||||
public Boolean getSuccess() {
|
||||
return success;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter method for property <tt>success</tt>.
|
||||
*
|
||||
* @param success value to be assigned to property success
|
||||
*/
|
||||
public void setSuccess(Boolean success) {
|
||||
this.success = success;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Getter method for property <tt>data</tt>.
|
||||
*
|
||||
* @return property value of data
|
||||
*/
|
||||
public T getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter method for property <tt>data</tt>.
|
||||
*
|
||||
* @param data value to be assigned to property data
|
||||
*/
|
||||
public void setData(T data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getStatus() {
|
||||
return success ? 1 : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter method for property <tt>errorCode</tt>.
|
||||
*
|
||||
* @return property value of errorCode
|
||||
*/
|
||||
public String getErrorCode() {
|
||||
return errorCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter method for property <tt>errorCode</tt>.
|
||||
*
|
||||
* @param errorCode value to be assigned to property errorCode
|
||||
*/
|
||||
public void setErrorCode(String errorCode) {
|
||||
this.errorCode = errorCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter method for property <tt>errorMsg</tt>.
|
||||
*
|
||||
* @return property value of errorMsg
|
||||
*/
|
||||
public String getErrorMessage() {
|
||||
return errorMessage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter method for property <tt>errorMsg</tt>.
|
||||
*
|
||||
* @param errorMessage value to be assigned to property errorMsg
|
||||
*/
|
||||
public void setErrorMessage(String errorMessage) {
|
||||
this.errorMessage = errorMessage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Message getMessage() {
|
||||
Message msg = new Message(this.getErrorMessage());
|
||||
//页面展示时,防止出现null状况
|
||||
msg.setCode("");
|
||||
return msg;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,122 @@
|
|||
package com.electromagnetic.industry.software.common.resp;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class ErrorContext implements Serializable {
|
||||
|
||||
/**
|
||||
* 序列ID
|
||||
*/
|
||||
private static final long serialVersionUID = 3939009139641299179L;
|
||||
|
||||
/**
|
||||
* 默认分隔符
|
||||
*/
|
||||
private static final String SPLIT = "|";
|
||||
|
||||
/**
|
||||
* 错误堆栈集合
|
||||
*/
|
||||
private List<ResultCode> errorStack = new ArrayList<ResultCode>();
|
||||
|
||||
/**
|
||||
* 第三方错误原始信息
|
||||
*/
|
||||
private String thirdPartyError;
|
||||
|
||||
/**
|
||||
* 错误变量映射
|
||||
*/
|
||||
private Map<String, String> errorVariableMap = new HashMap<String, String>();
|
||||
|
||||
/**
|
||||
* 默认构造方法。
|
||||
*/
|
||||
public ErrorContext() {
|
||||
// 默认构造方法
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前错误对象。
|
||||
*
|
||||
* @return 当前错误码对象
|
||||
*/
|
||||
public ResultCode fetchCurrentError() {
|
||||
if (errorStack != null && errorStack.size() > 0) {
|
||||
return errorStack.get(errorStack.size() - 1);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 向堆栈中添加错误对象。
|
||||
*
|
||||
* @param error 错误码
|
||||
*/
|
||||
public void addError(ResultCode error) {
|
||||
if (errorStack == null) {
|
||||
errorStack = new ArrayList<ResultCode>();
|
||||
}
|
||||
|
||||
errorStack.add(error);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取字符串形式的错误码堆栈
|
||||
*
|
||||
* @return 错误码堆栈
|
||||
*/
|
||||
@Deprecated
|
||||
public String fetchErrorCodeStack() {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
for (int i = errorStack.size(); i > 0; i--) {
|
||||
if (i == errorStack.size()) {
|
||||
sb.append(errorStack.get(i - 1));
|
||||
} else {
|
||||
sb.append(SPLIT).append(errorStack.get(i - 1));
|
||||
}
|
||||
}
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取字符串形式的错误码堆栈digest
|
||||
*
|
||||
* @return 错误码堆栈
|
||||
*/
|
||||
public String fetchErrorCodeStackDigest() {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
for (int i = errorStack.size(); i > 0; i--) {
|
||||
if (i == errorStack.size()) {
|
||||
sb.append(errorStack.get(i - 1));
|
||||
} else {
|
||||
sb.append(SPLIT).append(errorStack.get(i - 1));
|
||||
}
|
||||
}
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
|
||||
//错误堆栈
|
||||
sb.append("errorStack=[");
|
||||
sb.append(fetchErrorCodeStackDigest());
|
||||
sb.append("],");
|
||||
|
||||
//第三方错误
|
||||
sb.append("thirdPartyError=[");
|
||||
sb.append(thirdPartyError);
|
||||
sb.append("]");
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,50 @@
|
|||
package com.electromagnetic.industry.software.common.resp;
|
||||
|
||||
public class Message {
|
||||
|
||||
/**
|
||||
* 返回结果码
|
||||
*/
|
||||
private String code;
|
||||
/**
|
||||
* 返回结果信息
|
||||
*/
|
||||
private String message;
|
||||
/**
|
||||
* 返回错误明细
|
||||
*/
|
||||
private ErrorContext errorContext;
|
||||
|
||||
public Message(String messageStr) {
|
||||
this.message = messageStr;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public Message setCode(String code) {
|
||||
this.code = code;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("code = ");
|
||||
builder.append(code);
|
||||
builder.append(", message = ");
|
||||
builder.append(message);
|
||||
builder.append(", ");
|
||||
builder.append("BaseResult [");
|
||||
builder.append("errorContext=");
|
||||
builder.append(errorContext);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
package com.electromagnetic.industry.software.common.resp;
|
||||
|
||||
public interface Result {
|
||||
/**
|
||||
* 返回状态
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
Integer getStatus();
|
||||
|
||||
/**
|
||||
* 返回消息
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
Message getMessage();
|
||||
}
|
||||
|
|
@ -0,0 +1,396 @@
|
|||
package com.electromagnetic.industry.software.common.resp;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class ResultCode implements Serializable {
|
||||
|
||||
/** 序列ID */
|
||||
private static final long serialVersionUID = 3951948353107763580L;
|
||||
|
||||
/** 结果码固定前缀 */
|
||||
protected static final String PREFIX = "CE";
|
||||
|
||||
/** 结果码版本 */
|
||||
private String version;
|
||||
|
||||
/** 结果码级别[第9位],INFO-1,WARN-3,ERROR-5,FATAL-7,参见<code>ResultCodeLevel</code>定义 */
|
||||
private String codeLevel;
|
||||
|
||||
/** 结果码类型[第10位],SUCCESS-0,BIZ_ERROR-1,SYS_ERROR-2,THIRD_ERROR-3,参见<code>ResultCodeType</code>定义 */
|
||||
private String codeType;
|
||||
|
||||
/** 系统编号[第11-13位],见<code>SystemCode</code>定义 */
|
||||
private String systemCode;
|
||||
|
||||
/** 系统名称 */
|
||||
private String systemName;
|
||||
|
||||
/** 具体结果码[第14-17位] */
|
||||
private String errorSpecific;
|
||||
|
||||
/** 错误英文简称 */
|
||||
private String errorName;
|
||||
|
||||
/** 结果码信息描述,可空 */
|
||||
private String description;
|
||||
|
||||
// ~~~ 构造方法
|
||||
|
||||
/**
|
||||
* 默认构造方法。
|
||||
*/
|
||||
public ResultCode() {
|
||||
// 默认构造方法。
|
||||
}
|
||||
|
||||
/**
|
||||
* 构造方法。
|
||||
*
|
||||
* @param resultCode 结果码字符串
|
||||
*/
|
||||
public ResultCode(String resultCode) {
|
||||
|
||||
//结果码长度检查
|
||||
checkStringLength(resultCode, 16);
|
||||
|
||||
//拆分结果码
|
||||
spliteResultCode(resultCode);
|
||||
}
|
||||
|
||||
/**
|
||||
* 构造方法。
|
||||
*
|
||||
* @param resultCode 结果码字符串
|
||||
* @param errorName 错误码英文简称
|
||||
*/
|
||||
public ResultCode(String resultCode, String errorName) {
|
||||
this(resultCode);
|
||||
this.errorName = errorName;
|
||||
}
|
||||
|
||||
/**
|
||||
* 构造方法。
|
||||
*
|
||||
* @param resultCode 结果码字符串
|
||||
* @param errorName 错误码英文简称
|
||||
* @param description 结果码信息描述
|
||||
*/
|
||||
public ResultCode(String resultCode, String errorName, String description) {
|
||||
this(resultCode);
|
||||
this.errorName = errorName;
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
/**
|
||||
* 构造方法。
|
||||
*
|
||||
* @param version 版本
|
||||
* @param codeLevel 结果码级别
|
||||
* @param codeType 结果码类型
|
||||
* @param systemCode 系统编号
|
||||
* @param errorSpecific 具体错误码
|
||||
*/
|
||||
public ResultCode(String version, String codeLevel, String codeType, String systemCode, String errorSpecific) {
|
||||
this.version = version;
|
||||
this.codeLevel = codeLevel;
|
||||
this.codeType = codeType;
|
||||
this.systemCode = systemCode;
|
||||
this.errorSpecific = errorSpecific;
|
||||
}
|
||||
|
||||
/**
|
||||
* 构造方法。
|
||||
*
|
||||
* @param version 版本
|
||||
* @param codeLevel 结果码级别
|
||||
* @param codeType 结果码类型
|
||||
* @param systemCode 系统编号
|
||||
* @param errorSpecific 具体错误码
|
||||
* @param errorName 错误码英文简称
|
||||
*/
|
||||
public ResultCode(String version, String codeLevel, String codeType, String systemCode, String errorSpecific,
|
||||
String errorName) {
|
||||
this(version, codeLevel, codeType, systemCode, errorSpecific);
|
||||
this.errorName = errorName;
|
||||
}
|
||||
|
||||
// ~~~ 公有方法
|
||||
|
||||
/**
|
||||
* 组装返回码字符串。
|
||||
*
|
||||
* @return 返回码字符串
|
||||
*/
|
||||
public String fetchResultCode() {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
|
||||
sb.append(PREFIX);
|
||||
sb.append(version);
|
||||
sb.append(codeLevel);
|
||||
sb.append(codeType);
|
||||
sb.append(systemCode);
|
||||
sb.append(errorSpecific);
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 组装返回码字符串。 解决enum 单利线程安全问题
|
||||
*
|
||||
* @param eventCode
|
||||
* @return 返回码字符串
|
||||
*/
|
||||
public String fetchResultCode(String eventCode) {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
|
||||
sb.append(PREFIX);
|
||||
sb.append(version);
|
||||
sb.append(codeLevel);
|
||||
sb.append(codeType);
|
||||
sb.append(eventCode);
|
||||
sb.append(errorSpecific);
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建错误对象digest
|
||||
*
|
||||
* @return 错误码摘要日志
|
||||
*/
|
||||
// public String toDigest() {
|
||||
//
|
||||
// //组装结果码字符串
|
||||
// String resultCode = fetchResultCode();
|
||||
//
|
||||
// if (StringUtils.isNotBlank(errorName)) {
|
||||
// resultCode = resultCode + "@" + errorName;
|
||||
// } else {
|
||||
// resultCode = resultCode + "@";
|
||||
// }
|
||||
//
|
||||
// if (StringUtils.isNotBlank(systemName)) {
|
||||
// resultCode = resultCode + "@" + systemName;
|
||||
// } else {
|
||||
// resultCode = resultCode + "@";
|
||||
// }
|
||||
//
|
||||
// return resultCode;
|
||||
// }
|
||||
|
||||
// ~~~ 重写方法
|
||||
|
||||
/**
|
||||
* @see java.lang.Object#toString()
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
|
||||
//错误完整性检查
|
||||
checkStringLength(this.version, 1);
|
||||
checkStringLength(this.codeLevel, 1);
|
||||
checkStringLength(this.codeType, 1);
|
||||
checkStringLength(this.systemCode, 8);
|
||||
checkStringLength(this.errorSpecific, 3);
|
||||
|
||||
//组装结果码字符串
|
||||
String resultCode = fetchResultCode();
|
||||
|
||||
// if (StringUtils.isNotBlank(errorName)) {
|
||||
// resultCode = resultCode + "@" + errorName;
|
||||
// }
|
||||
|
||||
return resultCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see java.lang.Object#hashCode()
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return this.fetchResultCode().hashCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see java.lang.Object#equals(java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
|
||||
if (obj == this) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
|
||||
// return StringUtils.equals(this.fetchResultCode(), (((ResultCode) obj).fetchResultCode()));
|
||||
}
|
||||
|
||||
// ~~~ 内部方法
|
||||
|
||||
/**
|
||||
* 解析和拆分结果码。
|
||||
*
|
||||
* @param resultCode 结果码字符串
|
||||
*/
|
||||
private void spliteResultCode(String resultCode) {
|
||||
if (!resultCode.startsWith(PREFIX)) {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
|
||||
char[] chars = resultCode.toCharArray();
|
||||
|
||||
// 旧:CIC_RS_100000200
|
||||
// 新:CE15112000201001
|
||||
|
||||
this.version = "" + chars[2];
|
||||
this.codeLevel = "" + chars[3];
|
||||
this.codeType = "" + chars[4];
|
||||
this.systemCode = "" + chars[5] + chars[6] + chars[7] + chars[8] + chars[9] + chars[10] + chars[11] + chars[12];
|
||||
this.errorSpecific = "" + chars[13] + chars[14] + chars[15];
|
||||
}
|
||||
|
||||
/**
|
||||
* 字符串长度检查。
|
||||
*
|
||||
* @param resultCode 结果码字符串
|
||||
* @param length 长度
|
||||
*/
|
||||
private void checkStringLength(String resultCode, int length) {
|
||||
if (resultCode == null || resultCode.length() != length) {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
}
|
||||
|
||||
// ~~~ bean方法
|
||||
|
||||
/**
|
||||
* Getter method for property <tt>codeLevel</tt>.
|
||||
*
|
||||
* @return property value of codeLevel
|
||||
*/
|
||||
public String getCodeLevel() {
|
||||
return codeLevel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter method for property <tt>codeLevel</tt>.
|
||||
*
|
||||
* @param codeLevel value to be assigned to property codeLevel
|
||||
*/
|
||||
public void setCodeLevel(String codeLevel) {
|
||||
this.codeLevel = codeLevel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter method for property <tt>codeType</tt>.
|
||||
*
|
||||
* @return property value of codeType
|
||||
*/
|
||||
public String getCodeType() {
|
||||
return codeType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter method for property <tt>codeType</tt>.
|
||||
*
|
||||
* @param codeType value to be assigned to property codeType
|
||||
*/
|
||||
public void setCodeType(String codeType) {
|
||||
this.codeType = codeType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter method for property <tt>systemCode</tt>.
|
||||
*
|
||||
* @return property value of systemCode
|
||||
*/
|
||||
public String getSystemCode() {
|
||||
return systemCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter method for property <tt>systemCode</tt>.
|
||||
*
|
||||
* @param systemCode value to be assigned to property systemCode
|
||||
*/
|
||||
public void setSystemCode(String systemCode) {
|
||||
this.systemCode = systemCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter method for property <tt>errorSpecific</tt>.
|
||||
*
|
||||
* @return property value of errorSpecific
|
||||
*/
|
||||
public String getErrorSpecific() {
|
||||
return errorSpecific;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter method for property <tt>errorSpecific</tt>.
|
||||
*
|
||||
* @param errorSpecific value to be assigned to property errorSpecific
|
||||
*/
|
||||
public void setErrorSpecific(String errorSpecific) {
|
||||
this.errorSpecific = errorSpecific;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter method for property <tt>description</tt>.
|
||||
*
|
||||
* @return property value of description
|
||||
*/
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter method for property <tt>description</tt>.
|
||||
*
|
||||
* @param description value to be assigned to property description
|
||||
*/
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter method for property <tt>systemName</tt>.
|
||||
*
|
||||
* @return property value of systemName
|
||||
*/
|
||||
public String getSystemName() {
|
||||
return systemName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter method for property <tt>systemName</tt>.
|
||||
*
|
||||
* @param systemName value to be assigned to property systemName
|
||||
*/
|
||||
public void setSystemName(String systemName) {
|
||||
this.systemName = systemName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter method for property <tt>errorName</tt>.
|
||||
*
|
||||
* @return property value of errorName
|
||||
*/
|
||||
public String getErrorName() {
|
||||
return errorName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter method for property <tt>errorName</tt>.
|
||||
*
|
||||
* @param errorName value to be assigned to property errorName
|
||||
*/
|
||||
public void setErrorName(String errorName) {
|
||||
this.errorName = errorName;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,98 @@
|
|||
package com.electromagnetic.industry.software.common.util;
|
||||
|
||||
|
||||
import cn.hutool.core.codec.Base64;
|
||||
import org.bouncycastle.jce.provider.BouncyCastleProvider;
|
||||
|
||||
|
||||
import javax.crypto.*;
|
||||
import javax.crypto.spec.SecretKeySpec;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.security.InvalidKeyException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.security.SecureRandom;
|
||||
import java.security.Security;
|
||||
|
||||
/**
|
||||
* <p>Description: [AES对称加密和解密]</p>
|
||||
* @description:
|
||||
* @author:
|
||||
* @create: 2022/07/06 10:52
|
||||
*/
|
||||
public class AESUtils {
|
||||
|
||||
/**
|
||||
* <p>Discription:[加密]</p>
|
||||
* Created on 2022/07/06 10:52
|
||||
* @param content 明文 用JSON.toJSONString(Map<String, String> map)转换的json字符串
|
||||
* @param key 加解密规则 访客系统提供key
|
||||
* @return String 密文
|
||||
*/
|
||||
public static String ecodes(String content, String key) {
|
||||
if (content == null || content.length() < 1) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
KeyGenerator kgen = KeyGenerator.getInstance("AES");
|
||||
SecureRandom random= SecureRandom.getInstance("SHA1PRNG");
|
||||
random.setSeed(key.getBytes());
|
||||
kgen.init(128, random);
|
||||
SecretKey secretKey = kgen.generateKey();
|
||||
byte[] enCodeFormat = secretKey.getEncoded();
|
||||
SecretKeySpec secretKeySpec = new SecretKeySpec(enCodeFormat, "AES");
|
||||
Cipher cipher = Cipher.getInstance("AES");
|
||||
byte[] byteContent = content.getBytes("utf-8");
|
||||
cipher.init(Cipher.ENCRYPT_MODE, secretKeySpec);
|
||||
byte[] byteRresult = cipher.doFinal(byteContent);
|
||||
StringBuffer sb = new StringBuffer();
|
||||
for (int i = 0; i < byteRresult.length; i++) {
|
||||
String hex = Integer.toHexString(byteRresult[i] & 0xFF);
|
||||
if (hex.length() == 1) {
|
||||
hex = '0' + hex;
|
||||
}
|
||||
sb.append(hex.toUpperCase());
|
||||
}
|
||||
return sb.toString();
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
e.printStackTrace();
|
||||
} catch (NoSuchPaddingException e) {
|
||||
e.printStackTrace();
|
||||
} catch (InvalidKeyException e) {
|
||||
e.printStackTrace();
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IllegalBlockSizeException e) {
|
||||
e.printStackTrace();
|
||||
} catch (BadPaddingException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 前端使用ECB,后端解密方法
|
||||
* @param enc
|
||||
* @param key
|
||||
* @return
|
||||
*/
|
||||
public static String decrypt(String enc, String key) {
|
||||
try{
|
||||
SecretKeySpec secretKeySpec = new SecretKeySpec(key.getBytes(), "AES");
|
||||
Security.addProvider(new BouncyCastleProvider());
|
||||
Cipher cipher = Cipher.getInstance("AES/ECB/PKCS7Padding");
|
||||
cipher.init(Cipher.DECRYPT_MODE, secretKeySpec);
|
||||
return new String(cipher.doFinal(Base64.decode(enc)));
|
||||
} catch (NoSuchPaddingException e) {
|
||||
throw new RuntimeException(e);
|
||||
} catch (IllegalBlockSizeException e) {
|
||||
throw new RuntimeException(e);
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
throw new RuntimeException(e);
|
||||
} catch (BadPaddingException e) {
|
||||
throw new RuntimeException(e);
|
||||
} catch (InvalidKeyException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
package com.electromagnetic.industry.software.common.util;
|
||||
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public final class EleCommonUtil {
|
||||
|
||||
// 正则表达式模式,匹配中文字符、下划线、连字符、加号、数字和英文字符
|
||||
private static final String PATTERN = "^[\\u4e00-\\u9fa5a-zA-Z0-9._\\-+]+$";
|
||||
|
||||
// 编译正则表达式
|
||||
private static final Pattern pattern = Pattern.compile(PATTERN);
|
||||
|
||||
public static String getFileName(String fileFullName) {
|
||||
if (fileFullName == null) {
|
||||
return "";
|
||||
}
|
||||
if (!fileFullName.contains(".")) {
|
||||
return fileFullName;
|
||||
}
|
||||
|
||||
int index = fileFullName.lastIndexOf(".");
|
||||
return fileFullName.substring(0, index);
|
||||
}
|
||||
|
||||
public static String getFileType(String fileFullName) {
|
||||
if (fileFullName == null || !fileFullName.contains(".")) {
|
||||
return "";
|
||||
}
|
||||
int index = fileFullName.lastIndexOf(".");
|
||||
return fileFullName.substring(index + 1);
|
||||
}
|
||||
|
||||
public static boolean isFileNameValid(String fileFullName) {
|
||||
if (fileFullName.length() > 32) {
|
||||
return false;
|
||||
}
|
||||
return pattern.matcher(fileFullName).matches();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
package com.electromagnetic.industry.software.common.util;
|
||||
|
||||
import com.electromagnetic.industry.software.common.enums.ErrorEnum;
|
||||
import com.electromagnetic.industry.software.common.resp.ElectromagneticResult;
|
||||
|
||||
public class ElectromagneticResultUtil {
|
||||
|
||||
public static <T> ElectromagneticResult<T> success(T data){
|
||||
ElectromagneticResult<T> electromagneticResult = new ElectromagneticResult<>();
|
||||
electromagneticResult.setSuccess(true);
|
||||
electromagneticResult.setData(data);
|
||||
return electromagneticResult;
|
||||
}
|
||||
|
||||
|
||||
public static <T> ElectromagneticResult<T> fail(String code , String msg){
|
||||
ElectromagneticResult<T> electromagneticResult = new ElectromagneticResult<>();
|
||||
electromagneticResult.setSuccess(false);
|
||||
electromagneticResult.setErrorCode(code);
|
||||
electromagneticResult.setErrorMessage(msg);
|
||||
return electromagneticResult;
|
||||
}
|
||||
|
||||
public static <T> ElectromagneticResult fail(ErrorEnum errorEnum){
|
||||
ElectromagneticResult<T> electromagneticResult = new ElectromagneticResult<>();
|
||||
electromagneticResult.setSuccess(false);
|
||||
electromagneticResult.setErrorCode(errorEnum.getCode());
|
||||
electromagneticResult.setErrorMessage(errorEnum.getErrorMessage());
|
||||
return electromagneticResult;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,154 @@
|
|||
package com.electromagnetic.industry.software.common.util;
|
||||
|
||||
import java.lang.management.ManagementFactory;
|
||||
import java.net.InetAddress;
|
||||
import java.net.NetworkInterface;
|
||||
|
||||
public class IdWorker {
|
||||
|
||||
private static IdWorker idWorker=new IdWorker();
|
||||
|
||||
// 时间起始标记点,作为基准,一般取系统的最近时间(一旦确定不能变动)
|
||||
private final static long twepoch = 1288834974657L;
|
||||
// 机器标识位数
|
||||
private final static long workerIdBits = 5L;
|
||||
// 数据中心标识位数
|
||||
private final static long datacenterIdBits = 5L;
|
||||
// 机器ID最大值
|
||||
private final static long maxWorkerId = -1L ^ (-1L << workerIdBits);
|
||||
// 数据中心ID最大值
|
||||
private final static long maxDatacenterId = -1L ^ (-1L << datacenterIdBits);
|
||||
// 毫秒内自增位
|
||||
private final static long sequenceBits = 12L;
|
||||
// 机器ID偏左移12位
|
||||
private final static long workerIdShift = sequenceBits;
|
||||
// 数据中心ID左移17位
|
||||
private final static long datacenterIdShift = sequenceBits + workerIdBits;
|
||||
// 时间毫秒左移22位
|
||||
private final static long timestampLeftShift = sequenceBits + workerIdBits + datacenterIdBits;
|
||||
|
||||
private final static long sequenceMask = -1L ^ (-1L << sequenceBits);
|
||||
/* 上次生产id时间戳 */
|
||||
private static long lastTimestamp = -1L;
|
||||
// 0,并发控制
|
||||
private long sequence = 0L;
|
||||
|
||||
private final long workerId;
|
||||
// 数据标识id部分
|
||||
private final long datacenterId;
|
||||
|
||||
public IdWorker(){
|
||||
this.datacenterId = getDatacenterId(maxDatacenterId);
|
||||
this.workerId = getMaxWorkerId(datacenterId, maxWorkerId);
|
||||
}
|
||||
/**
|
||||
* @param workerId
|
||||
* 工作机器ID
|
||||
* @param datacenterId
|
||||
* 序列号
|
||||
*/
|
||||
public IdWorker(long workerId, long datacenterId) {
|
||||
if (workerId > maxWorkerId || workerId < 0) {
|
||||
throw new IllegalArgumentException(String.format("worker Id can't be greater than %d or less than 0", maxWorkerId));
|
||||
}
|
||||
if (datacenterId > maxDatacenterId || datacenterId < 0) {
|
||||
throw new IllegalArgumentException(String.format("datacenter Id can't be greater than %d or less than 0", maxDatacenterId));
|
||||
}
|
||||
this.workerId = workerId;
|
||||
this.datacenterId = datacenterId;
|
||||
}
|
||||
/**
|
||||
* 获取下一个ID
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public synchronized long nextId() {
|
||||
long timestamp = timeGen();
|
||||
if (timestamp < lastTimestamp) {
|
||||
throw new RuntimeException(String.format("Clock moved backwards. Refusing to generate id for %d milliseconds", lastTimestamp - timestamp));
|
||||
}
|
||||
|
||||
if (lastTimestamp == timestamp) {
|
||||
// 当前毫秒内,则+1
|
||||
sequence = (sequence + 1) & sequenceMask;
|
||||
if (sequence == 0) {
|
||||
// 当前毫秒内计数满了,则等待下一秒
|
||||
timestamp = tilNextMillis(lastTimestamp);
|
||||
}
|
||||
} else {
|
||||
sequence = 0L;
|
||||
}
|
||||
lastTimestamp = timestamp;
|
||||
// ID偏移组合生成最终的ID,并返回ID
|
||||
long nextId = ((timestamp - twepoch) << timestampLeftShift)
|
||||
| (datacenterId << datacenterIdShift)
|
||||
| (workerId << workerIdShift) | sequence;
|
||||
|
||||
return nextId;
|
||||
}
|
||||
|
||||
private long tilNextMillis(final long lastTimestamp) {
|
||||
long timestamp = this.timeGen();
|
||||
while (timestamp <= lastTimestamp) {
|
||||
timestamp = this.timeGen();
|
||||
}
|
||||
return timestamp;
|
||||
}
|
||||
|
||||
private long timeGen() {
|
||||
return System.currentTimeMillis();
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 获取 maxWorkerId
|
||||
* </p>
|
||||
*/
|
||||
protected static long getMaxWorkerId(long datacenterId, long maxWorkerId) {
|
||||
StringBuffer mpid = new StringBuffer();
|
||||
mpid.append(datacenterId);
|
||||
String name = ManagementFactory.getRuntimeMXBean().getName();
|
||||
if (!name.isEmpty()) {
|
||||
/*
|
||||
* GET jvmPid
|
||||
*/
|
||||
mpid.append(name.split("@")[0]);
|
||||
}
|
||||
/*
|
||||
* MAC + PID 的 hashcode 获取16个低位
|
||||
*/
|
||||
return (mpid.toString().hashCode() & 0xffff) % (maxWorkerId + 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 数据标识id部分
|
||||
* </p>
|
||||
*/
|
||||
protected static long getDatacenterId(long maxDatacenterId) {
|
||||
long id = 0L;
|
||||
try {
|
||||
InetAddress ip = InetAddress.getLocalHost();
|
||||
NetworkInterface network = NetworkInterface.getByInetAddress(ip);
|
||||
if (network == null) {
|
||||
id = 1L;
|
||||
} else {
|
||||
byte[] mac = network.getHardwareAddress();
|
||||
id = ((0x000000FF & (long) mac[mac.length - 1])
|
||||
| (0x0000FF00 & (((long) mac[mac.length - 2]) << 8))) >> 6;
|
||||
id = id % (maxDatacenterId + 1);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
System.out.println(" getDatacenterId: " + e.getMessage());
|
||||
}
|
||||
return id;
|
||||
}
|
||||
public static long getSnowFlakeId(){
|
||||
return idWorker.nextId();
|
||||
}
|
||||
|
||||
public static String getSnowFlakeIdString(){
|
||||
return String.valueOf(getSnowFlakeId());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,117 @@
|
|||
package com.electromagnetic.industry.software.common.util;
|
||||
|
||||
import java.security.MessageDigest;
|
||||
import java.util.Map;
|
||||
|
||||
public class SignUtils {
|
||||
|
||||
public static char[] hexDigits =
|
||||
{'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
|
||||
|
||||
public static String md5(String string) {
|
||||
try {
|
||||
MessageDigest md5 = MessageDigest.getInstance("MD5");
|
||||
byte[] bytes = md5.digest(string.getBytes("utf-8"));
|
||||
char[] chars = new char[bytes.length * 2];
|
||||
|
||||
for (int i = 0; i < bytes.length; ++i) {
|
||||
int b = bytes[i];
|
||||
chars[i * 2] = hexDigits[(b & 240) >> 4];
|
||||
chars[i * 2 + 1] = hexDigits[b & 15];
|
||||
}
|
||||
|
||||
return new String(chars);
|
||||
} catch (Exception var6) {
|
||||
var6.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取MD5加密后的字符串
|
||||
*
|
||||
* @param str 加密前的字符串
|
||||
* @return
|
||||
*/
|
||||
public static String MD5(String str) {
|
||||
try {
|
||||
MessageDigest md = MessageDigest.getInstance("MD5");
|
||||
md.reset();
|
||||
md.update(str.getBytes("UTF-8"));
|
||||
byte[] byteArray = md.digest();
|
||||
StringBuffer md5StrBuff = new StringBuffer();
|
||||
for (int i = 0; i < byteArray.length; i++) {
|
||||
if (Integer.toHexString(0xFF & byteArray[i]).length() == 1) {
|
||||
md5StrBuff.append("0").append(Integer.toHexString(0xFF & byteArray[i]));
|
||||
} else {
|
||||
md5StrBuff.append(Integer.toHexString(0xFF & byteArray[i]));
|
||||
}
|
||||
}
|
||||
return md5StrBuff.toString();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static Boolean equals(String v1, String v2) {
|
||||
if (v1 == null && v2 == null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (v1 != null && v2 != null && v1.equals(v2))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static String getString(Map<String,Object> params, String key, String defaultValue){
|
||||
String temp = null;
|
||||
if(params.get(key)==null){
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
else if(params.get(key).getClass().isArray())
|
||||
{
|
||||
temp = getArray(params,key)[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
temp = params.get(key).toString();
|
||||
}
|
||||
if(temp != null){
|
||||
temp = temp.replaceAll("%", "\\%");
|
||||
}
|
||||
if(temp==null)
|
||||
{
|
||||
return defaultValue;
|
||||
}
|
||||
return temp;
|
||||
}
|
||||
|
||||
public static String[] getArray(Map<String, Object> params, String key) {
|
||||
return getArray(params, key, null);
|
||||
}
|
||||
|
||||
public static String[] getArray(Map<String, Object> params, String
|
||||
key, String[] defaultValue) {
|
||||
if (params == null) {
|
||||
return defaultValue;
|
||||
}
|
||||
if (params.get(key) == null) {
|
||||
return defaultValue;
|
||||
}
|
||||
try {
|
||||
String[] values = (String[]) params.get(key);
|
||||
return values;
|
||||
} catch (ClassCastException e) {
|
||||
return defaultValue;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
package com.electromagnetic.industry.software.common.util;
|
||||
|
||||
import com.electromagnetic.industry.software.common.cons.UserConstants;
|
||||
import io.jsonwebtoken.Claims;
|
||||
import io.jsonwebtoken.Jwts;
|
||||
|
||||
public class TokenUtil {
|
||||
|
||||
/**
|
||||
* 获取Claim
|
||||
*
|
||||
* @param token
|
||||
* @return
|
||||
*/
|
||||
public static Claims getLoginInfo(String token) {
|
||||
return Jwts.parser()
|
||||
.setSigningKey(UserConstants.SECRET_KEY)
|
||||
.parseClaimsJws(token)
|
||||
.getBody();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
package com.electromagnetic.industry.software.common.util;
|
||||
|
||||
|
||||
import com.electromagnetic.industry.software.common.pojo.UserLoginInfo;
|
||||
|
||||
public class UserThreadLocal {
|
||||
/**
|
||||
* 存储用户信息
|
||||
*/
|
||||
private static ThreadLocal<UserLoginInfo> userThread = new ThreadLocal<>();
|
||||
|
||||
public static void set(UserLoginInfo userLoginInfo) {
|
||||
userThread.set(userLoginInfo);
|
||||
}
|
||||
|
||||
public static UserLoginInfo getUser() {
|
||||
return userThread.get();
|
||||
}
|
||||
|
||||
public static String getUsername() {
|
||||
return userThread.get().getUsername();
|
||||
}
|
||||
|
||||
public static String getUserId() {
|
||||
return userThread.get().getUserId();
|
||||
}
|
||||
|
||||
public static void remove() {
|
||||
userThread.remove();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
<?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>
|
||||
|
||||
<groupId>com.electromagnetic.data</groupId>
|
||||
<artifactId>electromagnetic-data-new</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<packaging>pom</packaging>
|
||||
<modules>
|
||||
<module>electrmangnetic</module>
|
||||
<module>electromagnetic-common</module>
|
||||
</modules>
|
||||
|
||||
<properties>
|
||||
<java.version>1.8</java.version>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
<maven.compiler.target>8</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<spring.boot.version>2.6.3</spring.boot.version>
|
||||
</properties>
|
||||
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-dependencies</artifactId>
|
||||
<version>${spring.boot.version}</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
</project>
|
||||
Loading…
Reference in New Issue