|
@@ -13,6 +13,7 @@ import io.swagger.annotations.ApiParam;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
|
|
|
/**
|
|
@@ -45,8 +46,24 @@ public class DocShareController extends BaseController {
|
|
|
@ApiOperation("添加人员")
|
|
|
@PostMapping("/{docId}")
|
|
|
public AjaxResult share(@ApiParam(value = "文件ID", required = true) @PathVariable(name = "docId") Long docId, @ApiParam(value = "分享人员", required = true) @RequestBody List<Long> users) {
|
|
|
+ //获取之前已选择的人员
|
|
|
+ List<DocShare> list = docShareService.selectDocShareListByDocId(docId);
|
|
|
docShareService.deleteDocShareByDocId(docId);
|
|
|
+ List<Long> oldUsers = new ArrayList<>();
|
|
|
+ list.forEach(au -> {
|
|
|
+ if (!users.contains(au.getUserId())) {
|
|
|
+ //如果当前列表没有的人员,则删除数据库记录
|
|
|
+ docShareService.deleteDocShareByShareId(au.getShareId());
|
|
|
+ } else {
|
|
|
+ //如果数据库中已有该用户,则记录下来,后面的逻辑中使用
|
|
|
+ oldUsers.add(au.getUserId());
|
|
|
+ }
|
|
|
+ });
|
|
|
users.forEach(uid -> {
|
|
|
+ if (oldUsers.contains(uid)) {
|
|
|
+ //如果数据库中已有,则不作任何处理
|
|
|
+ return;
|
|
|
+ }
|
|
|
//发送消息
|
|
|
ChatMsg msg = new ChatMsg();
|
|
|
msg.setMsgType("1");
|