|
@@ -63,13 +63,18 @@ import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.multipart.commons.CommonsMultipartFile;
|
|
import org.springframework.web.multipart.commons.CommonsMultipartFile;
|
|
|
|
|
|
|
|
+import javax.imageio.ImageIO;
|
|
import javax.persistence.criteria.Predicate;
|
|
import javax.persistence.criteria.Predicate;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
+
|
|
|
|
+import java.awt.image.BufferedImage;
|
|
import java.io.File;
|
|
import java.io.File;
|
|
import java.io.FileInputStream;
|
|
import java.io.FileInputStream;
|
|
|
|
+import java.io.FileNotFoundException;
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
import java.io.InputStream;
|
|
import java.io.InputStream;
|
|
|
|
+import java.math.BigDecimal;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Stream;
|
|
import java.util.stream.Stream;
|
|
@@ -86,6 +91,8 @@ import java.util.stream.Stream;
|
|
@Api(tags = "机构相关接口")
|
|
@Api(tags = "机构相关接口")
|
|
@RequestMapping("${$rmp.ctr.basic}/org")
|
|
@RequestMapping("${$rmp.ctr.basic}/org")
|
|
public class OrgController extends ControllerSupport {
|
|
public class OrgController extends ControllerSupport {
|
|
|
|
+
|
|
|
|
+ private final static long LOG_FILE_CACHE_AGE=2592000L;
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
OrgCache orgCache;
|
|
OrgCache orgCache;
|
|
@@ -720,9 +727,10 @@ public class OrgController extends ControllerSupport {
|
|
env.setRootOrgId(orgEntity.getId().toString());
|
|
env.setRootOrgId(orgEntity.getId().toString());
|
|
env.setRootOrgDomain(orgEntity.getDomainName());
|
|
env.setRootOrgDomain(orgEntity.getDomainName());
|
|
env.setExt1(propertyGroupId);
|
|
env.setExt1(propertyGroupId);
|
|
- pi = FileStorageUtil.saveFile("orgPropertiesByOrgId", env, file, null);
|
|
|
|
|
|
+ pi = FileStorageUtil.saveFile("orgPropertiesByOrgId", env, file, null,0L);
|
|
|
|
+
|
|
urlList.add(pi.getUrl());
|
|
urlList.add(pi.getUrl());
|
|
- pi = FileStorageUtil.saveFile("orgPropertiesByOrgDomain", env, file, null);
|
|
|
|
|
|
+ pi = FileStorageUtil.saveFile("orgPropertiesByOrgDomain", env, file, null,0L);
|
|
urlList.add(pi.getUrl());
|
|
urlList.add(pi.getUrl());
|
|
|
|
|
|
return urlList;
|
|
return urlList;
|
|
@@ -1138,6 +1146,9 @@ public class OrgController extends ControllerSupport {
|
|
if (!StringUtils.equals(prop.get("OE_STUDENT_SYS_NAME"), old.get("OE_STUDENT_SYS_NAME"))) {
|
|
if (!StringUtils.equals(prop.get("OE_STUDENT_SYS_NAME"), old.get("OE_STUDENT_SYS_NAME"))) {
|
|
sb.append("系统名称,");
|
|
sb.append("系统名称,");
|
|
}
|
|
}
|
|
|
|
+ if (!StringUtils.equals(prop.get("STUDENT_CLIENT_BG_PICTURE_URL"), old.get("STUDENT_CLIENT_BG_PICTURE_URL"))) {
|
|
|
|
+ sb.append("考生端登录页图片,");
|
|
|
|
+ }
|
|
if (!StringUtils.equals(prop.get("LOGO_FILE_URL"), old.get("LOGO_FILE_URL"))) {
|
|
if (!StringUtils.equals(prop.get("LOGO_FILE_URL"), old.get("LOGO_FILE_URL"))) {
|
|
sb.append("学校logo,");
|
|
sb.append("学校logo,");
|
|
}
|
|
}
|
|
@@ -1345,7 +1356,7 @@ public class OrgController extends ControllerSupport {
|
|
FileStoragePathEnvInfo env = new FileStoragePathEnvInfo();
|
|
FileStoragePathEnvInfo env = new FileStoragePathEnvInfo();
|
|
env.setFileSuffix(fileSuffix);
|
|
env.setFileSuffix(fileSuffix);
|
|
env.setRootOrgId(orgEntity.getRootId().toString());
|
|
env.setRootOrgId(orgEntity.getRootId().toString());
|
|
- YunPathInfo pi = FileStorageUtil.saveFile("orgLogo", env, storeLocation, null);
|
|
|
|
|
|
+ YunPathInfo pi = FileStorageUtil.saveFile("orgLogo", env, storeLocation, null,LOG_FILE_CACHE_AGE);
|
|
String url = pi.getUrl();
|
|
String url = pi.getUrl();
|
|
|
|
|
|
OrgPropertyEntity logoFileUrlEntity = orgPropertyRepo.findByOrgIdAndKeyId(orgId,
|
|
OrgPropertyEntity logoFileUrlEntity = orgPropertyRepo.findByOrgIdAndKeyId(orgId,
|
|
@@ -1361,6 +1372,79 @@ public class OrgController extends ControllerSupport {
|
|
ReportsUtil.report(new AdminOperateReport(accessUser.getRootOrgId(), accessUser.getUserId(), "考生端配置-上传学校logo", null));
|
|
ReportsUtil.report(new AdminOperateReport(accessUser.getRootOrgId(), accessUser.getUserId(), "考生端配置-上传学校logo", null));
|
|
return url;
|
|
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");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @ApiOperation(value = "导入考生端登录界面图片")
|
|
|
|
+ @PostMapping("importClientBgPicture/{orgId}")
|
|
|
|
+ @Transactional
|
|
|
|
+ public String importClientBgPicture(@PathVariable Long orgId, HttpServletRequest request,
|
|
|
|
+ @RequestParam CommonsMultipartFile file) throws IOException {
|
|
|
|
+
|
|
|
|
+ OrgEntity orgEntity = GlobalHelper.getEntity(orgRepo, orgId, OrgEntity.class);
|
|
|
|
+ if (null == orgEntity) {
|
|
|
|
+ throw new StatusException("140002", "orgEntity is null");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ validateRootOrgIsolation(orgEntity.getRootId());
|
|
|
|
+
|
|
|
|
+ DiskFileItem fileItem = (DiskFileItem) file.getFileItem();
|
|
|
|
+ File storeLocation = fileItem.getStoreLocation();
|
|
|
|
+ String name = file.getOriginalFilename();
|
|
|
|
+
|
|
|
|
+ if (1*1024*1024 < storeLocation.length()) {
|
|
|
|
+ throw new StatusException("140082", "文件过大");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ String fileSuffix = null;
|
|
|
|
+ if (name.endsWith(".jpg")) {
|
|
|
|
+ fileSuffix = ".jpg";
|
|
|
|
+ } else if (name.endsWith(".jpeg")) {
|
|
|
|
+ fileSuffix = ".jpeg";
|
|
|
|
+ } else if (name.endsWith(".png")) {
|
|
|
|
+ fileSuffix = ".png";
|
|
|
|
+ } else {
|
|
|
|
+ throw new StatusException("101001", "文件格式错误");
|
|
|
|
+ }
|
|
|
|
+ checkPicSize(storeLocation);
|
|
|
|
+
|
|
|
|
+ DynamicEnumManager manager = OrgProperty.getDynamicEnumManager();
|
|
|
|
+ DynamicEnum logoFileUrl = manager.getByName("STUDENT_CLIENT_BG_PICTURE_URL");
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ //通用存储
|
|
|
|
+ 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);
|
|
|
|
+ String url = pi.getUrl();
|
|
|
|
+
|
|
|
|
+ OrgPropertyEntity logoFileUrlEntity = orgPropertyRepo.findByOrgIdAndKeyId(orgId,
|
|
|
|
+ logoFileUrl.getId());
|
|
|
|
+ if (null == logoFileUrlEntity) {
|
|
|
|
+ logoFileUrlEntity = new OrgPropertyEntity();
|
|
|
|
+ logoFileUrlEntity.setKeyId(logoFileUrl.getId());
|
|
|
|
+ logoFileUrlEntity.setOrgId(orgId);
|
|
|
|
+ }
|
|
|
|
+ logoFileUrlEntity.setValue(url);
|
|
|
|
+ orgPropertyRepo.save(logoFileUrlEntity);
|
|
|
|
+ User accessUser = getAccessUser();
|
|
|
|
+ ReportsUtil.report(new AdminOperateReport(accessUser.getRootOrgId(), accessUser.getUserId(), "考生端配置-上传考生端登录界面图片", null));
|
|
|
|
+ return url;
|
|
|
|
+ }
|
|
|
|
|
|
@ApiOperation(value = "导入离线考试答题纸", notes = "导入离线考试答题纸")
|
|
@ApiOperation(value = "导入离线考试答题纸", notes = "导入离线考试答题纸")
|
|
@PostMapping("importAnswers/{orgId}")
|
|
@PostMapping("importAnswers/{orgId}")
|
|
@@ -1526,7 +1610,7 @@ public class OrgController extends ControllerSupport {
|
|
FileStoragePathEnvInfo env = new FileStoragePathEnvInfo();
|
|
FileStoragePathEnvInfo env = new FileStoragePathEnvInfo();
|
|
env.setFileSuffix(fileSuffix);
|
|
env.setFileSuffix(fileSuffix);
|
|
env.setRootOrgId(orgEntity.getRootId().toString());
|
|
env.setRootOrgId(orgEntity.getRootId().toString());
|
|
- YunPathInfo pi = FileStorageUtil.saveFile("orgLogo", env, storeLocation, null);
|
|
|
|
|
|
+ YunPathInfo pi = FileStorageUtil.saveFile("orgLogo", env, storeLocation, null,LOG_FILE_CACHE_AGE);
|
|
String url = pi.getUrl();
|
|
String url = pi.getUrl();
|
|
|
|
|
|
OrgPropertyEntity logoFileUrlEntity = orgPropertyRepo.findByOrgIdAndKeyId(orgId,
|
|
OrgPropertyEntity logoFileUrlEntity = orgPropertyRepo.findByOrgIdAndKeyId(orgId,
|