wangliang vor 4 Jahren
Ursprung
Commit
bb5923e936

+ 7 - 1
themis-backend/src/main/java/com/qmth/themis/backend/api/SysController.java

@@ -228,7 +228,13 @@ public class SysController {
         if (Objects.nonNull(enable)) {
             tbOrgQueryWrapper.lambda().eq(TBOrg::getEnable, enable);
         }
-        return ResultUtil.ok(tbOrgService.list(tbOrgQueryWrapper));
+        List<TBOrg> tbOrgList = tbOrgService.list(tbOrgQueryWrapper);
+        tbOrgList.forEach(s -> {
+            if (Objects.nonNull(s.getLogo()) && !Objects.equals(s.getLogo(), "")) {
+                s.setLogo(systemConfig.getProperty("aliyun.oss.url") + File.separator + s.getLogo());
+            }
+        });
+        return ResultUtil.ok(tbOrgList);
     }
 
     @ApiOperation(value = "角色查询接口")

+ 8 - 3
themis-backend/src/main/java/com/qmth/themis/backend/api/TBOrgController.java

@@ -1,18 +1,17 @@
 package com.qmth.themis.backend.api;
 
-import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.qmth.themis.business.annotation.ApiJsonObject;
 import com.qmth.themis.business.annotation.ApiJsonProperty;
 import com.qmth.themis.business.base.BasePage;
+import com.qmth.themis.business.config.SystemConfig;
 import com.qmth.themis.business.constant.SystemConstant;
 import com.qmth.themis.business.dto.response.TBOrgDto;
 import com.qmth.themis.business.entity.TBOrg;
 import com.qmth.themis.business.entity.TBUser;
 import com.qmth.themis.business.service.TBOrgService;
 import com.qmth.themis.business.util.EhcacheUtil;
-import com.qmth.themis.business.util.JacksonUtil;
 import com.qmth.themis.business.util.RedisUtil;
 import com.qmth.themis.business.util.ServletUtil;
 import com.qmth.themis.common.contanst.Constants;
@@ -25,8 +24,8 @@ import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.bind.annotation.*;
 
 import javax.annotation.Resource;
+import java.io.File;
 import java.util.Collections;
-import java.util.HashMap;
 import java.util.Map;
 import java.util.Objects;
 
@@ -45,6 +44,9 @@ public class TBOrgController {
     @Resource
     TBOrgService tbOrgService;
 
+    @Resource
+    SystemConfig systemConfig;
+
 //    @Resource
 //    private CacheManager cacheManager;
 
@@ -78,6 +80,9 @@ public class TBOrgController {
         } else {
             tbOrg.setUpdateId(tbUser.getId());
         }
+        if (Objects.nonNull(tbOrg.getLogo()) && !Objects.equals(tbOrg.getLogo(), "")) {
+            tbOrg.setLogo(tbOrg.getLogo().replaceAll(systemConfig.getProperty("aliyun.oss.url") + File.separator, ""));
+        }
         redisUtil.setOrg(tbOrg.getId(), tbOrg);
         EhcacheUtil.put(SystemConstant.orgCodeCache, tbOrg.getCode(), tbOrg);
         tbOrgService.saveOrUpdate(tbOrg);

+ 3 - 2
themis-business/src/main/java/com/qmth/themis/business/service/impl/TEExamServiceImpl.java

@@ -1,5 +1,6 @@
 package com.qmth.themis.business.service.impl;
 
+import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
 import java.math.BigDecimal;
@@ -560,7 +561,7 @@ public class TEExamServiceImpl extends ServiceImpl<TEExamMapper, TEExam> impleme
             throw new BusinessException("该考试已结束");
         }
 
-        String filePath = "upload/" + sdf.format(new Date()) + "/" + uuid() + "." + suffix;
+        String filePath = "upload" + File.separator + sdf.format(new Date()) + File.separator + uuid() + "." + suffix;
         InputStream in = null;
         try {
             String fileMd5 = DigestUtils.md5Hex(file.getBytes());
@@ -569,7 +570,7 @@ public class TEExamServiceImpl extends ServiceImpl<TEExamMapper, TEExam> impleme
             }
             in = file.getInputStream();
             OssUtil.ossUploadStream(systemConfig.getOssEnv(3), filePath, in);
-            String url = systemConfig.getProperty("aliyun.oss.url") + "/" + filePath;
+            String url = systemConfig.getProperty("aliyun.oss.url") + File.separator + filePath;
             ExamFileUploadBean ret = new ExamFileUploadBean();
             ret.setUrl(url);
             ret.setUploadTime(System.currentTimeMillis());

+ 2 - 2
themis-business/src/main/java/com/qmth/themis/business/service/impl/TEStudentServiceImpl.java

@@ -1,5 +1,6 @@
 package com.qmth.themis.business.service.impl;
 
+import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
 import java.util.Map;
@@ -37,7 +38,6 @@ public class TEStudentServiceImpl extends ServiceImpl<TEStudentMapper, TEStudent
     @Resource
     TEStudentMapper teStudentMapper;
     
-
     @Resource
     SystemConfig systemConfig;
 
@@ -92,7 +92,7 @@ public class TEStudentServiceImpl extends ServiceImpl<TEStudentMapper, TEStudent
         	this.saveOrUpdate(student);
             in = file.getInputStream();
             OssUtil.ossUploadStream(systemConfig.getOssEnv(3), filePath, in);
-            String url = systemConfig.getProperty("aliyun.oss.url") + "/" + filePath;
+            String url = systemConfig.getProperty("aliyun.oss.url") + File.separator + filePath;
             StudentPhotoUploadResponseBean ret=new StudentPhotoUploadResponseBean();
             ret.setPhotoUrl(url);
             return ret;

+ 2 - 1
themis-exam/src/main/java/com/qmth/themis/exam/api/TEStudentController.java

@@ -45,6 +45,7 @@ import org.springframework.web.bind.annotation.RequestMethod;
 import org.springframework.web.bind.annotation.RestController;
 
 import javax.annotation.Resource;
+import java.io.File;
 import java.security.NoSuchAlgorithmException;
 import java.util.*;
 
@@ -129,7 +130,7 @@ public class TEStudentController {
             throw new BusinessException(ExceptionResultEnum.STUDENT_NO);
         }
         if (StringUtils.isNotBlank(user.getBasePhotoPath())) {
-            user.setBasePhotoPath(systemConfig.getProperty("aliyun.oss.url") + "/" + user.getBasePhotoPath());
+            user.setBasePhotoPath(systemConfig.getProperty("aliyun.oss.url") + File.separator + user.getBasePhotoPath());
         }
         String loginPassword = AesUtil.decryptCs7(password, Constants.AES_RULE);
         //密码错误