add laws-modules-docking 模块
This commit is contained in:
+25
@@ -0,0 +1,25 @@
|
||||
package com.jero.common.api;
|
||||
|
||||
|
||||
import com.jero.common.api.dto.message.HiworkTodoAdd;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author: liao
|
||||
* @Date: 2023/10/27 15:15
|
||||
* @Description: 发送消息
|
||||
*/
|
||||
public interface PushWorkflowIntegrationAPI {
|
||||
|
||||
/**
|
||||
* @Author: liao
|
||||
* @Date: 2023/10/13 15:12
|
||||
* @Description: 统一待办集成
|
||||
**/
|
||||
void sendTodoTask(List<HiworkTodoAdd> hiworkTodoAddList);
|
||||
|
||||
void sendActivityComplete(List<HiworkTodoAdd> processInstanceId);
|
||||
|
||||
void sendDeleteTask(List<HiworkTodoAdd> todoAddList);
|
||||
}
|
||||
+1
-2
@@ -1,4 +1,4 @@
|
||||
package com.jero.modules.common.service;
|
||||
package com.jero.common.api;
|
||||
|
||||
import com.jero.common.api.dto.message.SendMessageDTO;
|
||||
|
||||
@@ -7,7 +7,6 @@ import com.jero.common.api.dto.message.SendMessageDTO;
|
||||
* @Date: 2023/10/27 15:15
|
||||
* @Description: 发送消息
|
||||
*/
|
||||
|
||||
public interface SendMessageAPI {
|
||||
|
||||
/**
|
||||
+87
@@ -0,0 +1,87 @@
|
||||
package com.jero.modules.docking.download.config;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.springframework.core.Ordered;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.filter.OncePerRequestFilter;
|
||||
import org.springframework.web.util.ContentCachingRequestWrapper;
|
||||
import org.springframework.web.util.ContentCachingResponseWrapper;
|
||||
import org.springframework.web.util.WebUtils;
|
||||
|
||||
import javax.servlet.FilterChain;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @author lqt
|
||||
* @version 1.0
|
||||
* @date 2023/11/24 11:36
|
||||
*/
|
||||
@Component
|
||||
public class ContentCachingWrapperFilter extends OncePerRequestFilter implements Ordered {
|
||||
|
||||
@Override
|
||||
public int getOrder() {
|
||||
return Ordered.LOWEST_PRECEDENCE - 10;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain)
|
||||
throws ServletException, IOException {
|
||||
// 包装流,可重复读取
|
||||
if (!(request instanceof ContentCachingRequestWrapper)) {
|
||||
request = new ContentCachingRequestWrapper(request);
|
||||
}
|
||||
if (!(response instanceof ContentCachingResponseWrapper)) {
|
||||
response = new ContentCachingResponseWrapper(response);
|
||||
}
|
||||
|
||||
filterChain.doFilter(request, response);
|
||||
updateResponse(response);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新响应(不操作这一步,会导致接口响应空白)
|
||||
*
|
||||
* @param response 响应对象
|
||||
* @throws IOException /
|
||||
*/
|
||||
public static void updateResponse(HttpServletResponse response) throws IOException {
|
||||
ContentCachingResponseWrapper responseWrapper = WebUtils.getNativeResponse(response, ContentCachingResponseWrapper.class);
|
||||
Objects.requireNonNull(responseWrapper).copyBodyToResponse();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取请求体
|
||||
*
|
||||
* @param request 请求对象
|
||||
* @return 请求体
|
||||
*/
|
||||
public static String getRequestBody(HttpServletRequest request) throws IOException {
|
||||
String requestBody = "";
|
||||
ContentCachingRequestWrapper wrapper = WebUtils.getNativeRequest(request, ContentCachingRequestWrapper.class);
|
||||
if (wrapper != null) {
|
||||
requestBody = IOUtils.toString(wrapper.getContentAsByteArray(), StandardCharsets.UTF_8.toString());
|
||||
}
|
||||
return requestBody;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取响应体
|
||||
*
|
||||
* @param response 响应对象
|
||||
* @return 响应体
|
||||
*/
|
||||
public static InputStream getResponseBody(HttpServletResponse response) throws IOException {
|
||||
InputStream responseBody = null;
|
||||
ContentCachingResponseWrapper wrapper = WebUtils.getNativeResponse(response, ContentCachingResponseWrapper.class);
|
||||
if (wrapper != null) {
|
||||
responseBody = wrapper.getContentInputStream();
|
||||
}
|
||||
return responseBody;
|
||||
}
|
||||
}
|
||||
+53
@@ -0,0 +1,53 @@
|
||||
package com.jero.modules.docking.download.config;
|
||||
|
||||
import com.jero.modules.docking.download.service.DownloadDecryptFileService;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.servlet.HandlerInterceptor;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* @author lqt
|
||||
* @version 1.0
|
||||
* @date 2023/11/23 18:20
|
||||
*/
|
||||
@Component
|
||||
public class DownloadInterceptor implements HandlerInterceptor{
|
||||
|
||||
@Resource
|
||||
private DownloadDecryptFileService downloadDecryptFileService;
|
||||
|
||||
public DownloadInterceptor(DownloadDecryptFileService downloadDecryptFileService) {
|
||||
this.downloadDecryptFileService = downloadDecryptFileService;
|
||||
}
|
||||
|
||||
/**
|
||||
* 预处理回调方法,实现处理器的预处理(如检查登陆),第三个参数为响应的处理器
|
||||
* 返回值:true表示继续流程(如调用下一个拦截器或处理器);false表示流程中断(如登录检查失败),不会继续调用其他的拦截器或处理器,此时我们需要通过response来产生响应
|
||||
* @throws Exception
|
||||
*/
|
||||
@Override
|
||||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 后处理回调方法,实现处理器的后处理(但在渲染视图之前),此时我们可以通过modelAndView(模型和视图对象)对模型数据进行处理或对视图进行处理,modelAndView也可能为null
|
||||
*/
|
||||
@Override
|
||||
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, @Nullable ModelAndView modelAndView) throws Exception {
|
||||
downloadDecryptFileService.downloadDecryptFile(request,response,handler,"1");
|
||||
}
|
||||
|
||||
/**
|
||||
*整个请求处理完毕回调方法,即在视图渲染完毕时回调,如性能监控中我们可以在此记录结束时间并输出消耗时间,还可以进行一些资源清理,类似于try-catch-finally中的finally,但仅调用处理器执行链中
|
||||
*/
|
||||
@Override
|
||||
public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, @Nullable Exception ex) throws Exception {
|
||||
downloadDecryptFileService.downloadDecryptFile(request,response,handler,null);
|
||||
}
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
package com.jero.modules.docking.download.config;
|
||||
|
||||
import com.jero.modules.docking.download.service.DownloadDecryptFileService;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* @author lqt
|
||||
* @version 1.0
|
||||
* @date 2023/11/23 18:21
|
||||
*/
|
||||
@Configuration
|
||||
public class InterceptorConfig implements WebMvcConfigurer {
|
||||
@Resource
|
||||
private DownloadDecryptFileService downloadDecryptFileService;
|
||||
|
||||
@Override
|
||||
public void addInterceptors(InterceptorRegistry registry) {
|
||||
registry.addInterceptor(new DownloadInterceptor(downloadDecryptFileService)).addPathPatterns("/**");
|
||||
}
|
||||
|
||||
}
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
package com.jero.modules.docking.download.controller;
|
||||
|
||||
import com.jero.common.util.IntekeyUtils;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
|
||||
/**
|
||||
* @author lqt
|
||||
* @version 1.0
|
||||
* @date 2023/11/27 17:41
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/home/search")
|
||||
public class SearchController {
|
||||
|
||||
|
||||
@PostMapping(value = "/download")
|
||||
public void downloadAndView(@RequestParam("file") MultipartFile file,
|
||||
@RequestParam("url") String url,
|
||||
@RequestParam("appCode") String appCode,
|
||||
@RequestParam("secretKey") String secretKey,
|
||||
@RequestParam(value = "scope",required = false) Integer scope,
|
||||
HttpServletResponse response) {
|
||||
try (InputStream inputStream = IntekeyUtils.decryptFile(url, appCode, secretKey, scope, file);
|
||||
OutputStream outputStream = response.getOutputStream()
|
||||
) {
|
||||
byte[] buf = new byte[1024];
|
||||
int len;
|
||||
while ((len = inputStream.read(buf)) > 0) {
|
||||
outputStream.write(buf, 0, len);
|
||||
}
|
||||
response.flushBuffer();
|
||||
} catch (Exception e) {
|
||||
response.setStatus(404);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
package com.jero.modules.docking.download.service;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* @author lqt
|
||||
* @version 1.0
|
||||
* @date 2023/11/24 9:04
|
||||
*/
|
||||
public interface DownloadDecryptFileService {
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LQT
|
||||
* @date 2023/11/24 9:06
|
||||
* @param request
|
||||
* @param response
|
||||
* @param handler
|
||||
* @param type 1 为直接返回文件流,其他为modelandview
|
||||
* @return void
|
||||
*/
|
||||
void downloadDecryptFile(HttpServletRequest request, HttpServletResponse response, Object handler,String type);
|
||||
}
|
||||
+269
@@ -0,0 +1,269 @@
|
||||
package com.jero.modules.docking.download.service.impl;
|
||||
|
||||
import com.jero.modules.docking.download.config.ContentCachingWrapperFilter;
|
||||
import com.jero.modules.docking.download.service.DownloadDecryptFileService;
|
||||
import com.jero.common.util.IntekeyUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.http.entity.ContentType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.mock.web.MockMultipartFile;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.method.HandlerMethod;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author lqt
|
||||
* @version 1.0
|
||||
* @date 2023/11/24 9:04
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class DownloadDecryptFileServiceImpl implements DownloadDecryptFileService {
|
||||
|
||||
@Value("#{'${download.download_url}'.split(',')}")
|
||||
private List<String> downloadUrl;
|
||||
|
||||
@Value("#{'${download.view_url}'.split(',')}")
|
||||
private List<String> viewUrl;
|
||||
|
||||
@Value("#{'${download.enable}'}")
|
||||
private boolean enable;
|
||||
|
||||
@Value("#{'${download.white_url}'.split(',')}")
|
||||
private List<String> whiteUrls;
|
||||
|
||||
@Value("#{'${download.dev_encrypt_url}'.split(',')}")
|
||||
private List<String> devEncryptUrls;
|
||||
|
||||
/**
|
||||
* 管理员角色
|
||||
*/
|
||||
@Value("#{'${download.admin_role_code}'.split(',')}")
|
||||
private List<String> adminRoleCode;
|
||||
|
||||
/**
|
||||
* 加密
|
||||
*/
|
||||
@Value("#{'${download.encrypt.url}'}")
|
||||
private String encryptUrl;
|
||||
@Value("#{'${download.encrypt.app_code}'}")
|
||||
private String encryptAppCode;
|
||||
@Value("#{'${download.encrypt.secret_key}'}")
|
||||
private String encryptSecretKey;
|
||||
|
||||
/**
|
||||
* 解密
|
||||
*/
|
||||
@Value("#{'${download.decrypt.url}'}")
|
||||
private String decryptUrl;
|
||||
@Value("#{'${download.decrypt.app_code}'}")
|
||||
private String decryptAppCode;
|
||||
@Value("#{'${download.decrypt.secret_key}'}")
|
||||
private String decryptSecretKey;
|
||||
|
||||
/**
|
||||
* 研发域
|
||||
*/
|
||||
@Value("#{'${download.scope_dev}'}")
|
||||
private int scopeDev;
|
||||
/**
|
||||
* 办公域
|
||||
*/
|
||||
@Value("#{'${download.scope_work}'}")
|
||||
private int scopeWork;
|
||||
|
||||
|
||||
@Override
|
||||
public void downloadDecryptFile(HttpServletRequest request, HttpServletResponse response, Object handler,String type) {
|
||||
if(!enable){
|
||||
return;
|
||||
}
|
||||
// 白名单不执行
|
||||
String requestUrl = request.getRequestURI();
|
||||
for (String whiteUrl : whiteUrls) {
|
||||
if (requestUrl.contains(whiteUrl)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// 是否加研发密
|
||||
boolean isDevEncrypt = false;
|
||||
for (String devEncryptUrl : devEncryptUrls) {
|
||||
if (requestUrl.contains(devEncryptUrl)) {
|
||||
isDevEncrypt = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// 判断返回值是否为文件流,否则其他接口返回值会变更成字符串,导致前端无法解析
|
||||
HandlerMethod handlerMethod = (HandlerMethod) handler;
|
||||
InputStream responseBody = null;
|
||||
try {
|
||||
String returnType = handlerMethod.getMethod().getReturnType().getName();
|
||||
if(!Objects.equals(returnType,"void") && !Objects.equals(returnType,"org.springframework.web.servlet.ModelAndView")){
|
||||
return;
|
||||
}
|
||||
if(Objects.equals(returnType,"void") && !Objects.equals(type,"1")){
|
||||
return;
|
||||
}
|
||||
responseBody = ContentCachingWrapperFilter.getResponseBody(response);
|
||||
} catch (Exception e) {
|
||||
log.error("Exception:",e);
|
||||
response.setStatus(404);
|
||||
}
|
||||
|
||||
String contentType = response.getContentType();
|
||||
String fileName = getFileName(response);
|
||||
if (!fileName.contains(".")) {
|
||||
return;
|
||||
}
|
||||
MultipartFile file = getMultipartFile(response,responseBody, contentType, fileName);
|
||||
// 访问路径
|
||||
String str = request.getRequestURI();
|
||||
|
||||
boolean b = isBoolean(str, viewUrl);
|
||||
|
||||
boolean b1 = isBoolean(str, downloadUrl);
|
||||
|
||||
int scope = getScope(isDevEncrypt);
|
||||
|
||||
if(b){
|
||||
// 预览,进行解密
|
||||
decryptFile(response, file, null);
|
||||
}else if(b1){
|
||||
// 下载文件 先解密,判断组织域,加密
|
||||
try (InputStream is = IntekeyUtils.decryptFile(decryptUrl, decryptAppCode, decryptSecretKey, null, file)) {
|
||||
MultipartFile fileDecrypt = getMultipartFile(response,is, contentType, fileName);
|
||||
// 判断fileDecrypt是不是zip压缩包,如果是压缩包的话则不加密
|
||||
boolean isZipFile = false;
|
||||
String originalFileName = fileDecrypt.getOriginalFilename();
|
||||
if (originalFileName != null && originalFileName.endsWith(".zip")) {
|
||||
isZipFile = true;
|
||||
}
|
||||
if (isZipFile) {
|
||||
return;
|
||||
}
|
||||
// 加密
|
||||
encryptFile(response, fileDecrypt, scope);
|
||||
} catch (Exception e) {
|
||||
log.error("Exception:",e);
|
||||
response.setStatus(404);
|
||||
}
|
||||
|
||||
}else{
|
||||
// 加密
|
||||
encryptFile(response, file, scope);
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private String getFileName(HttpServletResponse response) {
|
||||
String fileName = "";
|
||||
String headerField = response.getHeader("Content-Disposition");
|
||||
|
||||
if (headerField != null &&
|
||||
(!StringUtils.isBlank(headerField) || headerField.contains("fileName=") || headerField.contains("filename="))){
|
||||
String name = "";
|
||||
if(headerField.contains("fileName=")){
|
||||
name = "fileName";
|
||||
}else{
|
||||
name = "filename";
|
||||
}
|
||||
fileName = headerField.substring(headerField.lastIndexOf(name + "=") + 9);
|
||||
if (headerField.contains("filename*=UTF-8")){
|
||||
fileName = headerField.substring(headerField.lastIndexOf("filename*=UTF-8") + 17);
|
||||
}
|
||||
}else {
|
||||
fileName = UUID.randomUUID().toString();
|
||||
}
|
||||
return fileName;
|
||||
}
|
||||
|
||||
private void decryptFile(HttpServletResponse response, MultipartFile file, Integer scope) {
|
||||
try (InputStream is = IntekeyUtils.decryptFile(decryptUrl, decryptAppCode, decryptSecretKey, scope, file)) {
|
||||
writeResponse(response, is);
|
||||
} catch (Exception e) {
|
||||
log.error("Exception:",e);
|
||||
response.setStatus(404);
|
||||
}
|
||||
}
|
||||
|
||||
private void encryptFile(HttpServletResponse response, MultipartFile file, Integer scope) {
|
||||
try (InputStream is = IntekeyUtils.decryptFile(encryptUrl, encryptAppCode, encryptSecretKey, scope, file)) {
|
||||
writeResponse(response, is);
|
||||
} catch (Exception e) {
|
||||
log.error("Exception:",e);
|
||||
response.setStatus(404);
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private MultipartFile getMultipartFile(HttpServletResponse response,InputStream responseBody,String contentType,String fileName) {
|
||||
MultipartFile file = null;
|
||||
try {
|
||||
file = new MockMultipartFile(ContentType.APPLICATION_OCTET_STREAM.toString(),fileName,contentType, responseBody);
|
||||
} catch (IOException e) {
|
||||
log.error("Exception:",e);
|
||||
response.setStatus(404);
|
||||
}
|
||||
return file;
|
||||
}
|
||||
|
||||
private boolean isBoolean(String str, List<String> viewUrl) {
|
||||
boolean b = false;
|
||||
for (String s : viewUrl) {
|
||||
if (str.contains(s)) {
|
||||
b = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return b;
|
||||
}
|
||||
|
||||
private int getScope(boolean isDevEncrypt) {
|
||||
// 角色信息中存在 【系统管理员】或者 【标准管理员】即加为研发密,其他情况都是OA密
|
||||
// 研发密比较高级(加密需要传参)
|
||||
// 研发域 scope = 51
|
||||
// 办公密 scope = 52
|
||||
// LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
// List<String> listRoleCode = Arrays.asList(sysUser.getRoleIds().split(","));
|
||||
// if(CollectionUtils.isEmpty(listRoleCode)){
|
||||
// throw new JeroBootException(ResultCommon.ERROR);
|
||||
// }
|
||||
// int scope = scopeWork;
|
||||
// long l = listRoleCode.stream().filter(o->adminRoleCode.contains(o)).count();
|
||||
// if(l > 0){
|
||||
// scope = scopeDev;
|
||||
// }
|
||||
if (isDevEncrypt) {
|
||||
return scopeDev;
|
||||
} else {
|
||||
return scopeWork;
|
||||
}
|
||||
}
|
||||
|
||||
private void writeResponse(HttpServletResponse response,InputStream is) {
|
||||
response.resetBuffer();
|
||||
try (OutputStream outputStream = response.getOutputStream()) {
|
||||
byte[] buf = new byte[1024];
|
||||
int len;
|
||||
while ((len = is.read(buf)) > 0) {
|
||||
outputStream.write(buf, 0, len);
|
||||
}
|
||||
response.flushBuffer();
|
||||
}catch (Exception e){
|
||||
log.error("Exception:",e);
|
||||
response.setStatus(404);
|
||||
}
|
||||
}
|
||||
}
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
package com.jero.modules.docking.file.controller;
|
||||
|
||||
|
||||
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
||||
import com.jero.common.api.vo.Result;
|
||||
import com.jero.common.aspect.annotation.AutoLog;
|
||||
import com.jero.modules.docking.file.serviec.FileService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
@Slf4j
|
||||
@RestController
|
||||
@Api(tags = "文件")
|
||||
@RequestMapping("/file")
|
||||
public class FileController {
|
||||
|
||||
@Resource
|
||||
private FileService fileService;
|
||||
|
||||
@GetMapping("/allDocFileTransferPdf")
|
||||
@AutoLog(value = "文件-所有历史doc和docx文件生成pdf版本")
|
||||
@ApiOperation(value="文件-所有历史doc和docx文件生成pdf版本", notes="文件-所有历史doc和docx文件生成pdf版本")
|
||||
@ApiOperationSupport(order = 100)
|
||||
public Result<?> allDocFileTransferPdf(String fileId) {
|
||||
return Result.OK(fileService.allDocFileTransferPdf(fileId));
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
package com.jero.modules.docking.file.serviec;
|
||||
|
||||
public interface FileService {
|
||||
|
||||
|
||||
/**
|
||||
* 所有历史doc和docx文件生成pdf版本
|
||||
* @return
|
||||
*/
|
||||
String allDocFileTransferPdf(String fileId);
|
||||
|
||||
}
|
||||
+108
@@ -0,0 +1,108 @@
|
||||
package com.jero.modules.docking.file.serviec.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.jero.common.util.IntekeyUtils;
|
||||
import com.jero.common.util.MinioUtil;
|
||||
import com.jero.modules.docking.file.serviec.FileService;
|
||||
import com.jero.modules.onlyoffice.utils.OnlyOfficePdfUtil;
|
||||
import com.jero.modules.oss.entity.OSSFile;
|
||||
import com.jero.modules.oss.service.IOSSFileService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.nio.file.Files;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
public class FileServiceImpl implements FileService {
|
||||
|
||||
@Value("#{'${download.enable}'}")
|
||||
private boolean enable;
|
||||
|
||||
@Value("${file.path}")
|
||||
private String filePath;//文件存储路径
|
||||
|
||||
@Resource
|
||||
private IOSSFileService ossFileService;
|
||||
|
||||
@Resource
|
||||
private OnlyOfficePdfUtil onlyOfficePdfUtil;
|
||||
|
||||
@Override
|
||||
public String allDocFileTransferPdf(String fileIds) {
|
||||
List<OSSFile> resultList = new ArrayList<>();
|
||||
// 获取所有需要生成pdf版本的文件
|
||||
// 先获取所有有url的文件记录
|
||||
LambdaQueryWrapper<OSSFile> ossWrapper = new LambdaQueryWrapper<>();
|
||||
ossWrapper.in(StrUtil.isNotBlank(fileIds), OSSFile::getId, Arrays.asList(fileIds.split(",")));
|
||||
ossWrapper.isNotNull(OSSFile::getUrl);
|
||||
List<OSSFile> ossFileList = ossFileService.list(ossWrapper);
|
||||
if (CollUtil.isEmpty(ossFileList)) {
|
||||
return "没有需要处理的文件";
|
||||
}
|
||||
// 筛选出后缀为doc或docx的文件
|
||||
List<OSSFile> docFileList = ossFileList.stream()
|
||||
.filter(o -> o.getUrl().endsWith("doc") || o.getUrl().endsWith("docx"))
|
||||
.collect(Collectors.toList());
|
||||
// 筛选出已经转换过的pdf文件
|
||||
Map<String, List<OSSFile>> alreadyTransferFileMap = ossFileList.stream()
|
||||
.filter(o -> StrUtil.isNotBlank(o.getBindId()))
|
||||
.collect(Collectors.groupingBy(OSSFile::getBindId));
|
||||
for (OSSFile ossFile : docFileList){
|
||||
List<OSSFile> existPdfFileList = alreadyTransferFileMap.get(ossFile.getId());
|
||||
// 已经转换过的不再重复转换
|
||||
if (CollUtil.isNotEmpty(existPdfFileList)) {
|
||||
continue;
|
||||
}
|
||||
String docFileName = ossFile.getFileName();
|
||||
log.info("开始处理文件名为 {} 的文件转换工作", docFileName);
|
||||
// 根据文件url获取文件
|
||||
InputStream isDecrypt;
|
||||
try (InputStream is = MinioUtil.download(ossFile.getUrl())) {
|
||||
isDecrypt = is;
|
||||
// 文件解密
|
||||
if (enable) {
|
||||
isDecrypt = IntekeyUtils.autoDecryptInputStreamFile(isDecrypt, ossFile.getFileName());
|
||||
}
|
||||
// 转换为pdf
|
||||
String pdfFileName = docFileName.substring(0, docFileName.lastIndexOf("."));
|
||||
String targetPath = "convert/" + ossFile.getFileName();
|
||||
File targetFile = new File(filePath + targetPath);
|
||||
try (OutputStream outputStream = Files.newOutputStream(targetFile.toPath())) {
|
||||
byte[] buffer = new byte[1024];
|
||||
int bytesRead;
|
||||
while ((bytesRead = isDecrypt.read(buffer)) != -1) {
|
||||
outputStream.write(buffer, 0, bytesRead);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
log.error("文件写入失败:" + e.getMessage());
|
||||
}
|
||||
onlyOfficePdfUtil.convertAndSavePdfFile(pdfFileName, ossFile.getId(), targetPath);
|
||||
// 将下载到本地的文件删除
|
||||
FileUtil.del(targetFile);
|
||||
log.info("文件名为 {} 的文件转换成功", docFileName);
|
||||
resultList.add(ossFile);
|
||||
} catch (Exception e) {
|
||||
log.error("文件名为 {} 的文件转换失败,失败原因{}", docFileName, e.getMessage());
|
||||
}
|
||||
}
|
||||
return "文件转换完成,需要转换的文件数量为: " + ossFileList.size() + "成功转换数量为: " + resultList.size();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
package com.jero.modules.docking.hiwork.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.jero.common.api.vo.Result;
|
||||
import com.jero.modules.docking.hiwork.service.impl.HiworkService;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* @author liJiaRao
|
||||
* @date 2024-03-01 14:01
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/hiwork")
|
||||
@Slf4j
|
||||
public class HiworkLoginController {
|
||||
@Resource
|
||||
private HiworkService hiworkService;
|
||||
|
||||
@ApiOperation("hiwork单点登录")
|
||||
@PostMapping("/login")
|
||||
public Result<JSONObject> login(@RequestBody JSONObject jsonObject){
|
||||
return hiworkService.login(jsonObject);
|
||||
}
|
||||
}
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
package com.jero.modules.docking.hiwork.entity;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* @Author: liao
|
||||
* @Date: 2023/10/13 17:49
|
||||
* @Description: 统一消息集成-钉钉消息
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@ApiModel(value="统一消息集成-钉钉消息", description="统一消息集成-钉钉消息")
|
||||
public class HiworkDingDingMsg {
|
||||
@ApiModelProperty(value = "异构系统标识")
|
||||
private String sysCode;
|
||||
@ApiModelProperty(value = "服务号消息")
|
||||
private String noticeServiceCode;
|
||||
@ApiModelProperty(value = "消息推送类型 ding | message | jpush")
|
||||
private String noticePushType;
|
||||
@ApiModelProperty(value = "发送人员Id")
|
||||
private String useridList;
|
||||
@ApiModelProperty(value = "发送部门id")
|
||||
private String deptIdList;
|
||||
@ApiModelProperty(value = "agentId")
|
||||
private String agentId;
|
||||
@ApiModelProperty(value = "标题")
|
||||
private String title;
|
||||
@ApiModelProperty(value = "消息体")
|
||||
private JSONObject msg;
|
||||
}
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
package com.jero.modules.docking.hiwork.entity;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* @Author: liao
|
||||
* @Date: 2023/10/13 14:39
|
||||
* @Description: 统一待办集成返回
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@ApiModel(value="统一待办集成返回", description="统一待办集成返回")
|
||||
public class HiworkResult {
|
||||
@ApiModelProperty(value = "成功true,失败false")
|
||||
private Boolean success;
|
||||
@ApiModelProperty(value = "成功1,失败0")
|
||||
private Integer code;
|
||||
@ApiModelProperty(value = "消息")
|
||||
private String msg;
|
||||
@ApiModelProperty(value = "成功null,失败null")
|
||||
private Object data;
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
package com.jero.modules.docking.hiwork.entity;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* @Author: liao
|
||||
* @Date: 2023/10/13 17:49
|
||||
* @Description: 统一消息集成-系统消息
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@ApiModel(value="统一消息集成-系统消息", description="统一消息集成-系统消息")
|
||||
public class HiworkSystemMsg {
|
||||
@ApiModelProperty(value = "异构系统标识")
|
||||
private String sysCode;
|
||||
@ApiModelProperty(value = "消息推送类型 ding | message | jpush")
|
||||
private String noticePushType;
|
||||
@ApiModelProperty(value = "发送人员编号")
|
||||
private String sendCode;
|
||||
@ApiModelProperty(value = "发送人员姓名")
|
||||
private String sendName;
|
||||
@ApiModelProperty(value = "消息类型 字典")
|
||||
private String messageType;
|
||||
@ApiModelProperty(value = "消息标题")
|
||||
private String title;
|
||||
@ApiModelProperty(value = "消息接收人 集合")
|
||||
private JSONArray receiverList;
|
||||
@ApiModelProperty(value = "消息体")
|
||||
private JSONObject msg;
|
||||
}
|
||||
+78
@@ -0,0 +1,78 @@
|
||||
package com.jero.modules.docking.hiwork.entity;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.time.Instant;
|
||||
|
||||
/**
|
||||
* @Author: liao
|
||||
* @Date: 2023/10/13 14:22
|
||||
* @Description: 待办
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@ApiModel(value="统一待办集成", description="统一待办集成")
|
||||
public class HiworkTodo {
|
||||
@ApiModelProperty(value = "异构系统标识")
|
||||
private String sysCode;
|
||||
@ApiModelProperty(value = "标题")
|
||||
private String noticeTitle;
|
||||
@ApiModelProperty(value = "描述")
|
||||
private String noticeDescription;
|
||||
@ApiModelProperty(value = "流程编号")
|
||||
private String busiDefCode;
|
||||
@ApiModelProperty(value = "流程id")
|
||||
private String flowid;
|
||||
@ApiModelProperty(value = "流程实例id")
|
||||
private String processId;
|
||||
@ApiModelProperty(value = "流程实例名称")
|
||||
private String processName;
|
||||
@ApiModelProperty(value = "流程类型,字典")
|
||||
private String processType;
|
||||
@ApiModelProperty(value = "任务id")
|
||||
private String taskId;
|
||||
@ApiModelProperty(value = "节点名称")
|
||||
private String taskName;
|
||||
@ApiModelProperty(value = "是否进入下一节点(0是 1不是)")
|
||||
private Integer multiInstance;
|
||||
@ApiModelProperty(value = "节点编号")
|
||||
private String nodeBusiCode;
|
||||
@ApiModelProperty(value = "跳转链接")
|
||||
private String businessLink;
|
||||
@ApiModelProperty(value = "APP跳转链接")
|
||||
private String appBusinessLink;
|
||||
@ApiModelProperty(value = "创建人code")
|
||||
private String createUserCode;
|
||||
@ApiModelProperty(value = "创建人姓名")
|
||||
private String createUserName;
|
||||
@ApiModelProperty(value = "接收人id")
|
||||
private String userId;
|
||||
@ApiModelProperty(value = "接收人code")
|
||||
private String userCode;
|
||||
@ApiModelProperty(value = "接收人姓名")
|
||||
private String userName;
|
||||
@ApiModelProperty(value = "参与者id")
|
||||
private String participantId;
|
||||
@ApiModelProperty(value = "参与者编号")
|
||||
private String participantCode;
|
||||
@ApiModelProperty(value = "接收时间")
|
||||
private Instant receiveTime;
|
||||
@ApiModelProperty(value = "截止时间")
|
||||
private Long dueTime;
|
||||
@ApiModelProperty(value = "业务主键")
|
||||
private String bid;
|
||||
@ApiModelProperty(value = "待办、已办")
|
||||
private String isTodo;
|
||||
@ApiModelProperty(value = "是否展示在列表中")
|
||||
private String isShow;
|
||||
@ApiModelProperty(value = "优先级")
|
||||
private String priority;
|
||||
@ApiModelProperty(value = "是否通知消息")
|
||||
private String notifyConfig;
|
||||
|
||||
}
|
||||
+72
@@ -0,0 +1,72 @@
|
||||
package com.jero.modules.docking.hiwork.entity;
|
||||
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* @author liJiaRao
|
||||
* @date 2024-03-01 14:26
|
||||
*/
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
public class HiworkUserInfo {
|
||||
/**
|
||||
* errcode
|
||||
*/
|
||||
@JSONField(name = "errcode")
|
||||
private Integer errcode;
|
||||
/**
|
||||
* result
|
||||
*/
|
||||
@JSONField(name = "result")
|
||||
private ResultDTO result;
|
||||
/**
|
||||
* errmsg
|
||||
*/
|
||||
@JSONField(name = "errmsg")
|
||||
private String errmsg;
|
||||
|
||||
/**
|
||||
* ResultDTO
|
||||
*/
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
public static class ResultDTO {
|
||||
/**
|
||||
* associatedUnionid
|
||||
*/
|
||||
@JSONField(name = "associated_unionid")
|
||||
private String associatedUnionid;
|
||||
/**
|
||||
* unionid
|
||||
*/
|
||||
@JSONField(name = "unionid")
|
||||
private String unionid;
|
||||
/**
|
||||
* deviceId
|
||||
*/
|
||||
@JSONField(name = "device_id")
|
||||
private String deviceId;
|
||||
/**
|
||||
* sysLevel
|
||||
*/
|
||||
@JSONField(name = "sys_level")
|
||||
private Integer sysLevel;
|
||||
/**
|
||||
* name
|
||||
*/
|
||||
@JSONField(name = "name")
|
||||
private String name;
|
||||
/**
|
||||
* sys
|
||||
*/
|
||||
@JSONField(name = "sys")
|
||||
private Boolean sys;
|
||||
/**
|
||||
* userid
|
||||
*/
|
||||
@JSONField(name = "userid")
|
||||
private String userid;
|
||||
}
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
package com.jero.modules.docking.hiwork.enums;
|
||||
|
||||
/**
|
||||
* @Author: liao
|
||||
* @Date: 2023/10/13 15:05
|
||||
* @Description: 待办、已办
|
||||
*/
|
||||
public enum IsTodoEnum {
|
||||
TODO( "待办", "1"),
|
||||
DONE("已办", "2"),
|
||||
FINISH("结束", "3"),
|
||||
DEL("删除", "6")
|
||||
;
|
||||
|
||||
String name;
|
||||
String value;
|
||||
|
||||
IsTodoEnum(String name, String value) {
|
||||
this.name = name;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getName() {return name;}
|
||||
public String getValue() {return value;}
|
||||
}
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
package com.jero.modules.docking.hiwork.handle;
|
||||
|
||||
import com.jero.common.util.SpringContextUtils;
|
||||
import com.jero.modules.docking.hiwork.service.IHiworkMsgService;
|
||||
import com.jero.modules.message.handle.ISendMsgHandle;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* @Author: liao
|
||||
* @Date: 2023/10/17 14:29
|
||||
* @Description: Hiwork钉钉消息
|
||||
**/
|
||||
@Slf4j
|
||||
public class DingDingSendMsgHandle implements ISendMsgHandle {
|
||||
|
||||
/**
|
||||
* @Author: liao
|
||||
* @Date: 2023/10/17 14:29
|
||||
* @Description: Hiwork钉钉消息
|
||||
**/
|
||||
@Override
|
||||
public void SendMsg(String esReceiver, String esTitle, String esContent, String openType, String messageUrl) {
|
||||
IHiworkMsgService hiworkMsgService = SpringContextUtils.getBean(IHiworkMsgService.class);
|
||||
hiworkMsgService.sendDingDingMsg(Arrays.asList(esReceiver.split(",")), esTitle, esContent, messageUrl);
|
||||
}
|
||||
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
package com.jero.modules.docking.hiwork.handle;
|
||||
|
||||
import com.jero.common.util.SpringContextUtils;
|
||||
import com.jero.modules.docking.hiwork.service.IHiworkMsgService;
|
||||
import com.jero.modules.message.handle.ISendMsgHandle;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
@Slf4j
|
||||
public class SystemSendMsgHandle implements ISendMsgHandle {
|
||||
|
||||
@Override
|
||||
public void SendMsg(String esReceiver, String esTitle, String esContent, String openType, String openPage) {
|
||||
IHiworkMsgService hiworkMsgService = SpringContextUtils.getBean(IHiworkMsgService.class);
|
||||
// TODO 先写死 01 消息类型(暂未确定)
|
||||
String messageType = "01";
|
||||
hiworkMsgService.sendSystemMsg(Arrays.asList(esReceiver.split(",")), messageType, esTitle, esContent, openPage);
|
||||
}
|
||||
|
||||
}
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
package com.jero.modules.docking.hiwork.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author: liao
|
||||
* @Date: 2023/10/16 15:18
|
||||
* @Description: 统一消息集成
|
||||
*/
|
||||
public interface IHiworkMsgService {
|
||||
|
||||
/**
|
||||
* @Author: liao
|
||||
* @Date: 2023/10/16 15:32
|
||||
* @Description: 发送钉钉消息
|
||||
* senderIdList:发送人员id集合
|
||||
* title:消息标题
|
||||
* content:文本内容
|
||||
**/
|
||||
void sendDingDingMsg(List<String> senderIdList, String title, String content, String messageUrl);
|
||||
|
||||
/**
|
||||
* @Author: liao
|
||||
* @Date: 2023/10/16 16:11
|
||||
* @Description: 发送系统消息
|
||||
* senderId:发送人员id
|
||||
* receiverIdList:消息接收人id集合
|
||||
* messageType:消息类型 字典
|
||||
* title:消息标题
|
||||
* content:消息内容
|
||||
**/
|
||||
void sendSystemMsg(List<String> receiverIdList, String messageType, String title, String content, String messageUrl);
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
package com.jero.modules.docking.hiwork.service;
|
||||
|
||||
|
||||
import com.jero.common.api.dto.message.HiworkTodoAdd;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author: liao
|
||||
* @Date: 2023/10/13 14:23
|
||||
* @Description: 待办
|
||||
*/
|
||||
public interface IHiworkTodoService {
|
||||
|
||||
/**
|
||||
* @Author: liao
|
||||
* @Date: 2023/10/13 15:12
|
||||
* @Description: 统一待办集成
|
||||
**/
|
||||
void sendTodoTask(List<HiworkTodoAdd> hiworkTodoAddList);
|
||||
|
||||
}
|
||||
+152
@@ -0,0 +1,152 @@
|
||||
package com.jero.modules.docking.hiwork.service.impl;
|
||||
|
||||
import cn.hutool.core.annotation.Link;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.jero.common.exception.JeroBootException;
|
||||
import com.jero.common.system.vo.LoginUser;
|
||||
import com.jero.modules.docking.hiwork.entity.HiworkDingDingMsg;
|
||||
import com.jero.modules.docking.hiwork.entity.HiworkSystemMsg;
|
||||
import com.jero.modules.docking.hiwork.service.IHiworkMsgService;
|
||||
import com.jero.modules.docking.hiwork.util.HiworkPostUtil;
|
||||
import com.jero.common.api.vo.ResultCommon;
|
||||
import com.jero.modules.system.entity.SysUser;
|
||||
import com.jero.modules.system.service.ISysUserService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @Author: liao
|
||||
* @Date: 2023/10/16 15:18
|
||||
* @Description: 统一消息集成
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
public class HiworkMsgServiceImpl implements IHiworkMsgService {
|
||||
|
||||
@Autowired
|
||||
private HiworkPostUtil hiworkPostUtil;
|
||||
@Autowired
|
||||
private ISysUserService sysUserService;
|
||||
|
||||
private final static String TEXT = "text"; // 消息类型-文本
|
||||
private final static String LINK = "link"; // 消息类型-文本
|
||||
private final static String MSG_TYPE = "msgtype"; // 消息类型
|
||||
private final static String CONTENT = "content"; // 消息内容
|
||||
private final static String MESSAGE_URL = "messageUrl"; // 消息内容
|
||||
|
||||
/**
|
||||
* @Author: liao
|
||||
* @Date: 2023/10/16 15:32
|
||||
* @Description: 发送钉钉消息
|
||||
* senderIdList:发送人员id集合
|
||||
* content:文本内容
|
||||
**/
|
||||
@Override
|
||||
public void sendDingDingMsg(List<String> senderIdList, String title, String content, String messageUrl) {
|
||||
HiworkDingDingMsg hiworkDingDingMsg = new HiworkDingDingMsg();
|
||||
// 异步系统标识
|
||||
hiworkDingDingMsg.setSysCode(HiworkPostUtil.getSysCode());
|
||||
//服务号消息
|
||||
hiworkDingDingMsg.setNoticeServiceCode(HiworkPostUtil.getServiceCode());
|
||||
//消息推送类型
|
||||
hiworkDingDingMsg.setNoticePushType(HiworkPostUtil.Ding);
|
||||
|
||||
if (CollectionUtils.isEmpty(senderIdList)) {
|
||||
throw new JeroBootException(ResultCommon.EMPTY_COMMON, "senderIdList");
|
||||
}
|
||||
List<SysUser> senderUserList = sysUserService.listByIds(senderIdList);
|
||||
List<String> usernameList = senderUserList.stream().map(SysUser::getUsername).collect(Collectors.toList());
|
||||
// 发送人员id(工号以英文逗号分隔)
|
||||
hiworkDingDingMsg.setUseridList(StringUtils.join(usernameList, ","));
|
||||
// 标题
|
||||
hiworkDingDingMsg.setTitle(title);
|
||||
|
||||
// 消息体
|
||||
JSONObject msgJsonObject = new JSONObject();
|
||||
msgJsonObject.put(MSG_TYPE, TEXT);
|
||||
JSONObject textJsonObject = new JSONObject();
|
||||
textJsonObject.put(CONTENT, content);
|
||||
msgJsonObject.put(TEXT, textJsonObject);
|
||||
hiworkDingDingMsg.setMsg(msgJsonObject);
|
||||
|
||||
log.info("发送Hiwork钉钉消息: {}", JSONObject.toJSONString(hiworkDingDingMsg));
|
||||
|
||||
hiworkPostUtil.postDingDingMsg(hiworkDingDingMsg);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Author: liao
|
||||
* @Date: 2023/10/16 16:12
|
||||
* @Description: 发送系统消息
|
||||
* senderId:发送人员id
|
||||
* receiverIdList:消息接收人id集合
|
||||
* messageType:消息类型 字典
|
||||
* title:消息标题
|
||||
* content:消息内容
|
||||
**/
|
||||
@Override
|
||||
public void sendSystemMsg(List<String> receiverIdList, String messageType, String title, String content, String messageUrl) {
|
||||
HiworkSystemMsg hiworkSystemMsg = new HiworkSystemMsg();
|
||||
|
||||
// 异步系统标识
|
||||
hiworkSystemMsg.setSysCode(HiworkPostUtil.getSysCode());
|
||||
//消息推送类型
|
||||
hiworkSystemMsg.setNoticePushType(HiworkPostUtil.Message);
|
||||
|
||||
LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
// 发送人员编号
|
||||
hiworkSystemMsg.setSendCode(loginUser.getUsername());
|
||||
// 发送人员姓名
|
||||
hiworkSystemMsg.setSendName(loginUser.getRealname());
|
||||
// 消息标题
|
||||
hiworkSystemMsg.setTitle(title);
|
||||
// 消息类型
|
||||
hiworkSystemMsg.setMessageType(messageType);
|
||||
|
||||
if (CollectionUtils.isEmpty(receiverIdList)) {
|
||||
throw new JeroBootException(ResultCommon.EMPTY_COMMON, "receiverIdList");
|
||||
}
|
||||
List<SysUser> receiverUserList = sysUserService.listByIds(receiverIdList);
|
||||
JSONArray jsonArray = new JSONArray();
|
||||
receiverUserList.forEach(receiverUser -> {
|
||||
Map<String, String> receiverMap = new HashMap<>();
|
||||
// 人员编号
|
||||
receiverMap.put("employeeNo", receiverUser.getUsername());
|
||||
// 人员名称
|
||||
receiverMap.put("userName", receiverUser.getRealname());
|
||||
jsonArray.add(receiverMap);
|
||||
});
|
||||
// 消息接收人 集合
|
||||
hiworkSystemMsg.setReceiverList(jsonArray);
|
||||
|
||||
// 消息体
|
||||
JSONObject msgJsonObject = new JSONObject();
|
||||
msgJsonObject.put(MSG_TYPE, TEXT);
|
||||
|
||||
JSONObject textJsonObject = new JSONObject();
|
||||
textJsonObject.put(CONTENT, content);
|
||||
|
||||
JSONObject linkJsonObject = new JSONObject();
|
||||
linkJsonObject.put(MESSAGE_URL, messageUrl);
|
||||
|
||||
msgJsonObject.put(TEXT, textJsonObject);
|
||||
msgJsonObject.put(LINK, linkJsonObject);
|
||||
|
||||
hiworkSystemMsg.setMsg(msgJsonObject);
|
||||
|
||||
log.info("发送Hiwork系统消息: {}", JSONObject.toJSONString(hiworkSystemMsg));
|
||||
|
||||
hiworkPostUtil.postSystemMsg(hiworkSystemMsg);
|
||||
}
|
||||
}
|
||||
+51
@@ -0,0 +1,51 @@
|
||||
package com.jero.modules.docking.hiwork.service.impl;
|
||||
|
||||
import cn.hutool.http.HttpRequest;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.jero.common.api.vo.Result;
|
||||
import com.jero.modules.docking.hiwork.entity.HiworkUserInfo;
|
||||
import com.jero.modules.system.service.ILoginService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* @author liJiaRao
|
||||
* @date 2024-03-01 14:02
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class HiworkService {
|
||||
@Resource
|
||||
private ILoginService loginService;
|
||||
|
||||
@Value("${hiwork.appkey}")
|
||||
private String appkey;
|
||||
@Value("${hiwork.appsecret}")
|
||||
private String appsecret;
|
||||
|
||||
public Result<JSONObject> login(JSONObject jsonObject) {
|
||||
//根据appkey和appsecret获取accessToken
|
||||
String url1 = "https://oapi.dingtalk.com/gettoken?appkey=" + appkey + "&appsecret=" + appsecret;
|
||||
log.info("url:"+url1);
|
||||
String body = HttpRequest.get(url1)
|
||||
.execute().body();
|
||||
JSONObject responseJson = JSONObject.parseObject(body);
|
||||
log.info("responseJson:"+responseJson.toJSONString());
|
||||
String accessToken = responseJson.getString("access_token");
|
||||
//根据accessToken和前端传过来的jsonObject获得用户信息
|
||||
String url2 = "https://oapi.dingtalk.com/topapi/v2/user/getuserinfo?access_token=" + accessToken;
|
||||
log.info("url:"+url2);
|
||||
String body1 = HttpRequest.post(url2)
|
||||
//jsonObject中有code
|
||||
.body(jsonObject.toJSONString())
|
||||
.execute().body();
|
||||
HiworkUserInfo hiworkUserInfo = JSONObject.parseObject(body1, HiworkUserInfo.class);
|
||||
log.info("response:"+hiworkUserInfo.toString());
|
||||
String userid = hiworkUserInfo.getResult().getUserid();
|
||||
log.info("userid:"+userid);
|
||||
return loginService.loginByUserName(userid);
|
||||
}
|
||||
}
|
||||
+275
@@ -0,0 +1,275 @@
|
||||
package com.jero.modules.docking.hiwork.service.impl;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.jero.common.api.PushWorkflowIntegrationAPI;
|
||||
import com.jero.common.api.dto.message.HiworkTodoAdd;
|
||||
import com.jero.common.api.vo.ResultCommon;
|
||||
import com.jero.common.constant.enums.YesOrNoEnum;
|
||||
import com.jero.common.exception.JeroBootException;
|
||||
import com.jero.common.system.vo.LoginUser;
|
||||
import com.jero.modules.activiti.entity.ProcessAll;
|
||||
import com.jero.modules.activiti.entity.ProcessApprovalRecord;
|
||||
import com.jero.modules.activiti.entity.ProcessNode;
|
||||
import com.jero.modules.activiti.enums.ProcessTypeEnum;
|
||||
import com.jero.modules.activiti.service.ProcessAllService;
|
||||
import com.jero.modules.activiti.service.ProcessApprovalRecordService;
|
||||
import com.jero.modules.activiti.service.ProcessNodeService;
|
||||
import com.jero.modules.docking.hiwork.entity.HiworkTodo;
|
||||
import com.jero.modules.docking.hiwork.util.HiworkPostUtil;
|
||||
import com.jero.modules.system.entity.SysUser;
|
||||
import com.jero.modules.system.service.ISysUserService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.time.Instant;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @Author: liao
|
||||
* @Date: 2023/10/13 14:23
|
||||
* @Description: 待办
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class HiworkTodoServiceImpl implements PushWorkflowIntegrationAPI {
|
||||
|
||||
@Resource
|
||||
private ISysUserService sysUserService;
|
||||
@Resource
|
||||
private ProcessApprovalRecordService processApprovalRecordService;
|
||||
@Resource
|
||||
private HiworkPostUtil hiworkPostUtil;
|
||||
@Resource
|
||||
private ProcessNodeService processNodeService;
|
||||
@Resource
|
||||
private ProcessAllService processAllService;
|
||||
@Resource
|
||||
private RestTemplate restTemplate;
|
||||
|
||||
@Value("${hiwork.ip}")
|
||||
private String ip;
|
||||
@Value("${hiwork.todoUrl}")
|
||||
private String todoUrl;
|
||||
@Value("${hiwork.isWorkflow}")
|
||||
private boolean isWorkflow;
|
||||
@Value("${hiwork.sysCode}")
|
||||
private String hiworkSysCode;
|
||||
@Value("${hiwork.url}")
|
||||
private String hiworkUrl;
|
||||
@Value("${hiwork.fontUrl}")
|
||||
private String hiworkFontUrl;
|
||||
@Value("${hiwork.fontAppUrl}")
|
||||
private String hiworkFontAppUrl;
|
||||
|
||||
|
||||
private static final String PROCESS_TYPE = "srms";
|
||||
private static final String TODO_TYPE_2 = "2";
|
||||
private static final String TODO_TYPE_3 = "3";
|
||||
private static final String TODO_TYPE_6 = "6";
|
||||
|
||||
/**
|
||||
* @Author: liao
|
||||
* @Date: 2023/10/13 15:12
|
||||
* @Description: 统一待办集成
|
||||
**/
|
||||
@Override
|
||||
public void sendTodoTask(List<HiworkTodoAdd> hiworkTodoAddList) {
|
||||
if(!isWorkflow){
|
||||
return;
|
||||
}
|
||||
|
||||
if (CollectionUtils.isEmpty(hiworkTodoAddList)) {
|
||||
throw new JeroBootException(ResultCommon.EMPTY_COMMON, "hiworkTodoAddList");
|
||||
}
|
||||
try {
|
||||
List<HiworkTodo> hiworkTodoList = getHiworkTodos(hiworkTodoAddList);
|
||||
log.info("统一待办推送入参" + JSON.toJSONString(hiworkTodoList));
|
||||
log.info("统一待办推送url" + ip + todoUrl);
|
||||
// 远程调用
|
||||
JSONObject json = restTemplate.postForObject(ip + todoUrl,hiworkTodoList, JSONObject.class);
|
||||
if(!Objects.isNull(json) && json.containsKey("success") && Objects.equals("true",json.getString("success"))){
|
||||
log.info("统一待办推送成功");
|
||||
}else{
|
||||
log.info("统一待办推送失败{}",json);
|
||||
}
|
||||
}catch (Exception e){
|
||||
log.error("统一待办推送异常",e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendActivityComplete(List<HiworkTodoAdd> hiworkTodoAddList) {
|
||||
if(!isWorkflow){
|
||||
return;
|
||||
}
|
||||
try {
|
||||
for (HiworkTodoAdd hiworkTodoAdd : hiworkTodoAddList) {
|
||||
hiworkTodoAdd.setType(TODO_TYPE_3);
|
||||
}
|
||||
List<HiworkTodo> hiworkTodoList = getHiworkTodos(hiworkTodoAddList);
|
||||
log.info("统一待办推送入参" + JSON.toJSONString(hiworkTodoList));
|
||||
log.info("统一待办推送url" + ip + todoUrl);
|
||||
// 远程调用
|
||||
JSONObject json = restTemplate.postForObject(ip + todoUrl,hiworkTodoList, JSONObject.class);
|
||||
if(!Objects.isNull(json) && json.containsKey("success") && Objects.equals("true",json.getString("success"))){
|
||||
log.info("统一待办推送成功");
|
||||
}else{
|
||||
log.info("统一待办推送失败{}",json);
|
||||
}
|
||||
}catch (Exception e){
|
||||
log.error("统一待办推送异常",e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendDeleteTask(List<HiworkTodoAdd> hiworkTodoAddList) {
|
||||
if(!isWorkflow){
|
||||
return;
|
||||
}
|
||||
try {
|
||||
for (HiworkTodoAdd hiworkTodoAdd : hiworkTodoAddList) {
|
||||
hiworkTodoAdd.setType(TODO_TYPE_6);
|
||||
}
|
||||
List<HiworkTodo> hiworkTodoList = getHiworkTodos(hiworkTodoAddList);
|
||||
log.info("统一待办删除推送入参" + JSON.toJSONString(hiworkTodoList));
|
||||
log.info("统一待办推送url" + ip + todoUrl);
|
||||
// 远程调用
|
||||
JSONObject json = restTemplate.postForObject(ip + todoUrl,hiworkTodoList, JSONObject.class);
|
||||
if(!Objects.isNull(json) && json.containsKey("success") && Objects.equals("true",json.getString("success"))){
|
||||
log.info("统一待办删除推送成功");
|
||||
}else{
|
||||
log.info("统一待办删除推送失败{}",json);
|
||||
}
|
||||
}catch (Exception e){
|
||||
log.error("统一待办删除推送异常",e);
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private List<HiworkTodo> getHiworkTodos(List<HiworkTodoAdd> hiworkTodoAddList) {
|
||||
List<HiworkTodo> hiworkTodoList = new ArrayList<>();
|
||||
for (HiworkTodoAdd hiworkTodoAdd : hiworkTodoAddList) {
|
||||
String recordId = hiworkTodoAdd.getRecordId();
|
||||
String processDefinitionId = hiworkTodoAdd.getProcessDefinitionId();
|
||||
String type = hiworkTodoAdd.getType();
|
||||
ProcessApprovalRecord processApprovalRecord = processApprovalRecordService.getById(recordId);
|
||||
if(Objects.isNull(processApprovalRecord)){
|
||||
continue;
|
||||
}
|
||||
HiworkTodo hiworkTodo = new HiworkTodo();
|
||||
hiworkTodo.setSysCode(hiworkSysCode);
|
||||
|
||||
String date = DateUtil.formatDateTime(new Date());
|
||||
String taskId = processApprovalRecord.getTaskId();
|
||||
hiworkTodo.setFlowid(processApprovalRecord.getProcessInstanceId());
|
||||
hiworkTodo.setProcessId(taskId);
|
||||
hiworkTodo.setProcessType(PROCESS_TYPE);
|
||||
hiworkTodo.setTaskId(taskId);
|
||||
hiworkTodo.setTaskName(processApprovalRecord.getTaskName());
|
||||
|
||||
LambdaQueryWrapper<ProcessNode> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(ProcessNode::getProcessDefinitionId,processDefinitionId);
|
||||
wrapper.eq(ProcessNode::getNodeName,processApprovalRecord.getTaskName());
|
||||
wrapper.eq(ProcessNode::getIsView, YesOrNoEnum.YES.getValue());
|
||||
ProcessNode processNode = processNodeService.getOne(wrapper,false);
|
||||
if(!Objects.isNull(processNode)){
|
||||
if(processNode.getNodeName().contains("会签")){
|
||||
|
||||
}
|
||||
hiworkTodo.setNodeBusiCode(processNode.getXmlNodeId());
|
||||
// 是否显示(0否,1是)
|
||||
hiworkTodo.setIsShow(String.valueOf(processNode.getIsView()));
|
||||
}
|
||||
String userId;
|
||||
if (hiworkTodoAdd.getToUserId() == null){
|
||||
userId = processApprovalRecord.getUserId();
|
||||
}else {
|
||||
userId = hiworkTodoAdd.getToUserId();
|
||||
}
|
||||
SysUser sysUser = sysUserService.getById(userId);
|
||||
|
||||
String noticeTitle = processApprovalRecord.getTaskName() + "(" + sysUser.getRealname() + " " + date + ")";
|
||||
LambdaQueryWrapper<ProcessAll> queryProcessAll = new LambdaQueryWrapper<>();
|
||||
queryProcessAll.eq(ProcessAll::getProcessInstanceId,processApprovalRecord.getProcessInstanceId());
|
||||
ProcessAll processAll = processAllService.getOne(queryProcessAll);
|
||||
if(!Objects.isNull(processAll)){
|
||||
String processName = ProcessTypeEnum.getNameByValue(processAll.getPrcType());
|
||||
noticeTitle = processName + "(" + sysUser.getRealname() + " " + date + ")";
|
||||
hiworkTodo.setProcessName(processName);
|
||||
|
||||
SysUser createUser = sysUserService.getById(processAll.getCreateUserId());
|
||||
if(!Objects.isNull(createUser)){
|
||||
hiworkTodo.setCreateUserCode(createUser.getUsername());
|
||||
hiworkTodo.setCreateUserName(createUser.getRealname());
|
||||
}
|
||||
if(!Objects.isNull(processAll.getDueTime())){
|
||||
hiworkTodo.setDueTime(processAll.getDueTime().getTime());
|
||||
}
|
||||
String projectId = "";
|
||||
if (StrUtil.isNotBlank(processAll.getProjectId())){
|
||||
projectId = processAll.getProjectId();
|
||||
}
|
||||
hiworkTodo.setBid(projectId);
|
||||
String url = hiworkFontUrl
|
||||
//.replaceAll("&","%26")
|
||||
//.replaceAll("\\?","%3F")
|
||||
.replace("{projectId}",projectId)
|
||||
.replace("{taskName}",processApprovalRecord.getTaskName())
|
||||
.replace("{taskId}", taskId)
|
||||
.replace("{processInstanceId}",processApprovalRecord.getProcessInstanceId())
|
||||
.replace("{nodeId}",processApprovalRecord.getNodeId());
|
||||
// 跳转链接
|
||||
String businessLink = Objects.requireNonNull(ProcessTypeEnum.getFontReturnUrlPc(processAll.getPrcType())) + url;
|
||||
hiworkTodo.setBusinessLink(businessLink);
|
||||
// APP跳转链接
|
||||
String appUrl = hiworkFontAppUrl
|
||||
//.replaceAll("&","%26")
|
||||
//.replaceAll("\\?","%3F")
|
||||
.replace("{projectId}",projectId)
|
||||
.replace("{taskName}",processApprovalRecord.getTaskName())
|
||||
.replace("{taskId}", taskId)
|
||||
.replace("{processInstanceId}",processApprovalRecord.getProcessInstanceId())
|
||||
.replace("{nodeId}",processApprovalRecord.getNodeId());
|
||||
String appBusinessLink = appUrl.replace("{url}", Objects.requireNonNull(ProcessTypeEnum.getFontReturnUrlPc(processAll.getPrcType())));
|
||||
hiworkTodo.setAppBusinessLink(appBusinessLink);
|
||||
}
|
||||
hiworkTodo.setNoticeTitle(noticeTitle);
|
||||
hiworkTodo.setUserId(userId);
|
||||
hiworkTodo.setUserCode(sysUser.getUsername());
|
||||
hiworkTodo.setUserName(sysUser.getRealname());
|
||||
hiworkTodo.setReceiveTime(Instant.now());
|
||||
//2已完成时进入下一节点
|
||||
Integer finishFlag = processApprovalRecord.getFinishFlag();
|
||||
if (finishFlag.equals(2)){
|
||||
hiworkTodo.setMultiInstance(0);
|
||||
}else {
|
||||
hiworkTodo.setMultiInstance(1);
|
||||
}
|
||||
if (TODO_TYPE_3.equals(type)){
|
||||
hiworkTodo.setIsTodo(TODO_TYPE_3);
|
||||
}else if (TODO_TYPE_6.equals(type)){
|
||||
hiworkTodo.setIsTodo(TODO_TYPE_6);
|
||||
}else if (TODO_TYPE_2.equals(type)){
|
||||
hiworkTodo.setIsTodo(TODO_TYPE_2);
|
||||
}else {
|
||||
hiworkTodo.setIsTodo(String.valueOf(finishFlag));
|
||||
}
|
||||
hiworkTodoList.add(hiworkTodo);
|
||||
}
|
||||
return hiworkTodoList;
|
||||
}
|
||||
|
||||
}
|
||||
+8
-2
@@ -1,10 +1,12 @@
|
||||
package com.jero.modules.common.service.impl;
|
||||
package com.jero.modules.docking.hiwork.service.impl;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.jero.common.api.SendMessageAPI;
|
||||
import com.jero.common.api.dto.message.SendMessageDTO;
|
||||
import com.jero.common.exception.JeroBootException;
|
||||
import com.jero.modules.common.service.SendMessageAPI;
|
||||
import com.jero.modules.docking.hiwork.handle.DingDingSendMsgHandle;
|
||||
import com.jero.modules.docking.hiwork.handle.SystemSendMsgHandle;
|
||||
import com.jero.modules.message.entity.SysMessageTemplate;
|
||||
import com.jero.modules.message.handle.ISendMsgHandle;
|
||||
import com.jero.modules.message.handle.impl.SmsSendMsgHandle;
|
||||
@@ -16,6 +18,10 @@ import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.CharsetEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
+147
@@ -0,0 +1,147 @@
|
||||
package com.jero.modules.docking.hiwork.util;
|
||||
|
||||
import cn.hutool.http.Header;
|
||||
import cn.hutool.http.HttpResponse;
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.jero.common.exception.JeroBootException;
|
||||
import com.jero.modules.docking.hiwork.entity.HiworkResult;
|
||||
import com.jero.modules.docking.hiwork.entity.HiworkTodo;
|
||||
import com.jero.modules.docking.hiwork.entity.HiworkDingDingMsg;
|
||||
import com.jero.modules.docking.hiwork.entity.HiworkSystemMsg;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.http.HttpEntity;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static net.sf.jsqlparser.parser.feature.Feature.execute;
|
||||
|
||||
/**
|
||||
* @Author: liao
|
||||
* @Date: 2023/10/13 16:55
|
||||
* @Description: Hiwork集成
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class HiworkPostUtil {
|
||||
@Autowired
|
||||
private RestTemplate restTemplate;
|
||||
@Value("${hiwork.ip}")
|
||||
private String ip;
|
||||
@Value("${hiwork.todoUrl}")
|
||||
private String todoUrl;
|
||||
@Value("${hiwork.messageUrl}")
|
||||
private String messageUrl;
|
||||
|
||||
// 异构系统标识
|
||||
private static String sysCode;
|
||||
|
||||
@Value("${hiwork.sysCode}")
|
||||
public void setSysCode(String sysCode) {
|
||||
HiworkPostUtil.sysCode = sysCode;
|
||||
}
|
||||
|
||||
public static String getSysCode() {
|
||||
return sysCode;
|
||||
}
|
||||
// 异构系统标识
|
||||
private static String serviceCode;
|
||||
|
||||
@Value("${hiwork.serviceCode}")
|
||||
public void setServiceCode(String serviceCode) {
|
||||
HiworkPostUtil.serviceCode = serviceCode;
|
||||
}
|
||||
|
||||
public static String getServiceCode() {
|
||||
return serviceCode;
|
||||
}
|
||||
public static String Ding = "ding";
|
||||
public static String Message = "message";
|
||||
|
||||
/**
|
||||
* @Author: liao
|
||||
* @Date: 2023/10/13 17:45
|
||||
* @Description: 远程调用Hiwork
|
||||
**/
|
||||
private void postHiwork(String jsonString, String url) {
|
||||
log.info("远程调用Hiwork,url: {}, body: {}",url,jsonString);
|
||||
// 设置请求头
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.setContentType(MediaType.APPLICATION_JSON);
|
||||
|
||||
HttpEntity<String> requestEntity = new HttpEntity<>(jsonString, headers);
|
||||
|
||||
// 发送 POST 请求并获取响应
|
||||
HttpResponse response = HttpUtil.createPost(url)
|
||||
.header(Header.CONTENT_TYPE, "application/json")
|
||||
.body(jsonString)
|
||||
.execute();
|
||||
// 处理响应数据
|
||||
if (response.isOk()) {
|
||||
String body = response.body();
|
||||
HiworkResult hiworkResult = JSONObject.parseObject(body, HiworkResult.class);
|
||||
if (!hiworkResult.getSuccess()) {
|
||||
throw new JeroBootException("Hiwork:" + hiworkResult.getMsg());
|
||||
}
|
||||
} else {
|
||||
throw new JeroBootException("Hiwork: request failed with status code: " + response.getStatus());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @Author: liao
|
||||
* @Date: 2023/10/13 17:45
|
||||
* @Description: 统一待办集成远程调用
|
||||
**/
|
||||
public void postTodo(List<HiworkTodo> hiworkTodoList) {
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
String jsonString;
|
||||
try {
|
||||
jsonString = objectMapper.writeValueAsString(hiworkTodoList);
|
||||
} catch (JsonProcessingException e) {
|
||||
throw new JeroBootException("JSON string format conversion error");
|
||||
}
|
||||
postHiwork(jsonString, ip + todoUrl);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Author: liao
|
||||
* @Date: 2023/10/13 17:45
|
||||
* @Description: 统一消息集成远程调用-钉钉消息
|
||||
**/
|
||||
public void postDingDingMsg(HiworkDingDingMsg hiworkDingDingMsg) {
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
String jsonString;
|
||||
try {
|
||||
jsonString = objectMapper.writeValueAsString(hiworkDingDingMsg);
|
||||
} catch (JsonProcessingException e) {
|
||||
throw new JeroBootException("JSON string format conversion error");
|
||||
}
|
||||
postHiwork(jsonString, ip + messageUrl);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Author: liao
|
||||
* @Date: 2023/10/13 17:45
|
||||
* @Description: 统一消息集成远程调用-系统消息
|
||||
**/
|
||||
public void postSystemMsg(HiworkSystemMsg hiworkSystemMsg) {
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
String jsonString;
|
||||
try {
|
||||
jsonString = objectMapper.writeValueAsString(hiworkSystemMsg);
|
||||
} catch (JsonProcessingException e) {
|
||||
throw new JeroBootException("JSON string format conversion error");
|
||||
}
|
||||
postHiwork(jsonString, ip + messageUrl);
|
||||
}
|
||||
}
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
package com.jero.modules.docking.iam.annotation;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
@Target({ElementType.FIELD})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
@Inherited
|
||||
public @interface IamProperty {
|
||||
|
||||
// /**
|
||||
// * 字段属性名
|
||||
// * @return
|
||||
// */
|
||||
// String name() default "";
|
||||
//
|
||||
// /**
|
||||
// *
|
||||
// * @return
|
||||
// */
|
||||
// String type() default "";
|
||||
|
||||
/**
|
||||
* 定义对象的属性字段在创建时是否为必填字段
|
||||
* @return
|
||||
*/
|
||||
boolean required() default true;
|
||||
|
||||
/**
|
||||
* 定义对象的属性字段是否为多值
|
||||
* @return
|
||||
*/
|
||||
boolean multivalued() default false;
|
||||
|
||||
}
|
||||
+322
@@ -0,0 +1,322 @@
|
||||
package com.jero.modules.docking.iam.client;
|
||||
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import com.bamboocloud.codec.BamboocloudFacade;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.jero.common.util.DateUtils;
|
||||
import com.jero.common.util.UUIDGenerator;
|
||||
import com.jero.common.util.UUIDUtils;
|
||||
import com.jero.modules.docking.iam.dto.IamCommonAcceptDto;
|
||||
import com.jero.modules.docking.iam.dto.IamOrgAcceptDto;
|
||||
import com.jero.modules.docking.iam.dto.IamUserAcceptDto;
|
||||
import com.jero.modules.docking.iam.po.encrypt.AcceptEncryptPo;
|
||||
import com.jero.modules.docking.iam.po.MessageHeader;
|
||||
import com.jero.modules.docking.iam.po.encrypt.MessageEncryptTabels;
|
||||
import com.jero.modules.docking.iam.po.encrypt.MessageEncryptTabelsHeader;
|
||||
import com.jero.modules.docking.iam.po.encrypt.SendPoEncryptPo;
|
||||
import com.jero.modules.docking.utils.BamboocloudUtils;
|
||||
import com.jero.modules.docking.utils.DockingConstant;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 测试接口是否正确的客户端,mock IAM发送请求
|
||||
*/
|
||||
public class TestClient {
|
||||
|
||||
public static void main(String[] args) throws JsonProcessingException {
|
||||
TestClient testClient = new TestClient();
|
||||
// testClient.sendSchemaService(); // 字段映射接口测试
|
||||
// for (int i = 0; i < 1; i++) {
|
||||
// System.out.println(i);
|
||||
// testClient.sendUserCreate(i);
|
||||
// }
|
||||
// 创建用户接口测试
|
||||
// testClient.sendUserUpdate(); // 更新用户接口测试
|
||||
// testClient.sendOrgCreate(); // 组织创建接口测试
|
||||
// testClient.sendQueryAllUserIdsService(); // 查询所有用户ID接口测试
|
||||
// testClient.sendQueryAllOrgIdsService(); // 查询所有组织ID接口测试
|
||||
// testClient.sendQueryOrgByIdService(); // 查询指定id的组织数据测试
|
||||
// testClient.sendQueryUserByIdService(); // 查询指定id的用户数据测试
|
||||
testClient.decryptSting("8rAKWPUwkEZ3yYLy/1TuGGkIGCYtc+MD56pShLi97OmMttoFooo5GXZ/lY4NrQ5DiWmVUX23zqDwyQqufXLZNDU+KuJO/9UonpqUlZxM91w=");
|
||||
}
|
||||
|
||||
private void decryptSting(String encryptString) {
|
||||
String decrypt = BamboocloudUtils.getPlaintext(encryptString, DockingConstant.IAM_ENCRYPT_SECRET, DockingConstant.IAM_ENCRYPT_TYPE);
|
||||
System.out.println("解密后数据:" + decrypt);
|
||||
}
|
||||
|
||||
// 对数据解密
|
||||
private void decryptData(String encryptData) throws JsonProcessingException {
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
SendPoEncryptPo sendPoEncryptPo = objectMapper.readValue(encryptData, SendPoEncryptPo.class);
|
||||
String decrypt = BamboocloudUtils.getPlaintext(sendPoEncryptPo.getReturns().getData(), DockingConstant.IAM_ENCRYPT_SECRET, DockingConstant.IAM_ENCRYPT_TYPE);
|
||||
|
||||
System.out.println("解密后数据:" + decrypt);
|
||||
}
|
||||
|
||||
/**
|
||||
* 封装统一发送的PO层
|
||||
* @param encryptData
|
||||
* @return
|
||||
*/
|
||||
private AcceptEncryptPo handlerPoPackage(String encryptData) {
|
||||
MessageHeader messageHeader = new MessageHeader();
|
||||
messageHeader.setInterfaceID("SRMSUSERCREATE");
|
||||
messageHeader.setUUID(UUIDGenerator.generate());
|
||||
messageHeader.setMessageId(UUIDGenerator.generate());
|
||||
messageHeader.setSender(DockingConstant.IAM_SYSTEM_NAME);
|
||||
messageHeader.setReceiver(DockingConstant.SYSTEM_NAME);
|
||||
|
||||
Date curDate = new Date();
|
||||
messageHeader.setSendDate(DateUtils.formatDate(curDate, "YYYYMMDD"));
|
||||
messageHeader.setSendTime(DateUtils.formatDate(curDate, "HHmmss"));
|
||||
|
||||
MessageEncryptTabelsHeader messageEncryptTabelsHeader = new MessageEncryptTabelsHeader();
|
||||
messageEncryptTabelsHeader.setData(encryptData);
|
||||
|
||||
MessageEncryptTabels messageEncryptTabels = new MessageEncryptTabels();
|
||||
messageEncryptTabels.setHeader(messageEncryptTabelsHeader);
|
||||
|
||||
AcceptEncryptPo acceptEncryptPo = new AcceptEncryptPo();
|
||||
acceptEncryptPo.setMessageHeader(messageHeader);
|
||||
acceptEncryptPo.setMessageEncryptTabels(messageEncryptTabels);
|
||||
|
||||
return acceptEncryptPo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Schema映射获取
|
||||
*/
|
||||
private void sendSchemaService() throws JsonProcessingException {
|
||||
String url = "http://localhost:8184/laws-sinotruk/sync/iam/UserCreateService";
|
||||
|
||||
IamCommonAcceptDto iamCommonAcceptDto = new IamCommonAcceptDto();
|
||||
iamCommonAcceptDto.setBimRequestId(UUIDUtils.randomUUID20());
|
||||
iamCommonAcceptDto.setBimRemoteUser("srmsIam");
|
||||
iamCommonAcceptDto.setBimRemotePwd("srmsIam2023");
|
||||
|
||||
// 加密数据
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
String sendData = objectMapper.writeValueAsString(iamCommonAcceptDto);
|
||||
String encryptData = BamboocloudFacade.encrypt(sendData, DockingConstant.IAM_ENCRYPT_SECRET, DockingConstant.IAM_ENCRYPT_TYPE);
|
||||
|
||||
AcceptEncryptPo sendPoDataEntity = handlerPoPackage(encryptData);
|
||||
String sendPoDataJson = objectMapper.writeValueAsString(sendPoDataEntity);
|
||||
|
||||
String response = HttpUtil.post(url, sendPoDataJson);
|
||||
System.out.println("映射接口响应:" + response);
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户创建测试
|
||||
*/
|
||||
private void sendUserCreate(int i) throws JsonProcessingException {
|
||||
// 封装 IamUserAcceptDto 为用户数据层
|
||||
IamUserAcceptDto iamUserAcceptDto = new IamUserAcceptDto();
|
||||
iamUserAcceptDto.setSrmsCompanyCode("123");
|
||||
iamUserAcceptDto.setSrmsOrgCode("123/321");
|
||||
iamUserAcceptDto.setSrmsTypeId("001");
|
||||
iamUserAcceptDto.setSrmsUsername((108088 + i) +"");
|
||||
iamUserAcceptDto.setSrmsRealname("测试" + i);
|
||||
iamUserAcceptDto.setSrmsPassword("1qaz@WSX");
|
||||
iamUserAcceptDto.setSrmsSex("1"); // 男
|
||||
iamUserAcceptDto.setSrmsPost("主任");
|
||||
iamUserAcceptDto.setSrmsDutyLevelId("4"); // 主管级,srms不解析,直接存
|
||||
iamUserAcceptDto.setSrmsDirectLeadership("1706939999105900545"); // 直接上级,不清楚应该存什么,暂时存为id(fcc-test)
|
||||
iamUserAcceptDto.setSrmsPostStatus("1"); // 在岗,srms不解析,直接存
|
||||
iamUserAcceptDto.setSrmsStatus("1"); // 1在册,0离职
|
||||
iamUserAcceptDto.setSrmsOfficePhone("022-87648762");
|
||||
iamUserAcceptDto.setSrmsPhone("13811112232");
|
||||
iamUserAcceptDto.setSrmsEmail("test@sinotruk.com");
|
||||
iamUserAcceptDto.setSrmsCreateTime("2023-10-15 10:35:20");
|
||||
|
||||
iamUserAcceptDto.setBimRequestId(UUIDUtils.randomUUID20());
|
||||
iamUserAcceptDto.setBimRemoteUser("srmsIam");
|
||||
iamUserAcceptDto.setBimRemotePwd("srmsIam2023");
|
||||
|
||||
// 加密数据
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
String sendData = objectMapper.writeValueAsString(iamUserAcceptDto);
|
||||
String encryptData = BamboocloudFacade.encrypt(sendData, DockingConstant.IAM_ENCRYPT_SECRET, DockingConstant.IAM_ENCRYPT_TYPE);
|
||||
|
||||
// 封装 AcceptPoSystemPo 为PO层套壳
|
||||
AcceptEncryptPo sendPoDataEntity = handlerPoPackage(encryptData);
|
||||
String sendPoDataJson = objectMapper.writeValueAsString(sendPoDataEntity);
|
||||
|
||||
// 发送数据
|
||||
String url = "http://localhost:8184/laws-sinotruk/sync/iam/UserCreateService";
|
||||
// String url = "laws-test.sinotruk.com/laws-sinotruk/sync/iam/UserCreateService";
|
||||
String response = HttpUtil.post(url, sendPoDataJson);
|
||||
System.out.println("用户创建接口响应:" + response);
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户更新测试
|
||||
*/
|
||||
private void sendUserUpdate() throws JsonProcessingException {
|
||||
// 封装 IamUserAcceptDto 为用户数据层
|
||||
IamUserAcceptDto iamUserAcceptDto = new IamUserAcceptDto();
|
||||
iamUserAcceptDto.setBimUid("1709786346053017601"); // 数据库中取到的ID
|
||||
iamUserAcceptDto.setSrmsPost("科长");
|
||||
iamUserAcceptDto.setSrmsUpdateTime("2023-10-15 10:35:20"); // 测试不发送UpdateTime的情况
|
||||
|
||||
iamUserAcceptDto.setBimRequestId(UUIDUtils.randomUUID20());
|
||||
iamUserAcceptDto.setBimRemoteUser("srmsIam");
|
||||
iamUserAcceptDto.setBimRemotePwd("srmsIam2023");
|
||||
|
||||
// 加密数据
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
String sendData = objectMapper.writeValueAsString(iamUserAcceptDto);
|
||||
String encryptData = BamboocloudFacade.encrypt(sendData, DockingConstant.IAM_ENCRYPT_SECRET, DockingConstant.IAM_ENCRYPT_TYPE);
|
||||
|
||||
// 封装 AcceptPoSystemPo 为PO层套壳
|
||||
AcceptEncryptPo sendPoDataEntity = handlerPoPackage(encryptData);
|
||||
String sendPoDataJson = objectMapper.writeValueAsString(sendPoDataEntity);
|
||||
|
||||
// 发送数据
|
||||
String url = "http://localhost:8184/laws-sinotruk/sync/iam/UserUpdateService";
|
||||
String response = HttpUtil.post(url, sendPoDataJson);
|
||||
System.out.println("用户更新接口响应:" + response);
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户创建测试
|
||||
*/
|
||||
private void sendOrgCreate() throws JsonProcessingException {
|
||||
// 封装 IamUserAcceptDto 为用户数据层
|
||||
IamOrgAcceptDto iamOrgAcceptDto = new IamOrgAcceptDto();
|
||||
|
||||
iamOrgAcceptDto.setSrmsOrgCode("IA00102");
|
||||
iamOrgAcceptDto.setSrmsDepartName("测试IAM部门");
|
||||
iamOrgAcceptDto.setSrmsParentCode("");
|
||||
iamOrgAcceptDto.setSrmsCompany("测试公司");
|
||||
iamOrgAcceptDto.setSrmsStatus("1");
|
||||
iamOrgAcceptDto.setSrmsCreateTime("2023-10-12 10:35:20");
|
||||
iamOrgAcceptDto.setSrmsType("002");
|
||||
iamOrgAcceptDto.setSrmsOrgCategory("2");
|
||||
|
||||
iamOrgAcceptDto.setBimRequestId(UUIDUtils.randomUUID20());
|
||||
iamOrgAcceptDto.setBimRemoteUser("srmsIam");
|
||||
iamOrgAcceptDto.setBimRemotePwd("srmsIam2023");
|
||||
|
||||
// 加密数据
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
String sendData = objectMapper.writeValueAsString(iamOrgAcceptDto);
|
||||
String encryptData = BamboocloudFacade.encrypt(sendData, DockingConstant.IAM_ENCRYPT_SECRET, DockingConstant.IAM_ENCRYPT_TYPE);
|
||||
|
||||
// 封装 AcceptPoSystemPo 为PO层套壳
|
||||
AcceptEncryptPo sendPoDataEntity = handlerPoPackage(encryptData);
|
||||
String sendPoDataJson = objectMapper.writeValueAsString(sendPoDataEntity);
|
||||
|
||||
// 发送数据
|
||||
String url = "http://localhost:8184/laws-sinotruk/sync/iam/OrgCreateService";
|
||||
String response = HttpUtil.post(url, sendPoDataJson);
|
||||
System.out.println("组织创建接口响应:" + response);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取全部用户id
|
||||
*/
|
||||
private void sendQueryAllUserIdsService() throws JsonProcessingException {
|
||||
String url = "http://localhost:8184/laws-sinotruk/sync/iam/QueryAllUserIdsService";
|
||||
|
||||
IamCommonAcceptDto iamCommonAcceptDto = new IamCommonAcceptDto();
|
||||
iamCommonAcceptDto.setBimRequestId(UUIDUtils.randomUUID20());
|
||||
iamCommonAcceptDto.setBimRemoteUser("srmsIam");
|
||||
iamCommonAcceptDto.setBimRemotePwd("srmsIam2023");
|
||||
|
||||
// 加密数据
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
String sendData = objectMapper.writeValueAsString(iamCommonAcceptDto);
|
||||
String encryptData = BamboocloudFacade.encrypt(sendData, DockingConstant.IAM_ENCRYPT_SECRET, DockingConstant.IAM_ENCRYPT_TYPE);
|
||||
|
||||
AcceptEncryptPo sendPoDataEntity = handlerPoPackage(encryptData);
|
||||
String sendPoDataJson = objectMapper.writeValueAsString(sendPoDataEntity);
|
||||
String response = HttpUtil.post(url, sendPoDataJson);
|
||||
System.out.println("查询全部用户id接口响应:" + response);
|
||||
|
||||
this.decryptData(response);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取全部组织id
|
||||
*/
|
||||
private void sendQueryAllOrgIdsService() throws JsonProcessingException {
|
||||
String url = "http://localhost:8184/laws-sinotruk/sync/iam/QueryAllOrgIdsService";
|
||||
|
||||
IamCommonAcceptDto iamCommonAcceptDto = new IamCommonAcceptDto();
|
||||
iamCommonAcceptDto.setBimRequestId(UUIDUtils.randomUUID20());
|
||||
iamCommonAcceptDto.setBimRemoteUser("srmsIam");
|
||||
iamCommonAcceptDto.setBimRemotePwd("srmsIam2023");
|
||||
|
||||
// 加密数据
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
String sendData = objectMapper.writeValueAsString(iamCommonAcceptDto);
|
||||
String encryptData = BamboocloudFacade.encrypt(sendData, DockingConstant.IAM_ENCRYPT_SECRET, DockingConstant.IAM_ENCRYPT_TYPE);
|
||||
|
||||
AcceptEncryptPo sendPoDataEntity = handlerPoPackage(encryptData);
|
||||
String sendPoDataJson = objectMapper.writeValueAsString(sendPoDataEntity);
|
||||
|
||||
String response = HttpUtil.post(url, sendPoDataJson);
|
||||
System.out.println("查询全部组织id接口响应:" + response);
|
||||
|
||||
this.decryptData(response);
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户查询接口测试
|
||||
*/
|
||||
private void sendQueryUserByIdService() throws JsonProcessingException {
|
||||
// 封装 IamUserAcceptDto 为用户数据层
|
||||
IamUserAcceptDto iamUserAcceptDto = new IamUserAcceptDto();
|
||||
iamUserAcceptDto.setBimUid("1709786346053017601"); // 数据库中取到的ID
|
||||
iamUserAcceptDto.setBimRemoteUser("srmsIam");
|
||||
iamUserAcceptDto.setBimRemotePwd("srmsIam2023");
|
||||
|
||||
// 加密数据
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
String sendData = objectMapper.writeValueAsString(iamUserAcceptDto);
|
||||
String encryptData = BamboocloudFacade.encrypt(sendData, DockingConstant.IAM_ENCRYPT_SECRET, DockingConstant.IAM_ENCRYPT_TYPE);
|
||||
|
||||
// 封装 AcceptPoSystemPo 为PO层套壳
|
||||
AcceptEncryptPo sendPoDataEntity = handlerPoPackage(encryptData);
|
||||
String sendPoDataJson = objectMapper.writeValueAsString(sendPoDataEntity);
|
||||
|
||||
// 发送数据
|
||||
String url = "http://localhost:8184/laws-sinotruk/sync/iam/QueryUserByIdService";
|
||||
String response = HttpUtil.post(url, sendPoDataJson);
|
||||
System.out.println("用户查询接口响应:" + response);
|
||||
|
||||
this.decryptData(response);
|
||||
}
|
||||
|
||||
/**
|
||||
* 组织查询接口测试
|
||||
*/
|
||||
private void sendQueryOrgByIdService() throws JsonProcessingException {
|
||||
// 封装 IamUserAcceptDto 为用户数据层
|
||||
IamOrgAcceptDto iamOrgAcceptDto = new IamOrgAcceptDto();
|
||||
iamOrgAcceptDto.setBimOrgId("IA00102"); // 数据库中取到的ID
|
||||
iamOrgAcceptDto.setBimRemoteUser("srmsIam");
|
||||
iamOrgAcceptDto.setBimRemotePwd("srmsIam2023");
|
||||
|
||||
// 加密数据
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
String sendData = objectMapper.writeValueAsString(iamOrgAcceptDto);
|
||||
String encryptData = BamboocloudFacade.encrypt(sendData, DockingConstant.IAM_ENCRYPT_SECRET, DockingConstant.IAM_ENCRYPT_TYPE);
|
||||
|
||||
// 封装 AcceptPoSystemPo 为PO层套壳
|
||||
AcceptEncryptPo sendPoDataEntity = handlerPoPackage(encryptData);
|
||||
String sendPoDataJson = objectMapper.writeValueAsString(sendPoDataEntity);
|
||||
|
||||
// 发送数据
|
||||
String url = "http://localhost:8184/laws-sinotruk/sync/iam/QueryOrgByIdService";
|
||||
String response = HttpUtil.post(url, sendPoDataJson);
|
||||
System.out.println("组织查询接口响应:" + response);
|
||||
|
||||
this.decryptData(response);
|
||||
}
|
||||
|
||||
}
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
package com.jero.modules.docking.iam.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.jero.common.api.vo.Result;
|
||||
import com.jero.modules.system.entity.Oauth;
|
||||
import com.jero.modules.system.service.ILoginService;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* @Author: yjz
|
||||
* @Date: 2023/10/17/10:09
|
||||
* @Description:
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/iam")
|
||||
@Slf4j
|
||||
public class IamLoginController {
|
||||
private final ILoginService loginService;
|
||||
|
||||
public IamLoginController(ILoginService loginService) {
|
||||
this.loginService = loginService;
|
||||
}
|
||||
|
||||
@ApiOperation("单点登录")
|
||||
@PostMapping("/loginByOauth2")
|
||||
public Result<JSONObject> loginByOauth2(@Validated @RequestBody Oauth oauth){
|
||||
return loginService.loginByOauth2(oauth);
|
||||
}
|
||||
}
|
||||
+599
@@ -0,0 +1,599 @@
|
||||
package com.jero.modules.docking.iam.controller;
|
||||
|
||||
import cn.hutool.core.text.CharSequenceUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.aliyun.oss.ServiceException;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.jero.common.constant.CacheConstant;
|
||||
import com.jero.modules.base.service.BaseCommonService;
|
||||
import com.jero.modules.docking.iam.dto.IamCommonAcceptDto;
|
||||
import com.jero.modules.docking.iam.dto.IamOrgAcceptDto;
|
||||
import com.jero.modules.docking.iam.dto.IamUserAcceptDto;
|
||||
import com.jero.modules.docking.iam.dto.bpmc.*;
|
||||
import com.jero.modules.docking.iam.dto.response.*;
|
||||
import com.jero.modules.docking.iam.exception.IamGlobalException;
|
||||
import com.jero.modules.docking.iam.po.MessageHeader;
|
||||
import com.jero.modules.docking.iam.po.decrypt.AcceptDecryptPo;
|
||||
import com.jero.modules.docking.iam.po.encrypt.AcceptEncryptPo;
|
||||
import com.jero.modules.docking.iam.po.encrypt.SendPoEncryptPo;
|
||||
import com.jero.modules.docking.iam.service.SyncIamService;
|
||||
import com.jero.modules.docking.utils.BamboocloudUtils;
|
||||
import com.jero.modules.docking.utils.DockingConstant;
|
||||
import com.jero.modules.docking.utils.SHA256Util;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
import org.springframework.dao.DuplicateKeyException;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* IAM同步的控制器,提供用户、组织、菜单和权限的同步
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/sync/iam")
|
||||
@Slf4j
|
||||
public class SyncIamController {
|
||||
|
||||
@Value("${iam.bpmcAppkey}")
|
||||
private String bpmcAppkey;
|
||||
|
||||
@Resource
|
||||
private SyncIamService syncIamService;
|
||||
|
||||
public final String paramNotGetError = "参数传递错误,未收到参数";
|
||||
|
||||
@Resource
|
||||
private BaseCommonService baseCommonService;
|
||||
|
||||
@PostMapping({"/SchemaService"})
|
||||
public SendPoEncryptPo schemaService(@RequestBody AcceptEncryptPo iamCommon) throws JsonProcessingException {
|
||||
if (iamCommon == null
|
||||
|| iamCommon.getMessageEncryptTabels() == null
|
||||
|| iamCommon.getMessageEncryptTabels().getHeader() == null
|
||||
|| iamCommon.getMessageEncryptTabels().getHeader().getData() == null){
|
||||
throw new IamGlobalException(null, this.paramNotGetError);
|
||||
}
|
||||
|
||||
// 对核心数据解密
|
||||
String bodyParam = iamCommon.getMessageEncryptTabels().getHeader().getData();
|
||||
String bodyParamDecrypt = BamboocloudUtils.getPlaintext(bodyParam, DockingConstant.IAM_ENCRYPT_SECRET, DockingConstant.IAM_ENCRYPT_TYPE);
|
||||
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
IamCommonAcceptDto commonAcceptDto = objectMapper.readValue(bodyParamDecrypt, IamCommonAcceptDto.class);
|
||||
|
||||
// 校验身份认证,确保接口正确 必须调用!
|
||||
this.syncIamService.validateUserAndPwd(commonAcceptDto);
|
||||
|
||||
// 处理业务逻辑,封装字段
|
||||
IamSchemaResponse iamSchemaResponse = this.syncIamService.getSchemaInfo(commonAcceptDto);
|
||||
|
||||
// 处理统一响应PO层,并加密业务字段
|
||||
MessageHeader acceptMessageHeader = iamCommon.getMessageHeader();
|
||||
SendPoEncryptPo sendPoEncryptPo = this.syncIamService.handlerGloablEncryptResponse(acceptMessageHeader, iamSchemaResponse);
|
||||
|
||||
return sendPoEncryptPo;
|
||||
}
|
||||
|
||||
@PostMapping({"/UserCreateService"})
|
||||
public SendPoEncryptPo userCreateService(@RequestBody AcceptEncryptPo iamUserInfo) throws JsonProcessingException {
|
||||
log.info("进入账号创建");
|
||||
IamUserAcceptDto userAcceptDto = null;
|
||||
IamUserCreateResponse iamUserCreateResponse = new IamUserCreateResponse();
|
||||
SendPoEncryptPo sendPoEncryptPo = new SendPoEncryptPo();
|
||||
try {
|
||||
if (iamUserInfo == null
|
||||
|| iamUserInfo.getMessageEncryptTabels() == null
|
||||
|| iamUserInfo.getMessageEncryptTabels().getHeader() == null
|
||||
|| iamUserInfo.getMessageEncryptTabels().getHeader().getData() == null){
|
||||
throw new IamGlobalException(null, "参数传递错误,未收到参数");
|
||||
}
|
||||
|
||||
// 对核心数据解密
|
||||
String bodyParam = iamUserInfo.getMessageEncryptTabels().getHeader().getData();
|
||||
String bodyParamDecrypt = BamboocloudUtils.getPlaintext(bodyParam, DockingConstant.IAM_ENCRYPT_SECRET, DockingConstant.IAM_ENCRYPT_TYPE);
|
||||
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
userAcceptDto = objectMapper.readValue(bodyParamDecrypt, IamUserAcceptDto.class);
|
||||
|
||||
// 校验身份认证,确保接口正确 必须调用!
|
||||
this.syncIamService.validateUserAndPwd(userAcceptDto);
|
||||
iamUserCreateResponse.setBimRequestId(userAcceptDto.getBimRequestId());
|
||||
// 处理业务逻辑,存储用户,返回用户id
|
||||
iamUserCreateResponse = this.syncIamService.userCreateService(userAcceptDto);
|
||||
} catch (ServiceException e) {
|
||||
iamUserCreateResponse.setResultCode(DockingConstant.IAM_ERROR_RESULT_CODE);
|
||||
String message = e.getErrorMessage();
|
||||
iamUserCreateResponse.setMessage(message);
|
||||
log.error(iamUserCreateResponse.getMessage());
|
||||
}catch (Exception e){
|
||||
iamUserCreateResponse.setResultCode(DockingConstant.IAM_ERROR_RESULT_CODE);
|
||||
iamUserCreateResponse.setMessage("操作失败" + e.getMessage());
|
||||
log.error(iamUserCreateResponse.getMessage());
|
||||
}
|
||||
// 处理统一响应PO层,并加密业务字段
|
||||
MessageHeader acceptMessageHeader = iamUserInfo.getMessageHeader();
|
||||
sendPoEncryptPo = this.syncIamService.handlerGloablEncryptResponse(acceptMessageHeader, iamUserCreateResponse);
|
||||
return sendPoEncryptPo;
|
||||
}
|
||||
|
||||
@PostMapping({"/UserUpdateService"})
|
||||
public SendPoEncryptPo userUpdateService(@RequestBody AcceptEncryptPo iamUserInfo) throws JsonProcessingException {
|
||||
IamCommonResponseDto iamCommonResponseDto = new IamCommonResponseDto();
|
||||
try {
|
||||
if (iamUserInfo == null
|
||||
|| iamUserInfo.getMessageEncryptTabels() == null
|
||||
|| iamUserInfo.getMessageEncryptTabels().getHeader() == null
|
||||
|| iamUserInfo.getMessageEncryptTabels().getHeader().getData() == null){
|
||||
throw new IamGlobalException(null, "参数传递错误,未收到参数");
|
||||
}
|
||||
|
||||
// 对核心数据解密
|
||||
String bodyParam = iamUserInfo.getMessageEncryptTabels().getHeader().getData();
|
||||
String bodyParamDecrypt = BamboocloudUtils.getPlaintext(bodyParam, DockingConstant.IAM_ENCRYPT_SECRET, DockingConstant.IAM_ENCRYPT_TYPE);
|
||||
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
IamUserAcceptDto userAcceptDto = objectMapper.readValue(bodyParamDecrypt, IamUserAcceptDto.class);
|
||||
|
||||
// 校验身份认证,确保接口正确 必须调用!
|
||||
this.syncIamService.validateUserAndPwd(userAcceptDto);
|
||||
|
||||
// 处理业务逻辑,存储用户,返回用户id
|
||||
iamCommonResponseDto = this.syncIamService.userUpdateService(userAcceptDto);
|
||||
iamCommonResponseDto.setBimRequestId(userAcceptDto.getBimRequestId());
|
||||
}catch (IamGlobalException e){
|
||||
iamCommonResponseDto.setResultCode(DockingConstant.IAM_ERROR_RESULT_CODE);
|
||||
String message = e.getMessage();
|
||||
iamCommonResponseDto.setMessage(message);
|
||||
log.error(iamCommonResponseDto.getMessage());
|
||||
}catch (Exception e){
|
||||
iamCommonResponseDto.setResultCode(DockingConstant.IAM_ERROR_RESULT_CODE);
|
||||
iamCommonResponseDto.setMessage("操作失败" + e.getMessage());
|
||||
log.error(iamCommonResponseDto.getMessage());
|
||||
}
|
||||
// 处理统一响应PO层,并加密业务字段
|
||||
MessageHeader acceptMessageHeader = iamUserInfo.getMessageHeader();
|
||||
SendPoEncryptPo sendPoEncryptPo = this.syncIamService.handlerGloablEncryptResponse(acceptMessageHeader, iamCommonResponseDto);
|
||||
return sendPoEncryptPo;
|
||||
}
|
||||
|
||||
@PostMapping({"/UserDeleteService"})
|
||||
public SendPoEncryptPo userDeleteService(@RequestBody AcceptEncryptPo iamUserInfo) throws JsonProcessingException {
|
||||
IamCommonResponseDto iamCommonResponseDto = new IamCommonResponseDto();
|
||||
try {
|
||||
if (iamUserInfo == null
|
||||
|| iamUserInfo.getMessageEncryptTabels() == null
|
||||
|| iamUserInfo.getMessageEncryptTabels().getHeader() == null
|
||||
|| iamUserInfo.getMessageEncryptTabels().getHeader().getData() == null){
|
||||
throw new IamGlobalException(null, "参数传递错误,未收到参数");
|
||||
}
|
||||
|
||||
// 对核心数据解密
|
||||
String bodyParam = iamUserInfo.getMessageEncryptTabels().getHeader().getData();
|
||||
String bodyParamDecrypt = BamboocloudUtils.getPlaintext(bodyParam, DockingConstant.IAM_ENCRYPT_SECRET, DockingConstant.IAM_ENCRYPT_TYPE);
|
||||
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
IamUserAcceptDto userAcceptDto = objectMapper.readValue(bodyParamDecrypt, IamUserAcceptDto.class);
|
||||
|
||||
// 校验身份认证,确保接口正确 必须调用!
|
||||
this.syncIamService.validateUserAndPwd(userAcceptDto);
|
||||
|
||||
// 处理业务逻辑,存储用户,返回用户id
|
||||
iamCommonResponseDto = this.syncIamService.userDeleteService(userAcceptDto);
|
||||
iamCommonResponseDto.setBimRequestId(userAcceptDto.getBimRequestId());
|
||||
}catch (IamGlobalException e){
|
||||
iamCommonResponseDto.setResultCode(DockingConstant.IAM_ERROR_RESULT_CODE);
|
||||
String message = e.getMessage();
|
||||
iamCommonResponseDto.setMessage(message);
|
||||
log.error(iamCommonResponseDto.getMessage());
|
||||
}catch (Exception e){
|
||||
iamCommonResponseDto.setResultCode(DockingConstant.IAM_ERROR_RESULT_CODE);
|
||||
iamCommonResponseDto.setMessage("操作失败" + e.getMessage());
|
||||
log.error(iamCommonResponseDto.getMessage());
|
||||
}
|
||||
// 处理统一响应PO层,并加密业务字段
|
||||
MessageHeader acceptMessageHeader = iamUserInfo.getMessageHeader();
|
||||
SendPoEncryptPo sendPoEncryptPo = this.syncIamService.handlerGloablEncryptResponse(acceptMessageHeader, iamCommonResponseDto);
|
||||
return sendPoEncryptPo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 组织创建和更新移除缓存
|
||||
* @param iamOrgInfo
|
||||
* @return
|
||||
* @throws JsonProcessingException
|
||||
*/
|
||||
@PostMapping({"/OrgCreateService"})
|
||||
@CacheEvict(value= {CacheConstant.SYS_DEPARTS_CACHE,CacheConstant.SYS_DEPART_IDS_CACHE}, allEntries=true)
|
||||
public SendPoEncryptPo orgCreateService(@RequestBody AcceptEncryptPo iamOrgInfo) throws JsonProcessingException {
|
||||
IamOrgAcceptDto orgAcceptDto = null;
|
||||
try {
|
||||
if (iamOrgInfo == null
|
||||
|| iamOrgInfo.getMessageEncryptTabels() == null
|
||||
|| iamOrgInfo.getMessageEncryptTabels().getHeader() == null
|
||||
|| iamOrgInfo.getMessageEncryptTabels().getHeader().getData() == null){
|
||||
throw new IamGlobalException(null, "参数传递错误,未收到参数");
|
||||
}
|
||||
|
||||
// 对核心数据解密
|
||||
String bodyParam = iamOrgInfo.getMessageEncryptTabels().getHeader().getData();
|
||||
String bodyParamDecrypt = BamboocloudUtils.getPlaintext(bodyParam, DockingConstant.IAM_ENCRYPT_SECRET, DockingConstant.IAM_ENCRYPT_TYPE);
|
||||
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
orgAcceptDto = objectMapper.readValue(bodyParamDecrypt, IamOrgAcceptDto.class);
|
||||
|
||||
// 校验身份认证,确保接口正确 必须调用!
|
||||
this.syncIamService.validateUserAndPwd(orgAcceptDto);
|
||||
|
||||
// 处理业务逻辑,存储组织,返回组织id
|
||||
IamOrgCreateResponse iamOrgCreateResponse = this.syncIamService.orgCreateService(orgAcceptDto);
|
||||
|
||||
// 处理统一响应PO层,并加密业务字段
|
||||
MessageHeader acceptMessageHeader = iamOrgInfo.getMessageHeader();
|
||||
SendPoEncryptPo sendPoEncryptPo = this.syncIamService.handlerGloablEncryptResponse(acceptMessageHeader, iamOrgCreateResponse);
|
||||
return sendPoEncryptPo;
|
||||
} catch (DuplicateKeyException duplicateKeyException) {
|
||||
log.error("数据库值重复:{}", duplicateKeyException.getMessage());
|
||||
if (orgAcceptDto != null) {
|
||||
throw new IamGlobalException(orgAcceptDto.getBimRequestId(), "数据库值重复,请检查组织编号【" + orgAcceptDto.getSrmsOrgCode() + "】是否异常");
|
||||
} else {
|
||||
throw new IamGlobalException(null, "未知异常,请联系管理员");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 组织创建和更新移除缓存
|
||||
* @param iamOrgInfo
|
||||
* @return
|
||||
* @throws JsonProcessingException
|
||||
*/
|
||||
@PostMapping({"/OrgUpdateService"})
|
||||
@CacheEvict(value= {CacheConstant.SYS_DEPARTS_CACHE,CacheConstant.SYS_DEPART_IDS_CACHE}, allEntries=true)
|
||||
public SendPoEncryptPo orgUpdateService(@RequestBody AcceptEncryptPo iamOrgInfo) throws JsonProcessingException {
|
||||
if (iamOrgInfo == null
|
||||
|| iamOrgInfo.getMessageEncryptTabels() == null
|
||||
|| iamOrgInfo.getMessageEncryptTabels().getHeader() == null
|
||||
|| iamOrgInfo.getMessageEncryptTabels().getHeader().getData() == null){
|
||||
throw new IamGlobalException(null, "参数传递错误,未收到参数");
|
||||
}
|
||||
|
||||
// 对核心数据解密
|
||||
String bodyParam = iamOrgInfo.getMessageEncryptTabels().getHeader().getData();
|
||||
String bodyParamDecrypt = BamboocloudUtils.getPlaintext(bodyParam, DockingConstant.IAM_ENCRYPT_SECRET, DockingConstant.IAM_ENCRYPT_TYPE);
|
||||
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
IamOrgAcceptDto orgAcceptDto = objectMapper.readValue(bodyParamDecrypt, IamOrgAcceptDto.class);
|
||||
|
||||
// 校验身份认证,确保接口正确 必须调用!
|
||||
this.syncIamService.validateUserAndPwd(orgAcceptDto);
|
||||
|
||||
// 处理业务逻辑,更新组织
|
||||
IamCommonResponseDto iamCommonResponseDto = this.syncIamService.orgUpdateService(orgAcceptDto);
|
||||
|
||||
// 处理统一响应PO层,并加密业务字段
|
||||
MessageHeader acceptMessageHeader = iamOrgInfo.getMessageHeader();
|
||||
SendPoEncryptPo sendPoEncryptPo = this.syncIamService.handlerGloablEncryptResponse(acceptMessageHeader, iamCommonResponseDto);
|
||||
|
||||
return sendPoEncryptPo;
|
||||
}
|
||||
|
||||
@PostMapping({"/OrgDeleteService"})
|
||||
public SendPoEncryptPo orgDeleteService(@RequestBody AcceptEncryptPo iamOrgInfo) throws JsonProcessingException {
|
||||
if (iamOrgInfo == null
|
||||
|| iamOrgInfo.getMessageEncryptTabels() == null
|
||||
|| iamOrgInfo.getMessageEncryptTabels().getHeader() == null
|
||||
|| iamOrgInfo.getMessageEncryptTabels().getHeader().getData() == null){
|
||||
throw new IamGlobalException(null, "参数传递错误,未收到参数");
|
||||
}
|
||||
|
||||
// 对核心数据解密
|
||||
String bodyParam = iamOrgInfo.getMessageEncryptTabels().getHeader().getData();
|
||||
String bodyParamDecrypt = BamboocloudUtils.getPlaintext(bodyParam, DockingConstant.IAM_ENCRYPT_SECRET, DockingConstant.IAM_ENCRYPT_TYPE);
|
||||
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
IamOrgAcceptDto orgAcceptDto = objectMapper.readValue(bodyParamDecrypt, IamOrgAcceptDto.class);
|
||||
|
||||
// 校验身份认证,确保接口正确 必须调用!
|
||||
this.syncIamService.validateUserAndPwd(orgAcceptDto);
|
||||
|
||||
// 处理业务逻辑,更新组织
|
||||
IamCommonResponseDto iamCommonResponseDto = this.syncIamService.orgDeleteService(orgAcceptDto);
|
||||
|
||||
// 处理统一响应PO层,并加密业务字段
|
||||
MessageHeader acceptMessageHeader = iamOrgInfo.getMessageHeader();
|
||||
SendPoEncryptPo sendPoEncryptPo = this.syncIamService.handlerGloablEncryptResponse(acceptMessageHeader, iamCommonResponseDto);
|
||||
|
||||
return sendPoEncryptPo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 对接统一权限服务平台。
|
||||
* 该接口包含角色创建、菜单创建、角色菜单关联、用户角色关联等4个接口
|
||||
* 通过type字段来区分
|
||||
*/
|
||||
@PostMapping({"/bpmcCreate"})
|
||||
public SendPoEncryptPo bpmcCreate(@RequestBody AcceptDecryptPo acceptDecryptPo) throws JsonProcessingException {
|
||||
if (acceptDecryptPo == null
|
||||
|| acceptDecryptPo.getMessageDecryptTabels() == null
|
||||
|| acceptDecryptPo.getMessageDecryptTabels().getHeader() == null){
|
||||
throw new IamGlobalException(null, "参数传递错误,未收到参数");
|
||||
}
|
||||
|
||||
log.info("统一权限服务平台请求数据:{}", acceptDecryptPo.toString());
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
BpmcAcceptDto bpmcAcceptDto = objectMapper.readValue(acceptDecryptPo.getMessageDecryptTabels().getHeader().getData(), BpmcAcceptDto.class);
|
||||
|
||||
MessageHeader messageHeader = acceptDecryptPo.getMessageHeader();
|
||||
BpmcResponseDto bpmcResponseDto = BpmcResponseDto.success();
|
||||
SendPoEncryptPo sendPoEncryptPo = new SendPoEncryptPo();
|
||||
|
||||
if (CharSequenceUtil.isEmpty(bpmcAcceptDto.getType())){
|
||||
bpmcResponseDto.setResultCode(DockingConstant.IAM_ERROR_RESULT_CODE);
|
||||
bpmcResponseDto.setMessage("接口类型(type)未传参,请检查");
|
||||
log.error(bpmcResponseDto.getMessage());
|
||||
sendPoEncryptPo = this.syncIamService.handlerGloablEncryptResponse(messageHeader, bpmcResponseDto);
|
||||
sendPoEncryptPo.getReturns().setData(JSON.toJSONString(bpmcResponseDto));
|
||||
return sendPoEncryptPo;
|
||||
}
|
||||
|
||||
if (CharSequenceUtil.isEmpty(bpmcAcceptDto.getEntity())){
|
||||
bpmcResponseDto.setResultCode(DockingConstant.IAM_ERROR_RESULT_CODE);
|
||||
bpmcResponseDto.setMessage("数据实体(entity)未传参,请检查");
|
||||
log.error(bpmcResponseDto.getMessage());
|
||||
sendPoEncryptPo = this.syncIamService.handlerGloablEncryptResponse(messageHeader, bpmcResponseDto);
|
||||
sendPoEncryptPo.getReturns().setData(JSON.toJSONString(bpmcResponseDto));
|
||||
return sendPoEncryptPo;
|
||||
}
|
||||
|
||||
if (CharSequenceUtil.isEmpty(bpmcAcceptDto.getAction())){
|
||||
bpmcResponseDto.setResultCode(DockingConstant.IAM_ERROR_RESULT_CODE);
|
||||
bpmcResponseDto.setMessage("操作方式(action)未传参,请检查");
|
||||
log.error(bpmcResponseDto.getMessage());
|
||||
sendPoEncryptPo = this.syncIamService.handlerGloablEncryptResponse(messageHeader, bpmcResponseDto);
|
||||
sendPoEncryptPo.getReturns().setData(JSON.toJSONString(bpmcResponseDto));
|
||||
return sendPoEncryptPo;
|
||||
}
|
||||
|
||||
if (CharSequenceUtil.isEmpty(bpmcAcceptDto.getSignature())){
|
||||
bpmcResponseDto.setResultCode(DockingConstant.IAM_ERROR_RESULT_CODE);
|
||||
bpmcResponseDto.setMessage("签名(signature)未传参,请检查");
|
||||
log.error(bpmcResponseDto.getMessage());
|
||||
sendPoEncryptPo = this.syncIamService.handlerGloablEncryptResponse(messageHeader, bpmcResponseDto);
|
||||
sendPoEncryptPo.getReturns().setData(JSON.toJSONString(bpmcResponseDto));
|
||||
return sendPoEncryptPo;
|
||||
}
|
||||
|
||||
// 验证签名
|
||||
String validateSign = SHA256Util.getSHA256StrJava(bpmcAcceptDto.getEntity() + bpmcAppkey + bpmcAcceptDto.getTimestamp());
|
||||
if (!bpmcAcceptDto.getSignature().equals(validateSign)){
|
||||
bpmcResponseDto.setResultCode(DockingConstant.IAM_ERROR_RESULT_CODE);
|
||||
bpmcResponseDto.setMessage("签名校验不通过,请检查");
|
||||
log.error(bpmcResponseDto.getMessage());
|
||||
sendPoEncryptPo = this.syncIamService.handlerGloablEncryptResponse(messageHeader, bpmcResponseDto);
|
||||
sendPoEncryptPo.getReturns().setData(JSON.toJSONString(bpmcResponseDto));
|
||||
return sendPoEncryptPo;
|
||||
}
|
||||
|
||||
try {
|
||||
switch (bpmcAcceptDto.getType()){
|
||||
// 角色
|
||||
case DockingConstant.BPMC_TYPE_ROLE:
|
||||
bpmcResponseDto = bpmcTypeRole(objectMapper, bpmcAcceptDto, bpmcResponseDto);
|
||||
break;
|
||||
|
||||
// 菜单
|
||||
case DockingConstant.BPMC_TYPE_RESOURCE:
|
||||
bpmcResponseDto = bpmcTypeResource(objectMapper, bpmcAcceptDto, bpmcResponseDto);
|
||||
break;
|
||||
|
||||
// 用户角色关联
|
||||
case DockingConstant.BPMC_TYPE_USER_ROLE:
|
||||
bpmcResponseDto = bpmcTypeUserRole(objectMapper, bpmcAcceptDto, bpmcResponseDto);
|
||||
break;
|
||||
|
||||
// 角色菜单关联
|
||||
case DockingConstant.BPMC_TYPE_ROLE_RESOURCE:
|
||||
bpmcResponseDto = bpmcTypeRoleResource(objectMapper, bpmcAcceptDto, bpmcResponseDto);
|
||||
break;
|
||||
|
||||
default:
|
||||
bpmcResponseDto = BpmcResponseDto.error("接口类型(type)未找到,请检查");
|
||||
break;
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
log.error(e.getMessage());
|
||||
bpmcResponseDto = BpmcResponseDto.error(e.getMessage());
|
||||
}
|
||||
log.info(bpmcResponseDto.getMessage());
|
||||
sendPoEncryptPo = this.syncIamService.handlerGloablEncryptResponse(messageHeader, bpmcResponseDto);
|
||||
sendPoEncryptPo.getReturns().setData(JSON.toJSONString(bpmcResponseDto));
|
||||
return sendPoEncryptPo;
|
||||
}
|
||||
|
||||
private BpmcResponseDto bpmcTypeRoleResource(ObjectMapper objectMapper, BpmcAcceptDto bpmcAcceptDto, BpmcResponseDto bpmcResponseDto) throws JsonProcessingException {
|
||||
List<RoleResourceDto> roleResourceDtoList = objectMapper.readValue(bpmcAcceptDto.getEntity(), new TypeReference<List<RoleResourceDto>>() {});
|
||||
// 根据新增/删除调用不同的业务处理代码
|
||||
if (bpmcAcceptDto.getAction().equals(DockingConstant.BPMC_ACTION_ADD)){
|
||||
bpmcResponseDto = this.syncIamService.roleResourceCreateService(roleResourceDtoList);
|
||||
} else if (bpmcAcceptDto.getAction().equals(DockingConstant.BPMC_ACTION_DELETE)) {
|
||||
bpmcResponseDto = this.syncIamService.roleResourceDeleteService(roleResourceDtoList);
|
||||
}
|
||||
return bpmcResponseDto;
|
||||
}
|
||||
|
||||
private BpmcResponseDto bpmcTypeUserRole(ObjectMapper objectMapper, BpmcAcceptDto bpmcAcceptDto, BpmcResponseDto bpmcResponseDto) throws JsonProcessingException {
|
||||
List<UserRoleDto> userRoleDtoList = objectMapper.readValue(bpmcAcceptDto.getEntity(), new TypeReference<List<UserRoleDto>>() {});
|
||||
// 根据新增/删除调用不同的业务处理代码
|
||||
if (bpmcAcceptDto.getAction().equals(DockingConstant.BPMC_ACTION_ADD)){
|
||||
bpmcResponseDto = this.syncIamService.userRoleCreateService(userRoleDtoList);
|
||||
} else if (bpmcAcceptDto.getAction().equals(DockingConstant.BPMC_ACTION_DELETE)) {
|
||||
bpmcResponseDto = this.syncIamService.userRoleDeleteService(userRoleDtoList);
|
||||
}
|
||||
return bpmcResponseDto;
|
||||
}
|
||||
|
||||
private BpmcResponseDto bpmcTypeResource(ObjectMapper objectMapper, BpmcAcceptDto bpmcAcceptDto, BpmcResponseDto bpmcResponseDto) throws JsonProcessingException {
|
||||
ResourceDto resourceDto = objectMapper.readValue(bpmcAcceptDto.getEntity(), ResourceDto.class);
|
||||
// 根据新增/编辑/删除调用不同的业务处理代码
|
||||
if (bpmcAcceptDto.getAction().equals(DockingConstant.BPMC_ACTION_ADD)){
|
||||
bpmcResponseDto = this.syncIamService.resourceCreateService(resourceDto);
|
||||
} else if (bpmcAcceptDto.getAction().equals(DockingConstant.BPMC_ACTION_UPDATE)) {
|
||||
bpmcResponseDto = this.syncIamService.resourceUpdateService(resourceDto);
|
||||
} else if (bpmcAcceptDto.getAction().equals(DockingConstant.BPMC_ACTION_DELETE)) {
|
||||
bpmcResponseDto = this.syncIamService.resourceDeleteService(resourceDto);
|
||||
}
|
||||
return bpmcResponseDto;
|
||||
}
|
||||
|
||||
private BpmcResponseDto bpmcTypeRole(ObjectMapper objectMapper, BpmcAcceptDto bpmcAcceptDto, BpmcResponseDto bpmcResponseDto) throws JsonProcessingException {
|
||||
RoleDto roleDto = objectMapper.readValue(bpmcAcceptDto.getEntity(), RoleDto.class);
|
||||
// 根据新增/编辑/删除调用不同的业务处理代码
|
||||
if (bpmcAcceptDto.getAction().equals(DockingConstant.BPMC_ACTION_ADD)){
|
||||
bpmcResponseDto = this.syncIamService.roleCreateService(roleDto);
|
||||
} else if (bpmcAcceptDto.getAction().equals(DockingConstant.BPMC_ACTION_UPDATE)) {
|
||||
bpmcResponseDto = this.syncIamService.roleUpdateService(roleDto);
|
||||
} else if (bpmcAcceptDto.getAction().equals(DockingConstant.BPMC_ACTION_DELETE)) {
|
||||
bpmcResponseDto = this.syncIamService.roleDeleteService(roleDto);
|
||||
}
|
||||
return bpmcResponseDto;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询全部用户id
|
||||
* @param iamCommon
|
||||
* @return
|
||||
* @throws JsonProcessingException
|
||||
*/
|
||||
@PostMapping({"/QueryAllUserIdsService"})
|
||||
public SendPoEncryptPo QueryAllUserIdsService(@RequestBody AcceptEncryptPo iamCommon) throws JsonProcessingException {
|
||||
if (iamCommon == null
|
||||
|| iamCommon.getMessageEncryptTabels() == null
|
||||
|| iamCommon.getMessageEncryptTabels().getHeader() == null
|
||||
|| iamCommon.getMessageEncryptTabels().getHeader().getData() == null){
|
||||
throw new IamGlobalException(null, this.paramNotGetError);
|
||||
}
|
||||
|
||||
// 对核心数据解密
|
||||
String bodyParam = iamCommon.getMessageEncryptTabels().getHeader().getData();
|
||||
String bodyParamDecrypt = BamboocloudUtils.getPlaintext(bodyParam, DockingConstant.IAM_ENCRYPT_SECRET, DockingConstant.IAM_ENCRYPT_TYPE);
|
||||
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
IamCommonAcceptDto commonAcceptDto = objectMapper.readValue(bodyParamDecrypt, IamCommonAcceptDto.class);
|
||||
|
||||
// 校验身份认证,确保接口正确 必须调用!
|
||||
this.syncIamService.validateUserAndPwd(commonAcceptDto);
|
||||
|
||||
// 处理业务逻辑,封装字段
|
||||
IamUserIdListResponse userIdListResponse = this.syncIamService.getAllUserIds(commonAcceptDto);
|
||||
|
||||
// 处理统一响应PO层,并加密业务字段
|
||||
MessageHeader acceptMessageHeader = iamCommon.getMessageHeader();
|
||||
SendPoEncryptPo sendPoEncryptPo = this.syncIamService.handlerGloablEncryptResponse(acceptMessageHeader, userIdListResponse);
|
||||
|
||||
return sendPoEncryptPo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询全部组织id
|
||||
* @param iamCommon
|
||||
* @return
|
||||
* @throws JsonProcessingException
|
||||
*/
|
||||
@PostMapping({"/QueryAllOrgIdsService"})
|
||||
public SendPoEncryptPo QueryAllOrgIdsService(@RequestBody AcceptEncryptPo iamCommon) throws JsonProcessingException {
|
||||
if (iamCommon == null
|
||||
|| iamCommon.getMessageEncryptTabels() == null
|
||||
|| iamCommon.getMessageEncryptTabels().getHeader() == null
|
||||
|| iamCommon.getMessageEncryptTabels().getHeader().getData() == null){
|
||||
throw new IamGlobalException(null, this.paramNotGetError);
|
||||
}
|
||||
|
||||
// 对核心数据解密
|
||||
String bodyParam = iamCommon.getMessageEncryptTabels().getHeader().getData();
|
||||
String bodyParamDecrypt = BamboocloudUtils.getPlaintext(bodyParam, DockingConstant.IAM_ENCRYPT_SECRET, DockingConstant.IAM_ENCRYPT_TYPE);
|
||||
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
IamCommonAcceptDto commonAcceptDto = objectMapper.readValue(bodyParamDecrypt, IamCommonAcceptDto.class);
|
||||
|
||||
// 校验身份认证,确保接口正确 必须调用!
|
||||
this.syncIamService.validateUserAndPwd(commonAcceptDto);
|
||||
|
||||
// 处理业务逻辑,封装字段
|
||||
IamOrgIdListResponse orgIdListResponse = this.syncIamService.getAllOrgIds(commonAcceptDto);
|
||||
|
||||
// 处理统一响应PO层,并加密业务字段
|
||||
MessageHeader acceptMessageHeader = iamCommon.getMessageHeader();
|
||||
SendPoEncryptPo sendPoEncryptPo = this.syncIamService.handlerGloablEncryptResponse(acceptMessageHeader, orgIdListResponse);
|
||||
|
||||
return sendPoEncryptPo;
|
||||
}
|
||||
|
||||
@PostMapping({"/QueryUserByIdService"})
|
||||
public SendPoEncryptPo QueryUserByIdService(@RequestBody AcceptEncryptPo iamUserInfo) throws JsonProcessingException {
|
||||
if (iamUserInfo == null
|
||||
|| iamUserInfo.getMessageEncryptTabels() == null
|
||||
|| iamUserInfo.getMessageEncryptTabels().getHeader() == null
|
||||
|| iamUserInfo.getMessageEncryptTabels().getHeader().getData() == null){
|
||||
throw new IamGlobalException(null, "参数传递错误,未收到参数");
|
||||
}
|
||||
|
||||
// 对核心数据解密
|
||||
String bodyParam = iamUserInfo.getMessageEncryptTabels().getHeader().getData();
|
||||
String bodyParamDecrypt = BamboocloudUtils.getPlaintext(bodyParam, DockingConstant.IAM_ENCRYPT_SECRET, DockingConstant.IAM_ENCRYPT_TYPE);
|
||||
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
IamUserAcceptDto userAcceptDto = objectMapper.readValue(bodyParamDecrypt, IamUserAcceptDto.class);
|
||||
|
||||
// 校验身份认证,确保接口正确 必须调用!
|
||||
this.syncIamService.validateUserAndPwd(userAcceptDto);
|
||||
|
||||
// 处理业务逻辑,存储用户,返回用户id
|
||||
IamUserInfoResponse iamUserInfoResponse = this.syncIamService.getUserInfoById(userAcceptDto);
|
||||
|
||||
// 处理统一响应PO层,并加密业务字段
|
||||
MessageHeader acceptMessageHeader = iamUserInfo.getMessageHeader();
|
||||
SendPoEncryptPo sendPoEncryptPo = this.syncIamService.handlerGloablEncryptResponse(acceptMessageHeader, iamUserInfoResponse);
|
||||
|
||||
return sendPoEncryptPo;
|
||||
}
|
||||
|
||||
@PostMapping({"/QueryOrgByIdService"})
|
||||
public SendPoEncryptPo QueryOrgByIdService(@RequestBody AcceptEncryptPo iamUserInfo) throws JsonProcessingException {
|
||||
if (iamUserInfo == null
|
||||
|| iamUserInfo.getMessageEncryptTabels() == null
|
||||
|| iamUserInfo.getMessageEncryptTabels().getHeader() == null
|
||||
|| iamUserInfo.getMessageEncryptTabels().getHeader().getData() == null){
|
||||
throw new IamGlobalException(null, "参数传递错误,未收到参数");
|
||||
}
|
||||
|
||||
// 对核心数据解密
|
||||
String bodyParam = iamUserInfo.getMessageEncryptTabels().getHeader().getData();
|
||||
String bodyParamDecrypt = BamboocloudUtils.getPlaintext(bodyParam, DockingConstant.IAM_ENCRYPT_SECRET, DockingConstant.IAM_ENCRYPT_TYPE);
|
||||
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
IamOrgAcceptDto orgAcceptDto = objectMapper.readValue(bodyParamDecrypt, IamOrgAcceptDto.class);
|
||||
|
||||
// 校验身份认证,确保接口正确 必须调用!
|
||||
this.syncIamService.validateUserAndPwd(orgAcceptDto);
|
||||
|
||||
// 处理业务逻辑,存储用户,返回用户id
|
||||
IamOrgInfoResponse iamOrgInfoResponse = this.syncIamService.getOrgInfoById(orgAcceptDto);
|
||||
|
||||
// 处理统一响应PO层,并加密业务字段
|
||||
MessageHeader acceptMessageHeader = iamUserInfo.getMessageHeader();
|
||||
SendPoEncryptPo sendPoEncryptPo = this.syncIamService.handlerGloablEncryptResponse(acceptMessageHeader, iamOrgInfoResponse);
|
||||
|
||||
return sendPoEncryptPo;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
package com.jero.modules.docking.iam.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import lombok.Data;
|
||||
import lombok.ToString;
|
||||
|
||||
/**
|
||||
* IAM的通用Dto,存放IAM接口的非业务通用属性。接口呗请求时会带着该参数
|
||||
*/
|
||||
@Data
|
||||
@ToString
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class IamCommonAcceptDto {
|
||||
|
||||
/**
|
||||
* BIM每次调用生成的随机ID,应用系统每次响应返回此ID
|
||||
*/
|
||||
private String bimRequestId;
|
||||
|
||||
/**
|
||||
*BIM调用三方应用接口的授权账号,由应用分配给BIM系统
|
||||
*/
|
||||
private String bimRemoteUser ;
|
||||
|
||||
|
||||
/**
|
||||
* BIM调用三方应用接口的密码,由应用分配给BIM系统
|
||||
*/
|
||||
private String bimRemotePwd;
|
||||
|
||||
}
|
||||
+91
@@ -0,0 +1,91 @@
|
||||
package com.jero.modules.docking.iam.dto;
|
||||
|
||||
import com.jero.modules.docking.iam.annotation.IamProperty;
|
||||
import lombok.Data;
|
||||
import lombok.ToString;
|
||||
|
||||
/**
|
||||
* IAM的组织实体,接收IAM传递的组织数据
|
||||
*/
|
||||
@Data
|
||||
@ToString
|
||||
public class IamOrgAcceptDto extends IamCommonAcceptDto {
|
||||
|
||||
/**
|
||||
* 组织的id,在删除或编辑的接口会传递
|
||||
*/
|
||||
private String bimOrgId;
|
||||
|
||||
/**
|
||||
* 机构编码.全集团唯一,不可重复,撤销后不可重新启用
|
||||
*/
|
||||
@IamProperty(required = true, multivalued = false)
|
||||
private String srmsOrgCode;
|
||||
|
||||
/**
|
||||
* 组织名称
|
||||
*/
|
||||
@IamProperty(required = true, multivalued = false)
|
||||
private String srmsDepartName;
|
||||
|
||||
/**
|
||||
* 父级机构编码.当前组织所属的父节点code
|
||||
*/
|
||||
@IamProperty(required = true, multivalued = false)
|
||||
private String srmsParentCode;
|
||||
|
||||
/**
|
||||
* 所属单位,10位HR机构编号
|
||||
*/
|
||||
@IamProperty(required = true, multivalued = false)
|
||||
private String srmsCompany;
|
||||
|
||||
/**
|
||||
* 机构状态
|
||||
*/
|
||||
@IamProperty(required = true, multivalued = false)
|
||||
private String srmsStatus;
|
||||
|
||||
/**
|
||||
* 机构类型。001内部机构 002 外部机构 003 虚拟机构
|
||||
*/
|
||||
@IamProperty(required = true, multivalued = false)
|
||||
private String srmsType;
|
||||
|
||||
/**
|
||||
* 组织类型。1.单位 2.部门。单位下可以有单位,但是部门下不能有单位
|
||||
*/
|
||||
@IamProperty(required = true, multivalued = false)
|
||||
private String srmsOrgCategory;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@IamProperty(required = true, multivalued = false)
|
||||
private String srmsCreateTime;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@IamProperty(required = true, multivalued = false)
|
||||
private String srmsUpdateTime;
|
||||
|
||||
/**
|
||||
* 部门负责人
|
||||
*/
|
||||
@IamProperty(required = false, multivalued = false)
|
||||
private String srmsHeadOfDepartment;
|
||||
|
||||
/**
|
||||
* 分管领导
|
||||
*/
|
||||
@IamProperty(required = false, multivalued = false)
|
||||
private String srmsLeadersInCharge;
|
||||
|
||||
/**
|
||||
* 副职领导
|
||||
*/
|
||||
@IamProperty(required = false, multivalued = false)
|
||||
private String srmsDeputyLeader;
|
||||
|
||||
}
|
||||
+121
@@ -0,0 +1,121 @@
|
||||
package com.jero.modules.docking.iam.dto;
|
||||
|
||||
import com.jero.modules.docking.iam.annotation.IamProperty;
|
||||
import lombok.Data;
|
||||
import lombok.ToString;
|
||||
|
||||
/**
|
||||
* IAM的用户实体,接收IAM传递的用户数据
|
||||
*/
|
||||
@Data
|
||||
@ToString
|
||||
public class IamUserAcceptDto extends IamCommonAcceptDto {
|
||||
|
||||
/**
|
||||
* 用户的id,在删除或编辑的接口会传递
|
||||
*/
|
||||
private String bimUid;
|
||||
|
||||
/**
|
||||
* 单位编码
|
||||
*/
|
||||
@IamProperty(required = true, multivalued = false)
|
||||
private String srmsCompanyCode;
|
||||
|
||||
/**
|
||||
* 部门编码,用于做人员和组织的关联
|
||||
*/
|
||||
@IamProperty(required = true, multivalued = false)
|
||||
private String srmsOrgCode;
|
||||
|
||||
/**
|
||||
* 人员类型
|
||||
*/
|
||||
@IamProperty(required = true, multivalued = false)
|
||||
private String srmsTypeId;
|
||||
|
||||
/**
|
||||
* 工号
|
||||
*/
|
||||
@IamProperty(required = true, multivalued = false)
|
||||
private String srmsUsername;
|
||||
|
||||
/**
|
||||
* 姓名
|
||||
*/
|
||||
@IamProperty(required = true, multivalued = false)
|
||||
private String srmsRealname;
|
||||
|
||||
/**
|
||||
* 密码
|
||||
*/
|
||||
@IamProperty(required = false, multivalued = false)
|
||||
private String srmsPassword;
|
||||
|
||||
/**
|
||||
* 性别
|
||||
*/
|
||||
@IamProperty(required = true, multivalued = false)
|
||||
private String srmsSex;
|
||||
|
||||
/**
|
||||
* 岗位
|
||||
*/
|
||||
@IamProperty(required = true, multivalued = false)
|
||||
private String srmsPost;
|
||||
|
||||
/**
|
||||
* 职务级别
|
||||
*/
|
||||
@IamProperty(required = true, multivalued = false)
|
||||
private String srmsDutyLevelId;
|
||||
|
||||
/**
|
||||
* 直接上级
|
||||
*/
|
||||
@IamProperty(required = true, multivalued = false)
|
||||
private String srmsDirectLeadership;
|
||||
|
||||
/**
|
||||
* 岗位状态
|
||||
*/
|
||||
@IamProperty(required = true, multivalued = false)
|
||||
private String srmsPostStatus;
|
||||
|
||||
/**
|
||||
* 是否在册
|
||||
*/
|
||||
@IamProperty(required = true, multivalued = false)
|
||||
private String srmsStatus;
|
||||
|
||||
/**
|
||||
* 办公电话
|
||||
*/
|
||||
@IamProperty(required = true, multivalued = false)
|
||||
private String srmsOfficePhone;
|
||||
|
||||
/**
|
||||
* 移动电话
|
||||
*/
|
||||
@IamProperty(required = true, multivalued = false)
|
||||
private String srmsPhone;
|
||||
|
||||
/**
|
||||
* 电子邮件
|
||||
*/
|
||||
@IamProperty(required = true, multivalued = false)
|
||||
private String srmsEmail;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@IamProperty(required = true, multivalued = false)
|
||||
private String srmsCreateTime;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@IamProperty(required = true, multivalued = false)
|
||||
private String srmsUpdateTime;
|
||||
|
||||
}
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
package com.jero.modules.docking.iam.dto.bpmc;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.ToString;
|
||||
|
||||
/**
|
||||
* 和竹云统一权限服务平台对接的实体
|
||||
*/
|
||||
@Data
|
||||
@ToString
|
||||
public class BpmcAcceptDto {
|
||||
|
||||
/**
|
||||
* 角色:D_AR (本系统对接)
|
||||
* 功能权限:D_AM (本系统对接)
|
||||
* 账号与应用角色关系: R_USER_AR (本系统对接)
|
||||
* 应用角色与应用功能权限关系:R_AR_AM (本系统对接)
|
||||
* 账号与功能权限关系:R_USER_AM
|
||||
* 群组与应用角色关系:R_ACCSET_AR
|
||||
* 群组与功能权限关系:R_ACCSET_AM
|
||||
* 机构/岗位与应用角色关系:R_USERSET_AR
|
||||
* 机构/岗位与功能权限关系:R_USERSET_AM
|
||||
*/
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* 后续基础数据接口、权限关系接口章节中对应操作的entity JSON格式数据字符串
|
||||
*/
|
||||
private String entity;
|
||||
|
||||
/**
|
||||
* 操作方式
|
||||
* 基础数据接口:(add:新增;delete:删除;update:更新)
|
||||
* 关系数据接口:
|
||||
* (add:新增;delete:删除;)
|
||||
*/
|
||||
private String action;
|
||||
|
||||
/**
|
||||
* 请求签名,计算方式
|
||||
* SHA256 (entity+appKey+timestamp)
|
||||
*/
|
||||
private String signature;
|
||||
|
||||
/**
|
||||
* 时间戳
|
||||
*/
|
||||
private long timestamp;
|
||||
|
||||
}
|
||||
+112
@@ -0,0 +1,112 @@
|
||||
package com.jero.modules.docking.iam.dto.bpmc;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 统一权限服务平台的菜单实体
|
||||
*/
|
||||
@Data
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class ResourceDto {
|
||||
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 功能编码
|
||||
*/
|
||||
private String code;
|
||||
|
||||
/**
|
||||
* 父级id
|
||||
*/
|
||||
private String parentId;
|
||||
|
||||
/**
|
||||
* 功能名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 对应前端组件
|
||||
*/
|
||||
private String component;
|
||||
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* 一级菜单跳转地址
|
||||
*/
|
||||
private String redirect;
|
||||
|
||||
/**
|
||||
* 路径
|
||||
*/
|
||||
private String url;
|
||||
|
||||
/**
|
||||
* 类型(0:一级菜单; 1:子菜单:2:按钮权限)
|
||||
*/
|
||||
private int menu_type;
|
||||
|
||||
/**
|
||||
* 排序号
|
||||
*/
|
||||
private Integer sort;
|
||||
|
||||
/**
|
||||
* 菜单英文
|
||||
*/
|
||||
private String menu_en;
|
||||
|
||||
/**
|
||||
* 菜单是否为路径菜单(默认值为1)
|
||||
*/
|
||||
private Integer is_route;
|
||||
|
||||
/**
|
||||
* 打开外部链接菜单的方式(默认值为0)
|
||||
*/
|
||||
private Integer internal_or_external;
|
||||
|
||||
/**
|
||||
* 菜单是否隐藏(默认值为0)
|
||||
*/
|
||||
private Integer hidden;
|
||||
|
||||
/**
|
||||
* 菜单是否需要缓存(默认值为0)
|
||||
*/
|
||||
private Integer keep_alive;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
private String createBy;
|
||||
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
private Date modifyTime;
|
||||
|
||||
/**
|
||||
* 最近修改人
|
||||
*/
|
||||
private String modifyBy;
|
||||
|
||||
/**
|
||||
* 应用id
|
||||
*/
|
||||
private String appId;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
package com.jero.modules.docking.iam.dto.bpmc;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 统一权限服务平台的角色实体
|
||||
*/
|
||||
@Data
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class RoleDto {
|
||||
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 角色编码
|
||||
*/
|
||||
private String code;
|
||||
|
||||
/**
|
||||
* 角色名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* 排序号
|
||||
*/
|
||||
private int sort;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
private String createBy;
|
||||
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
private Date modifyTime;
|
||||
|
||||
/**
|
||||
* 最近修改人
|
||||
*/
|
||||
private String modifyBy;
|
||||
|
||||
/**
|
||||
* 应用id
|
||||
*/
|
||||
private String appId;
|
||||
|
||||
}
|
||||
+53
@@ -0,0 +1,53 @@
|
||||
package com.jero.modules.docking.iam.dto.bpmc;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 统一权限服务平台的 角色-菜单关联 实体
|
||||
*/
|
||||
@Data
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class RoleResourceDto {
|
||||
|
||||
/**
|
||||
* 角色id
|
||||
*/
|
||||
private String arId;
|
||||
|
||||
/**
|
||||
* 角色名称
|
||||
*/
|
||||
private String arName;
|
||||
|
||||
/**
|
||||
* 角色编码
|
||||
*/
|
||||
private String arCode;
|
||||
|
||||
/**
|
||||
* 菜单id
|
||||
*/
|
||||
private String amId;
|
||||
|
||||
/**
|
||||
* 菜单名称
|
||||
*/
|
||||
private String amName;
|
||||
|
||||
/**
|
||||
* 菜单编码
|
||||
*/
|
||||
private String amCode;
|
||||
|
||||
/**
|
||||
* 菜单类型(0 菜单 、1行为)
|
||||
*/
|
||||
private int amType;
|
||||
|
||||
/**
|
||||
* 菜单code绝对路径
|
||||
*/
|
||||
private String codePath;
|
||||
|
||||
}
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
package com.jero.modules.docking.iam.dto.bpmc;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 统一权限服务平台的 用户-角色关联 实体
|
||||
*/
|
||||
@Data
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class UserRoleDto {
|
||||
|
||||
/**
|
||||
* 用户ID
|
||||
*/
|
||||
private String userId;
|
||||
|
||||
/**
|
||||
* 账号名
|
||||
*/
|
||||
private String accountCode;
|
||||
|
||||
/**
|
||||
* 账号id
|
||||
*/
|
||||
private String accountId;
|
||||
|
||||
/**
|
||||
* 姓名
|
||||
*/
|
||||
private String fullName;
|
||||
|
||||
/**
|
||||
* 角色id
|
||||
*/
|
||||
private String arId;
|
||||
|
||||
/**
|
||||
* 角色编码
|
||||
*/
|
||||
private String arCode;
|
||||
|
||||
/**
|
||||
* 角色名称
|
||||
*/
|
||||
private String arName;
|
||||
|
||||
}
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
package com.jero.modules.docking.iam.dto.response;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class BpmcResponseDto {
|
||||
|
||||
private String resultCode;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "{" +
|
||||
"resultCode:'" + resultCode + '\'' +
|
||||
", message:'" + message + '\'' +
|
||||
'}';
|
||||
}
|
||||
|
||||
private String message;
|
||||
public static BpmcResponseDto success(){
|
||||
BpmcResponseDto bpmcResponseDto = new BpmcResponseDto();
|
||||
bpmcResponseDto.resultCode = "200"; // 成功时固定为200
|
||||
bpmcResponseDto.message = "操作成功";
|
||||
|
||||
return bpmcResponseDto;
|
||||
}
|
||||
|
||||
public static BpmcResponseDto error(String message){
|
||||
BpmcResponseDto bpmcResponseDto = new BpmcResponseDto();
|
||||
bpmcResponseDto.resultCode = "500"; // 失败时固定为500
|
||||
bpmcResponseDto.message = message;
|
||||
|
||||
return bpmcResponseDto;
|
||||
}
|
||||
|
||||
}
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
package com.jero.modules.docking.iam.dto.response;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* IAM出SchemaService外的成功响应 或 失败响应 通用报文
|
||||
*/
|
||||
@Data
|
||||
public class IamCommonResponseDto {
|
||||
|
||||
/**
|
||||
* 请求id,收到什么就返回什么
|
||||
*/
|
||||
private String bimRequestId;
|
||||
|
||||
/**
|
||||
* 相应码,0位正常
|
||||
*/
|
||||
private String resultCode;
|
||||
|
||||
/**
|
||||
* 消息
|
||||
*/
|
||||
private String message;
|
||||
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
package com.jero.modules.docking.iam.dto.response;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 组织机构创建的响应体
|
||||
*/
|
||||
@Data
|
||||
public class IamOrgCreateResponse extends IamCommonResponseDto{
|
||||
|
||||
/**
|
||||
* 用户创建后生成的id
|
||||
*/
|
||||
private String orgId;
|
||||
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
package com.jero.modules.docking.iam.dto.response;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 组织机构创建的响应体
|
||||
*/
|
||||
@Data
|
||||
public class IamOrgIdListResponse extends IamCommonResponseDto{
|
||||
|
||||
/**
|
||||
* 用户创建后生成的id
|
||||
*/
|
||||
private List<String> orgIdList;
|
||||
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
package com.jero.modules.docking.iam.dto.response;
|
||||
|
||||
import com.jero.modules.docking.iam.dto.IamOrgAcceptDto;
|
||||
import com.jero.modules.docking.iam.dto.IamUserAcceptDto;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 组织机构创建的响应体
|
||||
*/
|
||||
@Data
|
||||
public class IamOrgInfoResponse extends IamCommonResponseDto{
|
||||
|
||||
private IamOrgAcceptDto organization;
|
||||
|
||||
}
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
package com.jero.modules.docking.iam.dto.response;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Schema映射的响应体
|
||||
*/
|
||||
@Data
|
||||
public class IamSchemaResponse {
|
||||
|
||||
/**
|
||||
* 请求id,收到什么就返回什么
|
||||
*/
|
||||
private String bimRequestId;
|
||||
|
||||
/**
|
||||
* 用户账号的具体内容响应实体
|
||||
*/
|
||||
private List<SchemaResponseInner> account;
|
||||
|
||||
/**
|
||||
* 组织机构的具体内容响应实体
|
||||
*/
|
||||
private List<SchemaResponseInner> organization;
|
||||
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
package com.jero.modules.docking.iam.dto.response;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 用户创建的响应体
|
||||
*/
|
||||
@Data
|
||||
public class IamUserCreateResponse extends IamCommonResponseDto{
|
||||
|
||||
/**
|
||||
* 用户创建后生成的id
|
||||
*/
|
||||
private String uid;
|
||||
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
package com.jero.modules.docking.iam.dto.response;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 组织机构创建的响应体
|
||||
*/
|
||||
@Data
|
||||
public class IamUserIdListResponse extends IamCommonResponseDto{
|
||||
|
||||
/**
|
||||
* 用户创建后生成的id
|
||||
*/
|
||||
private List<String> userIdList;
|
||||
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
package com.jero.modules.docking.iam.dto.response;
|
||||
|
||||
import com.jero.modules.docking.iam.dto.IamUserAcceptDto;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 组织机构创建的响应体
|
||||
*/
|
||||
@Data
|
||||
public class IamUserInfoResponse extends IamCommonResponseDto{
|
||||
|
||||
private IamUserAcceptDto account;
|
||||
|
||||
}
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
package com.jero.modules.docking.iam.dto.response;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* Schema的核心内容
|
||||
*/
|
||||
@Data
|
||||
public class SchemaResponseInner {
|
||||
|
||||
/**
|
||||
* 定义对象的属性字段名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 定义对象的属性字段类型,可选值为String、int、double、float、long、byte、boolean
|
||||
*/
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* 定义对象的属性字段在创建时是否为必填字段。可选值true或者false
|
||||
*/
|
||||
private boolean required;
|
||||
|
||||
/**
|
||||
* 定义对象的属性字段是否为多值。可选值true或者false。字段为boolean类型
|
||||
*/
|
||||
private boolean multivalued;
|
||||
|
||||
}
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
package com.jero.modules.docking.iam.exception;
|
||||
|
||||
import com.jero.common.util.MessageUtils;
|
||||
|
||||
public class IamGlobalException extends RuntimeException {
|
||||
|
||||
private String bimRequestId;
|
||||
private String message;
|
||||
|
||||
private static final long serialVersionUID = 3634632351214L;
|
||||
|
||||
public IamGlobalException(String bimRequestId, String message){
|
||||
super(message);
|
||||
this.bimRequestId = bimRequestId;
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public String getBimRequestId() {
|
||||
return bimRequestId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
}
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
package com.jero.modules.docking.iam.exception;
|
||||
|
||||
import com.jero.common.api.vo.Result;
|
||||
import com.jero.common.exception.JeroBootException;
|
||||
import com.jero.modules.docking.iam.dto.response.IamCommonResponseDto;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.poi.ss.formula.functions.T;
|
||||
import org.apache.shiro.authz.AuthorizationException;
|
||||
import org.apache.shiro.authz.UnauthorizedException;
|
||||
import org.springframework.dao.DataIntegrityViolationException;
|
||||
import org.springframework.dao.DuplicateKeyException;
|
||||
import org.springframework.data.redis.connection.PoolException;
|
||||
import org.springframework.web.HttpRequestMethodNotSupportedException;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||
import org.springframework.web.multipart.MaxUploadSizeExceededException;
|
||||
import org.springframework.web.servlet.NoHandlerFoundException;
|
||||
|
||||
/**
|
||||
* IAM对接全局异常处理器
|
||||
*/
|
||||
@RestControllerAdvice
|
||||
@Slf4j
|
||||
public class IamGlobalExceptionHandler {
|
||||
|
||||
/**
|
||||
* 处理自定义异常
|
||||
*/
|
||||
@ExceptionHandler(IamGlobalException.class)
|
||||
public IamCommonResponseDto handleJeroBootException(IamGlobalException e){
|
||||
IamCommonResponseDto iamCommonResponseDto = new IamCommonResponseDto();
|
||||
iamCommonResponseDto.setBimRequestId(e.getBimRequestId());
|
||||
iamCommonResponseDto.setResultCode("-1"); // 错误码统一为-1
|
||||
iamCommonResponseDto.setMessage(e.getMessage());
|
||||
|
||||
return iamCommonResponseDto;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package com.jero.modules.docking.iam.po;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* PO系统交互必须的实体,包含接口传递的基本信息头
|
||||
*/
|
||||
@Data
|
||||
public class MessageHeader {
|
||||
|
||||
/**
|
||||
* 接口ID
|
||||
*/
|
||||
@JsonProperty("Interface_ID")
|
||||
private String interfaceID;
|
||||
|
||||
/**
|
||||
* UUID
|
||||
*/
|
||||
@JsonProperty("UUID")
|
||||
private String UUID;
|
||||
|
||||
/**
|
||||
* 消息Id
|
||||
*/
|
||||
@JsonProperty("MessageId")
|
||||
private String messageId;
|
||||
|
||||
/**
|
||||
* 发送系统
|
||||
*/
|
||||
@JsonProperty("Sender")
|
||||
private String sender;
|
||||
|
||||
/**
|
||||
* 接收系统
|
||||
*/
|
||||
@JsonProperty("Receiver")
|
||||
private String receiver;
|
||||
|
||||
/**
|
||||
* 发送日期
|
||||
*/
|
||||
@JsonProperty("SendDate")
|
||||
private String sendDate;
|
||||
|
||||
/**
|
||||
* 发送时间
|
||||
*/
|
||||
@JsonProperty("SendTime")
|
||||
private String sendTime;
|
||||
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
package com.jero.modules.docking.iam.po.decrypt;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.jero.modules.docking.iam.po.MessageHeader;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 和PO系统做数据交互的最外层壳,做数据接收用
|
||||
*/
|
||||
@Data
|
||||
public class AcceptDecryptPo {
|
||||
|
||||
@JsonProperty("MessageHeader")
|
||||
private MessageHeader messageHeader;
|
||||
|
||||
@JsonProperty("Tables")
|
||||
private MessageDecryptTabels messageDecryptTabels;
|
||||
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
package com.jero.modules.docking.iam.po.decrypt;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* PO系统交互必须的实体,包含接口传递的正式数据(仅为套的一层壳)
|
||||
*/
|
||||
@Data
|
||||
public class MessageDecryptTabels {
|
||||
|
||||
@JsonProperty("Header")
|
||||
private MessageTablesData header;
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
package com.jero.modules.docking.iam.po.decrypt;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @ClassName: MessageTablesData
|
||||
* @Description:
|
||||
* @Author: yjz
|
||||
* @Date: 2023-11-07 14:21
|
||||
* @Version: 1.0
|
||||
**/
|
||||
@Data
|
||||
public class MessageTablesData {
|
||||
@JsonProperty("data")
|
||||
private String data;
|
||||
}
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
package com.jero.modules.docking.iam.po.decrypt;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.jero.modules.docking.iam.po.MessageHeader;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 和PO系统做数据交互的最外层壳,做数据发送用
|
||||
*/
|
||||
@Data
|
||||
public class SendPoDecryptPo<T> {
|
||||
|
||||
@JsonProperty("MessageHeader")
|
||||
private MessageHeader messageHeader;
|
||||
|
||||
@JsonProperty("Returns")
|
||||
private T returns;
|
||||
|
||||
public SendPoDecryptPo<T> response(MessageHeader messageHeader, T t){
|
||||
SendPoDecryptPo<T> sendPoDecryptPo = new SendPoDecryptPo<>();
|
||||
sendPoDecryptPo.setMessageHeader(messageHeader);
|
||||
sendPoDecryptPo.setReturns(t);
|
||||
|
||||
return sendPoDecryptPo;
|
||||
}
|
||||
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
package com.jero.modules.docking.iam.po.encrypt;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.jero.modules.docking.iam.po.MessageHeader;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 和PO系统做数据交互的最外层壳,做数据接收用
|
||||
*/
|
||||
@Data
|
||||
public class AcceptEncryptPo {
|
||||
|
||||
@JsonProperty("MessageHeader")
|
||||
private MessageHeader messageHeader;
|
||||
|
||||
@JsonProperty("Tables")
|
||||
private MessageEncryptTabels messageEncryptTabels;
|
||||
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
package com.jero.modules.docking.iam.po.encrypt;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* PO系统交互必须的实体,包含接口传递的正式数据(仅为套的一层壳)
|
||||
*/
|
||||
@Data
|
||||
public class MessageEncryptTabels {
|
||||
|
||||
@JsonProperty("Header")
|
||||
private MessageEncryptTabelsHeader header;
|
||||
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
package com.jero.modules.docking.iam.po.encrypt;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 接受数据的tables中的header层
|
||||
*/
|
||||
@Data
|
||||
public class MessageEncryptTabelsHeader {
|
||||
|
||||
@JsonProperty("data")
|
||||
private String data;
|
||||
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
package com.jero.modules.docking.iam.po.encrypt;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 返回数据的Return层
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
public class SendEncryptReturnsPo {
|
||||
|
||||
@JsonProperty("data")
|
||||
private String data;
|
||||
|
||||
public SendEncryptReturnsPo(String data){
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
package com.jero.modules.docking.iam.po.encrypt;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.jero.modules.docking.iam.po.MessageHeader;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 和PO系统做数据交互的最外层壳,做数据发送用
|
||||
*/
|
||||
@Data
|
||||
public class SendPoEncryptPo {
|
||||
|
||||
@JsonProperty("MessageHeader")
|
||||
private MessageHeader messageHeader;
|
||||
|
||||
@JsonProperty("Returns")
|
||||
private SendEncryptReturnsPo returns;
|
||||
|
||||
}
|
||||
+1040
File diff suppressed because it is too large
Load Diff
+31
@@ -0,0 +1,31 @@
|
||||
package com.jero.modules.docking.oa.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.jero.common.api.vo.Result;
|
||||
import com.jero.modules.docking.oa.service.OAService;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
|
||||
/**
|
||||
* @author lijiarao
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/oa")
|
||||
@Slf4j
|
||||
public class OALoginController {
|
||||
@Resource
|
||||
private OAService oaService;
|
||||
|
||||
@ApiOperation("OA单点登录")
|
||||
@PostMapping("/login")
|
||||
public Result<JSONObject> login(@RequestBody JSONObject jsonObject){
|
||||
return oaService.login(jsonObject);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package com.jero.modules.docking.oa.service;
|
||||
|
||||
import cn.hutool.http.Header;
|
||||
import cn.hutool.http.HttpRequest;
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.jero.common.api.vo.Result;
|
||||
import com.jero.modules.system.service.ILoginService;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* @author liJiaRao
|
||||
* @date 2024-02-26 17:20
|
||||
*/
|
||||
@Service
|
||||
public class OAService {
|
||||
@Resource
|
||||
private ILoginService loginService;
|
||||
|
||||
public static final String TICKET = "ticket";
|
||||
public static final String APP_ID = "appId";
|
||||
public static final String APP_SECRET = "appSecret";
|
||||
public static final String ACCESS_TOKEN = "accessToken";
|
||||
public static final String USER_NAME = "userName";
|
||||
|
||||
@Value("${oa.getAccessTokenUrl}")
|
||||
private String getAccessTokenUrl;
|
||||
@Value("${oa.getTicketInfoUrl}")
|
||||
private String getTicketInfoUrl;
|
||||
@Value("${oa.appId}")
|
||||
private String appId;
|
||||
@Value("${oa.appSecret}")
|
||||
private String appSecret;
|
||||
|
||||
|
||||
public Result<JSONObject> login(JSONObject jsonObject) {
|
||||
String ticket = jsonObject.getString(TICKET);
|
||||
JSONObject body = new JSONObject();
|
||||
body.put(APP_ID, appId);
|
||||
body.put(APP_SECRET, appSecret);
|
||||
|
||||
String post = HttpRequest.post(getAccessTokenUrl)
|
||||
.header(Header.CONTENT_TYPE, "application/json")
|
||||
.body(body.toJSONString())
|
||||
.execute().body();
|
||||
JSONObject responseJson = JSONObject.parseObject(post);
|
||||
|
||||
String accessToken = responseJson.getString(ACCESS_TOKEN);
|
||||
JSONObject body1 = new JSONObject();
|
||||
body1.put(ACCESS_TOKEN, accessToken);
|
||||
body1.put(TICKET, ticket);
|
||||
String post1 = HttpRequest.post(getTicketInfoUrl)
|
||||
.header(Header.CONTENT_TYPE, "application/json")
|
||||
.body(body1.toJSONString())
|
||||
.execute().body();
|
||||
JSONObject responseJson1 = JSONObject.parseObject(post1);
|
||||
String userName = responseJson1.getString(USER_NAME);
|
||||
|
||||
return loginService.loginByUserName(userName);
|
||||
}
|
||||
}
|
||||
+85
@@ -0,0 +1,85 @@
|
||||
package com.jero.modules.docking.utils;//package com.jero.modules.iam;
|
||||
|
||||
import com.bamboocloud.codec.BamboocloudFacade;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
@Slf4j
|
||||
public class BamboocloudUtils {
|
||||
public static void main(String[] args) {
|
||||
String aes = BamboocloudFacade.encrypt("{\"uid\":\"104\",\"bimRequestId\":\"95d73fe7aa7a4930a3edea779708a46c\",\"resultCode\":\"0\",\"message\":\"success\"}", "123456", "AES");
|
||||
System.out.println(aes);
|
||||
String aes1 = getPlaintext("RCDFN8z1xhTVuDL8jCNwwYLlH9OqZZhZy+ExtFaM7ppAzIgcaf6MxVq/1hRmm8o7JWmro9Q8yMF7Jnb+Sw0JYOIxXcxgDvOb8E4OIHPXPMgMeuZokKANWQa7aZvGfQA7s+ncR1st9NyjSgo9MtUC7cL4zG+eGcDTb55b/TBBp2G/wqiXM2iNZs0mNMUgyAt7KpeCkvcxkugSbbR0uEteMiFjHTb11xdX/d2ySnJQe7eJ2OCuqC43ugnUr898BLZ+xuPQ1jBUb+OAo9yqvXcYD4nwrC7gKS1qlzTy09U4rymymC9olFpMA9TyP12M+My0XoFJ0gq5kJZnUpax9Xi1aghB0iSGXxUmJzL9kWm18KnMaVFtRYGhwYBv5doUa5bzTGExdokx2YMEzUjkY1MfCcBCGk6VfoiF56a5zfh2w13Okwke19jmFvwp8p4s04n6xrgK8ejg96kiMXjmu2R/HffRieNLK9wtXaEdsTCWwqdgyrm4I3mpmmrLIKnpe/cnYuzZw5wvDwVL0se/j9jVAhnLFyklxwb+x9iJK+EnUzbk9S/OOI8XxGIIgMC6SeNVNjuonzb3xN01IPCOteEAA43vYkRkcIWZnCFRVHez8fBVs4PlsGIN3GK+PpqZfcIKozrbBMD08YAvFGA9KL/wnp2pggpiixuXD+oG18WT3FsO1XD3yX7d7Gu/jONE2SDTNdtGQCXhYJ1ul9/Hp4uNAs6TCR7X2OYW/CnynizTifrGuArx6OD3qSIxeOa7ZH8d99GJ40sr3C1doR2xMJbCp0AmXDbpb/M9qYpLapBu2+BVs4PlsGIN3GK+PpqZfcIKsr9QrVNVIpgXmi+Af40P6qSJjek9yzYXDgzCWx9ry4IEEnyb2ZF42lVhmwOg6dIZ8qiG305NE9wxdW08KjWFDE23TbwkxdmWAAZy4nYp4LEX7nUIzGLsfmtq2h4D0CtioawcrJqNr67/BWlqwfkzl1NHoSnZozOqXE3eSCz3uKsuHJK4bMLTvoPAjhMA4ukMs+ncR1st9NyjSgo9MtUC7cL4zG+eGcDTb55b/TBBp2G/wqiXM2iNZs0mNMUgyAt7fw66deHvwplBeSRYdqWH0V5dH1+B1lYwX3nd1kAlHwez6dxHWy303KNKCj0y1QLtwvjMb54ZwNNvnlv9MEGnYb/CqJczaI1mzSY0xSDIC3uTr7zmnwMR5bQNIDP5s3/LhMSi3nNM2ZTAQfqZM8k0Ql6BSdIKuZCWZ1KWsfV4tWoIQdIkhl8VJicy/ZFptfCpzGlRbUWBocGAb+XaFGuW8w/VpjlYjjcDMh/x6yH1DpUKw9Uhgi5ypiFigrGuTGKSVbOD5bBiDdxivj6amX3CCrK/UK1TVSKYF5ovgH+ND+qkiY3pPcs2Fw4Mwlsfa8uCBBJ8m9mReNpVYZsDoOnSGe1TfeqA4g863/uHzY7iDjpawoNzZmGRL8j2nNhSxQ5F2EPL2VBKQ6qz8T+KD5pVlRpG513hlJIJTqU76qPYiwEWh+cZhAmZIcgN4t/Ao7kOGxvHtVBv24aHAzGnW1PMqM6TCR7X2OYW/CnynizTifrGuArx6OD3qSIxeOa7ZH8d99GJ40sr3C1doR2xMJbCp9/nxHeoEq7BrXIZOamG7dLDxrCHZj8jLTmGvMJREDNJs+ncR1st9NyjSgo9MtUC7cL4zG+eGcDTb55b/TBBp2G/wqiXM2iNZs0mNMUgyAt7R2Ly5850yACGSmx2687YmlWzg+WwYg3cYr4+mpl9wgqyv1CtU1UimBeaL4B/jQ/qpImN6T3LNhcODMJbH2vLggQSfJvZkXjaVWGbA6Dp0hmQ5+XEJykk0ygA1dEpxVSKaFtk5Pymwmv9bXqZrzj7E2dFOiF3Qw02R5xTY3kdeCt3tjzQwAjIZk1xu8aSyA51a9HH7ORSHbLC2odaKM7+R3eSzc73yprSM4ahKLw9g5ObDsl2fxBIcSBc2DEPANMC0rsHuVKLxkKyGGhc79bvlutQBAql+ZS57Yiob6qLIV+FSH7Bsk8dz1dcZM1Qcu9bEMkzY+INICBiJOB1wsVHsInY4K6oLje6CdSvz3wEtn7G49DWMFRv44Cj3Kq9dxgPifCsLuApLWqXNPLT1TivKbKe5XfgQH7+tPPbZM5dzR6155+FR9TbKL/SFDsDn4UFWsKDc2ZhkS/I9pzYUsUORVXCS7dZ54M/8vwQJPk2cgKhrBysmo2vrv8FaWrB+TOXU0ehKdmjM6pcTd5ILPe4qzLLUuVRkEKlSLrpFkFLHplEnNyMgh4SGTZBVyDVO4ED8FSM3DsdwQf8EAslOI+TvqFvMY04IdDTKol6Ggr0b6g/LVkdGi/5zyRKTtlG7ywQP7fw7wOatjZdSiAyHd4GcV2FOYWnylVtqOXfcZa+DjOhBpf77N8yqeClz4u7r/F2Bfl2xnKy0msdf5HSTSMg4sILp/BzbvOlSNy+95pkt/Rbun0JgKlC8vtOk0nsvQ++VbOD5bBiDdxivj6amX3CCqM62wTA9PGALxRgPSi/8J6dqYIKYosblw/qBtfFk9xbDtVw98l+3exrv4zjRNkg099i7AsRJvPp8ujh3VuQM9YQoFCbAFXyVALX3AtSXTWR1v6z2zY/O9ZE/cY5GJFIZ85FAC4u/cWWNknHIYkhiSm/wqiXM2iNZs0mNMUgyAt74NZpySRsMW4myzkMhW0vGgYuiY9YBQ7E16IM66swANIszSUdPD7DTYb1nn+X4nQHGcsXKSXHBv7H2Ikr4SdTNnIoqKznnUBlzkEvjF7jItLrUAQKpfmUue2IqG+qiyFfKFRbZ653kyAJFYEDsjxhnLFVjLloIPTtscY665JQsV8nDRf+NIbBDKQbxtCtCeT5JhmbYGRP3n2nWWUM3Y/m1QX5dsZystJrHX+R0k0jIOI91/XOz0G4csX/lV0/zwLLm6Ld99I8bawwp7DMZzPRpM6TCR7X2OYW/CnynizTifrGuArx6OD3qSIxeOa7ZH8dG+u+zS090O6PFigACG8Rp4VcWYgiVQguIzGdziVJQ38FJz9ez8lXw7E9M10CU7+qoGIhtWEGqmfThhOAWSlvuRnLFyklxwb+x9iJK+EnUzbk9S/OOI8XxGIIgMC6SeNVNjuonzb3xN01IPCOteEAA5HYDZVP7dy9JrGpLpwhqakhYx029dcXV/3dskpyUHu3idjgrqguN7oJ1K/PfAS2fsbj0NYwVG/jgKPcqr13GA+J8Kwu4Cktapc08tPVOK8pJtXmClh9/Wo2gLBFYWle51Wzg+WwYg3cYr4+mpl9wgqyv1CtU1UimBeaL4B/jQ/qpImN6T3LNhcODMJbH2vLggQSfJvZkXjaVWGbA6Dp0hkEHR7bpFZ3pOJLVZd33bnAXYU5hafKVW2o5d9xlr4OM6EGl/vs3zKp4KXPi7uv8XYF+XbGcrLSax1/kdJNIyDiODeK2/B0McXnO+NqhcB2zgmimMlDMmb/mMFMlg8xR3KbDsl2fxBIcSBc2DEPANMC0rsHuVKLxkKyGGhc79bvlutQBAql+ZS57Yiob6qLIV/o4VAE10DqfJcBhDDOYyk2RJzcjIIeEhk2QVcg1TuBA/BUjNw7HcEH/BALJTiPk76hbzGNOCHQ0yqJehoK9G+oPy1ZHRov+c8kSk7ZRu8sEE2BY3DKU8KxY4dvK6cI3oVegUnSCrmQlmdSlrH1eLVqCEHSJIZfFSYnMv2RabXwqcxpUW1FgaHBgG/l2hRrlvNOatmPEXzmtphZe1WoU220zTHBa0Wr6Bv4wNekbjQW6CcNF/40hsEMpBvG0K0J5PnGByStQR+czDTw/PskpqL8d4gWfAWqQwC4piREXJqCMlSg4nL5rkic6Ui/FO2pfAgFcb9RvDP4uwvljSOejSsIzpMJHtfY5hb8KfKeLNOJ+sa4CvHo4PepIjF45rtkfx330YnjSyvcLV2hHbEwlsKnBR34jI1sFr3w6u9HrzxxAM1agTZoUkEViFdIGlSQzodegUnSCrmQlmdSlrH1eLVqZa6wd8Guwj8sumb7Iwx/gKFvMY04IdDTKol6Ggr0b6g/LVkdGi/5zyRKTtlG7ywQEof2S70odz+MTkcK/h3ftVWzg+WwYg3cYr4+mpl9wgqjOtsEwPTxgC8UYD0ov/CenamCCmKLG5cP6gbXxZPcWw7VcPfJft3sa7+M40TZINMsQ17srKPL7v9frPXvm9E+ocn5y5dsGfPDW51szMq7r5IuO1T166XswzGk4T7A47CXW2Y/Gc5D42pKEXx8tu2i9Ew/UgT8eGfprJx0k4DWHQ==", "123456", "AES");
|
||||
System.out.println(aes1);
|
||||
}
|
||||
public static boolean checkUsernamePassword(String username, String password) {
|
||||
log.info("username --->" + username + " password --- >" + password + " ----ok");
|
||||
if("bbcadmin".equals(username)&&"P@ssw0rd".equals(password)) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static String getPlaintext(String ciphertext, String key, String type) {
|
||||
return BamboocloudFacade.decrypt(ciphertext, key, type);
|
||||
}
|
||||
|
||||
public static Boolean verify(Map<String, Object> reqmap, String type) {
|
||||
Map<String, Object> verifymap = new TreeMap<String, Object>();
|
||||
StringBuffer sb = new StringBuffer();
|
||||
Iterator<String> it = reqmap.keySet().iterator();
|
||||
while (it.hasNext()) {
|
||||
String key = (String) it.next();
|
||||
verifymap.put(key, reqmap.get(key));
|
||||
}
|
||||
Iterator<String> ittree = verifymap.keySet().iterator();
|
||||
while (ittree.hasNext()) {
|
||||
String key = (String) ittree.next();
|
||||
if (!"signature".equals(key)) {
|
||||
sb.append(key).append("=").append(verifymap.get(key)).append("&");
|
||||
}
|
||||
}
|
||||
sb.deleteCharAt(sb.length() - 1);
|
||||
System.out.println(reqmap.get("signature") + " now " + sb.toString());
|
||||
return BamboocloudFacade.verify(reqmap.get("signature").toString(), sb.toString(), type);
|
||||
}
|
||||
|
||||
public static String getRequestBody(HttpServletRequest request) {
|
||||
BufferedReader br = null;
|
||||
StringBuilder sb = new StringBuilder();
|
||||
String str = "";
|
||||
try {
|
||||
br = request.getReader();
|
||||
while ((str = br.readLine()) != null) {
|
||||
sb.append(str);
|
||||
}
|
||||
br.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
if (br != null) {
|
||||
try {
|
||||
br.close();
|
||||
} catch (IOException eo) {
|
||||
eo.printStackTrace();
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
if (br != null) {
|
||||
try {
|
||||
br.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
}
|
||||
+92
@@ -0,0 +1,92 @@
|
||||
package com.jero.modules.docking.utils;
|
||||
|
||||
/**
|
||||
* 常量类
|
||||
*/
|
||||
public class DockingConstant {
|
||||
|
||||
/**
|
||||
* 本系统名称
|
||||
*/
|
||||
public static String SYSTEM_NAME = "SRMS";
|
||||
|
||||
/**
|
||||
* IAM系统名称
|
||||
*/
|
||||
public static String IAM_SYSTEM_NAME = "IAM";
|
||||
|
||||
/**
|
||||
* IAM对称加密算法
|
||||
*/
|
||||
public static String IAM_ENCRYPT_TYPE = "AES";
|
||||
|
||||
/**
|
||||
* IAM对称加密密钥
|
||||
*/
|
||||
public static String IAM_ENCRYPT_SECRET = "123456";
|
||||
|
||||
/**
|
||||
* IAM正确时的返回码
|
||||
*/
|
||||
public static String IAM_SUCCESS_RESULT_CODE = "0";
|
||||
|
||||
/**
|
||||
* IAM正确时的返回消息
|
||||
*/
|
||||
public static String IAM_SUCCESS_MESSAGE = "success";
|
||||
|
||||
/**
|
||||
* IAM错误时的返回码
|
||||
*/
|
||||
public static String IAM_ERROR_RESULT_CODE = "500";
|
||||
|
||||
/**
|
||||
* 竹云统一认证平台,接口类型:角色
|
||||
*/
|
||||
public static final String BPMC_TYPE_ROLE = "D_AR";
|
||||
|
||||
/**
|
||||
* 竹云统一认证平台,接口类型:功能权限
|
||||
*/
|
||||
public static final String BPMC_TYPE_RESOURCE = "D_AM";
|
||||
|
||||
/**
|
||||
* 竹云统一认证平台,接口类型:账号与应用角色关系
|
||||
*/
|
||||
public static final String BPMC_TYPE_USER_ROLE = "R_USER_AR";
|
||||
|
||||
/**
|
||||
* 竹云统一认证平台,接口类型:应用角色与应用功能权限关系
|
||||
*/
|
||||
public static final String BPMC_TYPE_ROLE_RESOURCE = "R_AR_AM";
|
||||
|
||||
/**
|
||||
* 竹云统一认证平台,操作类型:新增
|
||||
*/
|
||||
public static String BPMC_ACTION_ADD = "add";
|
||||
/**
|
||||
* 竹云统一认证平台,操作类型:更新
|
||||
*/
|
||||
public static String BPMC_ACTION_UPDATE = "update";
|
||||
|
||||
/**
|
||||
* 竹云统一认证平台,操作类型:删除
|
||||
*/
|
||||
public static String BPMC_ACTION_DELETE = "delete";
|
||||
|
||||
/**
|
||||
* 竹云统一认证平台,功能权限(资源类型):菜单
|
||||
*/
|
||||
public static int BPMC_RESOURCE_TYPE_MENU = 0;
|
||||
|
||||
/**
|
||||
* 竹云统一认证平台,功能权限(资源类型):子菜单
|
||||
*/
|
||||
public static int BPMC_RESOURCE_TYPE_CHILD_MENU = 1;
|
||||
|
||||
/**
|
||||
* 竹云统一认证平台,功能权限(资源类型):按钮
|
||||
*/
|
||||
public static int BPMC_RESOURCE_TYPE_BUTTON = 2;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
package com.jero.modules.docking.utils;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.jero.common.constant.CommonConstant;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @author lqt
|
||||
* @version 1.0
|
||||
* @date 2024/1/18 14:45
|
||||
*/
|
||||
public class ResponsesUtil {
|
||||
private ResponsesUtil(){}
|
||||
|
||||
public static JSONObject getJsonResult(Object jsonMessageHeader,JSONObject jsonResponses) {
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("MessageHeader",jsonMessageHeader);
|
||||
if(!Objects.isNull(jsonResponses)){
|
||||
json.put("Responses",jsonResponses);
|
||||
}
|
||||
return json;
|
||||
}
|
||||
|
||||
public static JSONObject getJsonOk() {
|
||||
return getJsonOk("");
|
||||
}
|
||||
|
||||
public static JSONObject getJsonOkUpper() {
|
||||
return getJsonOkUpper("");
|
||||
}
|
||||
|
||||
public static JSONObject getJsonOkUpper(String message) {
|
||||
JSONObject jsonResponses = new JSONObject();
|
||||
jsonResponses.put("SrmsCode",CommonConstant.SC_OK_200);
|
||||
jsonResponses.put("Message",message);
|
||||
jsonResponses.put("Success",true);
|
||||
jsonResponses.put("Timestamp",System.currentTimeMillis());
|
||||
return jsonResponses;
|
||||
}
|
||||
|
||||
public static JSONObject getJsonOk(String message) {
|
||||
JSONObject jsonResponses = new JSONObject();
|
||||
jsonResponses.put("srmsCode",CommonConstant.SC_OK_200);
|
||||
jsonResponses.put("message",message);
|
||||
jsonResponses.put("success",true);
|
||||
jsonResponses.put("timestamp",System.currentTimeMillis());
|
||||
return jsonResponses;
|
||||
}
|
||||
|
||||
public static JSONObject getJsonErrUpper() {
|
||||
return getJsonErrUpper("",CommonConstant.SC_INTERNAL_SERVER_ERROR_500);
|
||||
}
|
||||
|
||||
public static JSONObject getJsonErrUpper(String message,Integer code) {
|
||||
JSONObject jsonResponses = new JSONObject();
|
||||
jsonResponses.put("SrmsCode",code);
|
||||
jsonResponses.put("Message",message);
|
||||
jsonResponses.put("Success",false);
|
||||
jsonResponses.put("Timestamp",System.currentTimeMillis());
|
||||
return jsonResponses;
|
||||
}
|
||||
|
||||
public static JSONObject getJsonErr() {
|
||||
return getJsonErr("",CommonConstant.SC_INTERNAL_SERVER_ERROR_500);
|
||||
}
|
||||
|
||||
public static JSONObject getJsonErr(String message,Integer code) {
|
||||
JSONObject jsonResponses = new JSONObject();
|
||||
jsonResponses.put("srmsCode",code);
|
||||
jsonResponses.put("message",message);
|
||||
jsonResponses.put("success",false);
|
||||
jsonResponses.put("timestamp",System.currentTimeMillis());
|
||||
return jsonResponses;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package com.jero.modules.docking.utils;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
|
||||
public class SHA256Util {
|
||||
public static void main(String[] args) {
|
||||
String sha256StrJava = getSHA256StrJava("123456");
|
||||
System.out.println(sha256StrJava);
|
||||
}
|
||||
/**
|
||||
* 利用java原生的摘要实现SHA256加密密后的报文
|
||||
*/
|
||||
public static String getSHA256StrJava(String str) {
|
||||
MessageDigest messageDigest;
|
||||
String encodeStr = "";
|
||||
try {
|
||||
messageDigest = MessageDigest.getInstance("SHA-256");
|
||||
messageDigest.update(str.getBytes(StandardCharsets.UTF_8));
|
||||
encodeStr = byte2Hex(messageDigest.digest());
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return encodeStr;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将byte转为16进制
|
||||
*/
|
||||
private static String byte2Hex(byte[] bytes) {
|
||||
StringBuilder stringBuffer = new StringBuilder();
|
||||
String temp;
|
||||
for (byte aByte : bytes) {
|
||||
temp = Integer.toHexString(aByte & 0xFF);
|
||||
if (temp.length() == 1) {
|
||||
//1得到一位的进行补0操作
|
||||
stringBuffer.append("0");
|
||||
}
|
||||
stringBuffer.append(temp);
|
||||
}
|
||||
return stringBuffer.toString();
|
||||
}
|
||||
}
|
||||
@@ -7,10 +7,10 @@ import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.jero.common.api.SendMessageAPI;
|
||||
import com.jero.common.api.dto.message.HiworkTodoAdd;
|
||||
import com.jero.common.api.dto.message.SendMessageDTO;
|
||||
import com.jero.common.api.vo.ResultCommon;
|
||||
import com.jero.modules.common.service.SendMessageAPI;
|
||||
import com.jero.common.constant.enums.YesOrNoEnum;
|
||||
import com.jero.common.exception.JeroBootException;
|
||||
import com.jero.common.system.vo.LoginUser;
|
||||
|
||||
+1
-1
@@ -4,9 +4,9 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.jero.common.api.SendMessageAPI;
|
||||
import com.jero.common.api.dto.message.SendMessageDTO;
|
||||
import com.jero.common.api.vo.ResultCommon;
|
||||
import com.jero.modules.common.service.SendMessageAPI;
|
||||
import com.jero.common.constant.enums.LanguageEnum;
|
||||
import com.jero.common.constant.enums.YesOrNoEnum;
|
||||
import com.jero.common.exception.JeroBootException;
|
||||
|
||||
+1
-1
@@ -3,8 +3,8 @@ package com.jero.modules.laws.localTool.service.impl;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.jero.common.api.SendMessageAPI;
|
||||
import com.jero.common.api.dto.message.SendMessageDTO;
|
||||
import com.jero.modules.common.service.SendMessageAPI;
|
||||
import com.jero.modules.laws.common.constant.MessageTemplateCodeCommon;
|
||||
import com.jero.modules.laws.common.util.DateUtil;
|
||||
import com.jero.modules.laws.localTool.entity.LawsEarlyWarningMessage;
|
||||
|
||||
+1
-1
@@ -4,11 +4,11 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.jero.common.api.SendMessageAPI;
|
||||
import com.jero.common.api.dto.message.SendMessageDTO;
|
||||
import com.jero.common.api.vo.ResultCommon;
|
||||
import com.jero.common.exception.JeroBootException;
|
||||
import com.jero.common.system.vo.LoginUser;
|
||||
import com.jero.modules.common.service.SendMessageAPI;
|
||||
import com.jero.modules.laws.common.constant.DictCommon;
|
||||
import com.jero.modules.laws.common.constant.FieldCommon;
|
||||
import com.jero.modules.laws.common.constant.MessageTemplateCodeCommon;
|
||||
|
||||
+1
-1
@@ -1,8 +1,8 @@
|
||||
package com.jero.modules.laws.standardmasterplan.job;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.jero.common.api.SendMessageAPI;
|
||||
import com.jero.common.api.dto.message.SendMessageDTO;
|
||||
import com.jero.modules.common.service.SendMessageAPI;
|
||||
import com.jero.modules.laws.standard.entity.LawsDomesticStandard;
|
||||
import com.jero.modules.laws.standard.service.ILawsDomesticStandardService;
|
||||
import com.jero.modules.laws.standardmasterplan.common.LawsStandardMasterPlanCommon;
|
||||
|
||||
Reference in New Issue
Block a user