WANG před 5 roky
rodič
revize
d29412e145

+ 14 - 1
examcloud-core-basic-service/src/main/java/cn/com/qmth/examcloud/core/basic/service/cache/StudentCache.java

@@ -1,11 +1,16 @@
 package cn.com.qmth.examcloud.core.basic.service.cache;
 
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import cn.com.qmth.examcloud.commons.exception.StatusException;
+import cn.com.qmth.examcloud.commons.util.UrlUtil;
+import cn.com.qmth.examcloud.core.basic.base.constants.PropKeys;
 import cn.com.qmth.examcloud.core.basic.dao.StudentRepo;
 import cn.com.qmth.examcloud.core.basic.dao.entity.StudentEntity;
 import cn.com.qmth.examcloud.support.cache.bean.StudentCacheBean;
+import cn.com.qmth.examcloud.web.bootstrap.PropertyHolder;
 import cn.com.qmth.examcloud.web.cache.RandomObjectRedisCache;
 import cn.com.qmth.examcloud.web.helpers.GlobalHelper;
 
@@ -29,11 +34,19 @@ public class StudentCache extends RandomObjectRedisCache<StudentCacheBean> {
 		b.setName(s.getName());
 		b.setOrgId(s.getOrgId());
 		b.setPhoneNumber(s.getPhoneNumber());
-		b.setPhotoPath(s.getPhotoPath());
 		b.setRemark(s.getRemark());
 		b.setRootOrgId(s.getRootOrgId());
 		b.setSecurityPhone(s.getSecurityPhone());
 
+		if (StringUtils.isNotBlank(s.getPhotoPath())) {
+			String basePath = PropertyHolder.getString(PropKeys.STUDENT_PHOTO_URL_PREFIX);
+			if (StringUtils.isBlank(basePath)) {
+				throw new StatusException("160212", "照片根路径未配置");
+			}
+			String path = UrlUtil.joinUrl(basePath, s.getPhotoPath());
+			b.setPhotoPath(path);
+		}
+
 		return b;
 	}