reformat code
This commit is contained in:
parent
7360a4d1fa
commit
4ad81053fb
|
|
@ -1,6 +1,6 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
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>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<parent>
|
<parent>
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ public class LoginInterceptor implements HandlerInterceptor {
|
||||||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
|
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
|
||||||
|
|
||||||
String token = request.getHeader("Authorization");
|
String token = request.getHeader("Authorization");
|
||||||
if (token==null) {
|
if (token == null) {
|
||||||
log.error("Authorization header is null");
|
log.error("Authorization header is null");
|
||||||
response.setStatus(401);
|
response.setStatus(401);
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -43,7 +43,7 @@ public class LoginInterceptor implements HandlerInterceptor {
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
Claims claims = TokenUtil.getLoginInfo(token);
|
Claims claims = TokenUtil.getLoginInfo(token);
|
||||||
if (claims==null) {
|
if (claims == null) {
|
||||||
log.error("User info is missing");
|
log.error("User info is missing");
|
||||||
response.setStatus(401);
|
response.setStatus(401);
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -68,7 +68,7 @@ public class LoginInterceptor implements HandlerInterceptor {
|
||||||
UserThreadLocal.remove();
|
UserThreadLocal.remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Boolean isTokenValid(String tokenStr){
|
public Boolean isTokenValid(String tokenStr) {
|
||||||
Token token = tokenMapper.selectToken(tokenStr);
|
Token token = tokenMapper.selectToken(tokenStr);
|
||||||
Date now = new Date(SystemClock.now());
|
Date now = new Date(SystemClock.now());
|
||||||
return token != null && now.before(token.getExpireAt());
|
return token != null && now.before(token.getExpireAt());
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,6 @@ public class WebMvcConfig implements WebMvcConfigurer {
|
||||||
private LoginInterceptor loginInterceptor;
|
private LoginInterceptor loginInterceptor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @param registry registry
|
* @param registry registry
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
package com.electromagnetic.industry.software.manage.controller;
|
package com.electromagnetic.industry.software.manage.controller;
|
||||||
|
|
||||||
import com.electromagnetic.industry.software.common.resp.*;
|
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.EDDataRequest;
|
||||||
import com.electromagnetic.industry.software.manage.pojo.req.FileChunkDTO;
|
import com.electromagnetic.industry.software.manage.pojo.req.FileChunkDTO;
|
||||||
import com.electromagnetic.industry.software.manage.service.EDDataService;
|
import com.electromagnetic.industry.software.manage.service.EDDataService;
|
||||||
|
|
@ -23,39 +23,39 @@ public class EDDataController {
|
||||||
@Resource
|
@Resource
|
||||||
private EDDataService edDataService;
|
private EDDataService edDataService;
|
||||||
|
|
||||||
@ApiOperation(value = "新建文件夹",notes = "")
|
@ApiOperation(value = "新建文件夹", notes = "")
|
||||||
@RequestMapping(value = "/createFolder",method = RequestMethod.POST)
|
@RequestMapping(value = "/createFolder", method = RequestMethod.POST)
|
||||||
public ElectromagneticResult<?> createFolder(@RequestBody EDDataRequest request){
|
public ElectromagneticResult<?> createFolder(@RequestBody EDDataRequest request) {
|
||||||
return edDataService.createFolder(request);
|
return edDataService.createFolder(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ApiOperation(value = "获取文件信息列表",notes = "")
|
@ApiOperation(value = "获取文件信息列表", notes = "")
|
||||||
@RequestMapping(value = "/getFileInfoList",method = RequestMethod.POST)
|
@RequestMapping(value = "/getFileInfoList", method = RequestMethod.POST)
|
||||||
public ElectromagneticResult<?> getFileInfoList(@RequestBody EDDataRequest request){
|
public ElectromagneticResult<?> getFileInfoList(@RequestBody EDDataRequest request) {
|
||||||
return edDataService.getDataInfoList(request);
|
return edDataService.getDataInfoList(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ApiOperation(value = "更新文件信息",notes = "")
|
@ApiOperation(value = "更新文件信息", notes = "")
|
||||||
@RequestMapping(value = "/updateFileInfo",method = RequestMethod.POST)
|
@RequestMapping(value = "/updateFileInfo", method = RequestMethod.POST)
|
||||||
public ElectromagneticResult<?> updateFileInfo(@RequestBody EDDataRequest request){
|
public ElectromagneticResult<?> updateFileInfo(@RequestBody EDDataRequest request) {
|
||||||
return edDataService.updateFileInfo(request);
|
return edDataService.updateFileInfo(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ApiOperation(value = "获取子文件数量",notes = "")
|
@ApiOperation(value = "获取子文件数量", notes = "")
|
||||||
@RequestMapping(value = "/getChildFileCount",method = RequestMethod.POST)
|
@RequestMapping(value = "/getChildFileCount", method = RequestMethod.POST)
|
||||||
public ElectromagneticResult<?> getChildFileCount(@RequestBody EDDataRequest request){
|
public ElectromagneticResult<?> getChildFileCount(@RequestBody EDDataRequest request) {
|
||||||
return edDataService.getChildFileCount(request);
|
return edDataService.getChildFileCount(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ApiOperation(value = "上传",notes = "")
|
@ApiOperation(value = "上传", notes = "")
|
||||||
@RequestMapping(value = "/upload", consumes = "multipart/form-data",method = RequestMethod.POST)
|
@RequestMapping(value = "/upload", consumes = "multipart/form-data", method = RequestMethod.POST)
|
||||||
public ElectromagneticResult<?> upload(@RequestParam("parentId") String parentId,
|
public ElectromagneticResult<?> upload(@RequestParam("parentId") String parentId,
|
||||||
@RequestParam("file") MultipartFile file,
|
@RequestParam("file") MultipartFile file,
|
||||||
@RequestParam("gmtBatchUpload") Long gmtBatchUpload){
|
@RequestParam("gmtBatchUpload") Long gmtBatchUpload) {
|
||||||
EDDataRequest request = new EDDataRequest();
|
EDDataRequest request = new EDDataRequest();
|
||||||
request.setParentId(parentId);
|
request.setParentId(parentId);
|
||||||
request.setFileData(file);
|
request.setFileData(file);
|
||||||
|
|
@ -64,41 +64,41 @@ public class EDDataController {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ApiOperation(value = "下载",notes = "")
|
@ApiOperation(value = "下载", notes = "")
|
||||||
@RequestMapping(value = "/download",method = RequestMethod.GET)
|
@RequestMapping(value = "/download", method = RequestMethod.GET)
|
||||||
public ResponseEntity<InputStreamResource> download(@RequestParam String dataId, HttpServletResponse response) throws IOException {
|
public ResponseEntity<InputStreamResource> download(@RequestParam String dataId, HttpServletResponse response) throws IOException {
|
||||||
return edDataService.download(dataId, response);
|
return edDataService.download(dataId, response);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ApiOperation(value = "数据导出",notes = "")
|
@ApiOperation(value = "数据导出", notes = "")
|
||||||
@RequestMapping(value = "/batchExport",method = RequestMethod.GET)
|
@RequestMapping(value = "/batchExport", method = RequestMethod.GET)
|
||||||
public ResponseEntity<InputStreamResource> batchExport(@RequestParam String dataIdArr, HttpServletResponse response) throws IOException {
|
public ResponseEntity<InputStreamResource> batchExport(@RequestParam String dataIdArr, HttpServletResponse response) throws IOException {
|
||||||
return edDataService.batchExport(dataIdArr, response);
|
return edDataService.batchExport(dataIdArr, response);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation(value = "获取已经上传的分片",notes = "")
|
@ApiOperation(value = "获取已经上传的分片", notes = "")
|
||||||
@RequestMapping(value = "/getUploadedChunkNums",method = RequestMethod.GET)
|
@RequestMapping(value = "/getUploadedChunkNums", method = RequestMethod.GET)
|
||||||
public ElectromagneticResult<?> getUploadedChunkNums(@RequestParam String identifier) {
|
public ElectromagneticResult<?> getUploadedChunkNums(@RequestParam String identifier) {
|
||||||
return edDataService.getUploadedChunkNums(identifier);
|
return edDataService.getUploadedChunkNums(identifier);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation(value = "合并分片",notes = "")
|
@ApiOperation(value = "合并分片", notes = "")
|
||||||
@RequestMapping(value = "/mergeChunks",method = RequestMethod.GET)
|
@RequestMapping(value = "/mergeChunks", method = RequestMethod.GET)
|
||||||
public ElectromagneticResult<?> mergeChunks(@RequestParam String identifier,
|
public ElectromagneticResult<?> mergeChunks(@RequestParam String identifier,
|
||||||
@RequestParam String fileName,
|
@RequestParam String fileName,
|
||||||
@RequestParam Integer totalChunks) {
|
@RequestParam Integer totalChunks) {
|
||||||
return edDataService.mergeChunks(identifier, fileName, totalChunks);
|
return edDataService.mergeChunks(identifier, fileName, totalChunks);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation(value = "分片上传",notes = "")
|
@ApiOperation(value = "分片上传", notes = "")
|
||||||
@RequestMapping(value = "/batchImport",method = RequestMethod.POST)
|
@RequestMapping(value = "/batchImport", method = RequestMethod.POST)
|
||||||
public ElectromagneticResult<?> batchImport(FileChunkDTO fileChunkDTO) {
|
public ElectromagneticResult<?> batchImport(FileChunkDTO fileChunkDTO) {
|
||||||
return edDataService.batchImport(fileChunkDTO);
|
return edDataService.batchImport(fileChunkDTO);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation(value = "检查分片是否存在",notes = "")
|
@ApiOperation(value = "检查分片是否存在", notes = "")
|
||||||
@RequestMapping(value = "/batchImport",method = RequestMethod.GET)
|
@RequestMapping(value = "/batchImport", method = RequestMethod.GET)
|
||||||
public ElectromagneticResult<?> checkChunkExist(FileChunkDTO fileChunkDTO) {
|
public ElectromagneticResult<?> checkChunkExist(FileChunkDTO fileChunkDTO) {
|
||||||
return edDataService.checkChunkExist(fileChunkDTO);
|
return edDataService.checkChunkExist(fileChunkDTO);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -27,9 +27,9 @@ public class UserController {
|
||||||
return userService.createUser(userRequest);
|
return userService.createUser(userRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation(value="编辑用户信息",notes = "")
|
@ApiOperation(value = "编辑用户信息", notes = "")
|
||||||
@PutMapping("/updateUser")
|
@PutMapping("/updateUser")
|
||||||
public ElectromagneticResult<?> updateUser(@RequestBody UserModiRequest userModiRequest){
|
public ElectromagneticResult<?> updateUser(@RequestBody UserModiRequest userModiRequest) {
|
||||||
return userService.modifyUser(userModiRequest);
|
return userService.modifyUser(userModiRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -57,13 +57,13 @@ public class UserController {
|
||||||
return userService.validateWorkNum(userWorkNumRequest);
|
return userService.validateWorkNum(userWorkNumRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation(value="删除用户信息",notes="")
|
@ApiOperation(value = "删除用户信息", notes = "")
|
||||||
@PostMapping(value = "/deleteUser")
|
@PostMapping(value = "/deleteUser")
|
||||||
public ElectromagneticResult<?> deleteUser(@RequestBody UserDeleteRequest userDeleteRequest) {
|
public ElectromagneticResult<?> deleteUser(@RequestBody UserDeleteRequest userDeleteRequest) {
|
||||||
return userService.deleteUser(userDeleteRequest);
|
return userService.deleteUser(userDeleteRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation(value="登出", notes = "")
|
@ApiOperation(value = "登出", notes = "")
|
||||||
@RequestMapping(value = "/logout", method = RequestMethod.POST)
|
@RequestMapping(value = "/logout", method = RequestMethod.POST)
|
||||||
public ElectromagneticResult<?> logout(@RequestHeader("Authorization") String token) {
|
public ElectromagneticResult<?> logout(@RequestHeader("Authorization") String token) {
|
||||||
return userService.logout(token);
|
return userService.logout(token);
|
||||||
|
|
|
||||||
|
|
@ -11,30 +11,35 @@ public interface CategoryMapper extends BaseMapper<Category> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取顶级节点
|
* 获取顶级节点
|
||||||
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
List<Category> selectTopCategories();
|
List<Category> selectTopCategories();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取所有节点
|
* 获取所有节点
|
||||||
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
List<Category> selectAllCategories();
|
List<Category> selectAllCategories();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取节点通过编码ID
|
* 获取节点通过编码ID
|
||||||
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
List<Category> selectCategories(Category category);
|
List<Category> selectCategories(Category category);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取子节点通过父ID
|
* 获取子节点通过父ID
|
||||||
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
List<Category> selectChildCategories(Category category);
|
List<Category> selectChildCategories(Category category);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建目录树节点数据
|
* 创建目录树节点数据
|
||||||
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
Boolean createCategory(Category category);
|
Boolean createCategory(Category category);
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@ import java.util.List;
|
||||||
public interface EDDataMapper extends BaseMapper<EDDataInfo> {
|
public interface EDDataMapper extends BaseMapper<EDDataInfo> {
|
||||||
/**
|
/**
|
||||||
* 创建文件/文件夹数据信息
|
* 创建文件/文件夹数据信息
|
||||||
|
*
|
||||||
* @param edDataInfo
|
* @param edDataInfo
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
|
@ -19,6 +20,7 @@ public interface EDDataMapper extends BaseMapper<EDDataInfo> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取文件信息列表
|
* 获取文件信息列表
|
||||||
|
*
|
||||||
* @param parames
|
* @param parames
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
|
@ -26,6 +28,7 @@ public interface EDDataMapper extends BaseMapper<EDDataInfo> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新文件信息
|
* 更新文件信息
|
||||||
|
*
|
||||||
* @param parames
|
* @param parames
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -11,22 +11,27 @@ import org.mapstruct.factory.Mappers;
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface EDDataMappers {
|
public interface EDDataMappers {
|
||||||
|
|
||||||
EDDataMappers INSTANCE= Mappers.getMapper(EDDataMappers.class);
|
EDDataMappers INSTANCE = Mappers.getMapper(EDDataMappers.class);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 文件数据扩展模型入参转换
|
* 文件数据扩展模型入参转换
|
||||||
|
*
|
||||||
* @param request
|
* @param request
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
EDDataParams getEDDataParames(EDDataRequest request);
|
EDDataParams getEDDataParames(EDDataRequest request);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 文件数据扩展模型入参转换
|
* 文件数据扩展模型入参转换
|
||||||
|
*
|
||||||
* @param request
|
* @param request
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
EDDataInfo getEDDataInfo(EDDataRequest request);
|
EDDataInfo getEDDataInfo(EDDataRequest request);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 指标卡扩展模型返回
|
* 指标卡扩展模型返回
|
||||||
|
*
|
||||||
* @param edDataPage
|
* @param edDataPage
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ public interface TokenMapper extends BaseMapper<Token> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 插入
|
* 插入
|
||||||
|
*
|
||||||
* @param token
|
* @param token
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
|
@ -16,6 +17,7 @@ public interface TokenMapper extends BaseMapper<Token> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询
|
* 查询
|
||||||
|
*
|
||||||
* @param token
|
* @param token
|
||||||
* @return Token
|
* @return Token
|
||||||
*/
|
*/
|
||||||
|
|
@ -23,6 +25,7 @@ public interface TokenMapper extends BaseMapper<Token> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除token
|
* 删除token
|
||||||
|
*
|
||||||
* @param token
|
* @param token
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ public interface UserMapper {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 插入
|
* 插入
|
||||||
|
*
|
||||||
* @param user
|
* @param user
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
|
@ -20,6 +21,7 @@ public interface UserMapper {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 编辑
|
* 编辑
|
||||||
|
*
|
||||||
* @param user
|
* @param user
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
|
@ -27,6 +29,7 @@ public interface UserMapper {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 发布
|
* 发布
|
||||||
|
*
|
||||||
* @param publishParam
|
* @param publishParam
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
|
@ -34,6 +37,7 @@ public interface UserMapper {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通过工号查询用户
|
* 通过工号查询用户
|
||||||
|
*
|
||||||
* @param workNumber
|
* @param workNumber
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
|
@ -41,6 +45,7 @@ public interface UserMapper {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通过用户编码查询用户
|
* 通过用户编码查询用户
|
||||||
|
*
|
||||||
* @param userId
|
* @param userId
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
|
@ -48,6 +53,7 @@ public interface UserMapper {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通过用户编码查询用户
|
* 通过用户编码查询用户
|
||||||
|
*
|
||||||
* @param searchKeywords
|
* @param searchKeywords
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
|
@ -55,13 +61,15 @@ public interface UserMapper {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询数据总条目数
|
* 查询数据总条目数
|
||||||
|
*
|
||||||
* @param searchKeywords
|
* @param searchKeywords
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
int getTotalCount (SearchKeyWords searchKeywords);
|
int getTotalCount(SearchKeyWords searchKeywords);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通过用户ID删除用户
|
* 通过用户ID删除用户
|
||||||
|
*
|
||||||
* @param userId
|
* @param userId
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -14,10 +14,11 @@ import java.util.List;
|
||||||
|
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface UserMappers {
|
public interface UserMappers {
|
||||||
UserMappers INSTANCE= Mappers.getMapper(UserMappers.class);
|
UserMappers INSTANCE = Mappers.getMapper(UserMappers.class);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户Request转用户模型
|
* 用户Request转用户模型
|
||||||
|
*
|
||||||
* @param userRequest
|
* @param userRequest
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
|
@ -25,6 +26,7 @@ public interface UserMappers {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户登录Request转用户登录模型
|
* 用户登录Request转用户登录模型
|
||||||
|
*
|
||||||
* @param loginRequest
|
* @param loginRequest
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
|
@ -32,6 +34,7 @@ public interface UserMappers {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取单条用户信息Request转用户模型
|
* 获取单条用户信息Request转用户模型
|
||||||
|
*
|
||||||
* @param user
|
* @param user
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
|
@ -40,6 +43,7 @@ public interface UserMappers {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户发布request转用户发布参数模型
|
* 用户发布request转用户发布参数模型
|
||||||
|
*
|
||||||
* @param userPublishRequest
|
* @param userPublishRequest
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
|
@ -47,6 +51,7 @@ public interface UserMappers {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取单条用户信息Request转用户模型
|
* 获取单条用户信息Request转用户模型
|
||||||
|
*
|
||||||
* @param searchUserRequest
|
* @param searchUserRequest
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
|
@ -54,6 +59,7 @@ public interface UserMappers {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取用户列表转response列表
|
* 获取用户列表转response列表
|
||||||
|
*
|
||||||
* @param users
|
* @param users
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
|
@ -61,6 +67,7 @@ public interface UserMappers {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 编辑用户Request转用户模型
|
* 编辑用户Request转用户模型
|
||||||
|
*
|
||||||
* @param userModiRequest
|
* @param userModiRequest
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
|
@ -68,6 +75,7 @@ public interface UserMappers {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 校验工号唯一性Request转用户模型
|
* 校验工号唯一性Request转用户模型
|
||||||
|
*
|
||||||
* @param userWorkNumRequest
|
* @param userWorkNumRequest
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
|
@ -75,6 +83,7 @@ public interface UserMappers {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除单条用户信息Request转用户模型
|
* 删除单条用户信息Request转用户模型
|
||||||
|
*
|
||||||
* @param userDeleteRequest
|
* @param userDeleteRequest
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ import java.io.Serializable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 分页综合返回
|
* 分页综合返回
|
||||||
|
*
|
||||||
* @author
|
* @author
|
||||||
* @version $Id: IndicatorCardPage.java, v 0.1 2024-08-14 17:30
|
* @version $Id: IndicatorCardPage.java, v 0.1 2024-08-14 17:30
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ import lombok.Data;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
public class BaseRequest implements Serializable {
|
public class BaseRequest implements Serializable {
|
||||||
|
|
||||||
private static final long serialVersionUID = -9017146892952264211L;
|
private static final long serialVersionUID = -9017146892952264211L;
|
||||||
|
|
||||||
|
|
@ -34,15 +34,15 @@ public class BaseRequest implements Serializable {
|
||||||
*/
|
*/
|
||||||
private String appName;
|
private String appName;
|
||||||
/**
|
/**
|
||||||
*人员编码
|
* 人员编码
|
||||||
*/
|
*/
|
||||||
private String personNo;
|
private String personNo;
|
||||||
/**
|
/**
|
||||||
*人员姓名
|
* 人员姓名
|
||||||
*/
|
*/
|
||||||
private String personName;
|
private String personName;
|
||||||
/**
|
/**
|
||||||
* 权限码
|
* 权限码
|
||||||
*/
|
*/
|
||||||
private String permissionCode;
|
private String permissionCode;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@ public class UserRequest extends BaseRequest implements Serializable {
|
||||||
/**
|
/**
|
||||||
* 入职日期
|
* 入职日期
|
||||||
*/
|
*/
|
||||||
@JsonFormat(pattern="yyyy-MM-dd")
|
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||||
private Date joinTime;
|
private Date joinTime;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -50,7 +50,7 @@ public class UserRequest extends BaseRequest implements Serializable {
|
||||||
/**
|
/**
|
||||||
* 实习截止日期
|
* 实习截止日期
|
||||||
*/
|
*/
|
||||||
@JsonFormat(pattern="yyyy-MM-dd")
|
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||||
private Date internshipEndDate;
|
private Date internshipEndDate;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@ import java.util.Map;
|
||||||
public interface EDDataService {
|
public interface EDDataService {
|
||||||
/**
|
/**
|
||||||
* 创建文件夹
|
* 创建文件夹
|
||||||
|
*
|
||||||
* @param request
|
* @param request
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
|
@ -24,6 +25,7 @@ public interface EDDataService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取文件信息列表
|
* 获取文件信息列表
|
||||||
|
*
|
||||||
* @param request
|
* @param request
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
|
@ -31,6 +33,7 @@ public interface EDDataService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新文件信息
|
* 更新文件信息
|
||||||
|
*
|
||||||
* @param request
|
* @param request
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
|
@ -38,6 +41,7 @@ public interface EDDataService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取子文件数量
|
* 获取子文件数量
|
||||||
|
*
|
||||||
* @param request
|
* @param request
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
|
@ -45,6 +49,7 @@ public interface EDDataService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 上传
|
* 上传
|
||||||
|
*
|
||||||
* @param request
|
* @param request
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
|
@ -60,6 +65,7 @@ public interface EDDataService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 导出数据
|
* 导出数据
|
||||||
|
*
|
||||||
* @param dataIdArr
|
* @param dataIdArr
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
|
@ -67,6 +73,7 @@ public interface EDDataService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 导入数据
|
* 导入数据
|
||||||
|
*
|
||||||
* @param fileChunkDTO
|
* @param fileChunkDTO
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
|
@ -74,6 +81,7 @@ public interface EDDataService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取已经上传的分片
|
* 获取已经上传的分片
|
||||||
|
*
|
||||||
* @param identifier
|
* @param identifier
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
|
@ -82,6 +90,7 @@ public interface EDDataService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 合并分片
|
* 合并分片
|
||||||
|
*
|
||||||
* @param identifier
|
* @param identifier
|
||||||
* @param fileName
|
* @param fileName
|
||||||
* @param totalChunks
|
* @param totalChunks
|
||||||
|
|
@ -92,6 +101,7 @@ public interface EDDataService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 检查分片是否存在
|
* 检查分片是否存在
|
||||||
|
*
|
||||||
* @param fileChunkDTO
|
* @param fileChunkDTO
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ public interface TokenService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建令牌
|
* 创建令牌
|
||||||
|
*
|
||||||
* @param loginInfo
|
* @param loginInfo
|
||||||
* @return 令牌
|
* @return 令牌
|
||||||
*/
|
*/
|
||||||
|
|
@ -15,6 +16,7 @@ public interface TokenService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建用户令牌
|
* 创建用户令牌
|
||||||
|
*
|
||||||
* @param user
|
* @param user
|
||||||
* @param tokenStr
|
* @param tokenStr
|
||||||
* @return
|
* @return
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ public interface UserService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户登录
|
* 用户登录
|
||||||
|
*
|
||||||
* @param loginRequest
|
* @param loginRequest
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
|
@ -14,6 +15,7 @@ public interface UserService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增用户信息
|
* 新增用户信息
|
||||||
|
*
|
||||||
* @param userRequest
|
* @param userRequest
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
|
@ -21,6 +23,7 @@ public interface UserService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 编辑用户信息
|
* 编辑用户信息
|
||||||
|
*
|
||||||
* @param userModiRequest
|
* @param userModiRequest
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
|
@ -29,6 +32,7 @@ public interface UserService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 发布用户
|
* 发布用户
|
||||||
|
*
|
||||||
* @param userPublishRequest
|
* @param userPublishRequest
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
|
@ -36,6 +40,7 @@ public interface UserService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 校验工号唯一性
|
* 校验工号唯一性
|
||||||
|
*
|
||||||
* @param workNumberRequest
|
* @param workNumberRequest
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
|
@ -43,6 +48,7 @@ public interface UserService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通过用户编码获取单条用户信息
|
* 通过用户编码获取单条用户信息
|
||||||
|
*
|
||||||
* @param getSingleUserRequest
|
* @param getSingleUserRequest
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
|
@ -50,6 +56,7 @@ public interface UserService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询用户信息
|
* 查询用户信息
|
||||||
|
*
|
||||||
* @param searchUserRequest
|
* @param searchUserRequest
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
|
@ -57,6 +64,7 @@ public interface UserService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 刪除用戶(逻辑删除)
|
* 刪除用戶(逻辑删除)
|
||||||
|
*
|
||||||
* @param userDeleteRequest
|
* @param userDeleteRequest
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
|
@ -64,6 +72,7 @@ public interface UserService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户登出
|
* 用户登出
|
||||||
|
*
|
||||||
* @param token
|
* @param token
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -39,10 +39,11 @@ public class CategoryServiceImpl implements CategoryService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 递归列表
|
* 递归列表
|
||||||
|
*
|
||||||
* @param list
|
* @param list
|
||||||
* @param category
|
* @param category
|
||||||
*/
|
*/
|
||||||
private void recursionFn (List<Category> list, Category category) {
|
private void recursionFn(List<Category> list, Category category) {
|
||||||
List<Category> childList = getChildList(list, category);
|
List<Category> childList = getChildList(list, category);
|
||||||
category.setChildren(childList);
|
category.setChildren(childList);
|
||||||
for (Category child : childList) {
|
for (Category child : childList) {
|
||||||
|
|
@ -54,6 +55,7 @@ public class CategoryServiceImpl implements CategoryService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 得到子节点列表
|
* 得到子节点列表
|
||||||
|
*
|
||||||
* @param list
|
* @param list
|
||||||
* @param category
|
* @param category
|
||||||
* @return
|
* @return
|
||||||
|
|
@ -72,6 +74,7 @@ public class CategoryServiceImpl implements CategoryService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 判断是否有子节点
|
* 判断是否有子节点
|
||||||
|
*
|
||||||
* @param list
|
* @param list
|
||||||
* @param category
|
* @param category
|
||||||
* @return
|
* @return
|
||||||
|
|
|
||||||
|
|
@ -56,27 +56,23 @@ import java.util.stream.Collectors;
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class EDDataServiceImpl implements EDDataService {
|
public class EDDataServiceImpl implements EDDataService {
|
||||||
|
|
||||||
|
private static final String UPLOAD_FILE_CHUNK_SUFFIX = ".part";
|
||||||
|
// 文件夹名称分隔符
|
||||||
|
private static final String FOLDER_NAME_SEPARATOR = "_";
|
||||||
@Resource
|
@Resource
|
||||||
private EDDataMapper edDataMapper;
|
private EDDataMapper edDataMapper;
|
||||||
@Resource
|
@Resource
|
||||||
private CategoryMapper categoryMapper;
|
private CategoryMapper categoryMapper;
|
||||||
|
|
||||||
|
|
||||||
@Value("${data.windows.path}")
|
@Value("${data.windows.path}")
|
||||||
private String uploadFilePath;
|
private String uploadFilePath;
|
||||||
|
|
||||||
@Value("${data.file.storage.dir}")
|
@Value("${data.file.storage.dir}")
|
||||||
private String fileStorageDir;
|
private String fileStorageDir;
|
||||||
|
|
||||||
@Value("${data.import.cache.dir}")
|
@Value("${data.import.cache.dir}")
|
||||||
private String importCacheDir;
|
private String importCacheDir;
|
||||||
|
|
||||||
@Value("${file.encode.passwd}")
|
@Value("${file.encode.passwd}")
|
||||||
private String encodePasswd;
|
private String encodePasswd;
|
||||||
|
|
||||||
@Value("${data.type.folder}")
|
@Value("${data.type.folder}")
|
||||||
private String dataTypeFolder;
|
private String dataTypeFolder;
|
||||||
|
|
||||||
@Value("${data.windows.path}")
|
@Value("${data.windows.path}")
|
||||||
private String windowsDir;
|
private String windowsDir;
|
||||||
@Value("${data.file.cache.dir}")
|
@Value("${data.file.cache.dir}")
|
||||||
|
|
@ -88,11 +84,6 @@ public class EDDataServiceImpl implements EDDataService {
|
||||||
@Value("${data.type.file}")
|
@Value("${data.type.file}")
|
||||||
private String dataTypeFile;
|
private String dataTypeFile;
|
||||||
|
|
||||||
private static final String UPLOAD_FILE_CHUNK_SUFFIX = ".part";
|
|
||||||
// 文件夹名称分隔符
|
|
||||||
private static final String FOLDER_NAME_SEPARATOR = "_";
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ElectromagneticResult<Boolean> createFolder(EDDataRequest request) {
|
public ElectromagneticResult<Boolean> createFolder(EDDataRequest request) {
|
||||||
|
|
||||||
|
|
@ -123,8 +114,7 @@ public class EDDataServiceImpl implements EDDataService {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Boolean createDataInfo(EDDataInfo edDataInfo) throws Exception
|
public Boolean createDataInfo(EDDataInfo edDataInfo) throws Exception {
|
||||||
{
|
|
||||||
// 获取上级目录的名称
|
// 获取上级目录的名称
|
||||||
String fileName = edDataInfo.getDataName();
|
String fileName = edDataInfo.getDataName();
|
||||||
Assert.isTrue(EleCommonUtil.isFileNameValid(fileName), "文件名不符合规范,只能包含中文字符、下划线、连字符、加号、数字和英文字符且长度小于32。");
|
Assert.isTrue(EleCommonUtil.isFileNameValid(fileName), "文件名不符合规范,只能包含中文字符、下划线、连字符、加号、数字和英文字符且长度小于32。");
|
||||||
|
|
@ -133,32 +123,29 @@ public class EDDataServiceImpl implements EDDataService {
|
||||||
categoryParent.setCategoryId(edDataInfo.getCategoryId());
|
categoryParent.setCategoryId(edDataInfo.getCategoryId());
|
||||||
List<Category> categoryParentList = categoryMapper.selectCategories(categoryParent);
|
List<Category> categoryParentList = categoryMapper.selectCategories(categoryParent);
|
||||||
|
|
||||||
if(categoryParentList.size() < 1) {
|
if (categoryParentList.size() < 1) {
|
||||||
throw new Exception("上级文件夹不存在");
|
throw new Exception("上级文件夹不存在");
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
// 获取新文件夹路径信息
|
// 获取新文件夹路径信息
|
||||||
categoryParent = categoryParentList.get(0);
|
categoryParent = categoryParentList.get(0);
|
||||||
|
|
||||||
String dataStoragePath = getDataStoragePath();
|
String dataStoragePath = getDataStoragePath();
|
||||||
String folderParent = categoryParent.getCategoryId() + FOLDER_NAME_SEPARATOR + categoryParent.getCategoryName() ;
|
String folderParent = categoryParent.getCategoryId() + FOLDER_NAME_SEPARATOR + categoryParent.getCategoryName();
|
||||||
String folderNew = dataStoragePath + File.separator + folderParent + File.separator + edDataInfo.getDataName();
|
String folderNew = dataStoragePath + File.separator + folderParent + File.separator + edDataInfo.getDataName();
|
||||||
|
|
||||||
// 判断文件夹名称是否存在
|
// 判断文件夹名称是否存在
|
||||||
EDDataParams folderParames = new EDDataParams();
|
EDDataParams folderParames = new EDDataParams();
|
||||||
folderParames.setParentId(edDataInfo.getCategoryId());
|
folderParames.setParentId(edDataInfo.getCategoryId());
|
||||||
List<EDDataInfo> childFileInfoList = edDataMapper.getDataInfoList(folderParames);
|
List<EDDataInfo> childFileInfoList = edDataMapper.getDataInfoList(folderParames);
|
||||||
for(EDDataInfo fileInfo : childFileInfoList)
|
for (EDDataInfo fileInfo : childFileInfoList) {
|
||||||
{
|
if (fileInfo.getDataName().equals(edDataInfo.getDataName())) {
|
||||||
if(fileInfo.getDataName().equals(edDataInfo.getDataName())){
|
|
||||||
throw new Exception("文件夹已存在");
|
throw new Exception("文件夹已存在");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 将文件夹数据写到数据库中
|
// 将文件夹数据写到数据库中
|
||||||
if(edDataMapper.createDataInfo(edDataInfo)) {
|
if (edDataMapper.createDataInfo(edDataInfo)) {
|
||||||
if (!FileUtil.exist(folderNew)){
|
if (!FileUtil.exist(folderNew)) {
|
||||||
FileUtil.mkdir(folderNew);
|
FileUtil.mkdir(folderNew);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -169,6 +156,7 @@ public class EDDataServiceImpl implements EDDataService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取数据存储目录
|
* 获取数据存储目录
|
||||||
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public String getDataStoragePath() {
|
public String getDataStoragePath() {
|
||||||
|
|
@ -178,7 +166,7 @@ public class EDDataServiceImpl implements EDDataService {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ElectromagneticResult<EDDataPageResponse> getDataInfoList(EDDataRequest request) {
|
public ElectromagneticResult<EDDataPageResponse> getDataInfoList(EDDataRequest request) {
|
||||||
EDDataParams parames= EDDataMappers.INSTANCE.getEDDataParames(request);
|
EDDataParams parames = EDDataMappers.INSTANCE.getEDDataParames(request);
|
||||||
//获取中支指标配置列表
|
//获取中支指标配置列表
|
||||||
PageHelper.startPage(parames.getPageIndex(), parames.getPageSize());
|
PageHelper.startPage(parames.getPageIndex(), parames.getPageSize());
|
||||||
List<EDDataInfo> edDataInfoList = edDataMapper.getDataInfoList(parames);
|
List<EDDataInfo> edDataInfoList = edDataMapper.getDataInfoList(parames);
|
||||||
|
|
@ -207,14 +195,14 @@ public class EDDataServiceImpl implements EDDataService {
|
||||||
public Boolean updateFileInfo(EDDataParams parames) throws Exception {
|
public Boolean updateFileInfo(EDDataParams parames) throws Exception {
|
||||||
|
|
||||||
String dataStoragePath = getDataStoragePath();
|
String dataStoragePath = getDataStoragePath();
|
||||||
if (!FileUtil.exist(dataStoragePath)){
|
if (!FileUtil.exist(dataStoragePath)) {
|
||||||
throw new Exception("数据存储文件夹不存在");
|
throw new Exception("数据存储文件夹不存在");
|
||||||
}
|
}
|
||||||
|
|
||||||
EDDataParams paramesFind = new EDDataParams();
|
EDDataParams paramesFind = new EDDataParams();
|
||||||
paramesFind.setDataId(parames.getDataId());
|
paramesFind.setDataId(parames.getDataId());
|
||||||
List<EDDataInfo> edDataInfoList = edDataMapper.getDataInfoList(paramesFind);
|
List<EDDataInfo> edDataInfoList = edDataMapper.getDataInfoList(paramesFind);
|
||||||
if(edDataInfoList.size() < 1) {
|
if (edDataInfoList.size() < 1) {
|
||||||
throw new Exception("文件信息不存在");
|
throw new Exception("文件信息不存在");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -223,19 +211,19 @@ public class EDDataServiceImpl implements EDDataService {
|
||||||
String fileType = StrUtil.isEmpty(edDataInfo.getFileType()) ? "" : "." + edDataInfo.getFileType();
|
String fileType = StrUtil.isEmpty(edDataInfo.getFileType()) ? "" : "." + edDataInfo.getFileType();
|
||||||
String fileStorageFullPath = dataStoragePath + filePathOfFolder + File.separator + edDataInfo.getDataName() + fileType;
|
String fileStorageFullPath = dataStoragePath + filePathOfFolder + File.separator + edDataInfo.getDataName() + fileType;
|
||||||
|
|
||||||
if (!FileUtil.exist(fileStorageFullPath)){
|
if (!FileUtil.exist(fileStorageFullPath)) {
|
||||||
throw new Exception("文件不存在");
|
throw new Exception("文件不存在");
|
||||||
}
|
}
|
||||||
|
|
||||||
String fileNameNew = parames.getName() + fileType;
|
String fileNameNew = parames.getName() + fileType;
|
||||||
if(fileNameNew != null && fileNameNew != "" && !fileNameNew.equals(edDataInfo.getDataName())) {
|
if (fileNameNew != null && fileNameNew != "" && !fileNameNew.equals(edDataInfo.getDataName())) {
|
||||||
FileUtil.rename(Paths.get(fileStorageFullPath) ,fileNameNew,true);
|
FileUtil.rename(Paths.get(fileStorageFullPath), fileNameNew, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 修改文件夹
|
// 修改文件夹
|
||||||
edDataMapper.updateFileInfo(parames);
|
edDataMapper.updateFileInfo(parames);
|
||||||
// 修改文件夹中的文件
|
// 修改文件夹中的文件
|
||||||
if(edDataInfo.getDataType().equals(dataTypeFolder) && parames.getEffectFlag() != null) {
|
if (edDataInfo.getDataType().equals(dataTypeFolder) && parames.getEffectFlag() != null) {
|
||||||
EDDataParams paramesChild = new EDDataParams();
|
EDDataParams paramesChild = new EDDataParams();
|
||||||
paramesChild.setParentId(edDataInfo.getDataId());
|
paramesChild.setParentId(edDataInfo.getDataId());
|
||||||
paramesChild.setEffectFlag(parames.getEffectFlag());
|
paramesChild.setEffectFlag(parames.getEffectFlag());
|
||||||
|
|
@ -253,17 +241,17 @@ public class EDDataServiceImpl implements EDDataService {
|
||||||
folderParames.setDataId(categoryId);
|
folderParames.setDataId(categoryId);
|
||||||
List<EDDataInfo> edDataInfoList = edDataMapper.getDataInfoList(folderParames);
|
List<EDDataInfo> edDataInfoList = edDataMapper.getDataInfoList(folderParames);
|
||||||
EDDataInfo edDataInfoParent = null;
|
EDDataInfo edDataInfoParent = null;
|
||||||
if(CollUtil.isNotEmpty(edDataInfoList)) {
|
if (CollUtil.isNotEmpty(edDataInfoList)) {
|
||||||
categoryIdHighest = edDataInfoList.get(0).getCategoryId();
|
categoryIdHighest = edDataInfoList.get(0).getCategoryId();
|
||||||
edDataInfoParent = edDataInfoList.get(0);
|
edDataInfoParent = edDataInfoList.get(0);
|
||||||
}
|
}
|
||||||
Category categoryParent = new Category();
|
Category categoryParent = new Category();
|
||||||
categoryParent.setCategoryId(categoryIdHighest);
|
categoryParent.setCategoryId(categoryIdHighest);
|
||||||
List<Category> categoryParentList = categoryMapper.selectCategories(categoryParent);
|
List<Category> categoryParentList = categoryMapper.selectCategories(categoryParent);
|
||||||
if(categoryParentList.size() > 0){
|
if (categoryParentList.size() > 0) {
|
||||||
categoryParent = categoryParentList.get(0);
|
categoryParent = categoryParentList.get(0);
|
||||||
filePathOfFolder = categoryParent.getCategoryId() + FOLDER_NAME_SEPARATOR + categoryParent.getCategoryName();
|
filePathOfFolder = categoryParent.getCategoryId() + FOLDER_NAME_SEPARATOR + categoryParent.getCategoryName();
|
||||||
if(edDataInfoParent != null) {
|
if (edDataInfoParent != null) {
|
||||||
String fileType = StrUtil.isEmpty(edDataInfoParent.getFileType()) ? "" : "." + edDataInfoParent.getFileType();
|
String fileType = StrUtil.isEmpty(edDataInfoParent.getFileType()) ? "" : "." + edDataInfoParent.getFileType();
|
||||||
filePathOfFolder = filePathOfFolder + File.separator + edDataInfoParent.getDataName() + fileType;
|
filePathOfFolder = filePathOfFolder + File.separator + edDataInfoParent.getDataName() + fileType;
|
||||||
}
|
}
|
||||||
|
|
@ -274,7 +262,7 @@ public class EDDataServiceImpl implements EDDataService {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ElectromagneticResult<Map<String, Integer>> getChildFileCount(EDDataRequest request) {
|
public ElectromagneticResult<Map<String, Integer>> getChildFileCount(EDDataRequest request) {
|
||||||
EDDataParams parames= EDDataMappers.INSTANCE.getEDDataParames(request);
|
EDDataParams parames = EDDataMappers.INSTANCE.getEDDataParames(request);
|
||||||
Integer fileCount = getChildFileCount(parames);
|
Integer fileCount = getChildFileCount(parames);
|
||||||
Map<String, Integer> result = new HashMap<>();
|
Map<String, Integer> result = new HashMap<>();
|
||||||
result.put("fileCount", fileCount);
|
result.put("fileCount", fileCount);
|
||||||
|
|
@ -287,13 +275,10 @@ public class EDDataServiceImpl implements EDDataService {
|
||||||
List<EDDataInfo> edDataInfoList = edDataMapper.getDataInfoList(parames);
|
List<EDDataInfo> edDataInfoList = edDataMapper.getDataInfoList(parames);
|
||||||
parames.setDataId(null);
|
parames.setDataId(null);
|
||||||
for (EDDataInfo edDataInfo : edDataInfoList) {
|
for (EDDataInfo edDataInfo : edDataInfoList) {
|
||||||
if(edDataInfo.getDataType().equals(dataTypeFolder))
|
if (edDataInfo.getDataType().equals(dataTypeFolder)) {
|
||||||
{
|
|
||||||
parames.setParentId(edDataInfo.getDataId());
|
parames.setParentId(edDataInfo.getDataId());
|
||||||
childFileCount += getChildFileCount(parames);
|
childFileCount += getChildFileCount(parames);
|
||||||
}
|
} else if (edDataInfo.getDataType().equals(dataTypeFile) && edDataInfo.getEffectFlag().equals(1)) {
|
||||||
else if(edDataInfo.getDataType().equals(dataTypeFile) && edDataInfo.getEffectFlag().equals(1))
|
|
||||||
{
|
|
||||||
++childFileCount;
|
++childFileCount;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -304,7 +289,7 @@ public class EDDataServiceImpl implements EDDataService {
|
||||||
@Override
|
@Override
|
||||||
public ElectromagneticResult<Boolean> uploadFile(EDDataRequest request) {
|
public ElectromagneticResult<Boolean> uploadFile(EDDataRequest request) {
|
||||||
try {
|
try {
|
||||||
EDDataParams parames= EDDataMappers.INSTANCE.getEDDataParames(request);
|
EDDataParams parames = EDDataMappers.INSTANCE.getEDDataParames(request);
|
||||||
parames.setUserId(UserThreadLocal.getUserId());
|
parames.setUserId(UserThreadLocal.getUserId());
|
||||||
parames.setUserName(UserThreadLocal.getUsername());
|
parames.setUserName(UserThreadLocal.getUsername());
|
||||||
return ElectromagneticResultUtil.success(upload(parames));
|
return ElectromagneticResultUtil.success(upload(parames));
|
||||||
|
|
@ -337,15 +322,14 @@ public class EDDataServiceImpl implements EDDataService {
|
||||||
EDDataParams folderParames = new EDDataParams();
|
EDDataParams folderParames = new EDDataParams();
|
||||||
folderParames.setParentId(categoryId);
|
folderParames.setParentId(categoryId);
|
||||||
List<EDDataInfo> childFileInfoList = edDataMapper.getDataInfoList(folderParames);
|
List<EDDataInfo> childFileInfoList = edDataMapper.getDataInfoList(folderParames);
|
||||||
for(EDDataInfo fileInfo : childFileInfoList)
|
for (EDDataInfo fileInfo : childFileInfoList) {
|
||||||
{
|
if (fileInfo.getDataName().equals(fileFullName)) {
|
||||||
if(fileInfo.getDataName().equals(fileFullName)){
|
|
||||||
throw new Exception("上传的文件已存在");
|
throw new Exception("上传的文件已存在");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String dataStoragePath = getDataStoragePath();
|
String dataStoragePath = getDataStoragePath();
|
||||||
if (!FileUtil.exist(dataStoragePath)){
|
if (!FileUtil.exist(dataStoragePath)) {
|
||||||
FileUtil.mkdir(dataStoragePath);
|
FileUtil.mkdir(dataStoragePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -382,14 +366,14 @@ public class EDDataServiceImpl implements EDDataService {
|
||||||
|
|
||||||
// 文件保存目录路径
|
// 文件保存目录路径
|
||||||
String fileSavePath = dataStoragePath + File.separator + filePathOfFolder;
|
String fileSavePath = dataStoragePath + File.separator + filePathOfFolder;
|
||||||
String newFileName = edDataInfo.getDataId() + FOLDER_NAME_SEPARATOR + fileFullName;
|
String newFileName = edDataInfo.getDataId() + FOLDER_NAME_SEPARATOR + fileFullName;
|
||||||
if (!FileUtil.exist(fileSavePath)){
|
if (!FileUtil.exist(fileSavePath)) {
|
||||||
FileUtil.mkdir(fileSavePath);
|
FileUtil.mkdir(fileSavePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
String dataCachePath = getDataCachePath();
|
String dataCachePath = getDataCachePath();
|
||||||
String uploadFileCachePath = dataCachePath + uploadCacheDir + FOLDER_NAME_SEPARATOR + getTimeStampString();
|
String uploadFileCachePath = dataCachePath + uploadCacheDir + FOLDER_NAME_SEPARATOR + getTimeStampString();
|
||||||
if (!FileUtil.exist(uploadFileCachePath)){
|
if (!FileUtil.exist(uploadFileCachePath)) {
|
||||||
FileUtil.mkdir(uploadFileCachePath);
|
FileUtil.mkdir(uploadFileCachePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -408,15 +392,12 @@ public class EDDataServiceImpl implements EDDataService {
|
||||||
|
|
||||||
|
|
||||||
fileParames.setDataId(edDataInfo.getDataId());
|
fileParames.setDataId(edDataInfo.getDataId());
|
||||||
if(fileInput.getSize() == saveFile.length())
|
if (fileInput.getSize() == saveFile.length()) {
|
||||||
{
|
|
||||||
Path source = Paths.get(fileCacheFullPath);
|
Path source = Paths.get(fileCacheFullPath);
|
||||||
Path target = Paths.get(fileSaveFullPath);
|
Path target = Paths.get(fileSaveFullPath);
|
||||||
Files.move(source, target);
|
Files.move(source, target);
|
||||||
fileParames.setSaveStatus("success");
|
fileParames.setSaveStatus("success");
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
saveFile.delete();
|
saveFile.delete();
|
||||||
fileParames.setSaveStatus("failure");
|
fileParames.setSaveStatus("failure");
|
||||||
}
|
}
|
||||||
|
|
@ -439,6 +420,7 @@ public class EDDataServiceImpl implements EDDataService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取时间戳字符串
|
* 获取时间戳字符串
|
||||||
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public String getTimeStampString() {
|
public String getTimeStampString() {
|
||||||
|
|
@ -448,6 +430,7 @@ public class EDDataServiceImpl implements EDDataService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取数据缓存目录
|
* 获取数据缓存目录
|
||||||
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public String getDataCachePath() {
|
public String getDataCachePath() {
|
||||||
|
|
@ -476,7 +459,7 @@ public class EDDataServiceImpl implements EDDataService {
|
||||||
headers.add("Pragma", "no-cache");
|
headers.add("Pragma", "no-cache");
|
||||||
headers.add("Expires", "0");
|
headers.add("Expires", "0");
|
||||||
String fileName = Base64.encode(fileSystemResource.getFilename());
|
String fileName = Base64.encode(fileSystemResource.getFilename());
|
||||||
response.setHeader("content-disposition","attachment;filename=" + fileName);
|
response.setHeader("content-disposition", "attachment;filename=" + fileName);
|
||||||
// 构建响应实体(可以返回<byte[]或Resource,返回类型取决body入参类型)
|
// 构建响应实体(可以返回<byte[]或Resource,返回类型取决body入参类型)
|
||||||
return ResponseEntity
|
return ResponseEntity
|
||||||
.ok()
|
.ok()
|
||||||
|
|
@ -486,8 +469,7 @@ public class EDDataServiceImpl implements EDDataService {
|
||||||
.body(new InputStreamResource(fileSystemResource.getInputStream()));
|
.body(new InputStreamResource(fileSystemResource.getInputStream()));
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getFilePathOfFolder1(String categoryId)
|
private String getFilePathOfFolder1(String categoryId) {
|
||||||
{
|
|
||||||
String filePathOfFolder = ""; //文件存放在文件夹的路径
|
String filePathOfFolder = ""; //文件存放在文件夹的路径
|
||||||
|
|
||||||
String categoryIdHighest = categoryId; //最高级的目录编码
|
String categoryIdHighest = categoryId; //最高级的目录编码
|
||||||
|
|
@ -495,17 +477,17 @@ public class EDDataServiceImpl implements EDDataService {
|
||||||
folderParames.setDataId(categoryId);
|
folderParames.setDataId(categoryId);
|
||||||
List<EDDataInfo> edDataInfoList = edDataMapper.getDataInfoList(folderParames);
|
List<EDDataInfo> edDataInfoList = edDataMapper.getDataInfoList(folderParames);
|
||||||
EDDataInfo edDataInfoParent = null;
|
EDDataInfo edDataInfoParent = null;
|
||||||
if(CollUtil.isNotEmpty(edDataInfoList)) {
|
if (CollUtil.isNotEmpty(edDataInfoList)) {
|
||||||
categoryIdHighest = edDataInfoList.get(0).getCategoryId();
|
categoryIdHighest = edDataInfoList.get(0).getCategoryId();
|
||||||
edDataInfoParent = edDataInfoList.get(0);
|
edDataInfoParent = edDataInfoList.get(0);
|
||||||
}
|
}
|
||||||
Category categoryParent = new Category();
|
Category categoryParent = new Category();
|
||||||
categoryParent.setCategoryId(categoryIdHighest);
|
categoryParent.setCategoryId(categoryIdHighest);
|
||||||
List<Category> categoryParentList = categoryMapper.selectCategories(categoryParent);
|
List<Category> categoryParentList = categoryMapper.selectCategories(categoryParent);
|
||||||
if(categoryParentList.size() > 0){
|
if (categoryParentList.size() > 0) {
|
||||||
categoryParent = categoryParentList.get(0);
|
categoryParent = categoryParentList.get(0);
|
||||||
filePathOfFolder = categoryParent.getCategoryId() + FOLDER_NAME_SEPARATOR + categoryParent.getCategoryName();
|
filePathOfFolder = categoryParent.getCategoryId() + FOLDER_NAME_SEPARATOR + categoryParent.getCategoryName();
|
||||||
if(edDataInfoParent != null) {
|
if (edDataInfoParent != null) {
|
||||||
String fileType = StrUtil.isEmpty(edDataInfoParent.getFileType()) ? "" : "." + edDataInfoParent.getFileType();
|
String fileType = StrUtil.isEmpty(edDataInfoParent.getFileType()) ? "" : "." + edDataInfoParent.getFileType();
|
||||||
filePathOfFolder = filePathOfFolder + File.separator + edDataInfoParent.getDataName() + fileType;
|
filePathOfFolder = filePathOfFolder + File.separator + edDataInfoParent.getDataName() + fileType;
|
||||||
}
|
}
|
||||||
|
|
@ -524,7 +506,7 @@ public class EDDataServiceImpl implements EDDataService {
|
||||||
|
|
||||||
Map<String, String> result = new HashMap<>();
|
Map<String, String> result = new HashMap<>();
|
||||||
List<String> dataIdList = Arrays.asList(dataIdArr.split(","));
|
List<String> dataIdList = Arrays.asList(dataIdArr.split(","));
|
||||||
if(!dataIdList.isEmpty()) {
|
if (!dataIdList.isEmpty()) {
|
||||||
String filePath = exportData(dataIdList);
|
String filePath = exportData(dataIdList);
|
||||||
|
|
||||||
Assert.isTrue(FileUtil.exist(filePath), "下载文件不存在。");
|
Assert.isTrue(FileUtil.exist(filePath), "下载文件不存在。");
|
||||||
|
|
@ -536,7 +518,7 @@ public class EDDataServiceImpl implements EDDataService {
|
||||||
String fileName = Base64.encode(fileSystemResource.getFilename());
|
String fileName = Base64.encode(fileSystemResource.getFilename());
|
||||||
headers.add("Pragma", "no-cache");
|
headers.add("Pragma", "no-cache");
|
||||||
headers.add("Expires", "0");
|
headers.add("Expires", "0");
|
||||||
response.setHeader("content-disposition","attachment;filename=" + fileName);
|
response.setHeader("content-disposition", "attachment;filename=" + fileName);
|
||||||
|
|
||||||
// 构建响应实体(可以返回<byte[]或Resource,返回类型取决body入参类型)
|
// 构建响应实体(可以返回<byte[]或Resource,返回类型取决body入参类型)
|
||||||
return ResponseEntity
|
return ResponseEntity
|
||||||
|
|
@ -660,11 +642,9 @@ public class EDDataServiceImpl implements EDDataService {
|
||||||
}
|
}
|
||||||
|
|
||||||
log.info("目录树数据+文件数据已成功复制到目标目录。" + enCodeZipPathFileName);
|
log.info("目录树数据+文件数据已成功复制到目标目录。" + enCodeZipPathFileName);
|
||||||
}
|
} catch (Exception e) {
|
||||||
catch (Exception e) {
|
|
||||||
log.error("导出数据异常..", e);
|
log.error("导出数据异常..", e);
|
||||||
}
|
} finally {
|
||||||
finally {
|
|
||||||
// 删除 导出数据的 缓存目录
|
// 删除 导出数据的 缓存目录
|
||||||
FileUtil.del(exportDataCachePath);
|
FileUtil.del(exportDataCachePath);
|
||||||
}
|
}
|
||||||
|
|
@ -777,8 +757,8 @@ public class EDDataServiceImpl implements EDDataService {
|
||||||
// 解密文件
|
// 解密文件
|
||||||
String decryptFilePath = destZipPath + "_decrypted";
|
String decryptFilePath = destZipPath + "_decrypted";
|
||||||
AES aes = SecureUtil.aes(encodePasswd.getBytes()); // aesKey是加密密钥
|
AES aes = SecureUtil.aes(encodePasswd.getBytes()); // aesKey是加密密钥
|
||||||
try(
|
try (
|
||||||
InputStream inputStream = new FileInputStream(destZipPath);
|
InputStream inputStream = new FileInputStream(destZipPath);
|
||||||
OutputStream outputStream = new FileOutputStream(decryptFilePath);
|
OutputStream outputStream = new FileOutputStream(decryptFilePath);
|
||||||
) {
|
) {
|
||||||
aes.decrypt(inputStream, outputStream, true);
|
aes.decrypt(inputStream, outputStream, true);
|
||||||
|
|
@ -851,7 +831,7 @@ public class EDDataServiceImpl implements EDDataService {
|
||||||
List<String> importFileFail = new ArrayList();
|
List<String> importFileFail = new ArrayList();
|
||||||
|
|
||||||
String dataStoragePath = getDataStoragePath();
|
String dataStoragePath = getDataStoragePath();
|
||||||
if (!FileUtil.exist(dataStoragePath)){
|
if (!FileUtil.exist(dataStoragePath)) {
|
||||||
FileUtil.mkdir(dataStoragePath);
|
FileUtil.mkdir(dataStoragePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -874,22 +854,19 @@ public class EDDataServiceImpl implements EDDataService {
|
||||||
&& FileUtil.exist(importFileCachePath)
|
&& FileUtil.exist(importFileCachePath)
|
||||||
&& FileUtil.exist(importFileCacheFullPath)
|
&& FileUtil.exist(importFileCacheFullPath)
|
||||||
&& !FileUtil.exist(fileStorageFullPath)
|
&& !FileUtil.exist(fileStorageFullPath)
|
||||||
)
|
) {
|
||||||
{
|
if (fileInfo.getDataType().equals(dataTypeFolder)) {
|
||||||
if(fileInfo.getDataType().equals(dataTypeFolder)) {
|
|
||||||
if (!FileUtil.exist(fileStorageFullPath)) {
|
if (!FileUtil.exist(fileStorageFullPath)) {
|
||||||
FileUtil.mkdir(fileStorageFullPath);
|
FileUtil.mkdir(fileStorageFullPath);
|
||||||
}
|
}
|
||||||
} else if(fileInfo.getDataType().equals(dataTypeFile)) {
|
} else if (fileInfo.getDataType().equals(dataTypeFile)) {
|
||||||
Path source = Paths.get(importFileCacheFullPath);
|
Path source = Paths.get(importFileCacheFullPath);
|
||||||
Path target = Paths.get(fileStorageFullPath);
|
Path target = Paths.get(fileStorageFullPath);
|
||||||
FileUtil.move(source,target,true);
|
FileUtil.move(source, target, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
importFileSuccess.add(fileInfo.getDataId() + FOLDER_NAME_SEPARATOR + fileInfo.getDataName());
|
importFileSuccess.add(fileInfo.getDataId() + FOLDER_NAME_SEPARATOR + fileInfo.getDataName());
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
importFileFail.add(fileInfo.getDataId() + FOLDER_NAME_SEPARATOR + fileInfo.getDataName());
|
importFileFail.add(fileInfo.getDataId() + FOLDER_NAME_SEPARATOR + fileInfo.getDataName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,6 @@ import org.apache.commons.lang3.RandomStringUtils;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
@ -45,6 +44,7 @@ public class UserServiceImpl implements UserService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户登录
|
* 用户登录
|
||||||
|
*
|
||||||
* @param loginRequest
|
* @param loginRequest
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
|
@ -55,7 +55,7 @@ public class UserServiceImpl implements UserService {
|
||||||
User user = userMapper.selectUserByWorkNumber(info.getWorkNumber());
|
User user = userMapper.selectUserByWorkNumber(info.getWorkNumber());
|
||||||
info.setUserId(user.getUserId());
|
info.setUserId(user.getUserId());
|
||||||
info.setUsername(user.getUserName());
|
info.setUsername(user.getUserName());
|
||||||
if ( checkUserValid(user) && matchPassword(user, decodePwd)) {
|
if (checkUserValid(user) && matchPassword(user, decodePwd)) {
|
||||||
String tokenStr = createToken(info);
|
String tokenStr = createToken(info);
|
||||||
createUserToken(user, tokenStr);
|
createUserToken(user, tokenStr);
|
||||||
UserLoginResponse userLoginResponse = new UserLoginResponse();
|
UserLoginResponse userLoginResponse = new UserLoginResponse();
|
||||||
|
|
@ -63,30 +63,30 @@ public class UserServiceImpl implements UserService {
|
||||||
userLoginResponse.setUserId(user.getUserId());
|
userLoginResponse.setUserId(user.getUserId());
|
||||||
return ElectromagneticResultUtil.success(userLoginResponse);
|
return ElectromagneticResultUtil.success(userLoginResponse);
|
||||||
}
|
}
|
||||||
return ElectromagneticResultUtil.fail("500","用户不存在/密码错误");
|
return ElectromagneticResultUtil.fail("500", "用户不存在/密码错误");
|
||||||
}
|
}
|
||||||
|
|
||||||
public Boolean createUserToken (User user, String tokenStr){
|
public Boolean createUserToken(User user, String tokenStr) {
|
||||||
Token token = new Token();
|
Token token = new Token();
|
||||||
token.setUserId(user.getUserId());
|
token.setUserId(user.getUserId());
|
||||||
token.setToken(tokenStr);
|
token.setToken(tokenStr);
|
||||||
token.setExpireAt(new DateTime(SystemClock.now()+ UserConstants.DEFAULT_EXPIRE_TIME));
|
token.setExpireAt(new DateTime(SystemClock.now() + UserConstants.DEFAULT_EXPIRE_TIME));
|
||||||
return tokenMapper.insert(token)>0;
|
return tokenMapper.insert(token) > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Boolean checkUserValid(User user){
|
public Boolean checkUserValid(User user) {
|
||||||
if ( user == null
|
if (user == null
|
||||||
|| user.getIsPublished() == PublishEnum.UNPUBLISHED.getCode()
|
|| user.getIsPublished() == PublishEnum.UNPUBLISHED.getCode()
|
||||||
|| user.getEffectFlag() == EffectFlagEnum.EFFECT_FLAG_0.getCode()
|
|| user.getEffectFlag() == EffectFlagEnum.EFFECT_FLAG_0.getCode()
|
||||||
) {
|
) {
|
||||||
return false;
|
return false;
|
||||||
} else if( user.getInternshipEndDate()!=null && user.getInternshipEndDate().before(now())) {
|
} else if (user.getInternshipEndDate() != null && user.getInternshipEndDate().before(now())) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String createToken(UserLoginInfo loginInfo){
|
public String createToken(UserLoginInfo loginInfo) {
|
||||||
Map<String, Object> claims = new HashMap<>();
|
Map<String, Object> claims = new HashMap<>();
|
||||||
claims.put(UserConstants.LOGIN_USER_ID, loginInfo.getUserId());
|
claims.put(UserConstants.LOGIN_USER_ID, loginInfo.getUserId());
|
||||||
claims.put(UserConstants.LOGIN_USER_NAME, loginInfo.getUsername());
|
claims.put(UserConstants.LOGIN_USER_NAME, loginInfo.getUsername());
|
||||||
|
|
@ -98,14 +98,15 @@ public class UserServiceImpl implements UserService {
|
||||||
.compact();
|
.compact();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Boolean matchPassword(User user, String password){
|
public Boolean matchPassword(User user, String password) {
|
||||||
String salt = user.getSalt();
|
String salt = user.getSalt();
|
||||||
String encodePwd = SignUtils.MD5(password+salt);
|
String encodePwd = SignUtils.MD5(password + salt);
|
||||||
return user.getUserPwd().equals(encodePwd);
|
return user.getUserPwd().equals(encodePwd);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增用户信息
|
* 新增用户信息
|
||||||
|
*
|
||||||
* @param userRequest
|
* @param userRequest
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
|
@ -115,7 +116,7 @@ public class UserServiceImpl implements UserService {
|
||||||
User user = UserMappers.INSTANCE.getUserRequestToModel(userRequest);
|
User user = UserMappers.INSTANCE.getUserRequestToModel(userRequest);
|
||||||
user.setSalt(RandomStringUtils.randomAlphanumeric(16));
|
user.setSalt(RandomStringUtils.randomAlphanumeric(16));
|
||||||
user.setUserId(IdWorker.getSnowFlakeIdString());
|
user.setUserId(IdWorker.getSnowFlakeIdString());
|
||||||
user.setUserPwd(SignUtils.MD5(UserConstants.DEFAULT_PASSWORD+user.getSalt()));
|
user.setUserPwd(SignUtils.MD5(UserConstants.DEFAULT_PASSWORD + user.getSalt()));
|
||||||
user.setIsPublished(UserConstants.DEFAULT_PUBLISH_STATUS);
|
user.setIsPublished(UserConstants.DEFAULT_PUBLISH_STATUS);
|
||||||
user.setCreator(UserThreadLocal.getUserId());
|
user.setCreator(UserThreadLocal.getUserId());
|
||||||
user.setCreatorName(UserThreadLocal.getUsername());
|
user.setCreatorName(UserThreadLocal.getUsername());
|
||||||
|
|
@ -124,6 +125,7 @@ public class UserServiceImpl implements UserService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改用户信息
|
* 修改用户信息
|
||||||
|
*
|
||||||
* @param userModiRequest
|
* @param userModiRequest
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
|
@ -137,6 +139,7 @@ public class UserServiceImpl implements UserService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 发布用户信息
|
* 发布用户信息
|
||||||
|
*
|
||||||
* @param userPublishRequest
|
* @param userPublishRequest
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
|
@ -145,7 +148,7 @@ public class UserServiceImpl implements UserService {
|
||||||
PublishParam model = UserMappers.INSTANCE.getUserPublishRequestToModel(userPublishRequest);
|
PublishParam model = UserMappers.INSTANCE.getUserPublishRequestToModel(userPublishRequest);
|
||||||
model.setModifier(UserThreadLocal.getUserId());
|
model.setModifier(UserThreadLocal.getUserId());
|
||||||
model.setModifierName(UserThreadLocal.getUsername());
|
model.setModifierName(UserThreadLocal.getUsername());
|
||||||
return ElectromagneticResultUtil.success(userMapper.publish(model) > 0 );
|
return ElectromagneticResultUtil.success(userMapper.publish(model) > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -154,30 +157,30 @@ public class UserServiceImpl implements UserService {
|
||||||
User user = UserMappers.INSTANCE.getUserWorkNumRequestToModel(workNumberRequest);
|
User user = UserMappers.INSTANCE.getUserWorkNumRequestToModel(workNumberRequest);
|
||||||
|
|
||||||
//根据请求对象的userId判断当前处于什么状态
|
//根据请求对象的userId判断当前处于什么状态
|
||||||
if(user.getUserId()==null){
|
if (user.getUserId() == null) {
|
||||||
//userId为空,表示是新增用户阶段
|
//userId为空,表示是新增用户阶段
|
||||||
//判断数据库中有无该工号对应的用户
|
//判断数据库中有无该工号对应的用户
|
||||||
User existingUser = userMapper.selectUserByWorkNumber(user.getWorkNumber());
|
User existingUser = userMapper.selectUserByWorkNumber(user.getWorkNumber());
|
||||||
//如果有该用户就返回false,如果没有(==null)就返回true
|
//如果有该用户就返回false,如果没有(==null)就返回true
|
||||||
boolean isWorkNumberUnique = (existingUser == null);
|
boolean isWorkNumberUnique = (existingUser == null);
|
||||||
return ElectromagneticResultUtil.success(isWorkNumberUnique);
|
return ElectromagneticResultUtil.success(isWorkNumberUnique);
|
||||||
}else{
|
} else {
|
||||||
//userId不为空,表示是编辑用户阶段
|
//userId不为空,表示是编辑用户阶段
|
||||||
//请求对象的userWordNum在数据库中对应的user
|
//请求对象的userWordNum在数据库中对应的user
|
||||||
User existingUser = userMapper.selectUserByWorkNumber(user.getWorkNumber());
|
User existingUser = userMapper.selectUserByWorkNumber(user.getWorkNumber());
|
||||||
//判断,请求对象的userId对应的user和请求对象的userWordNum在数据库中对应的user是否为用一个
|
//判断,请求对象的userId对应的user和请求对象的userWordNum在数据库中对应的user是否为用一个
|
||||||
if(existingUser!=null){
|
if (existingUser != null) {
|
||||||
//请求对象的userWordNum在数据库中对应的user与请求对象的userId对应的user是否为同一个
|
//请求对象的userWordNum在数据库中对应的user与请求对象的userId对应的user是否为同一个
|
||||||
if(user.getUserId().equals(existingUser.getUserId())){
|
if (user.getUserId().equals(existingUser.getUserId())) {
|
||||||
// 如果获取到的用户ID与当前编辑的用户ID相同,说明工号未改变,直接返回true
|
// 如果获取到的用户ID与当前编辑的用户ID相同,说明工号未改变,直接返回true
|
||||||
return ElectromagneticResultUtil.success(true);
|
return ElectromagneticResultUtil.success(true);
|
||||||
}else{
|
} else {
|
||||||
// 如果获取到的用户ID与当前编辑的用户ID不同,说明工号已改变,需要判断新工号是否唯一
|
// 如果获取到的用户ID与当前编辑的用户ID不同,说明工号已改变,需要判断新工号是否唯一
|
||||||
// 如果根据新工号获取不到用户,说明新工号唯一
|
// 如果根据新工号获取不到用户,说明新工号唯一
|
||||||
boolean isWorkNumberUnique = (userMapper.selectUserByWorkNumber(user.getWorkNumber()) == null);
|
boolean isWorkNumberUnique = (userMapper.selectUserByWorkNumber(user.getWorkNumber()) == null);
|
||||||
return ElectromagneticResultUtil.success(isWorkNumberUnique);
|
return ElectromagneticResultUtil.success(isWorkNumberUnique);
|
||||||
}
|
}
|
||||||
}else{
|
} else {
|
||||||
//请求对象的userWordNum在数据库中不存在对应的user
|
//请求对象的userWordNum在数据库中不存在对应的user
|
||||||
return ElectromagneticResultUtil.success(true);
|
return ElectromagneticResultUtil.success(true);
|
||||||
}
|
}
|
||||||
|
|
@ -194,12 +197,12 @@ public class UserServiceImpl implements UserService {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ElectromagneticResult<?> searchUser(SearchUserRequest searchUserRequest) {
|
public ElectromagneticResult<?> searchUser(SearchUserRequest searchUserRequest) {
|
||||||
searchUserRequest.setPageIndex((searchUserRequest.getPageIndex()-1)*searchUserRequest.getPageSize());
|
searchUserRequest.setPageIndex((searchUserRequest.getPageIndex() - 1) * searchUserRequest.getPageSize());
|
||||||
SearchKeyWords model = UserMappers.INSTANCE.getSearchKeywordsRequestToModel(searchUserRequest);
|
SearchKeyWords model = UserMappers.INSTANCE.getSearchKeywordsRequestToModel(searchUserRequest);
|
||||||
List<User> userList = userMapper.search(model);
|
List<User> userList = userMapper.search(model);
|
||||||
int totalCount = userMapper.getTotalCount(model);
|
int totalCount = userMapper.getTotalCount(model);
|
||||||
List<SingleUserResponse> singleUserResponseList = UserMappers.INSTANCE.userListToResponseList(userList);
|
List<SingleUserResponse> singleUserResponseList = UserMappers.INSTANCE.userListToResponseList(userList);
|
||||||
UserSearchResponse userSearchResponse = new UserSearchResponse();
|
UserSearchResponse userSearchResponse = new UserSearchResponse();
|
||||||
userSearchResponse.setUserList(singleUserResponseList);
|
userSearchResponse.setUserList(singleUserResponseList);
|
||||||
userSearchResponse.setTotalCount(totalCount);
|
userSearchResponse.setTotalCount(totalCount);
|
||||||
return ElectromagneticResultUtil.success(userSearchResponse);
|
return ElectromagneticResultUtil.success(userSearchResponse);
|
||||||
|
|
@ -215,15 +218,15 @@ public class UserServiceImpl implements UserService {
|
||||||
// 检查用户是否已经被逻辑删除
|
// 检查用户是否已经被逻辑删除
|
||||||
User existingUser = userMapper.getSingleUser(userDeleteKeyWords.getUserId());
|
User existingUser = userMapper.getSingleUser(userDeleteKeyWords.getUserId());
|
||||||
|
|
||||||
if(existingUser != null && existingUser.getEffectFlag()==0){
|
if (existingUser != null && existingUser.getEffectFlag() == 0) {
|
||||||
// 如果用户已经被逻辑删除(在这个假设中,0 表示已删除),则不进行任何操作或返回错误
|
// 如果用户已经被逻辑删除(在这个假设中,0 表示已删除),则不进行任何操作或返回错误
|
||||||
return ElectromagneticResultUtil.fail(ElectromagneticErrorEnum. FINE_DELETE_USER_ERROR);
|
return ElectromagneticResultUtil.fail(ElectromagneticErrorEnum.FINE_DELETE_USER_ERROR);
|
||||||
}
|
}
|
||||||
if(existingUser!=null && existingUser.getEffectFlag()==1){// 在这个假设中,1 表示未删除
|
if (existingUser != null && existingUser.getEffectFlag() == 1) {// 在这个假设中,1 表示未删除
|
||||||
return ElectromagneticResultUtil.success(userMapper.deleteUser(userDeleteKeyWords));
|
return ElectromagneticResultUtil.success(userMapper.deleteUser(userDeleteKeyWords));
|
||||||
}else{
|
} else {
|
||||||
// 如果用户不存在(理论上不应该发生,除非数据库状态不一致),则返回错误
|
// 如果用户不存在(理论上不应该发生,除非数据库状态不一致),则返回错误
|
||||||
return ElectromagneticResultUtil.fail(ElectromagneticErrorEnum. FINE_DELETE_USER_ERROR);
|
return ElectromagneticResultUtil.fail(ElectromagneticErrorEnum.FINE_DELETE_USER_ERROR);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,15 +9,12 @@ loggerPath=electromagnetic-data
|
||||||
logging.level.com.aliyun.fsi.insurance=${LOG_LEVEL:INFO}
|
logging.level.com.aliyun.fsi.insurance=${LOG_LEVEL:INFO}
|
||||||
#日志配置
|
#日志配置
|
||||||
logging.config=classpath:${LOG_CONFIG:log4j2-spring.xml}
|
logging.config=classpath:${LOG_CONFIG:log4j2-spring.xml}
|
||||||
|
|
||||||
|
|
||||||
spring.datasource.typd=com.alibaba.druid.pool.DruidDataSource
|
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.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.username=comac
|
||||||
spring.datasource.password=2024*Comac
|
spring.datasource.password=2024*Comac
|
||||||
spring.servlet.multipart.max-file-size=500MB
|
spring.servlet.multipart.max-file-size=500MB
|
||||||
spring.servlet.multipart.max-request-size=10MB
|
spring.servlet.multipart.max-request-size=10MB
|
||||||
|
|
||||||
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
|
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
|
||||||
spring.datasource.type=com.alibaba.druid.pool.DruidDataSource
|
spring.datasource.type=com.alibaba.druid.pool.DruidDataSource
|
||||||
mybatis-plus.mapper-locations=classpath:sqlmapper/*.xml
|
mybatis-plus.mapper-locations=classpath:sqlmapper/*.xml
|
||||||
|
|
@ -25,7 +22,6 @@ mybatis-plus.configuration.log-impl=org.apache.ibatis.logging.stdout.StdOutImpl
|
||||||
pagehelper.helperDialect=mysql
|
pagehelper.helperDialect=mysql
|
||||||
pagehelper.reasonable=false
|
pagehelper.reasonable=false
|
||||||
server.port=8888
|
server.port=8888
|
||||||
|
|
||||||
#windows文件存储目录
|
#windows文件存储目录
|
||||||
data.windows.path=E:/comacFileStorage/
|
data.windows.path=E:/comacFileStorage/
|
||||||
#文件缓存路径
|
#文件缓存路径
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,8 @@
|
||||||
<property name="LOG_LEVEL" value="INFO"/>
|
<property name="LOG_LEVEL" value="INFO"/>
|
||||||
<property name="APP_NAME" value="electromagnetic-data"/>
|
<property name="APP_NAME" value="electromagnetic-data"/>
|
||||||
<property name="LOG_HOME" value="./logs/${APP_NAME}"/>
|
<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="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%"/>
|
<property name="SIMPLE_LAYOUT" value="%d{yyyy-MM-dd HH:mm:ss.SSS} %m%n%"/>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,8 @@
|
||||||
<property name="LOG_LEVEL" value="DEBUG"/>
|
<property name="LOG_LEVEL" value="DEBUG"/>
|
||||||
<property name="APP_NAME" value="electromagnetic-data"/>
|
<property name="APP_NAME" value="electromagnetic-data"/>
|
||||||
<property name="LOG_HOME" value="./logs/${APP_NAME}"/>
|
<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="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%"/>
|
<property name="SIMPLE_LAYOUT" value="%d{yyyy-MM-dd HH:mm:ss.SSS} %m%n%"/>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,46 +2,56 @@
|
||||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
<!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">
|
<mapper namespace="com.electromagnetic.industry.software.manage.mapper.CategoryMapper">
|
||||||
<resultMap id="CategoryResultMap" type="com.electromagnetic.industry.software.manage.pojo.models.Category">
|
<resultMap id="CategoryResultMap" type="com.electromagnetic.industry.software.manage.pojo.models.Category">
|
||||||
<id column="id" jdbcType="BIGINT" property="id" />
|
<id column="id" jdbcType="BIGINT" property="id"/>
|
||||||
<result column="category_type_id" jdbcType="VARCHAR" property="categoryTypeId" />
|
<result column="category_type_id" jdbcType="VARCHAR" property="categoryTypeId"/>
|
||||||
<result column="parent_id" jdbcType="VARCHAR" property="parentId" />
|
<result column="parent_id" jdbcType="VARCHAR" property="parentId"/>
|
||||||
<result column="category_id" jdbcType="VARCHAR" property="categoryId" />
|
<result column="category_id" jdbcType="VARCHAR" property="categoryId"/>
|
||||||
<result column="category_name" jdbcType="VARCHAR" property="categoryName" />
|
<result column="category_name" jdbcType="VARCHAR" property="categoryName"/>
|
||||||
<result column="category_status" jdbcType="VARCHAR" property="categoryStatus" />
|
<result column="category_status" jdbcType="VARCHAR" property="categoryStatus"/>
|
||||||
<result column="creator" jdbcType="VARCHAR" property="creator" />
|
<result column="creator" jdbcType="VARCHAR" property="creator"/>
|
||||||
<result column="creator_name" jdbcType="VARCHAR" property="creatorName" />
|
<result column="creator_name" jdbcType="VARCHAR" property="creatorName"/>
|
||||||
<result column="gmt_create" jdbcType="TIMESTAMP" property="gmtCreate" />
|
<result column="gmt_create" jdbcType="TIMESTAMP" property="gmtCreate"/>
|
||||||
<result column="modifier" jdbcType="VARCHAR" property="modifier" />
|
<result column="modifier" jdbcType="VARCHAR" property="modifier"/>
|
||||||
<result column="modifier_name" jdbcType="VARCHAR" property="modifierName" />
|
<result column="modifier_name" jdbcType="VARCHAR" property="modifierName"/>
|
||||||
<result column="gmt_modified" jdbcType="TIMESTAMP" property="gmtModified" />
|
<result column="gmt_modified" jdbcType="TIMESTAMP" property="gmtModified"/>
|
||||||
<result column="effect_flag" jdbcType="TINYINT" property="effectFlag" />
|
<result column="effect_flag" jdbcType="TINYINT" property="effectFlag"/>
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<sql id="selectUserVo">
|
<sql id="selectUserVo">
|
||||||
select category_type_id, parent_id, category_id, category_name, category_status,
|
select category_type_id,
|
||||||
creator, creator_name, gmt_create, modifier, modifier_name, gmt_modified, effect_flag
|
parent_id,
|
||||||
|
category_id,
|
||||||
|
category_name,
|
||||||
|
category_status,
|
||||||
|
creator,
|
||||||
|
creator_name,
|
||||||
|
gmt_create,
|
||||||
|
modifier,
|
||||||
|
modifier_name,
|
||||||
|
gmt_modified,
|
||||||
|
effect_flag
|
||||||
from ed_category
|
from ed_category
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
<select id="selectTopCategories" resultMap="CategoryResultMap">
|
<select id="selectTopCategories" resultMap="CategoryResultMap">
|
||||||
<include refid="selectUserVo" />
|
<include refid="selectUserVo"/>
|
||||||
where parent_id = 0 and category_status="available"
|
where parent_id = 0 and category_status="available"
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectAllCategories" resultMap="CategoryResultMap">
|
<select id="selectAllCategories" resultMap="CategoryResultMap">
|
||||||
<include refid="selectUserVo" />
|
<include refid="selectUserVo"/>
|
||||||
where category_status="available"
|
where category_status="available"
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectCategories" resultMap="CategoryResultMap"
|
<select id="selectCategories" resultMap="CategoryResultMap"
|
||||||
parameterType="com.electromagnetic.industry.software.manage.pojo.models.Category">
|
parameterType="com.electromagnetic.industry.software.manage.pojo.models.Category">
|
||||||
<include refid="selectUserVo" />
|
<include refid="selectUserVo"/>
|
||||||
where category_id = #{categoryId,jdbcType=VARCHAR} and category_status="available"
|
where category_id = #{categoryId,jdbcType=VARCHAR} and category_status="available"
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectChildCategories" resultMap="CategoryResultMap"
|
<select id="selectChildCategories" resultMap="CategoryResultMap"
|
||||||
parameterType="com.electromagnetic.industry.software.manage.pojo.models.Category">
|
parameterType="com.electromagnetic.industry.software.manage.pojo.models.Category">
|
||||||
<include refid="selectUserVo" />
|
<include refid="selectUserVo"/>
|
||||||
where parent_id = #{parentId,jdbcType=VARCHAR} and category_status="available"
|
where parent_id = #{parentId,jdbcType=VARCHAR} and category_status="available"
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,130 +3,132 @@
|
||||||
|
|
||||||
<mapper namespace="com.electromagnetic.industry.software.manage.mapper.EDDataMapper">
|
<mapper namespace="com.electromagnetic.industry.software.manage.mapper.EDDataMapper">
|
||||||
|
|
||||||
<resultMap id="BaseResultMap" type="com.electromagnetic.industry.software.manage.pojo.models.EDDataInfo">
|
<resultMap id="BaseResultMap" type="com.electromagnetic.industry.software.manage.pojo.models.EDDataInfo">
|
||||||
<id column="id" jdbcType="BIGINT" property="id" />
|
<id column="id" jdbcType="BIGINT" property="id"/>
|
||||||
<result column="category_id" jdbcType="VARCHAR" property="categoryId" />
|
<result column="category_id" jdbcType="VARCHAR" property="categoryId"/>
|
||||||
<result column="data_id" jdbcType="VARCHAR" property="dataId" />
|
<result column="data_id" jdbcType="VARCHAR" property="dataId"/>
|
||||||
<result column="data_no" jdbcType="VARCHAR" property="dataNo" />
|
<result column="data_no" jdbcType="VARCHAR" property="dataNo"/>
|
||||||
<result column="data_name" jdbcType="VARCHAR" property="dataName" />
|
<result column="data_name" jdbcType="VARCHAR" property="dataName"/>
|
||||||
<result column="data_type" jdbcType="VARCHAR" property="dataType" />
|
<result column="data_type" jdbcType="VARCHAR" property="dataType"/>
|
||||||
<result column="file_type" jdbcType="VARCHAR" property="fileType" />
|
<result column="file_type" jdbcType="VARCHAR" property="fileType"/>
|
||||||
<result column="version" jdbcType="VARCHAR" property="version" />
|
<result column="version" jdbcType="VARCHAR" property="version"/>
|
||||||
<result column="content" jdbcType="VARCHAR" property="content" />
|
<result column="content" jdbcType="VARCHAR" property="content"/>
|
||||||
<result column="implant_json" jdbcType="VARCHAR" property="implantJson" />
|
<result column="implant_json" jdbcType="VARCHAR" property="implantJson"/>
|
||||||
<result column="data_status" jdbcType="VARCHAR" property="dataStatus" />
|
<result column="data_status" jdbcType="VARCHAR" property="dataStatus"/>
|
||||||
<result column="note" jdbcType="VARCHAR" property="note" />
|
<result column="note" jdbcType="VARCHAR" property="note"/>
|
||||||
<result column="editor" jdbcType="VARCHAR" property="editor" />
|
<result column="editor" jdbcType="VARCHAR" property="editor"/>
|
||||||
<result column="gmt_batch_upload" jdbcType="TIMESTAMP" property="gmtBatchUpload" />
|
<result column="gmt_batch_upload" jdbcType="TIMESTAMP" property="gmtBatchUpload"/>
|
||||||
<result column="save_status" jdbcType="VARCHAR" property="saveStatus" />
|
<result column="save_status" jdbcType="VARCHAR" property="saveStatus"/>
|
||||||
<result column="creator" jdbcType="VARCHAR" property="creator" />
|
<result column="creator" jdbcType="VARCHAR" property="creator"/>
|
||||||
<result column="creator_name" jdbcType="VARCHAR" property="creatorName" />
|
<result column="creator_name" jdbcType="VARCHAR" property="creatorName"/>
|
||||||
<result column="gmt_create" jdbcType="TIMESTAMP" property="gmtCreate" />
|
<result column="gmt_create" jdbcType="TIMESTAMP" property="gmtCreate"/>
|
||||||
<result column="modifier" jdbcType="VARCHAR" property="modifier" />
|
<result column="modifier" jdbcType="VARCHAR" property="modifier"/>
|
||||||
<result column="modifier_name" jdbcType="VARCHAR" property="modifierName" />
|
<result column="modifier_name" jdbcType="VARCHAR" property="modifierName"/>
|
||||||
<result column="gmt_modified" jdbcType="TIMESTAMP" property="gmtModified" />
|
<result column="gmt_modified" jdbcType="TIMESTAMP" property="gmtModified"/>
|
||||||
<result column="effect_flag" jdbcType="TINYINT" property="effectFlag" />
|
<result column="effect_flag" jdbcType="TINYINT" property="effectFlag"/>
|
||||||
</resultMap>
|
</resultMap>
|
||||||
<sql id="Base_Column_list">
|
<sql id="Base_Column_list">
|
||||||
id,category_id,data_id,data_no,data_name,data_type,file_type,version,content,
|
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,
|
implant_json,data_status,note,editor,gmt_batch_upload,save_status,creator,creator_name,gmt_create,modifier,modifier_name,
|
||||||
gmt_modified,effect_flag
|
gmt_modified,effect_flag
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
|
|
||||||
<insert id="createDataInfo" parameterType="com.electromagnetic.industry.software.manage.pojo.models.EDDataInfo">
|
<insert id="createDataInfo" parameterType="com.electromagnetic.industry.software.manage.pojo.models.EDDataInfo">
|
||||||
<selectKey keyProperty="id" order="AFTER" resultType="java.lang.Long">
|
<selectKey keyProperty="id" order="AFTER" resultType="java.lang.Long">
|
||||||
SELECT LAST_INSERT_ID()
|
SELECT LAST_INSERT_ID()
|
||||||
</selectKey>
|
</selectKey>
|
||||||
replace into ed_data_info (category_id,
|
replace into ed_data_info (category_id,
|
||||||
data_id, data_no, data_name,
|
data_id, data_no, data_name,
|
||||||
data_type, file_type, version,
|
data_type, file_type, version,
|
||||||
content, implant_json, data_status,
|
content, implant_json, data_status,
|
||||||
note, editor, gmt_batch_upload, save_status,
|
note, editor, gmt_batch_upload, save_status,
|
||||||
creator, creator_name, gmt_create,
|
creator, creator_name, gmt_create,
|
||||||
modifier, modifier_name, gmt_modified,
|
modifier, modifier_name, gmt_modified,
|
||||||
effect_flag
|
effect_flag
|
||||||
)
|
)
|
||||||
values (#{categoryId,jdbcType=VARCHAR},
|
values (#{categoryId,jdbcType=VARCHAR},
|
||||||
#{dataId,jdbcType=VARCHAR}, #{dataNo,jdbcType=VARCHAR}, #{dataName,jdbcType=VARCHAR},
|
#{dataId,jdbcType=VARCHAR}, #{dataNo,jdbcType=VARCHAR}, #{dataName,jdbcType=VARCHAR},
|
||||||
#{dataType,jdbcType=VARCHAR}, #{fileType,jdbcType=VARCHAR},#{version,jdbcType=VARCHAR},
|
#{dataType,jdbcType=VARCHAR}, #{fileType,jdbcType=VARCHAR},#{version,jdbcType=VARCHAR},
|
||||||
#{content,jdbcType=VARCHAR}, #{implantJson,jdbcType=VARCHAR}, #{dataStatus,jdbcType=VARCHAR},
|
#{content,jdbcType=VARCHAR}, #{implantJson,jdbcType=VARCHAR}, #{dataStatus,jdbcType=VARCHAR},
|
||||||
#{note,jdbcType=VARCHAR}, #{editor,jdbcType=VARCHAR}, #{gmtBatchUpload,jdbcType=TIMESTAMP}, #{saveStatus,jdbcType=VARCHAR},
|
#{note,jdbcType=VARCHAR}, #{editor,jdbcType=VARCHAR}, #{gmtBatchUpload,jdbcType=TIMESTAMP},
|
||||||
#{creator,jdbcType=VARCHAR}, #{creatorName,jdbcType=VARCHAR}, now(), #{modifier,jdbcType=VARCHAR},
|
#{saveStatus,jdbcType=VARCHAR},
|
||||||
#{modifierName,jdbcType=VARCHAR},now(),1
|
#{creator,jdbcType=VARCHAR}, #{creatorName,jdbcType=VARCHAR}, now(), #{modifier,jdbcType=VARCHAR},
|
||||||
)
|
#{modifierName,jdbcType=VARCHAR},now(),1
|
||||||
</insert>
|
)
|
||||||
|
</insert>
|
||||||
|
|
||||||
<select id="getDataInfoList" resultMap="BaseResultMap"
|
<select id="getDataInfoList" resultMap="BaseResultMap"
|
||||||
parameterType="com.electromagnetic.industry.software.manage.pojo.other.EDDataParams">
|
parameterType="com.electromagnetic.industry.software.manage.pojo.other.EDDataParams">
|
||||||
SELECT
|
SELECT
|
||||||
<include refid="Base_Column_list"/>
|
<include refid="Base_Column_list"/>
|
||||||
FROM
|
FROM
|
||||||
ed_data_info
|
ed_data_info
|
||||||
where
|
where
|
||||||
effect_flag = 1
|
effect_flag = 1
|
||||||
<if test="parentId!=null and parentId!=''">
|
<if test="parentId!=null and parentId!=''">
|
||||||
and category_id='${parentId}'
|
and category_id='${parentId}'
|
||||||
</if>
|
</if>
|
||||||
<if test="dataId!=null and dataId!=''">
|
<if test="dataId!=null and dataId!=''">
|
||||||
and data_id='${dataId}'
|
and data_id='${dataId}'
|
||||||
</if>
|
</if>
|
||||||
<if test="keyWord!=null and keyWord!=''">
|
<if test="keyWord!=null and keyWord!=''">
|
||||||
and data_name LIKE '%${keyWord}%'
|
and data_name LIKE '%${keyWord}%'
|
||||||
</if>
|
</if>
|
||||||
<if test="dataType != null and dataType!=''">
|
<if test="dataType != null and dataType!=''">
|
||||||
and data_type = '${dataType}'
|
and data_type = '${dataType}'
|
||||||
</if>
|
</if>
|
||||||
<if test="saveStatus!=null and saveStatus!=''">
|
<if test="saveStatus!=null and saveStatus!=''">
|
||||||
and save_status='${saveStatus}'
|
and save_status='${saveStatus}'
|
||||||
</if>
|
</if>
|
||||||
GROUP BY id
|
GROUP BY id
|
||||||
<if test="gmtCreate == 'asc' or gmtCreate =='desc'">
|
<if test="gmtCreate == 'asc' or gmtCreate =='desc'">
|
||||||
order by gmt_create ${gmtCreate}
|
order by gmt_create ${gmtCreate}
|
||||||
</if>
|
</if>
|
||||||
<if test = "gmtCreate == null or gmtCreate == ''">
|
<if test="gmtCreate == null or gmtCreate == ''">
|
||||||
order by gmt_create desc
|
order by gmt_create desc
|
||||||
</if>
|
</if>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<update id="updateFileInfo" parameterType="com.electromagnetic.industry.software.manage.pojo.other.EDDataParams">
|
<update id="updateFileInfo" parameterType="com.electromagnetic.industry.software.manage.pojo.other.EDDataParams">
|
||||||
update ed_data_info
|
update ed_data_info
|
||||||
<set>
|
<set>
|
||||||
<if test="name != null and name!=''">
|
<if test="name != null and name!=''">
|
||||||
data_name = #{name,jdbcType=VARCHAR},
|
data_name = #{name,jdbcType=VARCHAR},
|
||||||
</if>
|
</if>
|
||||||
<if test="dataStatus != null and dataStatus!=''">
|
<if test="dataStatus != null and dataStatus!=''">
|
||||||
data_status = #{dataStatus,jdbcType=VARCHAR},
|
data_status = #{dataStatus,jdbcType=VARCHAR},
|
||||||
</if>
|
</if>
|
||||||
<if test="note != null and note!=''">
|
<if test="note != null and note!=''">
|
||||||
note = #{note,jdbcType=VARCHAR},
|
note = #{note,jdbcType=VARCHAR},
|
||||||
</if>
|
</if>
|
||||||
<if test="saveStatus != null and note!=''">
|
<if test="saveStatus != null and note!=''">
|
||||||
save_status = #{saveStatus,jdbcType=VARCHAR},
|
save_status = #{saveStatus,jdbcType=VARCHAR},
|
||||||
</if>
|
</if>
|
||||||
<if test="effectFlag != null and effectFlag!=''">
|
<if test="effectFlag != null and effectFlag!=''">
|
||||||
effect_flag = #{effectFlag,jdbcType=VARCHAR},
|
effect_flag = #{effectFlag,jdbcType=VARCHAR},
|
||||||
</if>
|
</if>
|
||||||
<if test="userId != null and userId!=''">
|
<if test="userId != null and userId!=''">
|
||||||
modifier = #{userId,jdbcType=VARCHAR},
|
modifier = #{userId,jdbcType=VARCHAR},
|
||||||
</if>
|
</if>
|
||||||
<if test="userName != null and userName!=''">
|
<if test="userName != null and userName!=''">
|
||||||
modifier_name = #{userName,jdbcType=VARCHAR},
|
modifier_name = #{userName,jdbcType=VARCHAR},
|
||||||
</if>
|
</if>
|
||||||
gmt_modified = now()
|
gmt_modified = now()
|
||||||
</set>
|
</set>
|
||||||
<where>
|
<where>
|
||||||
<!-- 条件 1:按数据编码修改 -->
|
<!-- 条件 1:按数据编码修改 -->
|
||||||
<if test="dataId != null and dataId != ''">
|
<if test="dataId != null and dataId != ''">
|
||||||
data_id = #{dataId,jdbcType=VARCHAR}
|
data_id = #{dataId,jdbcType=VARCHAR}
|
||||||
</if>
|
</if>
|
||||||
<!-- 条件 2:按目录编码修改 -->
|
<!-- 条件 2:按目录编码修改 -->
|
||||||
<if test="parentId != null and parentId != ''">
|
<if test="parentId != null and parentId != ''">
|
||||||
category_id = #{parentId,jdbcType=VARCHAR}
|
category_id = #{parentId,jdbcType=VARCHAR}
|
||||||
</if>
|
</if>
|
||||||
</where>
|
</where>
|
||||||
|
|
||||||
</update>
|
</update>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,16 +2,17 @@
|
||||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
<!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">
|
<mapper namespace="com.electromagnetic.industry.software.manage.mapper.TokenMapper">
|
||||||
<resultMap id="TokenResultMap" type="com.electromagnetic.industry.software.manage.pojo.models.Token">
|
<resultMap id="TokenResultMap" type="com.electromagnetic.industry.software.manage.pojo.models.Token">
|
||||||
<id column="id" jdbcType="BIGINT" property="id" />
|
<id column="id" jdbcType="BIGINT" property="id"/>
|
||||||
<result column="user_id" jdbcType="VARCHAR" property="userId" />
|
<result column="user_id" jdbcType="VARCHAR" property="userId"/>
|
||||||
<result column="token" jdbcType="VARCHAR" property="token" />
|
<result column="token" jdbcType="VARCHAR" property="token"/>
|
||||||
<result column="is_long_term" jdbcType="TINYINT" property="isLongTerm" />
|
<result column="is_long_term" jdbcType="TINYINT" property="isLongTerm"/>
|
||||||
<result column="created_at" jdbcType="TIMESTAMP" property="createdAt" />
|
<result column="created_at" jdbcType="TIMESTAMP" property="createdAt"/>
|
||||||
<result column="expire_at" jdbcType="TIMESTAMP" property="expireAt" />
|
<result column="expire_at" jdbcType="TIMESTAMP" property="expireAt"/>
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<sql id="selectTokenVo">
|
<sql id="selectTokenVo">
|
||||||
select id, user_id, token, is_long_term, created_at, expire_at from tokens
|
select id, user_id, token, is_long_term, created_at, expire_at
|
||||||
|
from tokens
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
<insert id="insert" parameterType="com.electromagnetic.industry.software.manage.pojo.models.Token">
|
<insert id="insert" parameterType="com.electromagnetic.industry.software.manage.pojo.models.Token">
|
||||||
|
|
@ -32,12 +33,14 @@
|
||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
<select id="selectToken" parameterType="String" resultMap="TokenResultMap">
|
<select id="selectToken" parameterType="String" resultMap="TokenResultMap">
|
||||||
<include refid="selectTokenVo" />
|
<include refid="selectTokenVo"/>
|
||||||
where token=#{token}
|
where token=#{token}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<delete id="deleteToken" parameterType="String">
|
<delete id="deleteToken" parameterType="String">
|
||||||
delete from tokens where token=#{token}
|
delete
|
||||||
|
from tokens
|
||||||
|
where token = #{token}
|
||||||
</delete>
|
</delete>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
@ -1,38 +1,54 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?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">
|
<!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">
|
<mapper namespace="com.electromagnetic.industry.software.manage.mapper.UserMapper">
|
||||||
<resultMap id="UserResultMap" type="com.electromagnetic.industry.software.manage.pojo.models.User">
|
<resultMap id="UserResultMap" type="com.electromagnetic.industry.software.manage.pojo.models.User">
|
||||||
<id column="id" jdbcType="BIGINT" property="id" />
|
<id column="id" jdbcType="BIGINT" property="id"/>
|
||||||
<result column="user_id" jdbcType="VARCHAR" property="userId" />
|
<result column="user_id" jdbcType="VARCHAR" property="userId"/>
|
||||||
<result column="user_name" jdbcType="VARCHAR" property="userName" />
|
<result column="user_name" jdbcType="VARCHAR" property="userName"/>
|
||||||
<result column="work_number" jdbcType="VARCHAR" property="workNumber" />
|
<result column="work_number" jdbcType="VARCHAR" property="workNumber"/>
|
||||||
<result column="mobile" jdbcType="VARCHAR" property="mobile" />
|
<result column="mobile" jdbcType="VARCHAR" property="mobile"/>
|
||||||
<result column="user_dept" jdbcType="VARCHAR" property="userDept" />
|
<result column="user_dept" jdbcType="VARCHAR" property="userDept"/>
|
||||||
<result column="user_title" jdbcType="VARCHAR" property="userTitle" />
|
<result column="user_title" jdbcType="VARCHAR" property="userTitle"/>
|
||||||
<result column="user_pwd" jdbcType="VARCHAR" property="userPwd" />
|
<result column="user_pwd" jdbcType="VARCHAR" property="userPwd"/>
|
||||||
<result column="join_time" jdbcType="TIMESTAMP" property="joinTime" />
|
<result column="join_time" jdbcType="TIMESTAMP" property="joinTime"/>
|
||||||
<result column="is_published" jdbcType="TINYINT" property="isPublished" />
|
<result column="is_published" jdbcType="TINYINT" property="isPublished"/>
|
||||||
<result column="salt" jdbcType="VARCHAR" property="salt" />
|
<result column="salt" jdbcType="VARCHAR" property="salt"/>
|
||||||
<result column="user_status" jdbcType="VARCHAR" property="userStatus" />
|
<result column="user_status" jdbcType="VARCHAR" property="userStatus"/>
|
||||||
<result column="internship_end_date" jdbcType="DATE" property="internshipEndDate"/>
|
<result column="internship_end_date" jdbcType="DATE" property="internshipEndDate"/>
|
||||||
<result column="creator" jdbcType="VARCHAR" property="creator" />
|
<result column="creator" jdbcType="VARCHAR" property="creator"/>
|
||||||
<result column="creator_name" jdbcType="VARCHAR" property="creatorName" />
|
<result column="creator_name" jdbcType="VARCHAR" property="creatorName"/>
|
||||||
<result column="gmt_create" jdbcType="TIMESTAMP" property="gmtCreate" />
|
<result column="gmt_create" jdbcType="TIMESTAMP" property="gmtCreate"/>
|
||||||
<result column="modifier" jdbcType="VARCHAR" property="modifier" />
|
<result column="modifier" jdbcType="VARCHAR" property="modifier"/>
|
||||||
<result column="modifier_name" jdbcType="VARCHAR" property="modifierName" />
|
<result column="modifier_name" jdbcType="VARCHAR" property="modifierName"/>
|
||||||
<result column="gmt_modified" jdbcType="TIMESTAMP" property="gmtModified" />
|
<result column="gmt_modified" jdbcType="TIMESTAMP" property="gmtModified"/>
|
||||||
<result column="effect_flag" jdbcType="TINYINT" property="effectFlag" />
|
<result column="effect_flag" jdbcType="TINYINT" property="effectFlag"/>
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<sql id="selectUserVo">
|
<sql id="selectUserVo">
|
||||||
select user_id, user_name, work_number, mobile, user_dept, user_title, user_pwd,
|
select user_id,
|
||||||
join_time, is_published, salt, user_status, internship_end_date,
|
user_name,
|
||||||
creator, creator_name, gmt_create, modifier, modifier_name, gmt_modified, effect_flag
|
work_number,
|
||||||
from ed_users
|
mobile,
|
||||||
</sql>
|
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 id="insert" parameterType="com.electromagnetic.industry.software.manage.pojo.models.User">
|
||||||
insert into ed_users(
|
insert into ed_users(
|
||||||
<if test="userId != null and userId !='' ">user_id,</if>
|
<if test="userId != null and userId !='' ">user_id,</if>
|
||||||
<if test="userName != null and userName !='' ">user_name,</if>
|
<if test="userName != null and userName !='' ">user_name,</if>
|
||||||
<if test="workNumber != null and workNumber !='' ">work_number,</if>
|
<if test="workNumber != null and workNumber !='' ">work_number,</if>
|
||||||
|
|
@ -49,7 +65,7 @@
|
||||||
<if test="creatorName != null and creatorName !='' ">creator_name,</if>
|
<if test="creatorName != null and creatorName !='' ">creator_name,</if>
|
||||||
gmt_create,
|
gmt_create,
|
||||||
effect_flag)
|
effect_flag)
|
||||||
values (
|
values (
|
||||||
<if test="userId != null and userId !='' ">#{userId},</if>
|
<if test="userId != null and userId !='' ">#{userId},</if>
|
||||||
<if test="userName != null and userName !='' ">#{userName},</if>
|
<if test="userName != null and userName !='' ">#{userName},</if>
|
||||||
<if test="workNumber != null and workNumber !='' ">#{workNumber},</if>
|
<if test="workNumber != null and workNumber !='' ">#{workNumber},</if>
|
||||||
|
|
@ -66,26 +82,26 @@
|
||||||
<if test="creatorName != null and creatorName !='' ">#{creatorName},</if>
|
<if test="creatorName != null and creatorName !='' ">#{creatorName},</if>
|
||||||
now(),
|
now(),
|
||||||
1
|
1
|
||||||
)
|
)
|
||||||
</insert>
|
</insert>
|
||||||
<update id="modify" parameterType="com.electromagnetic.industry.software.manage.pojo.models.User">
|
<update id="modify" parameterType="com.electromagnetic.industry.software.manage.pojo.models.User">
|
||||||
update ed_users
|
update ed_users
|
||||||
<set>
|
<set>
|
||||||
<if test="userId != null and userId != ''">user_id = #{userId},</if>
|
<if test="userId != null and userId != ''">user_id = #{userId},</if>
|
||||||
<if test="userName != null and userName != ''">user_name = #{userName},</if>
|
<if test="userName != null and userName != ''">user_name = #{userName},</if>
|
||||||
<if test="workNumber != null and workNumber != ''">work_number = #{workNumber},</if>
|
<if test="workNumber != null and workNumber != ''">work_number = #{workNumber},</if>
|
||||||
<if test="mobile != null and mobile != ''">mobile = #{mobile},</if>
|
<if test="mobile != null and mobile != ''">mobile = #{mobile},</if>
|
||||||
<if test="userDept != null and userDept != ''">user_dept = #{userDept},</if>
|
<if test="userDept != null and userDept != ''">user_dept = #{userDept},</if>
|
||||||
<if test="userTitle != null and userTitle != ''">user_title = #{userTitle},</if>
|
<if test="userTitle != null and userTitle != ''">user_title = #{userTitle},</if>
|
||||||
<if test="joinTime != null">join_time = #{joinTime},</if>
|
<if test="joinTime != null">join_time = #{joinTime},</if>
|
||||||
<if test="userStatus != null and userStatus != ''">user_status = #{userStatus},</if>
|
<if test="userStatus != null and userStatus != ''">user_status = #{userStatus},</if>
|
||||||
internship_end_date = #{internshipEndDate},
|
internship_end_date = #{internshipEndDate},
|
||||||
<if test="modifier != null and modifier != ''">modifier = #{modifier},</if>
|
<if test="modifier != null and modifier != ''">modifier = #{modifier},</if>
|
||||||
<if test="modifierName != null and modifierName != ''">modifier_name = #{modifierName},</if>
|
<if test="modifierName != null and modifierName != ''">modifier_name = #{modifierName},</if>
|
||||||
gmt_modified=now()
|
gmt_modified=now()
|
||||||
</set>
|
</set>
|
||||||
where user_id= #{userId}
|
where user_id= #{userId}
|
||||||
</update>
|
</update>
|
||||||
|
|
||||||
|
|
||||||
<update id="publish" parameterType="com.electromagnetic.industry.software.manage.pojo.other.PublishParam">
|
<update id="publish" parameterType="com.electromagnetic.industry.software.manage.pojo.other.PublishParam">
|
||||||
|
|
@ -102,7 +118,8 @@
|
||||||
</foreach>
|
</foreach>
|
||||||
</update>
|
</update>
|
||||||
|
|
||||||
<select id="search" parameterType="com.electromagnetic.industry.software.manage.pojo.other.SearchKeyWords" resultMap="UserResultMap">
|
<select id="search" parameterType="com.electromagnetic.industry.software.manage.pojo.other.SearchKeyWords"
|
||||||
|
resultMap="UserResultMap">
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM ed_users
|
FROM ed_users
|
||||||
<where>
|
<where>
|
||||||
|
|
@ -146,7 +163,8 @@
|
||||||
LIMIT #{pageSize} OFFSET #{pageIndex}
|
LIMIT #{pageSize} OFFSET #{pageIndex}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="getTotalCount" parameterType="com.electromagnetic.industry.software.manage.pojo.other.SearchKeyWords" resultType="Integer">
|
<select id="getTotalCount" parameterType="com.electromagnetic.industry.software.manage.pojo.other.SearchKeyWords"
|
||||||
|
resultType="Integer">
|
||||||
SELECT COUNT(*)
|
SELECT COUNT(*)
|
||||||
FROM ed_users
|
FROM ed_users
|
||||||
<where>
|
<where>
|
||||||
|
|
@ -190,12 +208,12 @@
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectUserByWorkNumber" parameterType="String" resultMap="UserResultMap">
|
<select id="selectUserByWorkNumber" parameterType="String" resultMap="UserResultMap">
|
||||||
<include refid="selectUserVo" />
|
<include refid="selectUserVo"/>
|
||||||
where work_number = #{workNumber}
|
where work_number = #{workNumber}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="getSingleUser" parameterType="String" resultMap="UserResultMap">
|
<select id="getSingleUser" parameterType="String" resultMap="UserResultMap">
|
||||||
<include refid="selectUserVo" />
|
<include refid="selectUserVo"/>
|
||||||
where user_id = #{userId}
|
where user_id = #{userId}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
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>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<parent>
|
<parent>
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ public interface UserConstants {
|
||||||
/**
|
/**
|
||||||
* 默认令牌过期时间(7天)
|
* 默认令牌过期时间(7天)
|
||||||
*/
|
*/
|
||||||
long DEFAULT_EXPIRE_TIME = 7*24*60*60*1000;
|
long DEFAULT_EXPIRE_TIME = 7 * 24 * 60 * 60 * 1000;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 令牌密钥
|
* 令牌密钥
|
||||||
|
|
|
||||||
|
|
@ -15,11 +15,11 @@ public enum EffectFlagEnum {
|
||||||
/**
|
/**
|
||||||
* 有效
|
* 有效
|
||||||
*/
|
*/
|
||||||
EFFECT_FLAG_1(1,"有效"),
|
EFFECT_FLAG_1(1, "有效"),
|
||||||
/**
|
/**
|
||||||
* 无效
|
* 无效
|
||||||
*/
|
*/
|
||||||
EFFECT_FLAG_0(0,"无效"),
|
EFFECT_FLAG_0(0, "无效"),
|
||||||
;
|
;
|
||||||
private Integer code;
|
private Integer code;
|
||||||
private String desc;
|
private String desc;
|
||||||
|
|
|
||||||
|
|
@ -6,15 +6,23 @@ package com.electromagnetic.industry.software.common.enums;
|
||||||
*/
|
*/
|
||||||
public interface ErrorLevels {
|
public interface ErrorLevels {
|
||||||
|
|
||||||
/** INFO级别 */
|
/**
|
||||||
public static final String INFO = "1";
|
* INFO级别
|
||||||
|
*/
|
||||||
|
public static final String INFO = "1";
|
||||||
|
|
||||||
/** WARN级别 */
|
/**
|
||||||
public static final String WARN = "3";
|
* WARN级别
|
||||||
|
*/
|
||||||
|
public static final String WARN = "3";
|
||||||
|
|
||||||
/** ERROR级别 */
|
/**
|
||||||
|
* ERROR级别
|
||||||
|
*/
|
||||||
public static final String ERROR = "5";
|
public static final String ERROR = "5";
|
||||||
|
|
||||||
/** FATAL级别 */
|
/**
|
||||||
|
* FATAL级别
|
||||||
|
*/
|
||||||
public static final String FATAL = "7";
|
public static final String FATAL = "7";
|
||||||
}
|
}
|
||||||
|
|
@ -2,17 +2,25 @@ package com.electromagnetic.industry.software.common.enums;
|
||||||
|
|
||||||
public interface ErrorTypes {
|
public interface ErrorTypes {
|
||||||
|
|
||||||
/** 系统错误 */
|
/**
|
||||||
public static final String SYSTEM = "0";
|
* 系统错误
|
||||||
|
*/
|
||||||
|
public static final String SYSTEM = "0";
|
||||||
|
|
||||||
/** 业务错误 */
|
/**
|
||||||
|
* 业务错误
|
||||||
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public static final String BIZ = "1";
|
public static final String BIZ = "1";
|
||||||
|
|
||||||
/** 第三方错误 */
|
/**
|
||||||
|
* 第三方错误
|
||||||
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public static final String THIRD_PARTY = "2";
|
public static final String THIRD_PARTY = "2";
|
||||||
|
|
||||||
/** 业务错误,客户感知 */
|
/**
|
||||||
|
* 业务错误,客户感知
|
||||||
|
*/
|
||||||
public static final String BIZ_CUSTOMER = "9";
|
public static final String BIZ_CUSTOMER = "9";
|
||||||
}
|
}
|
||||||
|
|
@ -9,11 +9,11 @@ public enum PublishEnum {
|
||||||
/**
|
/**
|
||||||
* 已发布
|
* 已发布
|
||||||
*/
|
*/
|
||||||
PUBLISHED(1,"已发布"),
|
PUBLISHED(1, "已发布"),
|
||||||
/**
|
/**
|
||||||
* 未发布
|
* 未发布
|
||||||
*/
|
*/
|
||||||
UNPUBLISHED(0,"未发布"),
|
UNPUBLISHED(0, "未发布"),
|
||||||
;
|
;
|
||||||
private Integer code;
|
private Integer code;
|
||||||
private String desc;
|
private String desc;
|
||||||
|
|
|
||||||
|
|
@ -4,35 +4,53 @@ import java.io.Serializable;
|
||||||
|
|
||||||
public class ResultCode implements Serializable {
|
public class ResultCode implements Serializable {
|
||||||
|
|
||||||
/** 序列ID */
|
/**
|
||||||
private static final long serialVersionUID = 3951948353107763580L;
|
* 结果码固定前缀
|
||||||
|
*/
|
||||||
|
protected static final String PREFIX = "CE";
|
||||||
|
/**
|
||||||
|
* 序列ID
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 3951948353107763580L;
|
||||||
|
/**
|
||||||
|
* 结果码版本
|
||||||
|
*/
|
||||||
|
private String version;
|
||||||
|
|
||||||
/** 结果码固定前缀 */
|
/**
|
||||||
protected static final String PREFIX = "CE";
|
* 结果码级别[第9位],INFO-1,WARN-3,ERROR-5,FATAL-7,参见<code>ResultCodeLevel</code>定义
|
||||||
|
*/
|
||||||
|
private String codeLevel;
|
||||||
|
|
||||||
/** 结果码版本 */
|
/**
|
||||||
private String version;
|
* 结果码类型[第10位],SUCCESS-0,BIZ_ERROR-1,SYS_ERROR-2,THIRD_ERROR-3,参见<code>ResultCodeType</code>定义
|
||||||
|
*/
|
||||||
|
private String codeType;
|
||||||
|
|
||||||
/** 结果码级别[第9位],INFO-1,WARN-3,ERROR-5,FATAL-7,参见<code>ResultCodeLevel</code>定义 */
|
/**
|
||||||
private String codeLevel;
|
* 系统编号[第11-13位],见<code>SystemCode</code>定义
|
||||||
|
*/
|
||||||
|
private String systemCode;
|
||||||
|
|
||||||
/** 结果码类型[第10位],SUCCESS-0,BIZ_ERROR-1,SYS_ERROR-2,THIRD_ERROR-3,参见<code>ResultCodeType</code>定义 */
|
/**
|
||||||
private String codeType;
|
* 系统名称
|
||||||
|
*/
|
||||||
|
private String systemName;
|
||||||
|
|
||||||
/** 系统编号[第11-13位],见<code>SystemCode</code>定义 */
|
/**
|
||||||
private String systemCode;
|
* 具体结果码[第14-17位]
|
||||||
|
*/
|
||||||
|
private String errorSpecific;
|
||||||
|
|
||||||
/** 系统名称 */
|
/**
|
||||||
private String systemName;
|
* 错误英文简称
|
||||||
|
*/
|
||||||
|
private String errorName;
|
||||||
|
|
||||||
/** 具体结果码[第14-17位] */
|
/**
|
||||||
private String errorSpecific;
|
* 结果码信息描述,可空
|
||||||
|
*/
|
||||||
/** 错误英文简称 */
|
private String description;
|
||||||
private String errorName;
|
|
||||||
|
|
||||||
/** 结果码信息描述,可空 */
|
|
||||||
private String description;
|
|
||||||
|
|
||||||
// ~~~ 构造方法
|
// ~~~ 构造方法
|
||||||
|
|
||||||
|
|
@ -46,7 +64,7 @@ public class ResultCode implements Serializable {
|
||||||
/**
|
/**
|
||||||
* 构造方法。
|
* 构造方法。
|
||||||
*
|
*
|
||||||
* @param resultCode 结果码字符串
|
* @param resultCode 结果码字符串
|
||||||
*/
|
*/
|
||||||
public ResultCode(String resultCode) {
|
public ResultCode(String resultCode) {
|
||||||
|
|
||||||
|
|
@ -60,8 +78,8 @@ public class ResultCode implements Serializable {
|
||||||
/**
|
/**
|
||||||
* 构造方法。
|
* 构造方法。
|
||||||
*
|
*
|
||||||
* @param resultCode 结果码字符串
|
* @param resultCode 结果码字符串
|
||||||
* @param errorName 错误码英文简称
|
* @param errorName 错误码英文简称
|
||||||
*/
|
*/
|
||||||
public ResultCode(String resultCode, String errorName) {
|
public ResultCode(String resultCode, String errorName) {
|
||||||
this(resultCode);
|
this(resultCode);
|
||||||
|
|
@ -71,9 +89,9 @@ public class ResultCode implements Serializable {
|
||||||
/**
|
/**
|
||||||
* 构造方法。
|
* 构造方法。
|
||||||
*
|
*
|
||||||
* @param resultCode 结果码字符串
|
* @param resultCode 结果码字符串
|
||||||
* @param errorName 错误码英文简称
|
* @param errorName 错误码英文简称
|
||||||
* @param description 结果码信息描述
|
* @param description 结果码信息描述
|
||||||
*/
|
*/
|
||||||
public ResultCode(String resultCode, String errorName, String description) {
|
public ResultCode(String resultCode, String errorName, String description) {
|
||||||
this(resultCode);
|
this(resultCode);
|
||||||
|
|
@ -119,7 +137,7 @@ public class ResultCode implements Serializable {
|
||||||
/**
|
/**
|
||||||
* 组装返回码字符串。
|
* 组装返回码字符串。
|
||||||
*
|
*
|
||||||
* @return 返回码字符串
|
* @return 返回码字符串
|
||||||
*/
|
*/
|
||||||
public String fetchResultCode() {
|
public String fetchResultCode() {
|
||||||
StringBuffer sb = new StringBuffer();
|
StringBuffer sb = new StringBuffer();
|
||||||
|
|
@ -138,7 +156,7 @@ public class ResultCode implements Serializable {
|
||||||
* 组装返回码字符串。 解决enum 单利线程安全问题
|
* 组装返回码字符串。 解决enum 单利线程安全问题
|
||||||
*
|
*
|
||||||
* @param eventCode
|
* @param eventCode
|
||||||
* @return 返回码字符串
|
* @return 返回码字符串
|
||||||
*/
|
*/
|
||||||
public String fetchResultCode(String eventCode) {
|
public String fetchResultCode(String eventCode) {
|
||||||
StringBuffer sb = new StringBuffer();
|
StringBuffer sb = new StringBuffer();
|
||||||
|
|
@ -234,7 +252,7 @@ public class ResultCode implements Serializable {
|
||||||
/**
|
/**
|
||||||
* 解析和拆分结果码。
|
* 解析和拆分结果码。
|
||||||
*
|
*
|
||||||
* @param resultCode 结果码字符串
|
* @param resultCode 结果码字符串
|
||||||
*/
|
*/
|
||||||
private void spliteResultCode(String resultCode) {
|
private void spliteResultCode(String resultCode) {
|
||||||
if (!resultCode.startsWith(PREFIX)) {
|
if (!resultCode.startsWith(PREFIX)) {
|
||||||
|
|
@ -256,8 +274,8 @@ public class ResultCode implements Serializable {
|
||||||
/**
|
/**
|
||||||
* 字符串长度检查。
|
* 字符串长度检查。
|
||||||
*
|
*
|
||||||
* @param resultCode 结果码字符串
|
* @param resultCode 结果码字符串
|
||||||
* @param length 长度
|
* @param length 长度
|
||||||
*/
|
*/
|
||||||
private void checkStringLength(String resultCode, int length) {
|
private void checkStringLength(String resultCode, int length) {
|
||||||
if (resultCode == null || resultCode.length() != length) {
|
if (resultCode == null || resultCode.length() != length) {
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,6 @@ package com.electromagnetic.industry.software.common.util;
|
||||||
import cn.hutool.core.codec.Base64;
|
import cn.hutool.core.codec.Base64;
|
||||||
import org.bouncycastle.jce.provider.BouncyCastleProvider;
|
import org.bouncycastle.jce.provider.BouncyCastleProvider;
|
||||||
|
|
||||||
|
|
||||||
import javax.crypto.*;
|
import javax.crypto.*;
|
||||||
import javax.crypto.spec.SecretKeySpec;
|
import javax.crypto.spec.SecretKeySpec;
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
|
|
@ -15,6 +14,7 @@ import java.security.Security;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>Description: [AES对称加密和解密]</p>
|
* <p>Description: [AES对称加密和解密]</p>
|
||||||
|
*
|
||||||
* @description:
|
* @description:
|
||||||
* @author:
|
* @author:
|
||||||
* @create: 2022/07/06 10:52
|
* @create: 2022/07/06 10:52
|
||||||
|
|
@ -24,8 +24,9 @@ public class AESUtils {
|
||||||
/**
|
/**
|
||||||
* <p>Discription:[加密]</p>
|
* <p>Discription:[加密]</p>
|
||||||
* Created on 2022/07/06 10:52
|
* Created on 2022/07/06 10:52
|
||||||
|
*
|
||||||
* @param content 明文 用JSON.toJSONString(Map<String, String> map)转换的json字符串
|
* @param content 明文 用JSON.toJSONString(Map<String, String> map)转换的json字符串
|
||||||
* @param key 加解密规则 访客系统提供key
|
* @param key 加解密规则 访客系统提供key
|
||||||
* @return String 密文
|
* @return String 密文
|
||||||
*/
|
*/
|
||||||
public static String ecodes(String content, String key) {
|
public static String ecodes(String content, String key) {
|
||||||
|
|
@ -34,7 +35,7 @@ public class AESUtils {
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
KeyGenerator kgen = KeyGenerator.getInstance("AES");
|
KeyGenerator kgen = KeyGenerator.getInstance("AES");
|
||||||
SecureRandom random= SecureRandom.getInstance("SHA1PRNG");
|
SecureRandom random = SecureRandom.getInstance("SHA1PRNG");
|
||||||
random.setSeed(key.getBytes());
|
random.setSeed(key.getBytes());
|
||||||
kgen.init(128, random);
|
kgen.init(128, random);
|
||||||
SecretKey secretKey = kgen.generateKey();
|
SecretKey secretKey = kgen.generateKey();
|
||||||
|
|
@ -72,12 +73,13 @@ public class AESUtils {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 前端使用ECB,后端解密方法
|
* 前端使用ECB,后端解密方法
|
||||||
|
*
|
||||||
* @param enc
|
* @param enc
|
||||||
* @param key
|
* @param key
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static String decrypt(String enc, String key) {
|
public static String decrypt(String enc, String key) {
|
||||||
try{
|
try {
|
||||||
SecretKeySpec secretKeySpec = new SecretKeySpec(key.getBytes(), "AES");
|
SecretKeySpec secretKeySpec = new SecretKeySpec(key.getBytes(), "AES");
|
||||||
Security.addProvider(new BouncyCastleProvider());
|
Security.addProvider(new BouncyCastleProvider());
|
||||||
Cipher cipher = Cipher.getInstance("AES/ECB/PKCS7Padding");
|
Cipher cipher = Cipher.getInstance("AES/ECB/PKCS7Padding");
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ import com.electromagnetic.industry.software.common.resp.ElectromagneticResult;
|
||||||
|
|
||||||
public class ElectromagneticResultUtil {
|
public class ElectromagneticResultUtil {
|
||||||
|
|
||||||
public static <T> ElectromagneticResult<T> success(T data){
|
public static <T> ElectromagneticResult<T> success(T data) {
|
||||||
ElectromagneticResult<T> electromagneticResult = new ElectromagneticResult<>();
|
ElectromagneticResult<T> electromagneticResult = new ElectromagneticResult<>();
|
||||||
electromagneticResult.setSuccess(true);
|
electromagneticResult.setSuccess(true);
|
||||||
electromagneticResult.setData(data);
|
electromagneticResult.setData(data);
|
||||||
|
|
@ -13,7 +13,7 @@ public class ElectromagneticResultUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static <T> ElectromagneticResult<T> fail(String code , String msg){
|
public static <T> ElectromagneticResult<T> fail(String code, String msg) {
|
||||||
ElectromagneticResult<T> electromagneticResult = new ElectromagneticResult<>();
|
ElectromagneticResult<T> electromagneticResult = new ElectromagneticResult<>();
|
||||||
electromagneticResult.setSuccess(false);
|
electromagneticResult.setSuccess(false);
|
||||||
electromagneticResult.setErrorCode(code);
|
electromagneticResult.setErrorCode(code);
|
||||||
|
|
@ -21,7 +21,7 @@ public class ElectromagneticResultUtil {
|
||||||
return electromagneticResult;
|
return electromagneticResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <T> ElectromagneticResult fail(ErrorEnum errorEnum){
|
public static <T> ElectromagneticResult fail(ErrorEnum errorEnum) {
|
||||||
ElectromagneticResult<T> electromagneticResult = new ElectromagneticResult<>();
|
ElectromagneticResult<T> electromagneticResult = new ElectromagneticResult<>();
|
||||||
electromagneticResult.setSuccess(false);
|
electromagneticResult.setSuccess(false);
|
||||||
electromagneticResult.setErrorCode(errorEnum.getCode());
|
electromagneticResult.setErrorCode(errorEnum.getCode());
|
||||||
|
|
|
||||||
|
|
@ -6,8 +6,6 @@ import java.net.NetworkInterface;
|
||||||
|
|
||||||
public class IdWorker {
|
public class IdWorker {
|
||||||
|
|
||||||
private static IdWorker idWorker=new IdWorker();
|
|
||||||
|
|
||||||
// 时间起始标记点,作为基准,一般取系统的最近时间(一旦确定不能变动)
|
// 时间起始标记点,作为基准,一般取系统的最近时间(一旦确定不能变动)
|
||||||
private final static long twepoch = 1288834974657L;
|
private final static long twepoch = 1288834974657L;
|
||||||
// 机器标识位数
|
// 机器标识位数
|
||||||
|
|
@ -26,26 +24,24 @@ public class IdWorker {
|
||||||
private final static long datacenterIdShift = sequenceBits + workerIdBits;
|
private final static long datacenterIdShift = sequenceBits + workerIdBits;
|
||||||
// 时间毫秒左移22位
|
// 时间毫秒左移22位
|
||||||
private final static long timestampLeftShift = sequenceBits + workerIdBits + datacenterIdBits;
|
private final static long timestampLeftShift = sequenceBits + workerIdBits + datacenterIdBits;
|
||||||
|
|
||||||
private final static long sequenceMask = -1L ^ (-1L << sequenceBits);
|
private final static long sequenceMask = -1L ^ (-1L << sequenceBits);
|
||||||
|
private static IdWorker idWorker = new IdWorker();
|
||||||
/* 上次生产id时间戳 */
|
/* 上次生产id时间戳 */
|
||||||
private static long lastTimestamp = -1L;
|
private static long lastTimestamp = -1L;
|
||||||
// 0,并发控制
|
|
||||||
private long sequence = 0L;
|
|
||||||
|
|
||||||
private final long workerId;
|
private final long workerId;
|
||||||
// 数据标识id部分
|
// 数据标识id部分
|
||||||
private final long datacenterId;
|
private final long datacenterId;
|
||||||
|
// 0,并发控制
|
||||||
|
private long sequence = 0L;
|
||||||
|
|
||||||
public IdWorker(){
|
public IdWorker() {
|
||||||
this.datacenterId = getDatacenterId(maxDatacenterId);
|
this.datacenterId = getDatacenterId(maxDatacenterId);
|
||||||
this.workerId = getMaxWorkerId(datacenterId, maxWorkerId);
|
this.workerId = getMaxWorkerId(datacenterId, maxWorkerId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param workerId
|
* @param workerId 工作机器ID
|
||||||
* 工作机器ID
|
* @param datacenterId 序列号
|
||||||
* @param datacenterId
|
|
||||||
* 序列号
|
|
||||||
*/
|
*/
|
||||||
public IdWorker(long workerId, long datacenterId) {
|
public IdWorker(long workerId, long datacenterId) {
|
||||||
if (workerId > maxWorkerId || workerId < 0) {
|
if (workerId > maxWorkerId || workerId < 0) {
|
||||||
|
|
@ -57,47 +53,6 @@ public class IdWorker {
|
||||||
this.workerId = workerId;
|
this.workerId = workerId;
|
||||||
this.datacenterId = datacenterId;
|
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>
|
* <p>
|
||||||
|
|
@ -143,12 +98,55 @@ public class IdWorker {
|
||||||
}
|
}
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
public static long getSnowFlakeId(){
|
|
||||||
|
public static long getSnowFlakeId() {
|
||||||
return idWorker.nextId();
|
return idWorker.nextId();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getSnowFlakeIdString(){
|
public static String getSnowFlakeIdString() {
|
||||||
return String.valueOf(getSnowFlakeId());
|
return String.valueOf(getSnowFlakeId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取下一个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();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -55,39 +55,29 @@ public class SignUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Boolean equals(String v1, String v2) {
|
public static Boolean equals(String v1, String v2) {
|
||||||
if (v1 == null && v2 == null)
|
if (v1 == null && v2 == null) {
|
||||||
{
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (v1 != null && v2 != null && v1.equals(v2))
|
if (v1 != null && v2 != null && v1.equals(v2)) {
|
||||||
{
|
|
||||||
return true;
|
return true;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getString(Map<String,Object> params, String key, String defaultValue){
|
public static String getString(Map<String, Object> params, String key, String defaultValue) {
|
||||||
String temp = null;
|
String temp = null;
|
||||||
if(params.get(key)==null){
|
if (params.get(key) == null) {
|
||||||
return defaultValue;
|
return defaultValue;
|
||||||
}
|
} else if (params.get(key).getClass().isArray()) {
|
||||||
|
temp = getArray(params, key)[0];
|
||||||
else if(params.get(key).getClass().isArray())
|
} else {
|
||||||
{
|
|
||||||
temp = getArray(params,key)[0];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
temp = params.get(key).toString();
|
temp = params.get(key).toString();
|
||||||
}
|
}
|
||||||
if(temp != null){
|
if (temp != null) {
|
||||||
temp = temp.replaceAll("%", "\\%");
|
temp = temp.replaceAll("%", "\\%");
|
||||||
}
|
}
|
||||||
if(temp==null)
|
if (temp == null) {
|
||||||
{
|
|
||||||
return defaultValue;
|
return defaultValue;
|
||||||
}
|
}
|
||||||
return temp;
|
return temp;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue