|
@@ -30,6 +30,7 @@ import cn.com.qmth.examcloud.core.basic.service.cache.SystemPropertyCache;
|
|
|
import cn.com.qmth.examcloud.core.basic.service.impl.OrgServiceImpl;
|
|
|
import cn.com.qmth.examcloud.reports.commons.bean.AdminOperateReport;
|
|
|
import cn.com.qmth.examcloud.reports.commons.util.ReportsUtil;
|
|
|
+import cn.com.qmth.examcloud.support.CacheConstants;
|
|
|
import cn.com.qmth.examcloud.support.cache.CacheHelper;
|
|
|
import cn.com.qmth.examcloud.support.cache.bean.OrgCacheBean;
|
|
|
import cn.com.qmth.examcloud.support.cache.bean.OrgPropertyCacheBean;
|
|
@@ -69,13 +70,8 @@ import javax.imageio.ImageIO;
|
|
|
import javax.persistence.criteria.Predicate;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
-
|
|
|
import java.awt.image.BufferedImage;
|
|
|
-import java.io.File;
|
|
|
-import java.io.FileInputStream;
|
|
|
-import java.io.FileNotFoundException;
|
|
|
-import java.io.IOException;
|
|
|
-import java.io.InputStream;
|
|
|
+import java.io.*;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
@@ -93,8 +89,8 @@ import java.util.stream.Stream;
|
|
|
@Api(tags = "机构相关接口")
|
|
|
@RequestMapping("${$rmp.ctr.basic}/org")
|
|
|
public class OrgController extends ControllerSupport {
|
|
|
-
|
|
|
- private final static long LOG_FILE_CACHE_AGE=2592000L;
|
|
|
+
|
|
|
+ private final static long LOG_FILE_CACHE_AGE = 2592000L;
|
|
|
|
|
|
@Autowired
|
|
|
OrgCache orgCache;
|
|
@@ -660,7 +656,7 @@ public class OrgController extends ControllerSupport {
|
|
|
public Map<String, String> getOrgPropertiesByGroupWithCache(@PathVariable Long orgId,
|
|
|
@PathVariable String propertyGroupId) {
|
|
|
|
|
|
- String redisKey = "PROPERTIES_BY_GROUP:" + orgId + ":" + propertyGroupId;
|
|
|
+ String redisKey = CacheConstants.CACHE_B_ORG_PROP_LIST + orgId + ":" + propertyGroupId;
|
|
|
@SuppressWarnings("unchecked")
|
|
|
Map<String, String> properties = redisClient.get(redisKey, Map.class);
|
|
|
if (null != properties) {
|
|
@@ -732,10 +728,10 @@ public class OrgController extends ControllerSupport {
|
|
|
env.setRootOrgId(orgEntity.getId().toString());
|
|
|
env.setRootOrgDomain(orgEntity.getDomainName());
|
|
|
env.setExt1(propertyGroupId);
|
|
|
- pi = FileStorageUtil.saveFile("orgPropertiesByOrgId", env, file, null,0L);
|
|
|
-
|
|
|
+ pi = FileStorageUtil.saveFile("orgPropertiesByOrgId", env, file, null, 0L);
|
|
|
+
|
|
|
urlList.add(pi.getUrl());
|
|
|
- pi = FileStorageUtil.saveFile("orgPropertiesByOrgDomain", env, file, null,0L);
|
|
|
+ pi = FileStorageUtil.saveFile("orgPropertiesByOrgDomain", env, file, null, 0L);
|
|
|
urlList.add(pi.getUrl());
|
|
|
|
|
|
return urlList;
|
|
@@ -1132,7 +1128,7 @@ public class OrgController extends ControllerSupport {
|
|
|
if (CollectionUtils.isNotEmpty(relatedPropertyGroupIdList)) {
|
|
|
for (String propertyGroupId : relatedPropertyGroupIdList) {
|
|
|
// 删除缓存
|
|
|
- String redisKey = "PROPERTIES_BY_GROUP:" + orgId + ":" + propertyGroupId;
|
|
|
+ String redisKey = CacheConstants.CACHE_B_ORG_PROP_LIST + orgId + ":" + propertyGroupId;
|
|
|
redisClient.delete(redisKey);
|
|
|
|
|
|
// 上传upyun
|
|
@@ -1366,7 +1362,7 @@ public class OrgController extends ControllerSupport {
|
|
|
FileStoragePathEnvInfo env = new FileStoragePathEnvInfo();
|
|
|
env.setFileSuffix(fileSuffix);
|
|
|
env.setRootOrgId(orgEntity.getRootId().toString());
|
|
|
- YunPathInfo pi = FileStorageUtil.saveFile("orgLogo", env, storeLocation, null,LOG_FILE_CACHE_AGE);
|
|
|
+ YunPathInfo pi = FileStorageUtil.saveFile("orgLogo", env, storeLocation, null, LOG_FILE_CACHE_AGE);
|
|
|
String url = pi.getUrl();
|
|
|
|
|
|
OrgPropertyEntity logoFileUrlEntity = orgPropertyRepo.findByOrgIdAndKeyId(orgId,
|
|
@@ -1382,27 +1378,27 @@ public class OrgController extends ControllerSupport {
|
|
|
ReportsUtil.report(new AdminOperateReport(accessUser.getRootOrgId(), accessUser.getUserId(), AdminOperateType.TYPE2.getDesc(), null));
|
|
|
return url;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
private void checkPicSize(File image) throws FileNotFoundException, IOException {
|
|
|
- BufferedImage sourceImg =ImageIO.read(new FileInputStream(image));
|
|
|
- int w=sourceImg.getWidth();
|
|
|
- int h=sourceImg.getHeight();
|
|
|
- BigDecimal bw = new BigDecimal(w);
|
|
|
- BigDecimal bh = new BigDecimal(h);
|
|
|
- double ret = bw.divide(bh,1, BigDecimal.ROUND_HALF_UP).doubleValue();
|
|
|
- if(ret!=1.5) {
|
|
|
- throw new StatusException("图片宽高比例必须是3:2");
|
|
|
- }
|
|
|
- if(w<1200||w>2000) {
|
|
|
- throw new StatusException("图片宽度必须在1200px-2000px");
|
|
|
- }
|
|
|
+ BufferedImage sourceImg = ImageIO.read(new FileInputStream(image));
|
|
|
+ int w = sourceImg.getWidth();
|
|
|
+ int h = sourceImg.getHeight();
|
|
|
+ BigDecimal bw = new BigDecimal(w);
|
|
|
+ BigDecimal bh = new BigDecimal(h);
|
|
|
+ double ret = bw.divide(bh, 1, BigDecimal.ROUND_HALF_UP).doubleValue();
|
|
|
+ if (ret != 1.5) {
|
|
|
+ throw new StatusException("图片宽高比例必须是3:2");
|
|
|
+ }
|
|
|
+ if (w < 1200 || w > 2000) {
|
|
|
+ throw new StatusException("图片宽度必须在1200px-2000px");
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
@ApiOperation(value = "导入考生端登录界面图片")
|
|
|
@PostMapping("importClientBgPicture/{orgId}")
|
|
|
@Transactional
|
|
|
public String importClientBgPicture(@PathVariable Long orgId, HttpServletRequest request,
|
|
|
- @RequestParam CommonsMultipartFile file) throws IOException {
|
|
|
+ @RequestParam CommonsMultipartFile file) throws IOException {
|
|
|
|
|
|
OrgEntity orgEntity = GlobalHelper.getEntity(orgRepo, orgId, OrgEntity.class);
|
|
|
if (null == orgEntity) {
|
|
@@ -1415,7 +1411,7 @@ public class OrgController extends ControllerSupport {
|
|
|
File storeLocation = fileItem.getStoreLocation();
|
|
|
String name = file.getOriginalFilename();
|
|
|
|
|
|
- if (1*1024*1024 < storeLocation.length()) {
|
|
|
+ if (1 * 1024 * 1024 < storeLocation.length()) {
|
|
|
throw new StatusException("140082", "文件过大");
|
|
|
}
|
|
|
|
|
@@ -1439,7 +1435,7 @@ public class OrgController extends ControllerSupport {
|
|
|
FileStoragePathEnvInfo env = new FileStoragePathEnvInfo();
|
|
|
env.setFileSuffix(fileSuffix);
|
|
|
env.setRootOrgId(orgEntity.getRootId().toString());
|
|
|
- YunPathInfo pi = FileStorageUtil.saveFile("client_bg_picture", env, storeLocation, null,LOG_FILE_CACHE_AGE);
|
|
|
+ YunPathInfo pi = FileStorageUtil.saveFile("client_bg_picture", env, storeLocation, null, LOG_FILE_CACHE_AGE);
|
|
|
String url = pi.getUrl();
|
|
|
|
|
|
OrgPropertyEntity logoFileUrlEntity = orgPropertyRepo.findByOrgIdAndKeyId(orgId,
|
|
@@ -1472,7 +1468,7 @@ public class OrgController extends ControllerSupport {
|
|
|
File storeLocation = fileItem.getStoreLocation();
|
|
|
String name = file.getOriginalFilename();
|
|
|
|
|
|
- if ( 2048*1024 < storeLocation.length()) {
|
|
|
+ if (2048 * 1024 < storeLocation.length()) {
|
|
|
throw new StatusException("140082", "文件过大");
|
|
|
}
|
|
|
|
|
@@ -1620,7 +1616,7 @@ public class OrgController extends ControllerSupport {
|
|
|
FileStoragePathEnvInfo env = new FileStoragePathEnvInfo();
|
|
|
env.setFileSuffix(fileSuffix);
|
|
|
env.setRootOrgId(orgEntity.getRootId().toString());
|
|
|
- YunPathInfo pi = FileStorageUtil.saveFile("orgLogo", env, storeLocation, null,LOG_FILE_CACHE_AGE);
|
|
|
+ YunPathInfo pi = FileStorageUtil.saveFile("orgLogo", env, storeLocation, null, LOG_FILE_CACHE_AGE);
|
|
|
String url = pi.getUrl();
|
|
|
|
|
|
OrgPropertyEntity logoFileUrlEntity = orgPropertyRepo.findByOrgIdAndKeyId(orgId,
|