|
@@ -2,7 +2,8 @@ package com.ruoyi.zzb.common.controller;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.ruoyi.common.config.RuoYiConfig;
|
|
import com.ruoyi.common.config.RuoYiConfig;
|
|
-import com.ruoyi.zzb.common.bean.RspResult;
|
|
|
|
|
|
+import com.ruoyi.common.core.controller.BaseController;
|
|
|
|
+import com.ruoyi.common.core.domain.AjaxResult;
|
|
import com.ruoyi.zzb.common.domain.BaseFileInfo;
|
|
import com.ruoyi.zzb.common.domain.BaseFileInfo;
|
|
import com.ruoyi.zzb.common.domain.BaseFileSetDTO;
|
|
import com.ruoyi.zzb.common.domain.BaseFileSetDTO;
|
|
import com.ruoyi.zzb.common.service.BaseService;
|
|
import com.ruoyi.zzb.common.service.BaseService;
|
|
@@ -18,7 +19,7 @@ import java.util.List;
|
|
@Slf4j
|
|
@Slf4j
|
|
@RestController
|
|
@RestController
|
|
@RequestMapping("/api/base")
|
|
@RequestMapping("/api/base")
|
|
-public class BaseController {
|
|
|
|
|
|
+public class CommonController extends BaseController {
|
|
|
|
|
|
@Value("${module.zyww.templateFilePath}")
|
|
@Value("${module.zyww.templateFilePath}")
|
|
private String zywwTemplateFilePath;
|
|
private String zywwTemplateFilePath;
|
|
@@ -38,20 +39,20 @@ public class BaseController {
|
|
* @Date: 2024/12/2 10:48
|
|
* @Date: 2024/12/2 10:48
|
|
*/
|
|
*/
|
|
@PostMapping("/send")
|
|
@PostMapping("/send")
|
|
- public JSONObject send(@RequestBody JSONObject reqBody){
|
|
|
|
|
|
+ public AjaxResult send(@RequestBody JSONObject reqBody){
|
|
String subject; // 邮件主题
|
|
String subject; // 邮件主题
|
|
String text; // 邮件内容
|
|
String text; // 邮件内容
|
|
String attachmentPath; // 每一个模块对应的的申请模板文件在服务器的存储路径
|
|
String attachmentPath; // 每一个模块对应的的申请模板文件在服务器的存储路径
|
|
String toEmail = reqBody.getString("toEmail");
|
|
String toEmail = reqBody.getString("toEmail");
|
|
if(StringUtils.isBlank(toEmail)/* || !CommonUtils.isRightEmail(toEmail)*/){
|
|
if(StringUtils.isBlank(toEmail)/* || !CommonUtils.isRightEmail(toEmail)*/){
|
|
log.error("toEmail参数非法");
|
|
log.error("toEmail参数非法");
|
|
- return RspResult.error("toEmail参数非法");
|
|
|
|
|
|
+ return error("toEmail参数非法");
|
|
}
|
|
}
|
|
// 模块编码 前端在对应页面获取申请模板文件时需手动传入该参数,后端根据该参数值向目标邮箱发送对应的申请模板文件
|
|
// 模块编码 前端在对应页面获取申请模板文件时需手动传入该参数,后端根据该参数值向目标邮箱发送对应的申请模板文件
|
|
String moduleCode = reqBody.getString("moduleCode");
|
|
String moduleCode = reqBody.getString("moduleCode");
|
|
if(StringUtils.isBlank(moduleCode)){
|
|
if(StringUtils.isBlank(moduleCode)){
|
|
log.error("moduleCode参数为空");
|
|
log.error("moduleCode参数为空");
|
|
- return RspResult.error("moduleCode参数为空");
|
|
|
|
|
|
+ return error("moduleCode参数为空");
|
|
}
|
|
}
|
|
if("zyww".equals(moduleCode)){
|
|
if("zyww".equals(moduleCode)){
|
|
subject = "【住院慰问】";
|
|
subject = "【住院慰问】";
|
|
@@ -70,10 +71,10 @@ public class BaseController {
|
|
File directory = new File(attachmentPath);
|
|
File directory = new File(attachmentPath);
|
|
File[] files = directory.listFiles();
|
|
File[] files = directory.listFiles();
|
|
baseService.sendEmail(toEmail, subject, text, attachmentPath, files);
|
|
baseService.sendEmail(toEmail, subject, text, attachmentPath, files);
|
|
- return RspResult.success("服务器发送邮件成功");
|
|
|
|
|
|
+ return success("服务器发送邮件成功");
|
|
} catch (Exception e){
|
|
} catch (Exception e){
|
|
log.error("服务器发送邮件失败", e);
|
|
log.error("服务器发送邮件失败", e);
|
|
- return RspResult.error("服务器发送邮件失败 - " + e.getMessage());
|
|
|
|
|
|
+ return error("服务器发送邮件失败 - " + e.getMessage());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -86,12 +87,12 @@ public class BaseController {
|
|
* @Date: 2024/11/28 14:47
|
|
* @Date: 2024/11/28 14:47
|
|
*/
|
|
*/
|
|
@PostMapping("/upload")
|
|
@PostMapping("/upload")
|
|
- public JSONObject upload(BaseFileSetDTO baseFileSetDTO){
|
|
|
|
|
|
+ public AjaxResult upload(BaseFileSetDTO baseFileSetDTO){
|
|
String moduleCode = baseFileSetDTO.getModuleCode();
|
|
String moduleCode = baseFileSetDTO.getModuleCode();
|
|
String applyFormId = baseFileSetDTO.getApplyFormId();
|
|
String applyFormId = baseFileSetDTO.getApplyFormId();
|
|
if(StringUtils.isBlank(moduleCode) || StringUtils.isBlank(applyFormId)){
|
|
if(StringUtils.isBlank(moduleCode) || StringUtils.isBlank(applyFormId)){
|
|
log.error("文件上传参数为空");
|
|
log.error("文件上传参数为空");
|
|
- return RspResult.error("文件上传参数为空");
|
|
|
|
|
|
+ return error("文件上传参数为空");
|
|
}
|
|
}
|
|
try {
|
|
try {
|
|
// 文件上传路径
|
|
// 文件上传路径
|
|
@@ -111,12 +112,12 @@ public class BaseController {
|
|
BaseFileInfo baseFileInfo = baseFileInfoList.get(0);
|
|
BaseFileInfo baseFileInfo = baseFileInfoList.get(0);
|
|
// 保存文件信息到数据库
|
|
// 保存文件信息到数据库
|
|
boolean optFlag = baseService.saveBaseFileInfo(baseFileInfo);
|
|
boolean optFlag = baseService.saveBaseFileInfo(baseFileInfo);
|
|
- return optFlag? RspResult.success(baseFileInfo.getFileStorageId()) : RspResult.error("文件信息保存/修改失败 - 申请单ID:" + applyFormId);
|
|
|
|
|
|
+ return optFlag? success(baseFileInfo.getFileStorageId()) : error("文件信息保存/修改失败 - 申请单ID:" + applyFormId);
|
|
}
|
|
}
|
|
- return RspResult.error("文件对象为空,信息无法保存/修改");
|
|
|
|
|
|
+ return error("文件对象为空,信息无法保存/修改");
|
|
} catch (Exception e){
|
|
} catch (Exception e){
|
|
log.error("文件信息保存/修改失败", e);
|
|
log.error("文件信息保存/修改失败", e);
|
|
- return RspResult.error("文件信息保存/修改失败 - " + e.getMessage());
|
|
|
|
|
|
+ return error("文件信息保存/修改失败 - " + e.getMessage());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -128,18 +129,18 @@ public class BaseController {
|
|
* @Date: 2024/12/2 10:47
|
|
* @Date: 2024/12/2 10:47
|
|
*/
|
|
*/
|
|
@PostMapping("/cancelUpload")
|
|
@PostMapping("/cancelUpload")
|
|
- public JSONObject cancelUpload(@RequestBody JSONObject reqBody){
|
|
|
|
|
|
+ public AjaxResult cancelUpload(@RequestBody JSONObject reqBody){
|
|
String fileStorageId = reqBody.getString("fileStorageId");
|
|
String fileStorageId = reqBody.getString("fileStorageId");
|
|
if(StringUtils.isBlank(fileStorageId)){
|
|
if(StringUtils.isBlank(fileStorageId)){
|
|
- return RspResult.error("fileStorageId参数为空");
|
|
|
|
|
|
+ return error("fileStorageId参数为空");
|
|
}
|
|
}
|
|
try {
|
|
try {
|
|
// 删除文件信息记录
|
|
// 删除文件信息记录
|
|
boolean optFlag = baseService.delBaseFileInfosByFileStorageId(fileStorageId);
|
|
boolean optFlag = baseService.delBaseFileInfosByFileStorageId(fileStorageId);
|
|
- return optFlag? RspResult.success(true) : RspResult.error("文件信息删除失败 - 文件存储ID:" + fileStorageId);
|
|
|
|
|
|
+ return optFlag? success(true) : error("文件信息删除失败 - 文件存储ID:" + fileStorageId);
|
|
}catch (Exception e){
|
|
}catch (Exception e){
|
|
log.error("文件信息删除失败", e);
|
|
log.error("文件信息删除失败", e);
|
|
- return RspResult.error("文件信息删除失败 - " + e.getMessage());
|
|
|
|
|
|
+ return error("文件信息删除失败 - " + e.getMessage());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|