|
|
@@ -1,5 +1,7 @@
|
|
|
package com.fs.company.controller.qw;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.TypeReference;
|
|
|
import com.fs.common.annotation.Log;
|
|
|
import com.fs.common.annotation.RepeatSubmit;
|
|
|
import com.fs.common.core.controller.BaseController;
|
|
|
@@ -12,6 +14,7 @@ import com.fs.common.exception.ServiceException;
|
|
|
import com.fs.common.utils.ServletUtils;
|
|
|
import com.fs.common.utils.StringUtils;
|
|
|
import com.fs.common.utils.poi.ExcelUtil;
|
|
|
+import com.fs.company.controller.param.QwExternalContactEditTagDTO;
|
|
|
import com.fs.course.param.FsCourseLinkMiniParam;
|
|
|
import com.fs.course.param.FsCourseListBySidebarParam;
|
|
|
import com.fs.course.service.IFsCourseWatchLogService;
|
|
|
@@ -31,10 +34,7 @@ import com.fs.qw.domain.*;
|
|
|
import com.fs.qw.param.QwMsgSendParam;
|
|
|
import com.fs.qw.param.QwSessionParam;
|
|
|
import com.fs.qw.service.*;
|
|
|
-import com.fs.qw.vo.QwContactListVO;
|
|
|
-import com.fs.qw.vo.QwContactVO;
|
|
|
-import com.fs.qw.vo.QwMessageListVO;
|
|
|
-import com.fs.qw.vo.QwTagVO;
|
|
|
+import com.fs.qw.vo.*;
|
|
|
import com.fs.statis.service.IStatisticsService;
|
|
|
import com.fs.statistics.dto.WatchCourseStatisticsDTO;
|
|
|
import com.fs.statistics.param.WatchCourseStatisticsParam;
|
|
|
@@ -47,6 +47,7 @@ import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* 企微聊天记录Controller
|
|
|
@@ -84,6 +85,8 @@ public class QwMsgController extends BaseController
|
|
|
@Autowired
|
|
|
private IQwSessionService sessionService;
|
|
|
@Autowired
|
|
|
+ private IQwTagGroupService qwTagGroupService;
|
|
|
+ @Autowired
|
|
|
private IQwTagService tagService;
|
|
|
|
|
|
/**
|
|
|
@@ -398,7 +401,7 @@ public class QwMsgController extends BaseController
|
|
|
}
|
|
|
|
|
|
@ApiOperation("获取外部联系人标签列表")
|
|
|
- @GetMapping("/getQwExternalContactVisitList")
|
|
|
+ @GetMapping("/getQwExternalContactTagList")
|
|
|
public TableDataInfo getQwExternalContactTagList(@RequestParam(value = "qwExternalContactId") Long qwExternalContactId) {
|
|
|
QwExternalContact externalContact = qwExternalContactService.selectQwExternalContactById(qwExternalContactId);
|
|
|
if (Objects.isNull(externalContact)){
|
|
|
@@ -418,4 +421,77 @@ public class QwMsgController extends BaseController
|
|
|
return getDataTable(tagList);
|
|
|
}
|
|
|
|
|
|
+ @ApiOperation("获取企微主体标签列表")
|
|
|
+ @GetMapping("/getCorpTagList")
|
|
|
+ public TableDataInfo getCorpTagList(@RequestParam(value = "qwExternalContactId") Long qwExternalContactId,
|
|
|
+ @RequestParam(required = false) String name) {
|
|
|
+ QwExternalContact externalContact = qwExternalContactService.selectQwExternalContactById(qwExternalContactId);
|
|
|
+ if (Objects.isNull(externalContact)){
|
|
|
+ return getDataTable(new ArrayList<>());
|
|
|
+ }
|
|
|
+
|
|
|
+ startPage();
|
|
|
+ QwTagGroup params = new QwTagGroup();
|
|
|
+ params.setName(name);
|
|
|
+ params.setCorpId(externalContact.getCorpId());
|
|
|
+ List<QwTagGroupListVO> list = qwTagGroupService.selectQwTagGroupListVO(params);
|
|
|
+ return getDataTable(list);
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation("外部联系人添加标签")
|
|
|
+ @Log(title = "添加标签", businessType = BusinessType.UPDATE)
|
|
|
+ @PostMapping("/addQwExternalContactTag")
|
|
|
+ public R addQwExternalContactTag(@RequestBody QwExternalContactEditTagDTO param) {
|
|
|
+ QwExternalContact externalContact = qwExternalContactService.selectQwExternalContactById(param.getQwExternalContactId());
|
|
|
+ if (Objects.isNull(externalContact)){
|
|
|
+ throw new ServiceException("外部联系人不存在");
|
|
|
+ }
|
|
|
+
|
|
|
+ List<QwTag> addTags = tagService.selectQwTagListByCorpIdAndIds(param.getTagIds(), externalContact.getCorpId());
|
|
|
+ if (addTags.isEmpty()) {
|
|
|
+ throw new ServiceException("添加标签不能为空");
|
|
|
+ }
|
|
|
+
|
|
|
+ List<String> addTagList = new ArrayList<>();
|
|
|
+ if (StringUtils.isNotBlank(externalContact.getTagIds())) {
|
|
|
+ List<String> oldTags = JSON.parseObject(externalContact.getTagIds(), new TypeReference<List<String>>(){}.getType());
|
|
|
+ addTagList = addTags.stream().map(QwTag::getTagId).filter(tagId -> !oldTags.contains(tagId)).collect(Collectors.toList());
|
|
|
+ }
|
|
|
+
|
|
|
+ if (addTagList.isEmpty()) {
|
|
|
+ throw new ServiceException("添加标签不能为空");
|
|
|
+ }
|
|
|
+
|
|
|
+ qwExternalContactService.addQwExternalContactTag(externalContact.getId(), addTagList);
|
|
|
+ return R.ok();
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation("外部联系人删除标签")
|
|
|
+ @Log(title = "删除标签", businessType = BusinessType.UPDATE)
|
|
|
+ @PostMapping("/delQwExternalContactTag")
|
|
|
+ public R delQwExternalContactTag(@RequestBody QwExternalContactEditTagDTO param) {
|
|
|
+ QwExternalContact externalContact = qwExternalContactService.selectQwExternalContactById(param.getQwExternalContactId());
|
|
|
+ if (Objects.isNull(externalContact)){
|
|
|
+ throw new ServiceException("外部联系人不存在");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (StringUtils.isBlank(externalContact.getTagIds())) {
|
|
|
+ throw new ServiceException("外部联系人不存在标签");
|
|
|
+ }
|
|
|
+
|
|
|
+ List<QwTag> delTags = tagService.selectQwTagListByCorpIdAndIds(param.getTagIds(), externalContact.getCorpId());
|
|
|
+ if (delTags.isEmpty()) {
|
|
|
+ throw new ServiceException("删除标签不能为空");
|
|
|
+ }
|
|
|
+
|
|
|
+ List<String> oldTags = JSON.parseObject(externalContact.getTagIds(), new TypeReference<List<String>>(){}.getType());
|
|
|
+ List<String> delTagList = delTags.stream().map(QwTag::getTagId).filter(oldTags::contains).collect(Collectors.toList());
|
|
|
+ if (delTagList.isEmpty()) {
|
|
|
+ throw new ServiceException("删除标签不能为空");
|
|
|
+ }
|
|
|
+
|
|
|
+ qwExternalContactService.delQwExternalContactTag(externalContact.getId(), delTagList);
|
|
|
+ return R.ok();
|
|
|
+ }
|
|
|
+
|
|
|
}
|