|
@@ -0,0 +1,160 @@
|
|
|
|
|
+package com.fs.app.controller.app;
|
|
|
|
|
+
|
|
|
|
|
+import com.fs.app.annotation.Login;
|
|
|
|
|
+import com.fs.app.controller.AppBaseController;
|
|
|
|
|
+import com.fs.common.BeanCopyUtils;
|
|
|
|
|
+import com.fs.common.core.domain.R;
|
|
|
|
|
+import com.fs.common.exception.CustomException;
|
|
|
|
|
+import com.fs.common.utils.StringUtils;
|
|
|
|
|
+import com.fs.company.domain.CompanyUserUser;
|
|
|
|
|
+import com.fs.company.service.ICompanyUserUserService;
|
|
|
|
|
+import com.fs.qw.domain.QwExternalContact;
|
|
|
|
|
+import com.fs.qw.domain.QwExternalContactInfo;
|
|
|
|
|
+import com.fs.qw.domain.QwTagGroup;
|
|
|
|
|
+import com.fs.qw.param.sidebar.TagGroupListParam;
|
|
|
|
|
+import com.fs.qw.param.sidebar.TagGroupUpdateParam;
|
|
|
|
|
+import com.fs.qw.service.IQwExternalContactInfoService;
|
|
|
|
|
+import com.fs.qw.service.IQwExternalContactService;
|
|
|
|
|
+import com.fs.qw.service.IQwTagGroupService;
|
|
|
|
|
+import com.fs.qw.service.IQwUserService;
|
|
|
|
|
+import com.fs.qw.vo.QwTagGroupListVO;
|
|
|
|
|
+import com.fs.qw.vo.QwUserVO;
|
|
|
|
|
+import com.fs.qw.vo.sidebar.ExternalContactInfoVO;
|
|
|
|
|
+import com.fs.qw.vo.sidebar.ExternalContactTagVO;
|
|
|
|
|
+import com.fs.qwApi.param.QwExternalContactHParam;
|
|
|
|
|
+import com.github.pagehelper.PageHelper;
|
|
|
|
|
+import com.github.pagehelper.PageInfo;
|
|
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
|
|
+
|
|
|
|
|
+import java.util.List;
|
|
|
|
|
+
|
|
|
|
|
+/**
|
|
|
|
|
+* app的客户个人侧边栏
|
|
|
|
|
+*/
|
|
|
|
|
+@RestController
|
|
|
|
|
+@RequestMapping("/app/qw/user")
|
|
|
|
|
+public class AppQwUserController extends AppBaseController {
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private IQwUserService qwUserService;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private IQwExternalContactInfoService qwExternalContactInfoService;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private IQwExternalContactService iQwExternalContactService;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private IQwTagGroupService qwTagGroupService;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private IQwExternalContactService qwExternalContactService;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private ICompanyUserUserService companyUserUserService;
|
|
|
|
|
+
|
|
|
|
|
+ @Login
|
|
|
|
|
+ @PostMapping("/list")
|
|
|
|
|
+ @ApiOperation("获取企微用户对应的主体")
|
|
|
|
|
+ public R getQwUserList(@RequestParam(value = "companyUserId", required = false) Long companyUserId,
|
|
|
|
|
+ @RequestParam(value = "fsUserId", required = false) Long fsUserId) {
|
|
|
|
|
+ if (companyUserId != null) {
|
|
|
|
|
+ R denied = denyIfNotCurrentCourseCompanyUser(companyUserId);
|
|
|
|
|
+ if (denied != null) {
|
|
|
|
|
+ return denied;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ if (fsUserId == null) {
|
|
|
|
|
+ return R.error("客户id不能为空");
|
|
|
|
|
+ }
|
|
|
|
|
+ List<QwUserVO> qwUsers = qwUserService.selectQwUserListByCompanyUserIdAndFsUserId(companyUserId, fsUserId);
|
|
|
|
|
+ return R.ok().put("data", qwUsers);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Login
|
|
|
|
|
+ @GetMapping("/getQwUserInfo")
|
|
|
|
|
+ @ApiOperation("获取企微用户ai信息")
|
|
|
|
|
+ public R getQwUserInfo(@RequestParam(value = "userId", required = false) String userId,
|
|
|
|
|
+ @RequestParam(value = "corpId", required = false) String corpId,
|
|
|
|
|
+ @RequestParam(value = "fsUserId", required = false) Long fsUserId) {
|
|
|
|
|
+ R denied = denyIfCannotAccessFsUser(fsUserId);
|
|
|
|
|
+ if (denied != null) {
|
|
|
|
|
+ return denied;
|
|
|
|
|
+ }
|
|
|
|
|
+ QwExternalContactHParam qwExternalContactHParam = new QwExternalContactHParam();
|
|
|
|
|
+ qwExternalContactHParam.setUserId(userId);
|
|
|
|
|
+ qwExternalContactHParam.setCorpId(corpId);
|
|
|
|
|
+ qwExternalContactHParam.setFsUserId(fsUserId);
|
|
|
|
|
+ QwExternalContact qwExternalContact = iQwExternalContactService.getQwExternalContactDetail(qwExternalContactHParam);
|
|
|
|
|
+ if (qwExternalContact == null) {
|
|
|
|
|
+ return R.ok().put("data", qwExternalContact);
|
|
|
|
|
+ }
|
|
|
|
|
+ if (qwExternalContact.getId() == null) {
|
|
|
|
|
+ throw new CustomException("企微外部联系人id不能为空!");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ QwExternalContactInfo contactInfo = qwExternalContactInfoService.selectQwExternalContactInfoByExternalContactId(qwExternalContact.getId());
|
|
|
|
|
+ if (contactInfo == null) {
|
|
|
|
|
+ contactInfo = new QwExternalContactInfo();
|
|
|
|
|
+ contactInfo.setExternalContactId(qwExternalContact.getId());
|
|
|
|
|
+ qwExternalContactInfoService.insertQwExternalContactInfo(contactInfo);
|
|
|
|
|
+ }
|
|
|
|
|
+ return R.ok().put("data", contactInfo);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Login
|
|
|
|
|
+ @PostMapping("/UpdateQwUserInfo")
|
|
|
|
|
+ @ApiOperation("修改企微用户信息")
|
|
|
|
|
+ public R updateQwUserInfo(@RequestBody QwExternalContactInfo qwExternalContact) {
|
|
|
|
|
+ if (qwExternalContact.getExternalContactId() != null) {
|
|
|
|
|
+ QwExternalContact contact = iQwExternalContactService.selectQwExternalContactById(qwExternalContact.getExternalContactId());
|
|
|
|
|
+ if (contact != null && contact.getFsUserId() != null) {
|
|
|
|
|
+ R denied = denyIfCannotAccessFsUser(contact.getFsUserId());
|
|
|
|
|
+ if (denied != null) {
|
|
|
|
|
+ return denied;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ qwExternalContactInfoService.updateQwExternalContactInfo(qwExternalContact);
|
|
|
|
|
+ return R.ok();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ @GetMapping("/tagGroupList")
|
|
|
|
|
+ @ApiOperation("获取所有标签组和其下标签")
|
|
|
|
|
+ public R getTagGroupList(TagGroupListParam param) {
|
|
|
|
|
+ QwTagGroup qwTagGroup = new QwTagGroup();
|
|
|
|
|
+ BeanCopyUtils.copy(param, qwTagGroup);
|
|
|
|
|
+ qwTagGroup.setName(param.getTagName());
|
|
|
|
|
+
|
|
|
|
|
+ PageHelper.startPage(qwTagGroup.getPageNum(), qwTagGroup.getPageSize());
|
|
|
|
|
+ List<QwTagGroupListVO> list = qwTagGroupService.selectQwGroupTagList(qwTagGroup);
|
|
|
|
|
+
|
|
|
|
|
+ PageInfo<QwTagGroupListVO> result = new PageInfo<>(list);
|
|
|
|
|
+ return R.ok().put("data", result);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @PutMapping("/externalContact/tag")
|
|
|
|
|
+ @ApiOperation("编辑标签")
|
|
|
|
|
+ public R updateExternalContactTag(@RequestBody TagGroupUpdateParam param) {
|
|
|
|
|
+ int i = qwExternalContactService.updateExternalContactTag(param);
|
|
|
|
|
+ if (i > 0) {
|
|
|
|
|
+ return R.ok();
|
|
|
|
|
+ }
|
|
|
|
|
+ return R.error();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @GetMapping("/externalContact")
|
|
|
|
|
+ @ApiOperation("获取侧边栏外部联系人信息")
|
|
|
|
|
+ public R getExternalContactInfo(@RequestParam(value = "qwExternalContactId") Long qwExternalContactId) {
|
|
|
|
|
+ ExternalContactInfoVO externalContactInfo = qwExternalContactService.getExternalContactInfo(qwExternalContactId);
|
|
|
|
|
+ return R.ok().put("data", externalContactInfo);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @GetMapping("/externalContact/getTag")
|
|
|
|
|
+ @ApiOperation("获取侧边栏外部联系人标签")
|
|
|
|
|
+ public R getExternalContactTag(@RequestParam(value = "qwExternalContactId") Long qwExternalContactId) {
|
|
|
|
|
+ List<ExternalContactTagVO> tagList = qwExternalContactService.getExternalContactTag(qwExternalContactId);
|
|
|
|
|
+ return R.ok().put("data", tagList);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+}
|