|
@@ -3,6 +3,7 @@ package com.care.bms.service;
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
import cn.hutool.core.collection.CollUtil;
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
|
+
|
|
import cn.hutool.core.util.StrUtil;
|
|
import cn.hutool.core.util.StrUtil;
|
|
import cn.hutool.json.JSONArray;
|
|
import cn.hutool.json.JSONArray;
|
|
import cn.hutool.json.JSONObject;
|
|
import cn.hutool.json.JSONObject;
|
|
@@ -38,7 +39,9 @@ import org.springframework.util.StringUtils;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
|
|
+import java.io.File;
|
|
import java.io.FileOutputStream;
|
|
import java.io.FileOutputStream;
|
|
|
|
+import java.io.IOException;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
|
|
|
|
|
|
|
@@ -181,6 +184,38 @@ public class OrganizationService {
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
|
|
+ /**
|
|
|
|
+ * 上传文件
|
|
|
|
+ * @param file
|
|
|
|
+ * @return 访问URL
|
|
|
|
+ */
|
|
|
|
+ public String upload(MultipartFile file) throws Exception {
|
|
|
|
+ String logo = null;
|
|
|
|
+ try {
|
|
|
|
+ if (file != null) {
|
|
|
|
+ //获取文件名
|
|
|
|
+ String fileName = file.getOriginalFilename();
|
|
|
|
+ if (StringUtils.isEmpty(fileName) || file.getSize() == 0) {
|
|
|
|
+ throw new BDException("logo文件不能为空!");
|
|
|
|
+ }
|
|
|
|
+ //验证文件名是否合格
|
|
|
|
+ if (!ImgUtil.isImg(fileName)) {
|
|
|
|
+ throw new BDException("logo文件必须是图片格式!");
|
|
|
|
+ }
|
|
|
|
+ String saveFileName = UUID.randomUUID().toString() + "_" + fileName;
|
|
|
|
+ String picFullFileName = savePath + "/logo/" + saveFileName;
|
|
|
|
+ FileOutputStream fos = new FileOutputStream(picFullFileName);
|
|
|
|
+ fos.write(file.getBytes());
|
|
|
|
+ logo = fileUrl + "logo/" + saveFileName;
|
|
|
|
+ } else {
|
|
|
|
+ throw new BDException("上传失败");
|
|
|
|
+ }
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ throw new BDException("上传失败",e);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return logo;
|
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
/**
|
|
* 修改机构
|
|
* 修改机构
|
|
@@ -189,24 +224,6 @@ public class OrganizationService {
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
public void updateOrganization(OrganizationVO vo) throws Exception {
|
|
public void updateOrganization(OrganizationVO vo) throws Exception {
|
|
|
|
|
|
- MultipartFile logoImg = vo.getLogoImg();
|
|
|
|
- if (logoImg != null) {
|
|
|
|
- //获取文件名
|
|
|
|
- String fileName = logoImg.getOriginalFilename();
|
|
|
|
- if (StringUtils.isEmpty(fileName) || logoImg.getSize() == 0) {
|
|
|
|
- throw new BDException("logo文件不能为空!");
|
|
|
|
- }
|
|
|
|
- //验证文件名是否合格
|
|
|
|
- if (!ImgUtil.isImg(fileName)) {
|
|
|
|
- throw new BDException("logo文件必须是图片格式!");
|
|
|
|
- }
|
|
|
|
- String saveFileName = UUID.randomUUID().toString() + "_" + fileName;
|
|
|
|
- String picFullFileName = savePath + "/logo/" + saveFileName;
|
|
|
|
- FileOutputStream fos = new FileOutputStream(picFullFileName);
|
|
|
|
- fos.write(logoImg.getBytes());
|
|
|
|
- vo.setLogo(fileUrl + "logo/" + saveFileName);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
CareOrganization careOrganization = new CareOrganization();
|
|
CareOrganization careOrganization = new CareOrganization();
|
|
BeanUtil.copyProperties(vo, careOrganization);
|
|
BeanUtil.copyProperties(vo, careOrganization);
|
|
if(!this.careOrganizationService.updateById(careOrganization)){
|
|
if(!this.careOrganizationService.updateById(careOrganization)){
|