|
@@ -264,6 +264,87 @@ public class PostManagementServiceImpl implements PostManagementService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ public Map<String, Object> updatePostById(PostManagement postManagement, MultipartFile file1, MultipartFile file2, MultipartFile file3, MultipartFile file4, MultipartFile file5) throws IOException {
|
|
|
+ List<String> stringList = new ArrayList<>();
|
|
|
+ if (Blank.isNotEmpty(file1.getOriginalFilename())) {
|
|
|
+ Map<String, Object> map = uploadOneDoc(file1, filePath);
|
|
|
+ if ((Boolean) map.get("result")) {
|
|
|
+ postManagement.setDraftInterpretation(map.get("data").toString());
|
|
|
+ stringList.add(map.get("data").toString());
|
|
|
+ } else {
|
|
|
+ return SendUtil.send(false, ConstStr.ADD_FAILED, map.get("msg").toString());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (Blank.isNotEmpty(file2.getOriginalFilename())) {
|
|
|
+ Map<String, Object> map = uploadOneDoc(file2, filePath);
|
|
|
+ if ((Boolean) map.get("result")) {
|
|
|
+ postManagement.setDraftDecision(map.get("data").toString());
|
|
|
+ stringList.add(map.get("data").toString());
|
|
|
+ } else {
|
|
|
+ if (stringList != null && stringList.size() > 0) {
|
|
|
+ for (String url : stringList) {
|
|
|
+ File file = new File(filePath + "\\" + url);
|
|
|
+ file.delete();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return SendUtil.send(false, ConstStr.ADD_FAILED, map.get("msg").toString());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (Blank.isNotEmpty(file3.getOriginalFilename())) {
|
|
|
+ Map<String, Object> map = uploadOneDoc(file3, filePath);
|
|
|
+ if ((Boolean) map.get("result")) {
|
|
|
+ postManagement.setPolicyInterpretation(map.get("data").toString());
|
|
|
+ stringList.add(map.get("data").toString());
|
|
|
+ } else {
|
|
|
+ if (stringList != null && stringList.size() > 0) {
|
|
|
+ for (String url : stringList) {
|
|
|
+ File file = new File(filePath + "\\" + url);
|
|
|
+ file.delete();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (Blank.isNotEmpty(file4.getOriginalFilename())) {
|
|
|
+ Map<String, Object> map = uploadOneDoc(file4, filePath);
|
|
|
+ if ((Boolean) map.get("result")) {
|
|
|
+ postManagement.setMakePolicy(map.get("data").toString());
|
|
|
+ stringList.add(map.get("data").toString());
|
|
|
+ } else {
|
|
|
+ if (stringList != null && stringList.size() > 0) {
|
|
|
+ for (String url : stringList) {
|
|
|
+ File file = new File(filePath + "\\" + url);
|
|
|
+ file.delete();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (Blank.isNotEmpty(file5.getOriginalFilename())) {
|
|
|
+ Map<String, Object> map = uploadOneDoc(file5, filePath);
|
|
|
+ if ((Boolean) map.get("result")) {
|
|
|
+ postManagement.setPdfContent(map.get("data").toString());
|
|
|
+ stringList.add(map.get("data").toString());
|
|
|
+ } else {
|
|
|
+ if (stringList != null && stringList.size() > 0) {
|
|
|
+ for (String url : stringList) {
|
|
|
+ File file = new File(filePath + "\\" + url);
|
|
|
+ file.delete();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (postManagementDao.savePost(postManagement) <= 0) {
|
|
|
+ if (stringList != null && stringList.size() > 0) {
|
|
|
+ for (String url : stringList) {
|
|
|
+ File file = new File(filePath + "\\" + url);
|
|
|
+ file.delete();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return SendUtil.send(false, ConstStr.ADD_FAILED, "");
|
|
|
+ }
|
|
|
+ return SendUtil.send(true, ConstStr.ADD_SUCCESS, "");
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
public Map<String, Object> deletePostById(Integer id) {
|
|
|
PostManagement postManagement = postManagementDao.getPostById(id);
|
|
|
if (Blank.isNotEmpty(postManagement.getDraftDecision())) {
|