|
@@ -2,14 +2,18 @@ package org.jeecg.modules.ctop.controller;
|
|
|
|
|
|
import cn.com.ctop.common.module.annotation.AutoLog;
|
|
import cn.com.ctop.common.module.annotation.AutoLog;
|
|
import cn.com.ctop.common.module.constant.CtopRoleCodeConstant;
|
|
import cn.com.ctop.common.module.constant.CtopRoleCodeConstant;
|
|
|
|
+import cn.com.ctop.common.module.entity.CtopOauthToken;
|
|
import cn.com.ctop.common.module.entity.Project;
|
|
import cn.com.ctop.common.module.entity.Project;
|
|
import cn.com.ctop.common.module.entity.UserAllocation;
|
|
import cn.com.ctop.common.module.entity.UserAllocation;
|
|
import cn.com.ctop.common.module.mapper.UserAllocationMapper;
|
|
import cn.com.ctop.common.module.mapper.UserAllocationMapper;
|
|
|
|
+import cn.com.ctop.common.module.service.ICtopOauthTokenService;
|
|
import cn.com.ctop.common.module.service.IProjectService;
|
|
import cn.com.ctop.common.module.service.IProjectService;
|
|
import cn.com.ctop.common.module.service.ISysRoleExtService;
|
|
import cn.com.ctop.common.module.service.ISysRoleExtService;
|
|
import cn.com.ctop.common.module.service.IUserAllocationService;
|
|
import cn.com.ctop.common.module.service.IUserAllocationService;
|
|
import cn.com.ctop.common.module.utils.Check;
|
|
import cn.com.ctop.common.module.utils.Check;
|
|
import cn.com.ctop.common.module.utils.StringUtils;
|
|
import cn.com.ctop.common.module.utils.StringUtils;
|
|
|
|
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
|
|
|
|
+import cn.com.ctop.toutiao.modules.material.service.IByteDanceAdvertiserDataService;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
@@ -30,6 +34,7 @@ import org.springframework.web.bind.annotation.*;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import java.util.Arrays;
|
|
import java.util.Arrays;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
+import java.util.Map;
|
|
|
|
|
|
/**
|
|
/**
|
|
* 用户分配
|
|
* 用户分配
|
|
@@ -196,6 +201,63 @@ public class UserAllocationController {
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private ICtopOauthTokenService oauthTokenService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private IKuaishouInterfaceService kuaishouInterfaceService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private IByteDanceAdvertiserDataService advertiserDataService;
|
|
|
|
+
|
|
|
|
+ @GetMapping(value = "/updateAuthName")
|
|
|
|
+ public Result<UserAllocation> updateAuthName(Long accountId, String mediaId) {
|
|
|
|
+ Result<UserAllocation> result = new Result<>();
|
|
|
|
+ try {
|
|
|
|
+ CtopOauthToken oauthToken = oauthTokenService.getTokenByAccountId(accountId);
|
|
|
|
+ if (Check.isNull(oauthToken)) {
|
|
|
|
+ throw new Exception("未获取到账户信息");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ String authName = null;
|
|
|
|
+ if (mediaId.equals("2") || mediaId.equals("4")) {
|
|
|
|
+ Map<String, Object> advertiseBaseInfoMap = kuaishouInterfaceService.advertiserInfo(accountId, oauthToken.getAccessToken());
|
|
|
|
+ Integer code = (Integer) advertiseBaseInfoMap.get("code");
|
|
|
|
+ if (code != 0) {
|
|
|
|
+ throw new Exception("更新授权名称失败");
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ authName = (String) advertiseBaseInfoMap.get("userName");
|
|
|
|
+ } else if (mediaId.equals("1") || mediaId.equals("3")) {
|
|
|
|
+ Map<String, Object> advertiserDataMap = advertiserDataService.getAdvertiserInfo(String.valueOf(accountId), oauthToken.getAccessToken());
|
|
|
|
+ Integer code = (Integer) advertiserDataMap.get("code");
|
|
|
|
+ if (code != 0) {
|
|
|
|
+ throw new Exception("更新授权名称失败");
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ authName = (String) advertiserDataMap.get("name");
|
|
|
|
+ }
|
|
|
|
+ UserAllocation allocation = new UserAllocation();
|
|
|
|
+ allocation.setAuthName(authName);
|
|
|
|
+
|
|
|
|
+ QueryWrapper<UserAllocation> queryWrapper = new QueryWrapper<>();
|
|
|
|
+ queryWrapper.eq("account_id", accountId);
|
|
|
|
+ queryWrapper.eq("media_id", mediaId);
|
|
|
|
+
|
|
|
|
+ boolean update = userAllocationService.update(allocation, queryWrapper);
|
|
|
|
+ if (update) {
|
|
|
|
+ result.setSuccess(true);
|
|
|
|
+ } else {
|
|
|
|
+ result.setSuccess(false);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ result.setSuccess(false);
|
|
|
|
+ result.setMessage(e.getMessage());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return result;
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
|
|
/**
|
|
/**
|
|
* 统计报表 查看所有账号
|
|
* 统计报表 查看所有账号
|