Browse Source

配置文件修改

wangliang 2 năm trước cách đây
mục cha
commit
584d877db4

+ 6 - 0
pom.xml

@@ -41,6 +41,7 @@
         <junit.version>4.13</junit.version>
         <zip4j.version>1.3.3</zip4j.version>
         <aspectj.version>1.9.6</aspectj.version>
+        <nanoid.version>2.0.0</nanoid.version>
     </properties>
 
     <dependencyManagement>
@@ -217,6 +218,11 @@
                 <artifactId>aspectjweaver</artifactId>
                 <version>${aspectj.version}</version>
             </dependency>
+            <dependency>
+                <groupId>com.aventrix.jnanoid</groupId>
+                <artifactId>jnanoid</artifactId>
+                <version>${nanoid.version}</version>
+            </dependency>
         </dependencies>
     </dependencyManagement>
 

+ 4 - 0
teachcloud-exchange-common/pom.xml

@@ -122,6 +122,10 @@
             <groupId>org.aspectj</groupId>
             <artifactId>aspectjweaver</artifactId>
         </dependency>
+        <dependency>
+            <groupId>com.aventrix.jnanoid</groupId>
+            <artifactId>jnanoid</artifactId>
+        </dependency>
     </dependencies>
 
 </project>

+ 32 - 31
teachcloud-exchange-common/src/main/java/com/qmth/teachcloud/exchange/common/service/impl/AuthInfoServiceImpl.java

@@ -1,5 +1,6 @@
 package com.qmth.teachcloud.exchange.common.service.impl;
 
+import com.aventrix.jnanoid.jnanoid.NanoIdUtils;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.qmth.boot.core.cache.service.CacheService;
 import com.qmth.boot.core.solar.config.SolarProperties;
@@ -19,6 +20,8 @@ import com.qmth.teachcloud.exchange.common.service.BasicSchoolService;
 import com.qmth.teachcloud.exchange.common.service.TSAuthService;
 import com.qmth.teachcloud.exchange.common.util.FileStoreUtil;
 import org.apache.commons.codec.digest.DigestUtils;
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.io.FilenameUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.stereotype.Service;
@@ -167,13 +170,14 @@ public class AuthInfoServiceImpl implements AuthInfoService {
             orgCodesMap = new HashMap<>();
             basicSchoolSet = new HashSet<>();
         }
-        String config = null;
-        if (Objects.nonNull(dictionaryConfig.fssPublicDomain())) {
-            config = dictionaryConfig.fssPublicDomain().getConfig();
-        } else if (Objects.nonNull(dictionaryConfig.fssPrivateDomain())) {
-            config = dictionaryConfig.fssPrivateDomain().getConfig();
-        }
-        boolean oss = Objects.nonNull(config) && (config.startsWith(SystemConstant.OSS) || config.startsWith(SystemConstant.OSS.toUpperCase())) ? true : false;
+
+        LocalDateTime nowTime = LocalDateTime.now();
+        StringJoiner stringJoiner = new StringJoiner("");
+        stringJoiner.add(UploadFileEnum.FILE.name().toLowerCase()).add(File.separator)
+                .add(String.valueOf(nowTime.getYear())).add(File.separator)
+                .add(String.format("%02d", nowTime.getMonthValue())).add(File.separator)
+                .add(String.format("%02d", nowTime.getDayOfMonth())).add(File.separator);
+
         for (OrgInfo o : orgInfoList) {
             orgCodesMap.put(o.getCode(), o.getCode());
             if (authEnum == AuthEnum.OFF_LINE) {
@@ -191,33 +195,30 @@ public class AuthInfoServiceImpl implements AuthInfoService {
             BasicSchool basicSchool = basicSchoolService.getOne(basicSchoolQueryWrapper);
             if (Objects.isNull(basicSchool)) {//不存在则创建学校
                 basicSchool = new BasicSchool(o.getId(), o.getCode(), o.getName(), o.getAccessKey(), o.getAccessSecret());
-                if (Objects.nonNull(o.getLogo()) && (!o.getLogo().startsWith("https:") || !o.getLogo().startsWith("http"))) {
-                    String filePath = dictionaryConfig.fssPublicDomain().getConfig() + File.separator + SystemConstant.getUuid() + ".jpg";
-                    File logoFile = new File(filePath);
-                    if (!logoFile.getParentFile().exists()) {
-                        // 不存在则创建父目录及子文件
-                        logoFile.getParentFile().mkdirs();
-                        logoFile.createNewFile();
-                    }
-                    SystemConstant.base64ToImage(o.getLogo(), filePath);
+//                if (Objects.nonNull(o.getLogo()) && (!o.getLogo().startsWith("https:") || !o.getLogo().startsWith("http"))) {
+                File fileTemp = null;
+                String dirName = null;
+                try {
+                    File fileNew = new File("/Users/king/Downloads/spring.jpg");
+                    fileTemp = File.createTempFile("temp", ".jpg");
+//                        SystemConstant.base64ToImage(o.getLogo(), fileTemp.getPath());
+                    FileUtils.copyInputStreamToFile(new FileInputStream(fileNew), fileTemp);
 
-                    if (oss) {
-                        LocalDateTime nowTime = LocalDateTime.now();
-                        StringJoiner stringJoiner = new StringJoiner("");
-                        stringJoiner.add(UploadFileEnum.FILE.name().toLowerCase()).add(File.separator)
-                                .add(String.valueOf(nowTime.getYear())).add(File.separator)
-                                .add(String.format("%02d", nowTime.getMonthValue())).add(File.separator)
-                                .add(String.format("%02d", nowTime.getDayOfMonth())).add(File.separator)
-                                .add(SystemConstant.getUuid()).add(".jpg");
-                        fileStoreUtil.ossUpload(stringJoiner.toString(), logoFile, DigestUtils.md5Hex(new FileInputStream(logoFile)), UploadFileEnum.FILE.getFssType());
-                        logoFile.delete();
-                        basicSchool.setLogo(fileStoreUtil.getPrivateUrl(stringJoiner.toString(), UploadFileEnum.FILE.getFssType()));
-                    } else {
-                        basicSchool.setLogo(filePath);
+                    dirName = stringJoiner.toString() + NanoIdUtils.randomNanoId() + "." + FilenameUtils.getExtension(fileTemp.getPath());
+                    fileStoreUtil.ossUpload(dirName, fileTemp, DigestUtils.md5Hex(new FileInputStream(fileTemp)), UploadFileEnum.FILE.getFssType());
+                } catch (Exception e) {
+                    log.error(SystemConstant.LOG_ERROR, e);
+                } finally {
+                    if (Objects.nonNull(fileTemp)) {
+                        fileTemp.delete();
+                    }
+                    if (Objects.nonNull(dirName)) {
+                        basicSchool.setLogo(dictionaryConfig.fssPublicDomain().getServer() + File.separator + dirName);
                     }
-                } else {
-                    basicSchool.setLogo(o.getLogoUrl());
                 }
+//                } else {
+//                    basicSchool.setLogo(o.getLogoUrl());
+//                }
                 basicSchoolSet.add(basicSchool);
             } else {
                 basicSchool.setAccessKey(o.getAccessKey());

+ 0 - 2
xjtu-exchange/src/main/java/com/qmth/xjtu/api/OpenApiController.java

@@ -49,7 +49,6 @@ public class OpenApiController {
     private static final String ACCESS_TOKEN_URL = "http://org.xjtu.edu.cn/openplatform/oauth/getAccessToken";
     private static final String USER_INFO_URL = "http://org.xjtu.edu.cn/openplatform/oauth/open/getUserInfo";
     private static final String LOGOUT_URL = "http://org.xjtu.edu.cn/openplatform/oauth/logout";
-//    private static final String RETURN_URL = "https://org.xjtu.edu.cn/openplatform/login.html";
     private static final String schoolCode = "xjtu";//测试学校code,正式改成xjtu
 
     @Resource
@@ -73,7 +72,6 @@ public class OpenApiController {
                                @ApiParam(value = "用户类型") @RequestParam(required = false) String userType,
                                @ApiParam(value = "员工工号") @RequestParam(required = false) String employeeNo,
                                @ApiParam(value = "返回url") @RequestParam(required = false) String returnUrl) throws IOException {
-        authInfoService.appInfoInit();
         if ((Objects.isNull(code) || Objects.equals(code, ""))
                 || (Objects.isNull(employeeNo) || Objects.equals(employeeNo, ""))) {
             throw ExceptionResultEnum.ERROR.exception("请先通过学校地址登录");

+ 8 - 6
xjtu-exchange/src/main/resources/application.properties

@@ -21,14 +21,16 @@ db.password=123456789
 #com.qmth.fss.private.config=oss://key:secret@teachcloud-print-dev-private.oss-api.qmth.com.cn
 #com.qmth.fss.private.server=https://oss-file.qmth.com.cn/teachcloud-print-dev-private
 
-com.qmth.fss.public.config=oss://LTAI4Fi8jVRYT49QBXU9x5QX:97aBLBfkQR5mzCiQa82yWLAH57eUd8@teachcloud-test.oss-cn-shenzhen.aliyuncs.com
-com.qmth.fss.public.server=https://teachcloud-test.oss-cn-shenzhen.aliyuncs.com
-com.qmth.fss.private.config=oss://LTAI4Fi8jVRYT49QBXU9x5QX:97aBLBfkQR5mzCiQa82yWLAH57eUd8@teachcloud-test.oss-cn-shenzhen.aliyuncs.com
-com.qmth.fss.private.server=https://teachcloud-test.oss-cn-shenzhen.aliyuncs.com
+#com.qmth.fss.public.config=oss://LTAI4Fi8jVRYT49QBXU9x5QX:97aBLBfkQR5mzCiQa82yWLAH57eUd8@teachcloud-test.oss-cn-shenzhen.aliyuncs.com
+#com.qmth.fss.public.server=https://teachcloud-test.oss-cn-shenzhen.aliyuncs.com
+#com.qmth.fss.private.config=oss://LTAI4Fi8jVRYT49QBXU9x5QX:97aBLBfkQR5mzCiQa82yWLAH57eUd8@teachcloud-test.oss-cn-shenzhen.aliyuncs.com
+#com.qmth.fss.private.server=https://teachcloud-test.oss-cn-shenzhen.aliyuncs.com
 
-#com.qmth.fss.public.config=../static/
+com.qmth.fss.public.config=../static/
+com.qmth.fss.public.server=../static
 #com.qmth.fss.public.server=/static/
-#com.qmth.fss.private.config=../static/
+com.qmth.fss.private.config=../static/
+com.qmth.fss.private.server=../static
 #com.qmth.fss.private.server=/static/
 
 #mysql\u914D\u7F6E