dev
This commit is contained in:
parent
bf9770f552
commit
c3417d5b94
16
pom.xml
16
pom.xml
|
|
@ -108,7 +108,21 @@
|
||||||
<artifactId>springfox-swagger2</artifactId>
|
<artifactId>springfox-swagger2</artifactId>
|
||||||
<version>2.9.2</version>
|
<version>2.9.2</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.syjiaer.common</groupId>
|
||||||
|
<artifactId>bcpkix</artifactId>
|
||||||
|
<version>1.60</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.syjiaer.common</groupId>
|
||||||
|
<artifactId>bcprov</artifactId>
|
||||||
|
<version>1.60</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.syjiaer.common</groupId>
|
||||||
|
<artifactId>EncUtil</artifactId>
|
||||||
|
<version>1.00</version>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.springfox</groupId>
|
<groupId>io.springfox</groupId>
|
||||||
<artifactId>springfox-swagger-ui</artifactId>
|
<artifactId>springfox-swagger-ui</artifactId>
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,88 @@
|
||||||
|
package com.syjiaer.clinic.server.common.util;
|
||||||
|
|
||||||
|
import cn.hsaf.common.utils.EasyGmUtils;
|
||||||
|
import cn.hsaf.common.utils.SignUtil;
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import org.bouncycastle.util.encoders.Hex;
|
||||||
|
|
||||||
|
import java.util.Base64;
|
||||||
|
|
||||||
|
public class EncUtil {
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 加密
|
||||||
|
*
|
||||||
|
* @param data
|
||||||
|
* @param appId
|
||||||
|
* @param appSecret
|
||||||
|
* @return
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public static String encrypt(String data, String appId, String appSecret) throws Exception {
|
||||||
|
//加密流程
|
||||||
|
//用appId加密appSecret获取新秘钥
|
||||||
|
byte[] appSecretEncData = EasyGmUtils.sm4Encrypt(appId.substring(0, 16).getBytes("UTF-8"), appSecret.getBytes("UTF-8"));
|
||||||
|
//新秘钥串
|
||||||
|
byte[] secKey = Hex.toHexString(appSecretEncData).toUpperCase().substring(0, 16).getBytes("UTF-8");
|
||||||
|
//加密0数据
|
||||||
|
String encryptDataStr = Hex.toHexString(EasyGmUtils.sm4Encrypt(secKey, data.getBytes("UTF-8"))).toUpperCase();
|
||||||
|
return encryptDataStr;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 解密
|
||||||
|
*
|
||||||
|
* @param data
|
||||||
|
* @param appId
|
||||||
|
* @param appSecret
|
||||||
|
* @return
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public static String decrypt(String data, String appId, String appSecret) throws Exception {
|
||||||
|
byte[] appSecretEncDataDecode = EasyGmUtils.sm4Encrypt(appId.substring(0, 16).getBytes("UTF-8"), appSecret.getBytes("UTF-8"));
|
||||||
|
byte[] secKeyDecode = Hex.toHexString(appSecretEncDataDecode).toUpperCase().substring(0, 16).getBytes("UTF-8");
|
||||||
|
String decryptDataStr = new String(EasyGmUtils.sm4Decrypt(secKeyDecode, Hex.decode(data)));
|
||||||
|
return decryptDataStr;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 签名
|
||||||
|
*
|
||||||
|
* @param jsonObject
|
||||||
|
* @param appSecret
|
||||||
|
* @param privateKey
|
||||||
|
* @return
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public static String sign(JSONObject jsonObject, String appSecret, String privateKey) throws Exception {
|
||||||
|
// 获取签名串
|
||||||
|
byte[] signText = SignUtil.getSignText(jsonObject, appSecret).getBytes("UTF-8");
|
||||||
|
byte[] userId = appSecret.getBytes();
|
||||||
|
byte[] prvkey = Base64.getDecoder().decode(privateKey);
|
||||||
|
String responseSign = Base64.getEncoder().encodeToString(EasyGmUtils.signSm3WithSm2(signText, userId, prvkey));
|
||||||
|
return responseSign;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 验签
|
||||||
|
*
|
||||||
|
* @param jsonObject
|
||||||
|
* @param appSecret
|
||||||
|
* @param publicKey
|
||||||
|
* @param responseSign
|
||||||
|
* @return
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public static boolean verify(JSONObject jsonObject, String appSecret, String publicKey, String responseSign) throws Exception {
|
||||||
|
//验签
|
||||||
|
byte[] msg = SignUtil.getSignText(jsonObject, appSecret).getBytes("UTF-8");
|
||||||
|
byte[] userIdDecode = appSecret.getBytes("UTF-8");
|
||||||
|
byte[] pubkey = Base64.getDecoder().decode(publicKey);
|
||||||
|
byte[] signData = Base64.getDecoder().decode(responseSign);
|
||||||
|
return EasyGmUtils.verifySm3WithSm2(msg, userIdDecode, signData, pubkey);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -102,6 +102,15 @@ public class DiagnosisService extends BaseService {
|
||||||
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void save(MedicalRecordSaveDto saveDto) {
|
public void save(MedicalRecordSaveDto saveDto) {
|
||||||
|
int regisId =saveDto.getRegistrationId();
|
||||||
|
|
||||||
|
QueryWrapper<Diagnosis> queryWrapperRegis = new QueryWrapper<>();
|
||||||
|
queryWrapperRegis.eq("registration_id", regisId);
|
||||||
|
Diagnosis regisDbDiagnosis = diagnosisMapper.selectOne(queryWrapperRegis);
|
||||||
|
if(regisDbDiagnosis!=null){
|
||||||
|
throw new MessageException("该挂号已完诊,请不要重复完诊");
|
||||||
|
}
|
||||||
|
|
||||||
if (saveDto == null){
|
if (saveDto == null){
|
||||||
throw new MessageException("参数不能为空");
|
throw new MessageException("参数不能为空");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue