瀏覽代碼

修改照片信息保存接口

chenken 7 年之前
父節點
當前提交
531308b8b3
共有 3 個文件被更改,包括 19 次插入27 次删除
  1. 1 1
      .env.local
  2. 1 1
      .env.production
  3. 17 25
      src/views/index.vue

+ 1 - 1
.env.local

@@ -6,4 +6,4 @@ VUE_APP_UPYUN_OPERATOR=examcloud
 VUE_APP_UPYUN_PASSWORD=examcloud123456
 VUE_APP_UPYUN_SERVER=v0.api.upyun.com
 VUE_APP_UPYUN_BUCKET=exam-cloud-test
-VUE_APP_UPYUN_BUCKETURL=/exam-cloud-test
+VUE_APP_UPYUN_BUCKETURL=/exam-cloud-test/student_base_photo/

+ 1 - 1
.env.production

@@ -6,4 +6,4 @@ VUE_APP_UPYUN_OPERATOR=examcloud
 VUE_APP_UPYUN_PASSWORD=examcloud123456
 VUE_APP_UPYUN_SERVER=v0.api.upyun.com
 VUE_APP_UPYUN_BUCKET=exam-cloud-test
-VUE_APP_UPYUN_BUCKETURL=/exam-cloud-test
+VUE_APP_UPYUN_BUCKETURL=/exam-cloud-test/student_base_photo/

+ 17 - 25
src/views/index.vue

@@ -151,26 +151,27 @@
 		            return false;
 		        }
 		    },
+		    //处理单个照片
 		    processStudentPhoto(studentPhoto) {
 	    		let photoNameArr = studentPhoto.fileName.split('.');
-		        let fileName = photoNameArr[0];//文件名就是身份证号码
+		        let identityNumber = photoNameArr[0];//文件名就是身份证号码
 		        let fileSuffix = photoNameArr[1];//文件后缀
 		        
-		        let photo = fs.readFileSync(studentPhoto.path);
+		        let photoFile = fs.readFileSync(studentPhoto.path);
 		        //生成新名称
-		        let md5Hash = CryptoJS.MD5(Base64.encode(fileName+new Date().getTime())).toString();
+		        let md5Hash = CryptoJS.MD5(Base64.encode(identityNumber+new Date().getTime())).toString();
 	    		let rootOrgId = localStorage.getItem('rootOrgId');
 		        //根据身份证号码查询学生信息
-		        this.$http.get('/api/ecs_core/studentFaceInfo/identityNumber?orgId='+rootOrgId+'&identityNumber='+fileName, {})
+		        this.$http.get('/api/ecs_core/studentFaceInfo/identityNumber?orgId='+rootOrgId+'&identityNumber='+identityNumber, {})
 		        .then((response) => {
 		        	var studentFaceInfo = response.body;
 		        	if (studentFaceInfo.student && studentFaceInfo.student.id) {
-		        		this.detectFace(photo).then((res)=>{
+		        		this.detectFace(photoFile).then((res)=>{
 		        			if(res.body.faces.length>=1){
 		        				let face_token = res.body.faces[0].face_token;
 		        				this.getFaceSetToken().then((res)=>{
 		        					//var face_set_token = res.bodyText;
-		        					var face_set_token = '0c430026552ffcf4a8172e7182c91ae8';
+		        					var face_set_token = '9c515504ccf37f7b021ebaf4772b144e';
 		        					this.addFaceToSet(face_set_token, face_token).then((res)=>{
 		        						this.saveStudentFaceInfo({
 		        							'studentFaceInfoId':studentFaceInfo.id,
@@ -178,10 +179,9 @@
 		        							'face_set_token':face_set_token,
 		        							'face_token':face_token,
 		        							'studentPhoto':studentPhoto,
-		        							'identityNumber':fileName,
-		        							'fileSuffix':fileSuffix,
-		        							'photoNewName':md5Hash+'.'+fileSuffix,
-		        							'file':photo
+		        							'file':photoFile,
+		        							'rootOrgId':rootOrgId,
+		        							'photoPath':rootOrgId+'/'+identityNumber+'/'+md5Hash+'.'+fileSuffix
 			        					});
 		        					},(err)=>{
 		        						this.finishOne(false,'addFaceToSet失败',studentPhoto);
@@ -218,7 +218,7 @@
 		    //保存文件至又拍云
 		    saveImageToUpyun(photoInfo){
 		    	let fileBlob = new Blob([photoInfo.file]);
-		    	var url = process.env.VUE_APP_UPYUN_BUCKETURL+'/student_base_photo/'+photoInfo.identityNumber+'/'+photoInfo.photoNewName;
+		    	var url = process.env.VUE_APP_UPYUN_BUCKETURL+photoInfo.photoPath;
 		        var authorization = 'Basic '+Base64.encode(process.env.VUE_APP_UPYUN_OPERATOR+':'+process.env.VUE_APP_UPYUN_PASSWORD);
         		var headers = {headers:{'Authorization':authorization,'Content-Type': 'image/jpeg'}};
 		        return this.$http.put(url,photoInfo.file,headers);
@@ -247,15 +247,11 @@
 		    },
 		    saveStudentFaceInfoByPost(photoInfo){
 		    	this.$http.post('/api/ecs_core/studentFaceInfo', {
+		    		'rootOrgId':photoInfo.rootOrgId,
+		    		'studentId':photoInfo.studentId,
 		            'faceSetToken': photoInfo.face_set_token,
 		            'faceToken': photoInfo.face_token,
-		            'photoMD5': photoInfo.photoNewName,
-		            'student': {
-		                'id': photoInfo.studentId
-		            },
-		            'createUser':localStorage.getItem('userName'),
-		            'updateUser':localStorage.getItem('userName'),
-		            'createType':'IMPORT_TOOL'
+		            'photoPath': photoInfo.photoPath,
 		        }).then((res)=>{
 		        	this.finishOne(true,'处理成功',photoInfo.studentPhoto);
 		        },(err)=>{
@@ -264,15 +260,11 @@
 		    },
 		    saveStudentFaceInfoByPut(photoInfo){
 		    	this.$http.put('/api/ecs_core/studentFaceInfo', {
+		            'rootOrgId':photoInfo.rootOrgId,
+		    		'studentId':photoInfo.studentId,
 		            'faceSetToken': photoInfo.face_set_token,
 		            'faceToken': photoInfo.face_token,
-		            'photoMD5': photoInfo.photoNewName,
-		            'student': {
-		                'id': photoInfo.studentId
-		            },
-		            'createUser':localStorage.getItem('userName'),
-		            'updateUser':localStorage.getItem('userName'),
-		            'createType':'IMPORT_TOOL'
+		            'photoPath': photoInfo.photoPath,
 		        }).then((res)=>{
 		        	this.finishOne(true,'处理成功',photoInfo.studentPhoto);
 		        },(err)=>{