Commit c23c425d authored by 霍传世's avatar 霍传世

HaiNa---接口

parent c1117586
...@@ -39,6 +39,11 @@ ...@@ -39,6 +39,11 @@
<artifactId>spring-boot-starter-test</artifactId> <artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.75</version>
</dependency>
<dependency> <dependency>
<groupId>org.projectlombok</groupId> <groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId> <artifactId>lombok</artifactId>
......
...@@ -14,6 +14,6 @@ public class InterceptorConfig implements WebMvcConfigurer { ...@@ -14,6 +14,6 @@ public class InterceptorConfig implements WebMvcConfigurer {
@Override @Override
public void addInterceptors(InterceptorRegistry registry) { public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(loginInterceptor).addPathPatterns("/businessApi/**").excludePathPatterns("/login");; registry.addInterceptor(loginInterceptor).addPathPatterns("/businessApi/**","/faceMatchApi/**","/commitmentLetterApi/**").excludePathPatterns("/login","/publicApi/**","/scripts/**");;
} }
} }
...@@ -5,4 +5,5 @@ public class CosConstant { ...@@ -5,4 +5,5 @@ public class CosConstant {
public static final String COS_AccesskeyID = "AKID61zliQDpBOgqALHvLl25sRmvnV9cohPt"; public static final String COS_AccesskeyID = "AKID61zliQDpBOgqALHvLl25sRmvnV9cohPt";
public static final String COS_AccesskeySECRET = "TkqtgCUaYJhx1rTpztY2LQRO9h2pPmun"; public static final String COS_AccesskeySECRET = "TkqtgCUaYJhx1rTpztY2LQRO9h2pPmun";
public static final String COS_BUCKET = "schoolreportpdf-1317275686"; public static final String COS_BUCKET = "schoolreportpdf-1317275686";
public static final String COS_HTTPS = "https://schoolreportpdf-1317275686.cos.ap-beijing.myqcloud.com";
} }
...@@ -15,10 +15,12 @@ public class CommitmentLetterController { ...@@ -15,10 +15,12 @@ public class CommitmentLetterController {
private JdbcTemplate DBOperator; private JdbcTemplate DBOperator;
@PostMapping("/uploadLetter/{examConnectionCode}/{zkzNum}") @PostMapping("/uploadLetter/{examConnectionCode}/{zkzNum}")
public ResponseEntity upLoadCommitmentLetter(@PathVariable String examConnectionCode,@PathVariable String zkzNum,@RequestBody String url){ public ResponseEntity upLoadCommitmentLetter(@PathVariable String examConnectionCode,@PathVariable String zkzNum,@RequestBody String url){
JSONObject object = new JSONObject(url);
url = object.getString("url");
try{ try{
DBOperator.update("UPDATE candidate_exam \n" + DBOperator.update("UPDATE candidate_exam \n" +
"SET image_commitment = ? \n" + "SET image_commitment = ? \n" +
"AND status_commitment = 1 \n" + ", status_commitment = 1 \n" +
"WHERE\n" + "WHERE\n" +
"\tzkz_num = ? \n" + "\tzkz_num = ? \n" +
"\tAND exam_connection_code = ?",new Object[]{url,zkzNum,examConnectionCode}); "\tAND exam_connection_code = ?",new Object[]{url,zkzNum,examConnectionCode});
...@@ -28,6 +30,7 @@ public class CommitmentLetterController { ...@@ -28,6 +30,7 @@ public class CommitmentLetterController {
responseBody.put("message","承诺书上传成功"); responseBody.put("message","承诺书上传成功");
return ResponseEntity.ok(responseBody.toString()); return ResponseEntity.ok(responseBody.toString());
}catch (Exception e){ }catch (Exception e){
e.printStackTrace();
log.info("准考证:"+zkzNum+"参加面试编号:"+examConnectionCode+"上传承诺书失败"); log.info("准考证:"+zkzNum+"参加面试编号:"+examConnectionCode+"上传承诺书失败");
JSONObject responseBody = new JSONObject(); JSONObject responseBody = new JSONObject();
responseBody.put("code",500); responseBody.put("code",500);
......
package com.yuda.hainafacetofaceai.controller; package com.yuda.hainafacetofaceai.controller;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.yuda.hainafacetofaceai.constant.CosConstant; import com.yuda.hainafacetofaceai.constant.CosConstant;
import com.yuda.hainafacetofaceai.util.CosUtil; import com.yuda.hainafacetofaceai.util.CosUtil;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -15,7 +17,8 @@ public class PublicFunctionController { ...@@ -15,7 +17,8 @@ public class PublicFunctionController {
@RequestMapping("/getWebCosSign") @RequestMapping("/getWebCosSign")
public ResponseEntity getWebCosTempSign() throws Exception { public ResponseEntity getWebCosTempSign() throws Exception {
String tempSignBody = cosUtil.getSignatureForWeb(CosConstant.COS_BUCKET,CosConstant.COS_ENDPOINT); String tempSignBody = cosUtil.getSignatureForWeb(CosConstant.COS_BUCKET,CosConstant.COS_ENDPOINT);
return ResponseEntity.ok(tempSignBody); JSONObject jsonObject = JSON.parseObject(tempSignBody);
return ResponseEntity.ok(jsonObject);
} }
} }
package com.yuda.hainafacetofaceai.util; package com.yuda.hainafacetofaceai.util;
import com.alibaba.fastjson.JSONObject;
import com.qcloud.cos.COSClient; import com.qcloud.cos.COSClient;
import com.qcloud.cos.Headers; import com.qcloud.cos.Headers;
import com.qcloud.cos.http.HttpMethodName; import com.qcloud.cos.http.HttpMethodName;
...@@ -8,7 +9,6 @@ import com.qcloud.cos.model.GeneratePresignedUrlRequest; ...@@ -8,7 +9,6 @@ import com.qcloud.cos.model.GeneratePresignedUrlRequest;
import com.tencent.cloud.CosStsClient; import com.tencent.cloud.CosStsClient;
import com.tencent.cloud.Response; import com.tencent.cloud.Response;
import com.yuda.hainafacetofaceai.constant.CosConstant; import com.yuda.hainafacetofaceai.constant.CosConstant;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
...@@ -57,7 +57,11 @@ public class CosUtil { ...@@ -57,7 +57,11 @@ public class CosUtil {
}; };
config.put("allowActions", allowActions); config.put("allowActions", allowActions);
Response response = CosStsClient.getCredential(config); Response response = CosStsClient.getCredential(config);
return new JSONObject(response).toString(); JSONObject credential = new JSONObject();
credential.put("bucket", bucket);
credential.put("region", region);
credential.put("credential",response);
return credential.toString();
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment