Prechádzať zdrojové kódy

Merge remote-tracking branch 'origin/master'

Joburgess 5 rokov pred
rodič
commit
2ee3222300

+ 8 - 5
edu-im/edu-im-server/src/main/java/com/keao/edu/im/pojo/ChannelStateNotify.java

@@ -6,7 +6,7 @@ import java.util.List;
 public class ChannelStateNotify {
 
 	private String appKey;
-	private String channelId;
+	private String roomId;
 	private String sessionId;
 	private int event;
 	private String userId;
@@ -20,12 +20,15 @@ public class ChannelStateNotify {
 	public void setAppKey(String appKey) {
 		this.appKey = appKey;
 	}
-	public String getChannelId() {
-		return channelId;
+
+	public String getRoomId() {
+		return roomId;
 	}
-	public void setChannelId(String channelId) {
-		this.channelId = channelId;
+
+	public void setRoomId(String roomId) {
+		this.roomId = roomId;
 	}
+
 	public String getSessionId() {
 		return sessionId;
 	}

+ 1 - 1
edu-im/edu-im-server/src/main/java/com/keao/edu/im/service/Impl/RoomServiceImpl.java

@@ -1218,7 +1218,7 @@ public class RoomServiceImpl implements RoomService {
     @Override
     @Transactional(rollbackFor = Exception.class, isolation = Isolation.SERIALIZABLE)
     public boolean statusSync(ChannelStateNotify notify) throws Exception {
-        String roomId = notify.getChannelId();
+        String roomId = notify.getRoomId();
         String userId = notify.getUserId();
 
         RoomMember roomMember = roomMemberDao.findByRidAndUid(roomId, userId);

+ 12 - 0
edu-thirdparty/src/main/java/com/keao/edu/thirdparty/storage/StoragePlugin.java

@@ -8,6 +8,18 @@ public interface StoragePlugin {
 	String getName();
 
 	/**
+	 * @describe 设置文件访问为私有或公开
+	 * @apiNote 时光荏苒,认真工作的时间总是过得很快,而我、享受这一刻!
+	 * @author zouxuan
+	 * @date 2020/8/28
+	 * @time 17:35
+	 * @param fileName:
+	 * @param isPublic:
+	 * @return void
+	 */
+	void setFileAcl(String fileName,Boolean isPublic);
+
+	/**
 	 * 上传文件
 	 * @param folderName 文件夹
 	 * @param file 需要上传的文件

+ 6 - 0
edu-thirdparty/src/main/java/com/keao/edu/thirdparty/storage/StoragePluginContext.java

@@ -4,6 +4,7 @@ import java.io.File;
 import java.util.HashMap;
 import java.util.Map;
 
+import org.springframework.scheduling.annotation.Async;
 import org.springframework.stereotype.Component;
 
 import com.keao.edu.thirdparty.exception.ThirdpartyException;
@@ -25,6 +26,11 @@ public class StoragePluginContext {
 		return StoragePlugin.uploadFile(folderName, file);
 	}
 
+	public void setFileAcl(String storagePluginName,String fileName,Boolean isPublic){
+		StoragePlugin storagePlugin = getStoragePlugin(storagePluginName);
+		storagePlugin.setFileAcl(fileName,isPublic);
+	}
+
 	private StoragePlugin getStoragePlugin(String storagePluginName) {
 		StoragePlugin storagePlugin = mapper.get(storagePluginName);
 

+ 6 - 0
edu-thirdparty/src/main/java/com/keao/edu/thirdparty/storage/provider/AliyunOssStoragePlugin.java

@@ -3,6 +3,7 @@ package com.keao.edu.thirdparty.storage.provider;
 import com.aliyun.oss.ClientConfiguration;
 import com.aliyun.oss.OSSClient;
 import com.aliyun.oss.model.OSSObject;
+import com.google.zxing.client.result.BizcardResultParser;
 import com.keao.edu.thirdparty.exception.ThirdpartyException;
 import com.keao.edu.thirdparty.storage.StoragePlugin;
 import com.keao.edu.thirdparty.storage.StoragePluginContext;
@@ -40,6 +41,11 @@ public class AliyunOssStoragePlugin implements StoragePlugin, InitializingBean,
 	}
 
 	@Override
+	public void setFileAcl(String fileName, Boolean isPublic) {
+		return;
+	}
+
+	@Override
 	public void afterPropertiesSet() throws Exception {
 		// 创建ClientConfiguration。ClientConfiguration是OSSClient的配置类,可配置代理、连接超时、最大连接数等参数。
 		ClientConfiguration conf = new ClientConfiguration();

+ 14 - 0
edu-thirdparty/src/main/java/com/keao/edu/thirdparty/storage/provider/KS3StoragePlugin.java

@@ -3,6 +3,7 @@ package com.keao.edu.thirdparty.storage.provider;
 import java.io.File;
 import java.io.IOException;
 
+import com.ksyun.ks3.service.request.PutObjectACLRequest;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.poi.util.IOUtils;
 import org.springframework.beans.factory.DisposableBean;
@@ -115,6 +116,19 @@ public class KS3StoragePlugin implements StoragePlugin, InitializingBean, Dispos
 		}
 	}
 
+	public void setFileAcl(String fileName,Boolean isPublic){
+		PutObjectACLRequest request = new PutObjectACLRequest(bucketName,fileName);
+		if (isPublic){
+			//设为公开读
+			request.setCannedAcl(CannedAccessControlList.PublicRead);
+		}else {
+			//设为私有
+			request.setCannedAcl(CannedAccessControlList.Private);
+		}
+		client.putObjectACL(request);
+
+	}
+
 	@Override
 	public void destroy() throws Exception {
 	}

+ 12 - 8
edu-thirdparty/src/main/java/com/keao/edu/thirdparty/storage/provider/QiniuKodoStoragePlugin.java

@@ -1,9 +1,9 @@
 package com.keao.edu.thirdparty.storage.provider;
 
-import java.io.File;
-import java.io.IOException;
-import java.net.URLEncoder;
-
+import com.keao.edu.thirdparty.exception.ThirdpartyException;
+import com.keao.edu.thirdparty.storage.StoragePlugin;
+import com.keao.edu.thirdparty.storage.StoragePluginContext;
+import com.qiniu.util.Auth;
 import org.apache.commons.io.FileUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.DisposableBean;
@@ -11,10 +11,9 @@ import org.springframework.beans.factory.InitializingBean;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Component;
 
-import com.keao.edu.thirdparty.exception.ThirdpartyException;
-import com.keao.edu.thirdparty.storage.StoragePlugin;
-import com.keao.edu.thirdparty.storage.StoragePluginContext;
-import com.qiniu.util.Auth;
+import java.io.File;
+import java.io.IOException;
+import java.net.URLEncoder;
 
 @Component
 public class QiniuKodoStoragePlugin implements StoragePlugin, InitializingBean, DisposableBean {
@@ -37,6 +36,11 @@ public class QiniuKodoStoragePlugin implements StoragePlugin, InitializingBean,
 	}
 
 	@Override
+	public void setFileAcl(String fileName, Boolean isPublic) {
+		return;
+	}
+
+	@Override
 	public void afterPropertiesSet() throws Exception {
 		auth = Auth.create(accessKeyId, accessKeySecret);
 

+ 1 - 1
edu-user/edu-user-biz/src/main/java/com/keao/edu/user/service/NotifyCallback.java

@@ -90,7 +90,7 @@ public class NotifyCallback implements MQTTCallbackHandler {
         }
         String orderNo = dataObj.getString("order_no");
         ExamRegistrationPayment order = notifyCallback.examRegistrationPaymentService.getByOrderNo(orderNo);
-        if (order == null || !order.getTransStatus().equals("ING")) {
+        if (order == null || !order.getTransStatus().equals(TransStatusEnum.ING)) {
             return;
         }
         Map<String, String> rpMap = new HashMap<>();

+ 1 - 3
edu-user/edu-user-biz/src/main/java/com/keao/edu/user/service/impl/StudentAttendanceServiceImpl.java

@@ -32,14 +32,12 @@ public class StudentAttendanceServiceImpl extends BaseServiceImpl<Long, StudentA
 		if(studentAttendance == null){
 			studentAttendance = new StudentAttendance();
 			studentAttendance.setExamRegistrationId(examRegistrationId);
-//			studentAttendance.setSignInTime(date);
+			studentAttendance.setSignInTime(date);
 			studentAttendanceDao.insert(studentAttendance);
 		}
 		//0代表签到1签退
 		if(signFlag == 1){
 			studentAttendance.setSignOutTime(date);
-		}else {
-			studentAttendance.setSignInTime(date);
 		}
 		studentAttendanceDao.update(studentAttendance);
 	}

+ 11 - 3
edu-user/edu-user-biz/src/main/java/com/keao/edu/user/service/impl/StudentExamResultServiceImpl.java

@@ -15,6 +15,8 @@ import com.keao.edu.im.api.client.ImFeignService;
 import com.keao.edu.im.api.entity.MemberChangedMessage;
 import com.keao.edu.im.api.entity.PublishMessageDto;
 import com.keao.edu.thirdparty.message.provider.JiguangPushPlugin;
+import com.keao.edu.thirdparty.storage.StoragePluginContext;
+import com.keao.edu.thirdparty.storage.provider.KS3StoragePlugin;
 import com.keao.edu.user.api.entity.ExamRoom;
 import com.keao.edu.user.api.entity.ExamRoomStudentRelation;
 import com.keao.edu.user.api.entity.Student;
@@ -72,6 +74,8 @@ public class StudentExamResultServiceImpl extends BaseServiceImpl<Long, StudentE
 	private ExamReviewDao examReviewDao;
 	@Autowired
 	private SysConfigService sysConfigService;
+	@Autowired
+	private StoragePluginContext storagePluginContext;
 
 	private final static Logger logger = LoggerFactory.getLogger(StudentExamResultServiceImpl.class);
 
@@ -279,7 +283,7 @@ public class StudentExamResultServiceImpl extends BaseServiceImpl<Long, StudentE
 
 	@Override
 	@Transactional(rollbackFor = Exception.class)
-	public void recordSync(RecordNotify recordNotify) {
+	public synchronized void recordSync(RecordNotify recordNotify) {
 		logger.info("recordSync paramJson{}",recordNotify);
 		if (recordNotify.getType() == 4){
 			JSONObject jsonObject = JSONObject.parseObject(recordNotify.getOutput());
@@ -294,10 +298,14 @@ public class StudentExamResultServiceImpl extends BaseServiceImpl<Long, StudentE
 						return;
 					}
 					String videoUrl = studentExamResult.getVideoUrl();
+					String fileName = jsonObject.get("fileUrl").toString();
+					String substring = fileName.substring(0, fileName.lastIndexOf("?"));
+					String substring1 = substring.substring(substring.lastIndexOf("/") + 1);
+					storagePluginContext.setFileAcl(KS3StoragePlugin.PLUGIN_NAME,substring1,true);
 					if(StringUtils.isNotEmpty(videoUrl)){
-						videoUrl += "," + jsonObject.get("fileUrl");
+						videoUrl += "," + substring;
 					}else {
-						videoUrl = jsonObject.get("fileUrl").toString();
+						videoUrl = substring;
 					}
 					studentExamResult.setVideoUrl(videoUrl);
 					studentExamResultDao.update(studentExamResult);