Преглед изворни кода

Merge remote-tracking branch 'origin/master'

yumeng пре 5 година
родитељ
комит
c5a4d6b3ad

+ 1 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/config/ShiroConfig.java

@@ -75,7 +75,7 @@ public class ShiroConfig {
 		filterChainDefinitionMap.put("/kuaishou/**", "anon");
 		filterChainDefinitionMap.put("/ctop/bindAccount/**", "anon");
 		filterChainDefinitionMap.put("/**/*.mp4", "anon");
-		filterChainDefinitionMap.put("/bytedance", "anon");
+        filterChainDefinitionMap.put("/bytedance", "anon");
 
 
 		//性能监控

+ 47 - 37
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/CallbackController.java

@@ -9,11 +9,13 @@ import cn.com.ctop.toutiao.common.BytedanceInterfaceConstant;
 import com.alibaba.fastjson.JSONObject;
 import constant.KuaishouInterfaceConstant;
 import org.apache.commons.lang.StringUtils;
+import org.jeecg.modules.ctop.entity.ByteDanceAdvertiser;
 import org.jeecg.modules.ctop.entity.CTopOauthToken;
 import org.jeecg.modules.ctop.entity.UserAllocation;
 import org.jeecg.modules.ctop.mapper.CTopOauthTokenMapper;
 import org.jeecg.modules.ctop.mapper.UserAllocationMapper;
 import org.jeecg.modules.ctop.service.IBindAccountAuthService;
+import org.jeecg.modules.ctop.service.IByteDanceAdvertiserDataService;
 import org.jeecg.modules.kuaishou.service.IKuaishouInterfaceService;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -31,7 +33,6 @@ import java.util.HashMap;
 import java.util.Map;
 
 @Controller
-@RequestMapping("/")
 public class CallbackController {
     private static final Logger logger = LoggerFactory.getLogger(CallbackController.class);
 
@@ -138,6 +139,8 @@ public class CallbackController {
         return "auth_fail";
     }
 
+    @Autowired
+    private IByteDanceAdvertiserDataService advertiserDataService;
     public Map<String, Object> getByteDanceAccessToken(String authCode, String state) {
         Map<String, Object> param = new HashMap<String, Object>();
         param.put("app_id", PropertiesUtils.getValue("bytedance_config", "bytedance_appid"));
@@ -158,47 +161,54 @@ public class CallbackController {
             if (null == code || code != 0) {
                 logger.info("获取token失败,state:{},message:{}", state, message);
                 throw new Exception("token返回码异常");
-
             }
+            String advertiser_id = json.getString("advertiserId");
+            String mediaId = json.getString("mediaId"); // 媒体类型: 1 头条 2 快手
+            String realName = json.getString("realName");
+            String departmentId = json.getString("departmentId"); //部门id
+            String distributionName = json.getString("distributionName");//指定分配人姓名
+            String advertiserName = json.getString("advertiser_name"); // 广告主名称
+            String userId = json.getString("userId"); //创建人
+
             JSONObject data = resultObject.getJSONObject("data");
             CTopOauthToken token = new CTopOauthToken(data.getString("advertiser_id"), data);
-            if (Check.isNull(token)) {
-                String advertiser_id = json.getString("advertiserId");
-                String mediaId = json.getString("mediaId"); // 媒体类型: 1 头条 2 快手
-                String realName = json.getString("realName");
-                String departmentId = json.getString("departmentId"); //部门id
-                String distributionName = json.getString("distributionName");//指定分配人姓名
-                String advertiserName = json.getString("advertiser_name"); // 广告主名称
-                String userId = json.getString("userId"); //创建人
-                UserAllocation userAllocation = new UserAllocation();
-                userAllocation.setDistributionName(distributionName);
-                userAllocation.setUserId(userId);
-                userAllocation.setDepartmentId(departmentId);
-                userAllocation.setOperationName(realName);
-                userAllocation.setAccountId(token.getAccountId());
-                userAllocation.setAdvertiserName(advertiserName);
-                userAllocation.setMediaId(mediaId);
-                userAllocation.setAdvertiserId(advertiser_id);
-                allocationMapper.deleteById(userAllocation.getId());
-                Map<String, Object> deleteUserMap = new HashMap<>();
-                deleteUserMap.put("advertiser_id", advertiser_id);
-                deleteUserMap.put("account_id", token.getAccountId());
-                allocationMapper.deleteByMap(deleteUserMap);
-                int i = allocationMapper.insert(userAllocation);
-                if (i > 0) {
-                    logger.info("同步分配用户表完成,task_id:{},accountId:{}", state, token.getAccountId());
+            Map<String, Object> deleteMap = new HashMap<>();
+            deleteMap.put("advertiser_id", advertiser_id);
+            deleteMap.put("account_id", token.getAccountId());
+            cTopOauthTokenMapper.deleteByMap(deleteMap); //删除 广告主id下的相关授权信息
+            token.setAdvertiserId(advertiser_id);
+            cTopOauthTokenMapper.insert(token);
+            //获取广告主信息
+            Map<String, Object> advertiserDataMap = advertiserDataService.getAdvertiserInfo(token.getAccountId() + "");
+            Boolean getSuccess = (Boolean) advertiserDataMap.get("success");
+            if (null == getSuccess || !getSuccess) {
+                logger.info("获取广告主信息失败,accountId:{},message:{}", token.getAccountId(), (String) advertiserDataMap.get("message"));
+                throw new Exception("获取广告主信息失败");
+            }
+            ByteDanceAdvertiser advertiserData = (ByteDanceAdvertiser) advertiserDataMap.get("data");
+            UserAllocation userAllocation = new UserAllocation();
+            userAllocation.setDistributionName(distributionName);
+            userAllocation.setUserId(userId);
+            userAllocation.setDepartmentId(departmentId);
+            userAllocation.setOperationName(realName);
+            userAllocation.setAccountId(token.getAccountId());
+            userAllocation.setAdvertiserName(advertiserName);
+            userAllocation.setMediaId(mediaId);
+            userAllocation.setAuthName(advertiserData.getName());
+            userAllocation.setAdvertiserId(advertiser_id);
+            allocationMapper.deleteById(userAllocation.getId());
+            Map<String, Object> deleteUserMap = new HashMap<>();
+            deleteUserMap.put("advertiser_id", advertiser_id);
+            deleteUserMap.put("account_id", token.getAccountId());
+            allocationMapper.deleteByMap(deleteUserMap);
+            int i = allocationMapper.insert(userAllocation);
+            if (i > 0) {
+                logger.info("同步分配用户表完成,task_id:{},accountId:{}", state, token.getAccountId());
 
-                }
-                Map<String, Object> deleteMap = new HashMap<>();
-                deleteMap.put("advertiser_id", advertiser_id);
-                deleteMap.put("account_id", token.getAccountId());
-                cTopOauthTokenMapper.deleteByMap(deleteMap); //删除 广告主id下的相关授权信息
-                token.setAdvertiserId(advertiser_id);
-                cTopOauthTokenMapper.insert(token);
-                bindAccountAuthService.addBindAccount(token.getAccountId(), KuaishouInterfaceConstant.LOGIN_TYPE_BYTEDANCE, advertiser_id); //账号绑定
-                returnMap.put("code", 0);
-                returnMap.put("desc", "success");
             }
+            bindAccountAuthService.addBindAccount(token.getAccountId(), KuaishouInterfaceConstant.LOGIN_TYPE_BYTEDANCE, advertiser_id); //账号绑定
+            returnMap.put("code", 0);
+            returnMap.put("desc", "success");
         } catch (Exception e) {
             e.printStackTrace();
             returnMap.put("code", -1);

+ 1 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/mapper/UserAllocationMapper.java

@@ -9,7 +9,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 /**
  * @Description: 用户分配
  * @Author: jeecg-boot
- * @Date:   2019-08-08
+ * @Date: 2019-08-08
  * @Version: V1.0
  */
 public interface UserAllocationMapper extends BaseMapper<UserAllocation> {

+ 1 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/IUserAllocationService.java

@@ -6,7 +6,7 @@ import org.jeecg.modules.ctop.entity.UserAllocation;
 /**
  * @Description: 用户分配
  * @Author: jeecg-boot
- * @Date:   2019-08-08
+ * @Date: 2019-08-08
  * @Version: V1.0
  */
 public interface IUserAllocationService extends IService<UserAllocation> {

+ 1 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/impl/ByteDanceAdvertiserDataServiceImpl.java

@@ -78,6 +78,7 @@ public class ByteDanceAdvertiserDataServiceImpl implements IByteDanceAdvertiserD
             //清除清数据,插入新数据
             advertiserMapper.deleteById(advertiser.getId());
             advertiserMapper.insert(advertiser);
+            resultMap.put("data", advertiser);
         }
         resultMap.put("code", 0);
         resultMap.put("message", "获取广告主信息成功");

+ 8 - 8
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/vue/UserAllocationList.vue

@@ -178,15 +178,15 @@
             dataIndex: 'operationName'
            },
 		   {
-            title: '授权名称',
-            align:"center",
-            dataIndex: 'authName'
-           },
-		   {
-            title: '平台类型 1 头条 2快手',
-            align:"center",
-            dataIndex: 'mediaId'
+               title: '授权名称',
+               align: "center",
+               dataIndex: 'authName'
            },
+            {
+                title: '平台类型 1 头条 2快手',
+                align:"center",
+                dataIndex: 'mediaId'
+            },
           {
             title: '操作',
             dataIndex: 'action',

+ 9 - 9
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/vue/modules/UserAllocationModal.vue

@@ -60,16 +60,16 @@
           <a-input placeholder="请输入输入账号  --登陆" v-decorator="['accountName', {}]" />
         </a-form-item>
         <a-form-item
-          :labelCol="labelCol"
-          :wrapperCol="wrapperCol"
-          label="操作人姓名">
-          <a-input placeholder="请输入操作人姓名" v-decorator="['operationName', {}]" />
+                :labelCol="labelCol"
+                :wrapperCol="wrapperCol"
+                label="操作人姓名">
+            <a-input placeholder="请输入操作人姓名" v-decorator="['operationName', {}]"/>
         </a-form-item>
         <a-form-item
-          :labelCol="labelCol"
-          :wrapperCol="wrapperCol"
-          label="授权名称">
-          <a-input placeholder="请输入授权名称" v-decorator="['authName', {}]" />
+                :labelCol="labelCol"
+                :wrapperCol="wrapperCol"
+                label="授权名称">
+            <a-input placeholder="请输入授权名称" v-decorator="['authName', {}]"/>
         </a-form-item>
         <a-form-item
           :labelCol="labelCol"
@@ -125,7 +125,7 @@
         this.model = Object.assign({}, record);
         this.visible = true;
         this.$nextTick(() => {
-          this.form.setFieldsValue(pick(this.model,'userId','accountId','advertiserId','distributionName','departmentId','adminName','advertiserName','accountName','operationName','authName','mediaId'))
+            this.form.setFieldsValue(pick(this.model, 'userId', 'accountId', 'advertiserId', 'distributionName', 'departmentId', 'adminName', 'advertiserName', 'accountName', 'operationName', 'authName', 'mediaId'))
 		  //时间格式化
         });
 

+ 9 - 9
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/vue/modules/UserAllocationModal__Style#Drawer.vue

@@ -60,16 +60,16 @@
           <a-input placeholder="请输入输入账号  --登陆" v-decorator="['accountName', {}]" />
         </a-form-item>
         <a-form-item
-          :labelCol="labelCol"
-          :wrapperCol="wrapperCol"
-          label="操作人姓名">
-          <a-input placeholder="请输入操作人姓名" v-decorator="['operationName', {}]" />
+                :labelCol="labelCol"
+                :wrapperCol="wrapperCol"
+                label="操作人姓名">
+            <a-input placeholder="请输入操作人姓名" v-decorator="['operationName', {}]"/>
         </a-form-item>
         <a-form-item
-          :labelCol="labelCol"
-          :wrapperCol="wrapperCol"
-          label="授权名称">
-          <a-input placeholder="请输入授权名称" v-decorator="['authName', {}]" />
+                :labelCol="labelCol"
+                :wrapperCol="wrapperCol"
+                label="授权名称">
+            <a-input placeholder="请输入授权名称" v-decorator="['authName', {}]"/>
         </a-form-item>
         <a-form-item
           :labelCol="labelCol"
@@ -127,7 +127,7 @@
         this.model = Object.assign({}, record);
         this.visible = true;
         this.$nextTick(() => {
-          this.form.setFieldsValue(pick(this.model,'userId','accountId','advertiserId','distributionName','departmentId','adminName','advertiserName','accountName','operationName','authName','mediaId'))
+            this.form.setFieldsValue(pick(this.model, 'userId', 'accountId', 'advertiserId', 'distributionName', 'departmentId', 'adminName', 'advertiserName', 'accountName', 'operationName', 'authName', 'mediaId'))
 		  //时间格式化
         });
 

+ 15 - 0
module-toutiao/pom.xml

@@ -79,5 +79,20 @@
                 </plugin>
             </plugins>
         </pluginManagement>
+        <resources>
+            <!-- 解决MyBatis配置文件引入问题 -->
+            <resource>
+                <directory>src/main/java</directory>
+                <includes>
+                    <include>**/*.properties</include>
+                    <include>**/*.xml</include>
+                </includes>
+                <!-- 是否替换资源中的属性-->
+                <filtering>false</filtering>
+            </resource>
+            <resource>
+                <directory>src/main/resources</directory>
+            </resource>
+        </resources>
     </build>
 </project>