Compare commits

...

6 Commits

Author SHA1 Message Date
yang d5157ce481 Merge branch 'feature/community-center' into preview 2025-01-18 19:04:15 +08:00
Diyu0904 a8bf9b7390 Merge remote-tracking branch 'origin/preview' into preview 2025-01-18 15:01:24 +08:00
ChenYan 925705caaa Merge remote-tracking branch 'origin/preview' into preview 2025-01-18 15:00:19 +08:00
Diyu0904 f2c3d73071 Merge branch 'feature/admin' into preview
# Conflicts:
#	mcwl-resource/src/main/java/com/mcwl/resource/domain/WorkFlow.java
#	mcwl-resource/src/main/java/com/mcwl/resource/domain/WorkFlowVersion.java
2025-01-18 15:00:05 +08:00
ChenYan 0fc813f3a0 feat 2025-01-18 14:58:53 +08:00
Diyu0904 b5ca5718f6 新增线程池异步审核工作流
新增工作流的名称审核
新增工作流版本得名称+内容+图片审核
修复工作流修改时间丢失bug
2025-01-18 14:55:28 +08:00
17 changed files with 997 additions and 75 deletions

View File

@ -0,0 +1,74 @@
/*
* Copyright (c) 2017. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
* www.hnapay.com
*/
package com.mcwl.common.constant;
/**
*
*/
public class NcountKey {
public static String NCOUNT_URL = "https://ncount.hnapay.com/api/";
//新生签名使用的算法
public static String ALGORITHM = "RSA";
//类型
public static String SIGN_ALGORITHM = "SHA1withRSA";
//前置系统公钥
/*public static String NCOUNT_PUBLIC_KEY = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC9vGvYjivDF5uPBNDXMtoAtjYQ2YPSsfareduDG6kHL/N3A05rFHA11Dbr+UON82Y4V0RFKAQeZFPWcTLjcy6ntZVI8XoYLpuVQBPsb0Ya+PwbzR8/TmUdUf91ru8APtJgqkULgPVrO1hhzZ1tQMznosNLTOqbknMnnMcwzB5yYwIDAQAB";*/
public static String NCOUNT_PUBLIC_KEY = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC9vGvYjivDF5uPBNDXMtoAtjYQ" +
"2YPSsfareduDG6kHL/N3A05rFHA11Dbr+UON82Y4V0RFKAQeZFPWcTLjcy6ntZVI" +
"8XoYLpuVQBPsb0Ya+PwbzR8/TmUdUf91ru8APtJgqkULgPVrO1hhzZ1tQMznosNL" +
"TOqbknMnnMcwzB5yYwIDAQAB";
// public static String MER_PRIVATE_KEY = "MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBAOMNbm6VJwmOQh74\r\n" +
// "DyhrKpX+qLKYeeW3sUoXmmstka5AeAVf3UjHCwuZQHviwwGxUIdi0r320aIUetb1\r\n" +
// "gRPm4WDMz9FPsBs54hPhHxIBrt3mXEl9cP4S8YdlivQY7Hbf1WqxNhy5wEf0OpkZ\r\n" +
// "JjS7wEU46JfKwbGuzcSVkgWi+iuTAgMBAAECgYBX9OAO3qDcxss+jAHzOnCo4pof\r\n" +
// "dYnjP6HiffpIAsMoqbjU/CoRA2p398pPM60vfq0fhVz2UiMrkptzom96cjpkNpQ4\r\n" +
// "4uztdoozxKmnHiIV1ttISLqMjfh4xkapxVkFJDcEn8ZTpiMmfjEHX0ao3xk1gprL\r\n" +
// "vLMpRr1ar5vCqFEGIQJBAPgrGYpteTtjpZqskP9Pg9O7E4XuAgJ01Kqd7Mp8s3Ij\r\n" +
// "1nPUmhG+GDDV6MTNDVUfvLWTTvc4MjU2xTQm+6cu2RcCQQDqN72gqLbaKAMULUCt\r\n" +
// "vVST7eT53OBPMjbBi90JRqNPZrXuS+Wr7tw3zVb8j5p0w2qBotK7wEq9Pmjidlma\r\n" +
// "JhblAkAT95vJeH9tmNnlNQdBk4s+yOmMOBcvTWkjBSvdKuVhRKLnlO6EiO/3Ve6x\r\n" +
// "jvIIrFIJpf2PhJT9lReO16gdznYnAkEApvOCpNF+PXUF9Mzo7K8naabKb9yku28E\r\n" +
// "nuPOc/05DbEd/7V0CiFiMhiZZ8AJDi/5bFyesBw6ajjhVIOeDQYXjQJARsJP8PDK\r\n" +
// "8sEtHtXwOn2vKbx1lSpT9aX3uK/eB7zJLUMBcAsLsoHZC+YqjKjoSD4sGM6ukH0w\r\n" +
// "zzlZdaTU3Ued3g==";
//测试环境商户私钥
/*public static String MER_PRIVATE_KEY = "MIICeAIBADANBgkqhkiG9w0BAQEFAASCAmIwggJeAgEAAoGBAM2Ak5XX86FypU3t\n" +
"DSXlDQp+eXgowPLjBoEt0ZfEfhUtLIrU8J4YzUiz9tUzI6o6mGafDltUasdyRtt3\n" +
"+NdSQuFq7MhZyWwGUqle3ybGswYVkN8+LMADCQEOYphM4p0j/OGw7QYcL/ERHsUW\n" +
"2MGPR6M/9xe0KURIDdeJC0ulxQ8TAgMBAAECgYEAqgTfldBl68PbSb5+60Q25uC+\n" +
"hJBLGmiDwCp1Rng1zDVkrbQBIvvoE2d5Jui5cCQsZHLhwOP1t+8u+nKmuRaA51vB\n" +
"sQ+F01SqYrmS/TV/iD5xjAteSXmTf76doP7FwrHuRQ391KcdIn+W0R7cv1tLBY5B\n" +
"oRnAcAwWhQMiRWf+yPECQQD6TtJ7kETd5Rl3YryFMTvfW73oHxss87jz6/tUIPxF\n" +
"rXYu+ywD4Ut1AWwtN6Td6kZhWOUhG2d4OUVYP0FtjjprAkEA0izql6EQB7SF8AE5\n" +
"j8U7Weg8IqPk8b78neav8y1CpjSuwOaRxcS1Mk+W2/AXRvTRL2VUw+Az4boAz3MS\n" +
"WnP3+QJBAJW6vtfhRgDCQciTjJfUCq+irmgC63upUzK+L7p0fNOlXrPd1ceAZmXY\n" +
"cwBdb8a7lFw5E98JCIz3HU8bj6TcVn8CQQC3EfLBYsSwwXjNBnQaHAVHmfcPgU0B\n" +
"mYc3DuKB4hGk7kytr+iXqHDgQt039FiCMOso6o28FEV8v+TGzgfVjCAZAkA9NWuj\n" +
"VEHwFLZLtftLDQxGfJmWJGl4CipOjv6YpQEw0A2NBtUp5tuiJ09DNq5RaKJbfWUY\n" +
"fQJkAZ0tsrXBWqgK";*/
public static String MER_PRIVATE_KEY = "MIICeAIBADANBgkqhkiG9w0BAQEFAASCAmIwggJeAgEAAoGBALAkYQn6emeoRsStWebayuyqMB91j27j+gMJO+YqdK1jVpgp4yh2pja9TxQvoLnd3mJcjyACYvW8imWjgtRDDJK4FOj1pYK+EgbX+32PpD8STDnbC93JertbexKk3NNQi5cur40qGEWRspJEPHZTvobZ+EhsJlH8b/oGG1VKORlXAgMBAAECgYA5qf82tBCEhNt+Ib4vzGroZaLRebwWMn4zpj88z6NY7A96SyQ5p/YsL3eHBTyZ/J+EFgcpFH7vMeUg9xGqibTAexqulCNTvOQBYNGra85yUsnob19sHR/YCx80HI5el8RD2mRL6kbmOnab5yi5O2fc8tl+DRJztKXU3YgNH+OhsQJBAPUENKWJJU/OloKYAvOceAy66ZzEKI/myt5x5jcmZTp7bc0wzsxQQ60TfTqfmpOqEd9cJWxggHvutzCBqPovOZkCQQC4CcaSKs3Z2E9/uPr92Z+DIv/5RHTkq66WstG5iM/5aoz7Hf7mP8xTgcjtKNPTcb+nC5IE6M41IuWnSAz8bCBvAkEAuR/FW3GFFIil5eRPDpuhhRTQn9cCQsABdhMe+3pyL77Elq2TAoJ+r82y59FhrMJqIJZx3DIJwhn6pZbCAs4duQJBAKTMrDIrflY660WWIbu7aqmFZ+6QrJQwYJC15DPeHU5daY1dGOqZ6qBEseYdD0Jis5okNEeNKUpPy5J2ZJqNQKUCQQDdyqJhwxjiQ7BtafYNEf/fmP5bkHSKhzOM6lIN8cLX6h535xHObHdOpmKgUg9mLHgJvlNQy+glh40AF2HdNcLS";
public static String MER_ID = "300050402928";
/**
* id
*/
public static String ZFB_MER_ID = "2405101553133642463";
//测试环境商户ID
//public static String MER_ID = "110000030228";
}

View File

@ -0,0 +1,114 @@
/**
*
*/
package com.mcwl.common.exception;
import org.apache.commons.lang3.StringUtils;
/**
* NCountDemoException
*/
public class NCountDemoException extends Exception {
/**
*
*/
private static final long serialVersionUID = -7121642511651992156L;
/**
*
*/
@SuppressWarnings("rawtypes")
protected Class errClass = null;
/**
*
*/
protected String errCode = null;
/**
*
*/
protected String errMsg = null;
public NCountDemoException() {
super();
}
public NCountDemoException(String errMsg) {
super("no errMsg");
this.errMsg = errMsg;
}
public NCountDemoException(String errMsg, Exception e) {
super("no errMsg", e);
this.errMsg = errMsg;
}
public NCountDemoException(String errCode, String errMsg) {
super(errMsg);
this.errCode = errCode;
this.errMsg = errMsg;
}
public NCountDemoException(String errCode, String errMsg, Exception e) {
super(errMsg, e);
this.errCode = errCode;
this.errMsg = errMsg;
}
@SuppressWarnings("rawtypes")
public NCountDemoException(String errCode, Class errClass) {
super("no errMsg");
this.errCode = errCode;
this.errClass = errClass;
}
@SuppressWarnings("rawtypes")
public NCountDemoException(String errCode, String errMsg, Class errClass) {
super(errMsg);
this.errCode = errCode;
this.errMsg = errMsg;
this.errClass = errClass;
}
@SuppressWarnings("rawtypes")
public NCountDemoException(String errCode, String errMsg, Class errClass, Exception e) {
super(errMsg, e);
this.errClass = errClass;
this.errCode = errCode;
this.errMsg = errMsg;
}
public String printErrMsg() {
StringBuffer msg = new StringBuffer("");
if (StringUtils.isNotBlank(errCode)) {
msg.append("Exception errCode is [").append(this.errCode).append("];\n");
}
if (this.errClass != null) {
msg.append("Exception Class is [").append(this.errClass.getName()).append("];\n");
}
msg.append("Exception Message is [").append(this.errMsg).append("];\n");
// 打印错误异常堆栈
if (getCause() != null) {
getCause().printStackTrace();
}
return msg.toString();
}
@SuppressWarnings("rawtypes")
public Class getErrClass() {
return errClass;
}
public String getErrCode() {
return errCode;
}
public String getErrMsg() {
return errMsg;
}
}

View File

@ -0,0 +1,197 @@
package com.mcwl.common.utils;
import com.alibaba.fastjson2.util.DateUtils;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
public class ToDateUtils {
/** 时间格式yyyyMMddHHmmss'. */
public static String DEFAULT_PATTERN = "yyyyMMddHHmmss";
/** 时间格式yyyyMMdd'. */
public static String yyyyMMdd = "yyyyMMdd";
/** 时间格式yyyy-MM-dd'. */
public static String yyyy_MM_dd = "yyyy-MM-dd";
/** 时间格式HH:mm:ss'. */
public static String HH_mm_ss = "HH:mm:ss";
/** 时间格式yyyy-MM-dd' 'HH:mm:ss'. */
public static String yyyy_MM_dd_HH_mm_ss = "yyyy-MM-dd' 'HH:mm:ss";
/** 时间格式yyyy-MM-dd' 'HH:mm'. */
public static String yyyy_MM_dd_HH_mm = "yyyy-MM-dd' 'HH:mm";
/**
* (:yyyyMMddHHmmss)
*
* @return
*/
public static String getCurrDate() {
return getCurrDate(DEFAULT_PATTERN);
}
/**
* yyyyMMddHHmmss
*
* @param str
* @return
*/
public static Date strToDate(String str) {
return strToDate(str, DEFAULT_PATTERN);
}
/**
* yyyyMMddHHmmss
*
* @param date
*
* @return
*/
public static String format(Date date) {
return DateUtils.format(date, DEFAULT_PATTERN);
}
/**
*
*
* @param str
*
* @param pattern
*
* @return
*/
public static Date strToDate(String str, String pattern) {
SimpleDateFormat format = new SimpleDateFormat(pattern);
Date date = null;
try {
date = format.parse(str);
} catch (ParseException e) {
e.printStackTrace();
}
return date;
}
/**
*
*
* @param date
*
* @param pattern
*
* @return
*/
public static String format(Date date, String pattern) {
SimpleDateFormat sdf = new SimpleDateFormat(pattern);
return sdf.format(date);
}
/**
*
*
* @param pattern
*
* @return
*/
public static String getCurrDate(String pattern) {
long d = System.currentTimeMillis();
Date date = new Date(d);
return format(date, pattern);
}
/**
*
*
* @return
*/
public static Date getSystemDate() {
long d = System.currentTimeMillis();
Date date = new Date(d);
return date;
}
/**
*
*
* @param strTime
* @param pattern
* @return
*/
public static String getTime(String strTime, String pattern) {
SimpleDateFormat s = new SimpleDateFormat(pattern);
try {
return String.valueOf(s.parse(strTime).getTime());// 时间戳
} catch (ParseException e) {
e.printStackTrace();
return String.valueOf(new Date().getTime());
}
}
/**
*
*
* @param date
* @param mask
* @return
*/
public static final String date2string(Date date, String style) {
SimpleDateFormat sdf = new SimpleDateFormat(style);
return sdf.format(date);
}
/**
* .
*
* @return yyyyMMddHHmmss
*/
public static String getLocalFullDateTime14() {
return date2string(new Date(), DEFAULT_PATTERN);
}
/**
*
* @param mask
* @return
*/
public static final String now2string(String mask){
return date2string(new Date(), mask);
}
/**
*
* @param date
* @param field
* @param amount
* @return <br>
* add(new Date(), Calendar.DATE, -1)<br>
* add(new Date(), Calendar.YEAR, 1)
*/
public static Date add(Date date, int field, int amount) {
Calendar c = Calendar.getInstance();
c.setTime(date);
c.add(field, amount);
return c.getTime();
}
/**
*
* @param str
* @param patternS
* @param patternE
* @return
*/
public static String strToStr(String str, String patternS,String patternE){
return format(strToDate(str,patternS),patternE);
}
}

View File

@ -1,4 +1,4 @@
package com.mcwl.web.controller.common.baidu;
package com.mcwl.common.utils.baidu;
import org.codehaus.jettison.json.JSONObject;
@ -11,6 +11,7 @@ import java.util.List;
import java.util.Map;
/**
*
* @author DaiZibo
* @date 2025/1/16
* @apiNote

View File

@ -1,4 +1,4 @@
package com.mcwl.web.controller.common.baidu;
package com.mcwl.common.utils.baidu;
import com.mcwl.common.utils.Base64Util;
@ -11,7 +11,7 @@ import java.net.URL;
import java.net.URLEncoder;
/**
/**
* @author DaiZibo
* @date 2025/1/16
* @apiNote
@ -21,9 +21,9 @@ import java.net.URLEncoder;
public class BaiduCensor {
//设置APPID/AK/SK
public static final String APP_ID = "115921420";
public static final String API_KEY = "UOU5eZh73FOrsQbSKbO0wAAA";
public static final String SECRET_KEY = "nKT1ztffZk9XTxEnhcFdQW0UFggMWq9t";
public static final String APP_ID = "6273132";
public static final String API_KEY = "8cxN3yyAbQeKGhS0cHAVzlNN";
public static final String SECRET_KEY = "hubX4QXVGJbV9ccEVGv4Ifd2w80B71nD";
//图像审核
public static String ImageCnesor(String filePath) {

View File

@ -0,0 +1,98 @@
package com.mcwl.common.utils.sign;
/**
*
*/
public class HexStringByte {
/**
*
* @param bin String
* @return
*/
public static String stringToHex(String bin) {
char[] digital = "0123456789ABCDEF".toCharArray();
StringBuffer sb = new StringBuffer("");
byte[] bs = bin.getBytes();
int bit;
for (int i = 0; i < bs.length; i++) {
bit = (bs[i] & 0x0f0) >> 4;
sb.append(digital[bit]);
bit = bs[i] & 0x0f;
sb.append(digital[bit]);
}
return sb.toString();
}
/**
*
* @param hex String
* @return String
*/
public static String hexToString(String hex) {
String digital = "0123456789ABCDEF";
char[] hex2char = hex.toCharArray();
byte[] bytes = new byte[hex.length() / 2];
int temp;
for (int i = 0; i < bytes.length; i++) {
temp = digital.indexOf(hex2char[2 * i]) * 16;
temp += digital.indexOf(hex2char[2 * i + 1]);
bytes[i] = (byte) (temp & 0xff);
}
return new String(bytes);
}
/**
* java
* @param bts
* @return
*/
public static String byteToHex(byte[] bts) {
String des = "";
String tmp = null;
for (int i = 0; i < bts.length; i++) {
tmp = (Integer.toHexString(bts[i] & 0xFF));
if (tmp.length() == 1) {
des += "0";
}
des += tmp;
}
return des;
}
/**
* hex2byte.
*
* @param hexStr hexStr
* @return byte[]
*/
public static byte[] hex2byte(String hexStr) {
byte[] bts = new byte[hexStr.length() / 2];
for (int i = 0, j = 0; j < bts.length; j++) {
bts[j] = (byte) Integer.parseInt(hexStr.substring(i, i + 2), 16);
i += 2;
}
return bts;
}
/**
* java
* @param b
* @return
*/
public static byte[] hexToByte(byte[] b) {
if ((b.length % 2) != 0) {
throw new IllegalArgumentException("长度不是偶数");
}
byte[] b2 = new byte[b.length / 2];
for (int n = 0; n < b.length; n += 2) {
String item = new String(b, n, 2);
// 两位一组,表示一个字节,把这样表示的16进制字符串还原成一个进制字节
b2[n / 2] = (byte) Integer.parseInt(item, 16);
}
b = null;
return b2;
}
}

View File

@ -0,0 +1,161 @@
package com.mcwl.common.utils.sign;
import com.baidu.aip.util.Base64Util;
import com.mcwl.common.constant.NcountKey;
import com.mcwl.common.exception.NCountDemoException;
import lombok.extern.slf4j.Slf4j;
import javax.crypto.Cipher;
import java.io.ByteArrayOutputStream;
import java.security.Key;
import java.security.KeyFactory;
import java.security.PrivateKey;
import java.security.PublicKey;
import java.security.spec.InvalidKeySpecException;
import java.security.spec.X509EncodedKeySpec;
/**
*
*/
@Slf4j
public class HnapaySign {
/**
* RSA
*/
private static final int MAX_ENCRYPT_BLOCK = 117;
/**
*
*
* @param privateKey
* @param merData
* @return
*/
public static byte[] sign(PrivateKey privateKey, String merData) throws NCountDemoException {
try {
return RSAAlgorithms.sign(privateKey, merData);
} catch (Exception e) {
throw new NCountDemoException("100F1002", "读取密钥异常", e);
}
}
/**
*
*
* @param merData
* @param signMsg
* @return true-- false--
* @throws NCountDemoException
*/
public static boolean verify(String merData, String signMsg)
throws NCountDemoException {
boolean result = false;
String hexPublicKey = HexStringByte.byteToHex(Base64Util.decode(NcountKey.NCOUNT_PUBLIC_KEY));
String signVal = HexStringByte.byteToHex(Base64Util.decode(signMsg));
result = verifySignatureByRSA(merData, signVal, "UTF-8", hexPublicKey);
return result;
}
/**
* @param src
* @param dit
* @param charsetType
* @param publicKey
* @return
* @throws NCountDemoException
*/
private static boolean verifySignatureByRSA(String src, String dit, String charsetType, String publicKey)
throws NCountDemoException {
if ((src == null) || ("".equals(src.trim()))) {
throw new NCountDemoException("src is empty ,verifySignatureByRSA无法执行");
}
if ((dit == null) || ("".equals(dit.trim()))) {
throw new NCountDemoException("dit is empty ,verifySignatureByRSA无法执行");
}
try {
return RSAAlgorithms.verify(publicKey, src, dit);
} catch (Exception e) {
e.printStackTrace();
throw new NCountDemoException("验证签名出现异常:请检查输入参数", e.getMessage());
}
}
/**
* <p>
*
* </p>
*
* @param data
* @return
* @throws Exception
*/
public static byte[] encryptByPublicKey(byte[] data, String key) throws Exception {
if (data == null) {
throw new Exception("需要加密的数据为空");
}
PublicKey publicKey = getPublicKey(key);
X509EncodedKeySpec x509KeySpec = new X509EncodedKeySpec(publicKey.getEncoded());
KeyFactory keyFactory = KeyFactory.getInstance(NcountKey.ALGORITHM);
Key publicK = keyFactory.generatePublic(x509KeySpec);
// 对数据加密
Cipher cipher = Cipher.getInstance(keyFactory.getAlgorithm());
cipher.init(Cipher.ENCRYPT_MODE, publicK);
int inputLen = data.length;
ByteArrayOutputStream out = new ByteArrayOutputStream();
int offSet = 0;
byte[] cache;
int i = 0;
// 对数据分段加密
while (inputLen - offSet > 0) {
if (inputLen - offSet > MAX_ENCRYPT_BLOCK) {
cache = cipher.doFinal(data, offSet, MAX_ENCRYPT_BLOCK);
} else {
cache = cipher.doFinal(data, offSet, inputLen - offSet);
}
out.write(cache, 0, cache.length);
i++;
offSet = i * MAX_ENCRYPT_BLOCK;
}
byte[] encryptedData = out.toByteArray();
out.close();
return encryptedData;
}
/**
* @param publicKey
* @return
* @throws Exception
*/
private static PublicKey getPublicKey(String publicKey) throws Exception {
PublicKey pubKey = null;
try {
KeyFactory keyFactory = KeyFactory.getInstance(NcountKey.ALGORITHM);
pubKey = keyFactory.generatePublic(new X509EncodedKeySpec(Base64Util.decode(publicKey)));
} catch (InvalidKeySpecException e) {
throw new Exception("公钥无效!", e);
}
return pubKey;
}
/**
* hex2byte.
*
* @param hexStr hexStr
* @return byte[]
*/
public static byte[] hex2byte(String hexStr) {
byte[] bts = new byte[hexStr.length() / 2];
for (int i = 0, j = 0; j < bts.length; j++) {
bts[j] = (byte) Integer.parseInt(hexStr.substring(i, i + 2), 16);
i += 2;
}
return bts;
}
}

View File

@ -0,0 +1,35 @@
package com.mcwl.common.utils.sign;
import com.baidu.aip.util.Base64Util;
import com.mcwl.common.constant.NcountKey;
import com.mcwl.common.exception.NCountDemoException;
import java.security.KeyFactory;
import java.security.PrivateKey;
import java.security.spec.PKCS8EncodedKeySpec;
public class KeyUtils {
/**
*
*
*/
public static PrivateKey loadPrivateKey(String privateKey) throws NCountDemoException {
// 去除头尾标志
// 去除换行符
privateKey = privateKey.replace("\r", "").replace("\n", "").replace(" ", "");
byte[] bPriKey = Base64Util.decode(privateKey);
PKCS8EncodedKeySpec keySpec = new PKCS8EncodedKeySpec(bPriKey);
KeyFactory keyFactory;
try {
keyFactory = KeyFactory.getInstance(NcountKey.ALGORITHM);
PrivateKey key = keyFactory.generatePrivate(keySpec);
return key;
} catch (Exception e) {
e.printStackTrace();
throw new NCountDemoException("加载私钥异常", e);
}
}
}

View File

@ -0,0 +1,108 @@
/*
* Copyright (c) 2016. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
* www.hnapay.com
*/
package com.mcwl.common.utils.sign;
import com.mcwl.common.constant.NcountKey;
import com.mcwl.common.exception.NCountDemoException;
import java.io.UnsupportedEncodingException;
import java.security.*;
import java.security.spec.InvalidKeySpecException;
import java.security.spec.X509EncodedKeySpec;
/**
*
*/
public class RSAAlgorithms {
/**
* @param publicKey
* HEX
* @return
* @throws Exception
*/
public static PublicKey getPublicKey(String publicKey) throws NCountDemoException {
PublicKey pubKey = null;
try {
byte[] encodedKey = HexStringByte.hexToByte(publicKey.getBytes());
KeyFactory keyFactory = KeyFactory.getInstance(NcountKey.ALGORITHM);
pubKey = keyFactory.generatePublic(new X509EncodedKeySpec(encodedKey));
} catch (InvalidKeySpecException e) {
throw new NCountDemoException("公钥无效!", e);
} catch (NoSuchAlgorithmException e) {
throw new NCountDemoException("算法类型无效!", e);
}
return pubKey;
}
/**
* @param priKey
*
* @param data
*
* @return
* @throws Exception
*/
public static byte[] sign(PrivateKey priKey, String data) throws NCountDemoException {
try {
Signature signet = Signature.getInstance(NcountKey.SIGN_ALGORITHM);
signet.initSign(priKey);
signet.update(data.getBytes("UTF-8"));
return signet.sign();
} catch (Exception e) {
throw new NCountDemoException(e.getMessage());
}
}
/**
*
*
* @param publicKey
* HEX
* @param merData
*
* @param signMsg
*
* @return true false
* @throws Exception
*/
public static Boolean verify(String publicKey, String merData, String signMsg) throws NCountDemoException {
boolean bVerify = false;
Signature signet = null;
try {
signet = Signature.getInstance(NcountKey.SIGN_ALGORITHM);
} catch (NoSuchAlgorithmException e) {
throw new NCountDemoException("算法类型不能为空!", e);
}
PublicKey pubKey = getPublicKey(publicKey);
try {
signet.initVerify(pubKey);
} catch (InvalidKeyException e) {
throw new NCountDemoException("公钥无效!", e);
}
try {
signet.update(merData.getBytes("UTF-8"));
} catch (SignatureException e) {
throw new NCountDemoException("验签时符号异常!", e);
} catch (UnsupportedEncodingException e) {
throw new NCountDemoException("不支持的编码方式", e);
}
try {
bVerify = signet.verify(HexStringByte.hex2byte(signMsg));
} catch (SignatureException e) {
throw new NCountDemoException("验签异常!", e);
}
return bVerify;
}
}

View File

@ -1,31 +0,0 @@
//package com.mcwl.common.web;
//
//
//import org.springframework.dao.DataAccessException;
//
//import java.util.List;
//
///**
// * 公共mapper
//
// */
//public interface BaseMapper<K, V> {
//
// /**
// * 根据条件查询数据的数量
// *
// * @param v 实体类
// * @return 数量
// */
// int searchCount(V v);
//
// /**
// * 根据条件查询数据
// *
// * @param v 实体类
// * @return List<K> 实体类的集合
// * @throws DataAccessException 数据访问异常
// */
// List<K> searchByCondition(V v) throws DataAccessException;
//
//}

View File

@ -91,9 +91,9 @@ public class PublishCommissionServiceImpl extends ServiceImpl<PublishCommissionM
.orderByDesc(PublishCommission::getCreateTime);
// 添加父评论
List<PublishCommission> modelCommentList = publishCommentMapper.selectList(lqw);
for (PublishCommission modelComment : modelCommentList) {
PublicModelCommentVo modelCommentVo = getModelCommentVo(modelComment);
CommentVoList.add(modelCommentVo);
for (PublishCommission Comment : modelCommentList) {
PublicModelCommentVo CommentVo = getModelCommentVo(Comment);
CommentVoList.add(CommentVo);
}
return CommentVoList;
@ -101,17 +101,17 @@ public class PublishCommissionServiceImpl extends ServiceImpl<PublishCommissionM
/**
* ModelCommentVo
* CommentVo
*
* @param Comment
* @return ModelCommentVo
* @return CommentVo
*/
@NotNull
private PublicModelCommentVo getModelCommentVo(PublishCommission Comment) {
Long userId = Comment.getUserId();
SysUser sysUser = sysUserService.selectUserById(userId);
// 构建ModelCommentVo对象
// 构建CommentVo对象
PublicModelCommentVo CommentVo = new PublicModelCommentVo();
CommentVo.setUserId(userId);
CommentVo.setUserName(sysUser.getUserName());
@ -129,18 +129,18 @@ public class PublishCommissionServiceImpl extends ServiceImpl<PublishCommissionM
/**
*
*
* @param modelCommentId id
* @param CommentId id
* @return List<ModelCommentVo>
*/
private List<PublicModelCommentVo> getContentList(Long modelCommentId) {
private List<PublicModelCommentVo> getContentList(Long CommentId) {
List<PublicModelCommentVo> CommentVoList = new ArrayList<>();
if (Objects.isNull(modelCommentId)) {
if (Objects.isNull(CommentId)) {
return CommentVoList;
}
// 查询子评论
LambdaQueryWrapper<PublishCommission> lqw = new LambdaQueryWrapper<PublishCommission>()
.eq(PublishCommission::getParentId, modelCommentId)
.eq(PublishCommission::getParentId, CommentId)
.orderByDesc(PublishCommission::getCreateTime);
List<PublishCommission> CommentList = publishCommentMapper.selectList(lqw);

View File

@ -60,4 +60,5 @@ public class ThreadPoolConfig
}
};
}
}

View File

@ -84,7 +84,7 @@ public class WorkFlow {
* 0 1- 2- 3 4
*/
@ApiModelProperty(value = "审核状态0全部状态 1已发布-公开 2已发布-仅自己可见 3审核中 4审核未通过")
private Integer auditStatus = 0;
private Integer auditStatus = 3;
/**
*
@ -141,6 +141,12 @@ public class WorkFlow {
@ApiModelProperty(value = "封面图地址")
private String coverPath;
/**
*
*/
@ApiModelProperty(value = "审核权限")
private Integer jurisdiction;
/**
*
*/

View File

@ -64,7 +64,7 @@ public class WorkFlowVersion {
* 0 1- 2- 3 4
*/
@ApiModelProperty("审核状态0全部状态 1已发布-公开 2已发布-仅自己可见 3审核中 4审核未通过")
private Integer auditStatus = 0;
private Integer auditStatus = 3;
/**
*

View File

@ -22,4 +22,6 @@ public interface WorkFlowVersionMapper extends BaseMapper<WorkFlowVersion> {
void updateWorkFlowVersion(WorkFlowVersion workFlowVersion);
void updateByName(WorkFlowVersion workFlowVersion);
}

View File

@ -1,9 +1,11 @@
package com.mcwl.resource.service.impl;
import cn.hutool.core.bean.BeanUtil;
import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.baomidou.mybatisplus.core.metadata.OrderItem;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@ -12,7 +14,9 @@ import com.mcwl.common.constant.HttpStatus;
import com.mcwl.common.core.domain.AjaxResult;
import com.mcwl.common.core.domain.entity.SysUser;
import com.mcwl.common.core.page.TableDataInfo;
import com.mcwl.common.utils.SecurityUtils;
import com.mcwl.common.utils.StringUtils;
import com.mcwl.common.utils.baidu.BaiduCensor;
import com.mcwl.resource.domain.WorkFlow;
import com.mcwl.resource.domain.WorkFlowVersion;
import com.mcwl.resource.domain.dto.ModelImagePageRes;
@ -27,6 +31,7 @@ import com.mcwl.system.init.DictInit;
import com.mcwl.system.service.ISysUserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
@ -36,6 +41,7 @@ import java.util.Objects;
/**
*
*
* @author DaiZibo
* @date 2025/1/9
* @apiNote
@ -57,6 +63,10 @@ public class WorkFlowServiceImpl extends ServiceImpl<WorkFlowMapper, WorkFlow> i
@Autowired
private ISysUserService sysUserService;
@Autowired
private ThreadPoolTaskExecutor threadPoolTaskExecutor;
@Override
public AjaxResult addWorkFlow(RequestWorkFlow requestWorkFlow) {
@ -66,35 +76,173 @@ public class WorkFlowServiceImpl extends ServiceImpl<WorkFlowMapper, WorkFlow> i
String[] split = filePath.split(",");
WorkFlow workFlow = requestWorkFlow.getWorkFlow();
workFlow .setCoverPath(split[0]);
workFlow.setUserId(SecurityUtils.getUserId());
workFlow.setCoverPath(split[0]);
workFlow.setCreateTime(new Date());
//添加模型表数据
flowMapper.insert(requestWorkFlow.getWorkFlow());
flowMapper.insert(workFlow);
log.info("获取到的入参:{}",requestWorkFlow.getWorkFlow());
log.info("获取到的入参:{}", requestWorkFlow.getWorkFlow());
//批量添加版本
workFlowVersionMapper.addWorkFlowVersion(requestWorkFlow.getWorkFlow(),requestWorkFlow.getWorkFlowVersionList());
workFlowVersionMapper.addWorkFlowVersion(requestWorkFlow.getWorkFlow(), requestWorkFlow.getWorkFlowVersionList());
audit(requestWorkFlow);
return AjaxResult.success("添加成功,等待审核");
}
private void audit(RequestWorkFlow requestWorkFlow) {
// 执行审核操作
threadPoolTaskExecutor.submit(() -> {
WorkFlow workFlow = requestWorkFlow.getWorkFlow();
if (workFlow != null){
if (workFlow.getWorkflowName() != null){
//审核名称
String s = BaiduCensor.TextCensor(workFlow.getWorkflowName());
// 解析 JSON 字符串
JSONObject jsonObject = JSONObject.parseObject(s);
// 获取 'conclusion' 字段的值
String conclusion = jsonObject.getString("conclusion");
if (conclusion.equals("不合规")) {
//更改状态,添加原因 -> 结束任务
// 获取 'data' 数组
JSONArray dataArray = jsonObject.getJSONArray("data");
// 存储所有的失败原因
List<String> failureReasons = new ArrayList<>();
// 遍历 'data' 数组中的每个元素
for (Object itemObj : dataArray) {
JSONObject item = (JSONObject) itemObj;
String msg = item.getString("msg");
failureReasons.add(msg);
}
// 使用逗号拼接所有的失败原因
String concatenatedReasons = String.join(", ", failureReasons);
workFlow.setAuditText(concatenatedReasons);
//修改状态以及失败原因
workFlow.setAuditStatus(4);
flowMapper.updateById(workFlow);
log.info("工作流审核未通过");
//结束任务
return;
}
//修改为合格
workFlow.setAuditStatus(workFlow.getJurisdiction());
flowMapper.updateById(workFlow);
}
}
List<WorkFlowVersion> workFlowVersionList = requestWorkFlow.getWorkFlowVersionList();
if (workFlowVersionList != null){
//审核版本
for (WorkFlowVersion workFlowVersion : workFlowVersionList) {
workFlowVersion.setWorkFlowId(workFlow.getId());
//版本名称
String s1 = BaiduCensor.TextCensor(workFlowVersion.getVersionName() + "," + workFlowVersion.getVersionDescription());
// 解析 JSON 字符串
JSONObject jsonObject1 = JSONObject.parseObject(s1);
// 获取 'conclusion' 字段的值
String conclusion1 = jsonObject1.getString("conclusion");
if (conclusion1.equals("不合规")) {
//更改版本状态->跳出循环 审核下一个版本
// 获取 'data' 数组
JSONArray dataArray1 = jsonObject1.getJSONArray("data");
// 存储所有的失败原因
List<String> failureReasons = new ArrayList<>();
// 遍历 'data' 数组中的每个元素
for (Object itemObj : dataArray1) {
JSONObject item = (JSONObject) itemObj;
String msg = item.getString("msg");
failureReasons.add(msg);
}
// 使用逗号拼接所有的失败原因
String concatenatedReasons = String.join(", ", failureReasons);
workFlow.setAuditText(concatenatedReasons);
workFlowVersion.setAuditStatus(4);
//校验id是否存在 区别修改审核或者新增审核
if (workFlowVersion.getId() != null){
workFlowVersionMapper.updateById(workFlowVersion);
}else {
workFlowVersionMapper.updateByName(workFlowVersion);
}
log.info("版本审核未通过");
continue;
}
//审核版本图片
String[] split = workFlowVersion.getFilePath().split(",");
for (String path : split) {
String s2 = BaiduCensor.ImageCnesor(path);
JSONObject jsonObject2 = JSONObject.parseObject(s2);
if (jsonObject2.getString("conclusion").equals("不合规")) {
//修改状态->跳出循环 判断下一个版本
// 获取 'data' 数组
JSONArray dataArray2 = jsonObject2.getJSONArray("data");
// 存储所有的失败原因
List<String> failureReasons = new ArrayList<>();
// 遍历 'data' 数组中的每个元素
for (Object itemObj : dataArray2) {
JSONObject item = (JSONObject) itemObj;
String msg = item.getString("msg");
failureReasons.add(msg);
}
// 使用逗号拼接所有的失败原因
String concatenatedReasons = String.join(", ", failureReasons);
workFlow.setAuditText(concatenatedReasons);
workFlowVersion.setAuditStatus(4);
//校验id是否存在 区别修改审核或者新增审核
if (workFlowVersion.getId() != null){
workFlowVersionMapper.updateById(workFlowVersion);
}else {
workFlowVersionMapper.updateByName(workFlowVersion);
}
workFlowVersionMapper.updateByName(workFlowVersion);
log.info("图片审核未通过");
break;
}
}
//修改版本成功审核状态
workFlowVersion.setAuditStatus(1);
workFlowVersionMapper.updateByName(workFlowVersion);
log.info("全部通过审核");
}
}
});
}
@Override
public void updateWorkFlow(RequestWorkFlow requestWorkFlow) {
WorkFlow workFlows = requestWorkFlow.getWorkFlow();
//修改工作流的信息
if (ObjectUtils.isEmpty(workFlows)){
if (ObjectUtils.isEmpty(workFlows)) {
return;
}
if (StringUtils.isNotNull(workFlows.getId() )){
if (StringUtils.isNotNull(workFlows.getId())) {
workFlows.setUpdateTime(new Date());
workFlows.setAuditStatus(3);
// flowMapper.updateWorkFlow(requestWorkFlow.getWorkFlow());
flowMapper.updateById(requestWorkFlow.getWorkFlow());
}
//修改工作流版本的信息
if (requestWorkFlow.getWorkFlowVersionList().size() != 0){
if (requestWorkFlow.getWorkFlowVersionList().size() != 0) {
//批量修改
for (WorkFlowVersion workFlowVersion : requestWorkFlow.getWorkFlowVersionList()) {
@ -107,8 +255,11 @@ public class WorkFlowServiceImpl extends ServiceImpl<WorkFlowMapper, WorkFlow> i
.updateTime(new Date()).build();
//更新时间
flowMapper.updateById(workFlow);
}
//审核修改后的数据
audit(requestWorkFlow);
}
@Override
@ -127,17 +278,17 @@ public class WorkFlowServiceImpl extends ServiceImpl<WorkFlowMapper, WorkFlow> i
LambdaQueryWrapper<WorkFlow> lambdaQueryWrapper = Wrappers.<WorkFlow>lambdaQuery()
.like(StringUtils.isNotBlank(pageVo.getName()), WorkFlow::getWorkflowName, pageVo.getName())
.eq(WorkFlow::getDelFlag,0);
.eq(WorkFlow::getDelFlag, 0);
if (pageVo.getOrder() == 1){
if (pageVo.getOrder() == 1) {
lambdaQueryWrapper.orderByDesc(WorkFlow::getUseNumber);
}else {
} else {
lambdaQueryWrapper.orderByDesc(WorkFlow::getId);
}
lambdaQueryWrapper.select(WorkFlow::getId, WorkFlow::getWorkflowName,WorkFlow::getCoverPath);
lambdaQueryWrapper.select(WorkFlow::getId, WorkFlow::getWorkflowName, WorkFlow::getCoverPath);
return AjaxResult.success(flowMapper.selectPage(page,lambdaQueryWrapper));
return AjaxResult.success(flowMapper.selectPage(page, lambdaQueryWrapper));
}
@Override
@ -147,41 +298,41 @@ public class WorkFlowServiceImpl extends ServiceImpl<WorkFlowMapper, WorkFlow> i
WorkFlow workFlow = flowMapper.selectById(id);
//翻译属性 垂类
if (StringUtils.isNotEmpty(workFlow.getCategory())){
workFlow.setCategory(DictInit.getDictValue(DictConstants.MODEL_CHILD_CATEGORY,workFlow.getCategory()));
if (StringUtils.isNotEmpty(workFlow.getCategory())) {
workFlow.setCategory(DictInit.getDictValue(DictConstants.MODEL_CHILD_CATEGORY, workFlow.getCategory()));
}
//主体
if (StringUtils.isNotEmpty(workFlow.getTheme())){
if (StringUtils.isNotEmpty(workFlow.getTheme())) {
ArrayList<String> strings = new ArrayList<>();
String[] split = workFlow.getTheme().split(",");
for (String s : split) {
if (s != ""){
strings.add(DictInit.getDictValue(DictConstants.WORK_FLOW_THEME,workFlow.getCategory()));
if (s != "") {
strings.add(DictInit.getDictValue(DictConstants.WORK_FLOW_THEME, workFlow.getCategory()));
}
}
workFlow.setThemeList(strings);
}
//风格
if (StringUtils.isNotEmpty(workFlow.getStyle())){
if (StringUtils.isNotEmpty(workFlow.getStyle())) {
ArrayList<String> strings = new ArrayList<>();
String[] split = workFlow.getTheme().split(",");
for (String s : split) {
if (s != ""){
strings.add(DictInit.getDictValue(DictConstants.WORK_FLOW_STYLE,workFlow.getStyle()));
if (s != "") {
strings.add(DictInit.getDictValue(DictConstants.WORK_FLOW_STYLE, workFlow.getStyle()));
}
}
workFlow.setStyleList(strings);
}
//功能
if (StringUtils.isNotEmpty(workFlow.getFunctions())){
workFlow.setCategory(DictInit.getDictValue(DictConstants.WORK_FLOW_FUNCTIONS,workFlow.getFunctions()));
if (StringUtils.isNotEmpty(workFlow.getFunctions())) {
workFlow.setCategory(DictInit.getDictValue(DictConstants.WORK_FLOW_FUNCTIONS, workFlow.getFunctions()));
}
//活动
if (StringUtils.isNotEmpty(workFlow.getActivityParticipation())){
if (StringUtils.isNotEmpty(workFlow.getActivityParticipation())) {
workFlow.setActivityParticipation(toActivityService.getById(workFlow.getActivityParticipation()).getActivityName());
}

View File

@ -17,4 +17,9 @@
<update id="updateWorkFlowVersion">
-- update work_flow_version
</update>
<update id="updateByName">
update work_flow_version set audit_status = #{auditStatus},
audit_text = #{auditText}
where version_name = #{versionName} and work_flow_id = #{workFlowId}
</update>
</mapper>