|
|
@@ -1,5 +1,8 @@
|
|
|
package com.fs.company.controller.qw;
|
|
|
|
|
|
+import cn.hutool.http.HttpRequest;
|
|
|
+import cn.hutool.http.HttpResponse;
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
import com.fs.common.annotation.DataScope;
|
|
|
import com.fs.common.annotation.Log;
|
|
|
import com.fs.common.core.controller.BaseController;
|
|
|
@@ -7,6 +10,7 @@ import com.fs.common.core.domain.AjaxResult;
|
|
|
import com.fs.common.core.domain.R;
|
|
|
import com.fs.common.core.page.TableDataInfo;
|
|
|
import com.fs.common.enums.BusinessType;
|
|
|
+import com.fs.common.utils.SecurityUtils;
|
|
|
import com.fs.common.utils.ServletUtils;
|
|
|
import com.fs.common.utils.poi.ExcelUtil;
|
|
|
import com.fs.company.domain.CompanyUser;
|
|
|
@@ -18,12 +22,15 @@ import com.fs.qw.param.QwFriendWelcomeParam;
|
|
|
import com.fs.qw.service.IQwFriendWelcomeService;
|
|
|
import com.fs.qw.service.IQwUserService;
|
|
|
import com.fs.qw.vo.QwFriendWelcomeVO;
|
|
|
-import com.fs.qw.vo.QwOptionsVO;
|
|
|
+import com.fs.qwApi.config.OpenQwConfig;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
+import org.springframework.data.redis.core.RedisTemplate;
|
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
-import org.springframework.util.StringUtils;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
+import java.net.SocketTimeoutException;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@@ -33,6 +40,7 @@ import java.util.stream.Collectors;
|
|
|
* @author fs
|
|
|
* @date 2024-07-20
|
|
|
*/
|
|
|
+@Slf4j
|
|
|
@RestController
|
|
|
@RequestMapping("/qw/friendWelcome")
|
|
|
public class QwFriendWelcomeController extends BaseController
|
|
|
@@ -49,6 +57,13 @@ public class QwFriendWelcomeController extends BaseController
|
|
|
@Autowired
|
|
|
private CompanyDeptServiceImpl companyDeptService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private RedisTemplate redisTemplate;
|
|
|
+
|
|
|
+ /** HTTP调用超时时间(秒) */
|
|
|
+ @Value("${qw.api.timeout:30}")
|
|
|
+ private int apiTimeout;
|
|
|
+
|
|
|
/**
|
|
|
* 查询好友欢迎语列表
|
|
|
*/
|
|
|
@@ -150,7 +165,28 @@ public class QwFriendWelcomeController extends BaseController
|
|
|
qwFriendWelcomeParam.setDeptId(companyUser.getDeptId());
|
|
|
qwFriendWelcomeParam.setCreateTime(new Date());
|
|
|
qwFriendWelcomeParam.setUpdateTime(new Date());
|
|
|
- return qwFriendWelcomeService.insertQwFriendWelcomeVO(qwFriendWelcomeParam);
|
|
|
+
|
|
|
+ // 从当前登录用户获取租户ID
|
|
|
+ Long tenantId = SecurityUtils.getTenantId();
|
|
|
+ String url = OpenQwConfig.api + "/qw/friendWelcome?tenantId=" + tenantId;
|
|
|
+ try {
|
|
|
+ HttpResponse response = HttpRequest.post(url)
|
|
|
+ .body(JSON.toJSONString(qwFriendWelcomeParam))
|
|
|
+ .timeout(apiTimeout * 1000)
|
|
|
+ .execute();
|
|
|
+ if (response.getStatus() == 200) {
|
|
|
+ return JSON.parseObject(response.body(), R.class);
|
|
|
+ } else {
|
|
|
+ log.error("新增好友欢迎语失败,HTTP状态码: {}", response.getStatus());
|
|
|
+ return R.error("新增好友欢迎语失败,服务返回状态码: " + response.getStatus());
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("新增好友欢迎语异常, url={}", url, e);
|
|
|
+ if (e.getCause() instanceof SocketTimeoutException) {
|
|
|
+ return R.error("新增好友欢迎语超时,请稍后重试");
|
|
|
+ }
|
|
|
+ return R.error("新增好友欢迎语失败: " + e.getMessage());
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -161,7 +197,27 @@ public class QwFriendWelcomeController extends BaseController
|
|
|
@PutMapping
|
|
|
public R edit(@RequestBody QwFriendWelcome qwFriendWelcome)
|
|
|
{
|
|
|
- return qwFriendWelcomeService.updateQwFriendWelcome(qwFriendWelcome);
|
|
|
+ // 从当前登录用户获取租户ID
|
|
|
+ Long tenantId = SecurityUtils.getTenantId();
|
|
|
+ String url = OpenQwConfig.api + "/qw/friendWelcome/update?tenantId=" + tenantId;
|
|
|
+ try {
|
|
|
+ HttpResponse response = HttpRequest.post(url)
|
|
|
+ .body(JSON.toJSONString(qwFriendWelcome))
|
|
|
+ .timeout(apiTimeout * 1000)
|
|
|
+ .execute();
|
|
|
+ if (response.getStatus() == 200) {
|
|
|
+ return JSON.parseObject(response.body(), R.class);
|
|
|
+ } else {
|
|
|
+ log.error("修改好友欢迎语失败,HTTP状态码: {}", response.getStatus());
|
|
|
+ return R.error("修改好友欢迎语失败,服务返回状态码: " + response.getStatus());
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("修改好友欢迎语异常, url={}", url, e);
|
|
|
+ if (e.getCause() instanceof SocketTimeoutException) {
|
|
|
+ return R.error("修改好友欢迎语超时,请稍后重试");
|
|
|
+ }
|
|
|
+ return R.error("修改好友欢迎语失败: " + e.getMessage());
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -172,6 +228,26 @@ public class QwFriendWelcomeController extends BaseController
|
|
|
@DeleteMapping("/{ids}")
|
|
|
public AjaxResult remove(@PathVariable Long[] ids)
|
|
|
{
|
|
|
- return toAjax(qwFriendWelcomeService.deleteQwFriendWelcomeByIds(ids));
|
|
|
+ // 从当前登录用户获取租户ID
|
|
|
+ Long tenantId = SecurityUtils.getTenantId();
|
|
|
+ String idsStr = Arrays.stream(ids).map(String::valueOf).collect(Collectors.joining(","));
|
|
|
+ String url = OpenQwConfig.api + "/qw/friendWelcome/" + idsStr + "?tenantId=" + tenantId;
|
|
|
+ try {
|
|
|
+ HttpResponse response = HttpRequest.delete(url)
|
|
|
+ .timeout(apiTimeout * 1000)
|
|
|
+ .execute();
|
|
|
+ if (response.getStatus() == 200) {
|
|
|
+ return JSON.parseObject(response.body(), AjaxResult.class);
|
|
|
+ } else {
|
|
|
+ log.error("删除好友欢迎语失败,HTTP状态码: {}", response.getStatus());
|
|
|
+ return AjaxResult.error("删除好友欢迎语失败,服务返回状态码: " + response.getStatus());
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("删除好友欢迎语异常, url={}", url, e);
|
|
|
+ if (e.getCause() instanceof SocketTimeoutException) {
|
|
|
+ return AjaxResult.error("删除好友欢迎语超时,请稍后重试");
|
|
|
+ }
|
|
|
+ return AjaxResult.error("删除好友欢迎语失败: " + e.getMessage());
|
|
|
+ }
|
|
|
}
|
|
|
}
|