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