|
@@ -5,16 +5,21 @@ import com.doc.biz.domain.DocActorUser;
|
|
|
import com.doc.biz.domain.DocInfo;
|
|
|
import com.doc.biz.service.IDocActorService;
|
|
|
import com.doc.biz.service.IDocActorUserService;
|
|
|
+import com.doc.biz.service.IDocInfoService;
|
|
|
+import com.doc.chat.domain.ChatMsg;
|
|
|
+import com.doc.chat.service.IChatMsgService;
|
|
|
import com.doc.common.core.controller.BaseController;
|
|
|
import com.doc.common.core.domain.AjaxResult;
|
|
|
import com.doc.common.core.page.TableDataInfo;
|
|
|
import com.doc.common.utils.SecurityUtils;
|
|
|
+import com.doc.system.service.ISysConfigService;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import io.swagger.annotations.ApiParam;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
|
|
@@ -32,6 +37,12 @@ public class DocActorController extends BaseController {
|
|
|
private IDocActorService docActorService;
|
|
|
@Resource
|
|
|
private IDocActorUserService actorUserService;
|
|
|
+ @Resource
|
|
|
+ private IChatMsgService msgService;
|
|
|
+ @Resource
|
|
|
+ private ISysConfigService configService;
|
|
|
+ @Resource
|
|
|
+ private IDocInfoService infoService;
|
|
|
|
|
|
@ApiOperation("归档")
|
|
|
@PutMapping("/{docId}")
|
|
@@ -46,9 +57,7 @@ public class DocActorController extends BaseController {
|
|
|
@ApiOperation("获取已选择人员")
|
|
|
@GetMapping("/{docId}")
|
|
|
public List<DocActorUser> get(@ApiParam(value = "文件ID", required = true) @PathVariable(name = "docId") Long docId) {
|
|
|
- DocActorUser actorUser = new DocActorUser();
|
|
|
- actorUser.setDocId(docId);
|
|
|
- return actorUserService.selectDocActorUserList(actorUser);
|
|
|
+ return actorUserService.selectDocActorUserListByDocId(docId);
|
|
|
}
|
|
|
|
|
|
@ApiOperation("添加协作人员")
|
|
@@ -60,12 +69,38 @@ public class DocActorController extends BaseController {
|
|
|
actor.setDocId(docId);
|
|
|
docActorService.insertDocActor(actor);
|
|
|
}
|
|
|
- actorUserService.deleteDocActorUserByDocId(docId);
|
|
|
+ /**查询出已有的协作人员*/
|
|
|
+ List<DocActorUser> actorUsers = actorUserService.selectDocActorUserListByDocId(docId);
|
|
|
+ List<Long> oldUsers = new ArrayList<>();
|
|
|
+ actorUsers.forEach(au -> {
|
|
|
+ if (!users.contains(au.getUserId())) {
|
|
|
+ //如果当前列表没有的人员,则删除数据库记录
|
|
|
+ actorUserService.delete(au);
|
|
|
+ } else {
|
|
|
+ //如果数据库中已有该用户,则记录下来,后面的逻辑中使用
|
|
|
+ oldUsers.add(au.getUserId());
|
|
|
+ }
|
|
|
+ });
|
|
|
+ String content = configService.selectConfigByKey("msg.actor.content");
|
|
|
+ DocInfo info = infoService.selectDocInfoByDocId(docId);
|
|
|
users.forEach(u -> {
|
|
|
+ if (oldUsers.contains(u)) {
|
|
|
+ //如果数据库中已有,则不作任何处理
|
|
|
+ return;
|
|
|
+ }
|
|
|
DocActorUser actorUser = new DocActorUser();
|
|
|
actorUser.setUserId(u);
|
|
|
actorUser.setDocId(docId);
|
|
|
actorUserService.insertDocActorUser(actorUser);
|
|
|
+
|
|
|
+ //发送消息
|
|
|
+ ChatMsg msg = new ChatMsg();
|
|
|
+ String txt = content.replace("{from}", SecurityUtils.getLoginUser().getUser().getNickName()).replace("{file}", info.getFileName());
|
|
|
+ msg.setMsgType("2");
|
|
|
+ msg.setToId(u);
|
|
|
+ msg.setContent(txt);
|
|
|
+ msg.setFromId(SecurityUtils.getUserId());
|
|
|
+ msgService.send(msg);
|
|
|
});
|
|
|
|
|
|
return success();
|