|
@@ -12,8 +12,10 @@ import java.util.stream.Stream;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
|
+import org.apache.commons.fileupload.FileItem;
|
|
|
import org.apache.commons.io.FileUtils;
|
|
|
import org.apache.commons.io.IOUtils;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -34,11 +36,15 @@ import org.springframework.web.bind.annotation.RequestParam;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
import org.springframework.web.multipart.commons.CommonsMultipartFile;
|
|
|
|
|
|
+import cn.com.qmth.examcloud.commons.base.exception.StatusException;
|
|
|
import cn.com.qmth.examcloud.commons.base.util.ErrorMsg;
|
|
|
+import cn.com.qmth.examcloud.commons.base.util.PropertiesUtil;
|
|
|
import cn.com.qmth.examcloud.commons.base.util.excel.ExcelError;
|
|
|
+import cn.com.qmth.examcloud.commons.web.CommonPropKeys;
|
|
|
import cn.com.qmth.examcloud.commons.web.security.bean.User;
|
|
|
import cn.com.qmth.examcloud.commons.web.security.entity.AccessUser;
|
|
|
import cn.com.qmth.examcloud.commons.web.support.ControllerSupport;
|
|
|
+import cn.com.qmth.examcloud.core.basic.base.constants.PropKeys;
|
|
|
import cn.com.qmth.examcloud.core.basic.dao.OrgRepo;
|
|
|
import cn.com.qmth.examcloud.core.basic.dao.entity.Org;
|
|
|
import cn.com.qmth.examcloud.core.basic.service.bean.OrgDto;
|
|
@@ -62,9 +68,6 @@ public class OrgController extends ControllerSupport{
|
|
|
@Autowired
|
|
|
OrgService orgService;
|
|
|
|
|
|
- @Value("${staticResource.rootPath}")
|
|
|
- private String rootPath;
|
|
|
-
|
|
|
@Autowired
|
|
|
private JdbcTemplate jdbcTemplate;
|
|
|
|
|
@@ -286,16 +289,25 @@ public class OrgController extends ControllerSupport{
|
|
|
|
|
|
@ApiOperation(value = "导入logo", notes = "导入logo")
|
|
|
@PostMapping("/importLogo/{id}")
|
|
|
- public ResponseEntity importLogo(@PathVariable Long id, HttpServletRequest request,
|
|
|
- @RequestParam CommonsMultipartFile file) {
|
|
|
- try {
|
|
|
- String filePath = rootPath + "/logo/" + id + ".jpg";
|
|
|
- FileUtils.copyInputStreamToFile(file.getInputStream(), new File(filePath));
|
|
|
- jdbcTemplate.update("update ecs_core_org t set t.logo=? where t.id=?", filePath, id);
|
|
|
- return new ResponseEntity("", HttpStatus.OK);
|
|
|
- } catch (Exception e) {
|
|
|
- return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
+ public void importLogo(@PathVariable Long id, HttpServletRequest request,
|
|
|
+ @RequestParam CommonsMultipartFile file) throws IOException {
|
|
|
+ String schoolLogoPath = PropertiesUtil.getString(PropKeys.SCHOOL_LOGO_PATH);
|
|
|
+ if (StringUtils.isBlank(schoolLogoPath)) {
|
|
|
+ FileUtils.forceMkdir(new File(schoolLogoPath));
|
|
|
+ }
|
|
|
+ FileItem fileItem = file.getFileItem();
|
|
|
+ String name = fileItem.getName();
|
|
|
+ String filePath = null;
|
|
|
+ if (name.endsWith(".jpg")) {
|
|
|
+ filePath = schoolLogoPath + "/" + id + ".jpg";
|
|
|
+ } else if (name.endsWith(".gif")) {
|
|
|
+ filePath = schoolLogoPath + "/" + id + ".gif";
|
|
|
+ } else {
|
|
|
+ throw new StatusException("B-101001", "文件格式错误");
|
|
|
}
|
|
|
+
|
|
|
+ FileUtils.copyInputStreamToFile(file.getInputStream(), new File(filePath));
|
|
|
+ jdbcTemplate.update("update ecs_core_org t set t.logo=? where t.id=?", filePath, id);
|
|
|
}
|
|
|
|
|
|
@ApiOperation(value = "按机构名称模糊查询机构列表", notes = "")
|