|
@@ -0,0 +1,85 @@
|
|
|
|
|
+package com.fs.app.controller;
|
|
|
|
|
+
|
|
|
|
|
+import com.fs.common.core.controller.BaseController;
|
|
|
|
|
+import com.fs.common.core.domain.R;
|
|
|
|
|
+import com.fs.framework.datasource.TenantDataSourceUtil;
|
|
|
|
|
+import com.fs.qw.service.IQwGroupChatService;
|
|
|
|
|
+import com.fs.qw.service.IQwUserService;
|
|
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
|
|
+
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
|
|
+import java.util.List;
|
|
|
|
|
+
|
|
|
|
|
+/**
|
|
|
|
|
+ * 客户群详情Controller(API端)
|
|
|
|
|
+ * 由Company端通过HTTP远程调用
|
|
|
|
|
+ *
|
|
|
|
|
+ * @author fs
|
|
|
|
|
+ */
|
|
|
|
|
+@Slf4j
|
|
|
|
|
+@RestController
|
|
|
|
|
+@RequestMapping("/qw/groupChat")
|
|
|
|
|
+public class QwGroupChatController extends BaseController {
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private IQwGroupChatService qwGroupChatService;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private IQwUserService iQwUserService;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private TenantDataSourceUtil tenantDataSourceUtil;
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 同步客户群信息
|
|
|
|
|
+ */
|
|
|
|
|
+ @GetMapping("/cogradientGroupChat/{corpId}")
|
|
|
|
|
+ public R cogradientGroupChat(@PathVariable("corpId") String corpId, @RequestParam("tenantId") Long tenantId) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ log.info("[GroupChat] 同步客户群信息,tenantId={}, corpId={}", tenantId, corpId);
|
|
|
|
|
+ return tenantDataSourceUtil.executeWithResult(tenantId, () -> {
|
|
|
|
|
+ try {
|
|
|
|
|
+ return qwGroupChatService.cogradientGroupChat(corpId, new ArrayList<>());
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ log.error("[GroupChat] 同步客户群信息异常", e);
|
|
|
|
|
+ return R.error("同步客户群信息失败: " + e.getMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ } catch (IllegalArgumentException e) {
|
|
|
|
|
+ log.error("[GroupChat] 同步客户群信息失败,租户不存在或已禁用,tenantId={}", tenantId, e);
|
|
|
|
|
+ return R.error("租户不存在或已禁用");
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ log.error("[GroupChat] 同步客户群信息异常,tenantId={}, corpId={}", tenantId, corpId, e);
|
|
|
|
|
+ return R.error("同步客户群信息失败: " + e.getMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 同步我的客户群信息
|
|
|
|
|
+ */
|
|
|
|
|
+ @GetMapping("/cogradientMyGroupChat/{corpId}")
|
|
|
|
|
+ public R cogradientMyGroupChat(@PathVariable("corpId") String corpId,
|
|
|
|
|
+ @RequestParam("companyUserId") Long companyUserId,
|
|
|
|
|
+ @RequestParam("tenantId") Long tenantId) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ log.info("[GroupChat] 同步我的客户群信息,tenantId={}, corpId={}, companyUserId={}", tenantId, corpId, companyUserId);
|
|
|
|
|
+ return tenantDataSourceUtil.executeWithResult(tenantId, () -> {
|
|
|
|
|
+ try {
|
|
|
|
|
+ List<String> qwUserIdList = iQwUserService.selectQwUserListByCompanyUserId(companyUserId, corpId);
|
|
|
|
|
+ return qwGroupChatService.cogradientGroupChat(corpId, qwUserIdList);
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ log.error("[GroupChat] 同步我的客户群信息异常", e);
|
|
|
|
|
+ return R.error("同步我的客户群信息失败: " + e.getMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ } catch (IllegalArgumentException e) {
|
|
|
|
|
+ log.error("[GroupChat] 同步我的客户群信息失败,租户不存在或已禁用,tenantId={}", tenantId, e);
|
|
|
|
|
+ return R.error("租户不存在或已禁用");
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ log.error("[GroupChat] 同步我的客户群信息异常,tenantId={}, corpId={}", tenantId, corpId, e);
|
|
|
|
|
+ return R.error("同步我的客户群信息失败: " + e.getMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+}
|