|
|
@@ -16,6 +16,7 @@
|
|
|
*/
|
|
|
package org.springblade.bank.message.controller;
|
|
|
|
|
|
+import cn.hutool.json.JSONUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
@@ -24,14 +25,22 @@ import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
import javax.validation.Valid;
|
|
|
|
|
|
+import org.springblade.bank.checklist.entity.Checklist;
|
|
|
+import org.springblade.bank.userlog.entity.UserLog;
|
|
|
+import org.springblade.bank.userlog.service.IUserLogService;
|
|
|
import org.springblade.core.mp.support.Condition;
|
|
|
import org.springblade.core.mp.support.Query;
|
|
|
+import org.springblade.core.secure.BladeUser;
|
|
|
+import org.springblade.core.secure.utils.AuthUtil;
|
|
|
import org.springblade.core.tool.api.R;
|
|
|
+import org.springblade.core.tool.utils.DateUtil;
|
|
|
import org.springblade.core.tool.utils.Func;
|
|
|
import org.springblade.modules.resource.entity.Attach;
|
|
|
import org.springblade.modules.resource.service.IAttachService;
|
|
|
import org.springblade.modules.system.entity.Dept;
|
|
|
+import org.springblade.modules.system.entity.User;
|
|
|
import org.springblade.modules.system.service.IDeptService;
|
|
|
+import org.springblade.modules.system.service.IUserService;
|
|
|
import org.springframework.util.Assert;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
@@ -42,6 +51,9 @@ import org.springblade.bank.message.wrapper.MessageWrapper;
|
|
|
import org.springblade.bank.message.service.IMessageService;
|
|
|
import org.springblade.core.boot.ctrl.BladeController;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
/**
|
|
|
* 信息發佈 控制器
|
|
|
*
|
|
|
@@ -57,6 +69,8 @@ public class MessageController extends BladeController {
|
|
|
private final IMessageService messageService;
|
|
|
private final IAttachService attachService;
|
|
|
private final IDeptService deptService;
|
|
|
+ private final IUserService userService;
|
|
|
+ private final IUserLogService userLogService;
|
|
|
|
|
|
/**
|
|
|
* 详情
|
|
|
@@ -127,12 +141,37 @@ public class MessageController extends BladeController {
|
|
|
message.setExtension(attach.getExtension());
|
|
|
message.setAttachSize(attach.getAttachSize());
|
|
|
|
|
|
- if (messageService.saveOrUpdate(message)){
|
|
|
+ boolean isAdd = message.getId() == null;
|
|
|
+ BladeUser currentUser = AuthUtil.getUser();
|
|
|
+ User user = userService.getById(currentUser.getUserId());
|
|
|
+ Dept dept = deptService.getById(user.getDeptId());
|
|
|
+ UserLog userLog = new UserLog();
|
|
|
+ Message old = null;
|
|
|
+ if (isAdd){
|
|
|
+ messageService.save(message);
|
|
|
message.setCreateDept(message.getDeptId());
|
|
|
- return R.status(messageService.saveOrUpdate(message));
|
|
|
+ }else{
|
|
|
+ old = messageService.getById(message.getId());
|
|
|
+ }
|
|
|
+
|
|
|
+ if (messageService.saveOrUpdate(message)){
|
|
|
+ userLog.setTableName("message");
|
|
|
+ userLog.setBankNo(dept.getBankNo());
|
|
|
+ userLog.setOrgNo(dept.getOrgNo());
|
|
|
+ userLog.setNewData(JSONUtil.toJsonStr(message));
|
|
|
+ userLog.setPersonNo(user.getEhr());
|
|
|
+ userLog.setPersonName(user.getName());
|
|
|
+
|
|
|
+ if (isAdd){
|
|
|
+ userLog.setOperationType("add");
|
|
|
+ }else{
|
|
|
+ userLog.setOperationType("edit");
|
|
|
+ userLog.setOldData(JSONUtil.toJsonStr(old));
|
|
|
+ }
|
|
|
+ userLogService.save(userLog);
|
|
|
}
|
|
|
|
|
|
- return R.status(false);
|
|
|
+ return R.status(true);
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -143,7 +182,28 @@ public class MessageController extends BladeController {
|
|
|
@ApiOperationSupport(order = 7)
|
|
|
@ApiOperation(value = "逻辑删除", notes = "传入ids")
|
|
|
public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
|
|
|
- return R.status(messageService.deleteLogic(Func.toLongList(ids)));
|
|
|
+
|
|
|
+ List<Long> idList = Func.toLongList(ids);
|
|
|
+ List<UserLog> userLogList = new ArrayList<>();
|
|
|
+
|
|
|
+ // 日誌記錄
|
|
|
+ BladeUser currentUser = AuthUtil.getUser();
|
|
|
+ User user = userService.getById(currentUser.getUserId());
|
|
|
+ Dept dept = deptService.getById(user.getDeptId());
|
|
|
+ idList.forEach(id -> {
|
|
|
+ UserLog userLog = new UserLog();
|
|
|
+ Message message = messageService.getById(id);
|
|
|
+ userLog.setTableName("message");
|
|
|
+ userLog.setOperationType("del");
|
|
|
+ userLog.setBankNo(dept.getBankNo());
|
|
|
+ userLog.setOrgNo(dept.getOrgNo());
|
|
|
+ userLog.setOldData(JSONUtil.toJsonStr(message));
|
|
|
+ userLog.setPersonNo(user.getEhr());
|
|
|
+ userLog.setPersonName(user.getName());
|
|
|
+ userLogList.add(userLog);
|
|
|
+ });
|
|
|
+
|
|
|
+ return R.status(messageService.deleteLogic(idList) && userLogService.saveBatch(userLogList));
|
|
|
}
|
|
|
|
|
|
|