|
@@ -4,7 +4,9 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.zanxiang.erp.security.util.SecurityUtil;
|
|
|
+import com.zanxiang.game.module.manage.enums.KfActionEnum;
|
|
|
import com.zanxiang.game.module.manage.enums.KfApiEnum;
|
|
|
+import com.zanxiang.game.module.manage.pojo.dto.KfMsgResultDTO;
|
|
|
import com.zanxiang.game.module.manage.pojo.params.KfApiParam;
|
|
|
import com.zanxiang.game.module.manage.pojo.vo.KfGameVO;
|
|
|
import com.zanxiang.game.module.manage.service.IGameAppletService;
|
|
@@ -21,7 +23,6 @@ import com.zanxiang.module.util.URIUtil;
|
|
|
import com.zanxiang.module.util.bean.BeanUtil;
|
|
|
import com.zanxiang.module.util.exception.BaseException;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
-import org.apache.logging.log4j.util.Strings;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.http.HttpEntity;
|
|
|
import org.springframework.http.HttpHeaders;
|
|
@@ -68,21 +69,37 @@ public class KfMsgContentServiceImpl extends ServiceImpl<KfMsgContentMapper, KfM
|
|
|
.eq(GameApplet::getType, 1)
|
|
|
.in(!SecurityUtil.isAdmin(), GameApplet::getGameId,
|
|
|
gameAuthList.stream().map(GameAuth::getGameId).collect(Collectors.toSet()))
|
|
|
- ).stream().map(gameApplet -> BeanUtil.copy(gameApplet, KfGameVO.class)).collect(Collectors.toList());
|
|
|
+ ).stream().map(this::toVO).collect(Collectors.toList());
|
|
|
+ }
|
|
|
+
|
|
|
+ private KfGameVO toVO(GameApplet gameApplet) {
|
|
|
+ KfGameVO kfGameVO = BeanUtil.copy(gameApplet, KfGameVO.class);
|
|
|
+ if (kfGameVO == null) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ //判断是否存在授权记录
|
|
|
+ KfUser kfUser = kfUserService.getOne(new LambdaQueryWrapper<KfUser>()
|
|
|
+ .eq(KfUser::getKfUserId, SecurityUtil.getUserId())
|
|
|
+ .eq(KfUser::getAppId, kfGameVO.getAppId()));
|
|
|
+ kfGameVO.setIsAuth(kfUser != null ? Boolean.TRUE : Boolean.FALSE);
|
|
|
+ if (kfUser == null) {
|
|
|
+ return kfGameVO;
|
|
|
+ }
|
|
|
+ //判断授权信息是否过期, 请求获取客服信息接口
|
|
|
+ String result = this.commKfApi(kfUser, KfActionEnum.GET_KF_ACCT.getValue(),
|
|
|
+ KfApiEnum.getApiUrl(KfActionEnum.GET_KF_ACCT), Collections.emptyMap());
|
|
|
+ KfMsgResultDTO kfMsgResultDTO = JsonUtil.toObj(result, KfMsgResultDTO.class);
|
|
|
+ kfGameVO.setIsValid(kfMsgResultDTO.isSueecss());
|
|
|
+ return kfGameVO;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public String kfApi(KfApiParam param) {
|
|
|
log.error("请求参数, param : {}", JsonUtil.toString(param));
|
|
|
- //匹配行为对应的api地址
|
|
|
- String apiUrl = KfApiEnum.getApiUrl(param.getAction());
|
|
|
- if (Strings.isBlank(apiUrl)) {
|
|
|
- throw new BaseException("参数错误, 接口地址匹配异常!");
|
|
|
- }
|
|
|
//查询用户授权信息
|
|
|
KfUser kfUser = kfUserService.getKfUser(SecurityUtil.getUserId(), param.getAppId());
|
|
|
//请求调用腾讯接口
|
|
|
- return this.commKfApi(kfUser, param.getAction().getValue(), apiUrl, param.getParam());
|
|
|
+ return this.commKfApi(kfUser, param.getAction().getValue(), KfApiEnum.getApiUrl(param.getAction()), param.getParam());
|
|
|
}
|
|
|
|
|
|
private String commKfApi(KfUser kfUser, String action, String url, Map<String, Object> param) {
|