|
@@ -18,8 +18,9 @@
|
|
</resultMap>
|
|
</resultMap>
|
|
|
|
|
|
<sql id="Base_Column_List">
|
|
<sql id="Base_Column_List">
|
|
- id,media_id,advertiser_id,account_id,access_token,refresh_token,access_token_expires_in,refresh_token_expires_in,agent_type,app_id,create_time,update_time
|
|
|
|
- </sql>
|
|
|
|
|
|
+ id
|
|
|
|
+ ,media_id,advertiser_id,account_id,access_token,refresh_token,access_token_expires_in,refresh_token_expires_in,agent_type,app_id,create_time,update_time
|
|
|
|
+ </sql>
|
|
|
|
|
|
<select id="selectByteDanceTokens" resultMap="BaseResultMap">
|
|
<select id="selectByteDanceTokens" resultMap="BaseResultMap">
|
|
select
|
|
select
|
|
@@ -89,73 +90,66 @@
|
|
|
|
|
|
|
|
|
|
<select id="selectKuaiShouToken" resultType="cn.com.ctop.common.module.entity.CtopOauthToken">
|
|
<select id="selectKuaiShouToken" resultType="cn.com.ctop.common.module.entity.CtopOauthToken">
|
|
- SELECT
|
|
|
|
- t1.id AS 'id',
|
|
|
|
- t1.media_id AS 'mediaId',
|
|
|
|
- t1.advertiser_id AS 'advertiser_id',
|
|
|
|
- t1.account_id AS 'accountId',
|
|
|
|
- ( CASE WHEN t3.access_token IS NOT NULL THEN t3.access_token ELSE t1.access_token END ) AS 'accessToken',
|
|
|
|
- ( CASE WHEN t3.refresh_token IS NOT NULL THEN t3.refresh_token ELSE t1.refresh_token END ) AS 'refreshToken',
|
|
|
|
- t1.agent_type AS 'agentType',
|
|
|
|
- t1.app_id AS 'appId',
|
|
|
|
- t1.access_token_expires_in as 'accessTokenExpiresIn',
|
|
|
|
- t1.refresh_token_expires_in as 'refreshTokenExpiresIn',
|
|
|
|
- t1.create_time as 'createTime',
|
|
|
|
- t1.update_time as 'updateTime'
|
|
|
|
- FROM
|
|
|
|
- ctop_oauth_token t1
|
|
|
|
- LEFT JOIN ctop_user_allocation t2 ON t1.account_id = t2.account_id
|
|
|
|
- LEFT JOIN ctop_oauth_agent_token t3 ON t1.app_id = t3.app_id
|
|
|
|
- WHERE
|
|
|
|
- t2.account_status = 0
|
|
|
|
- AND t1.media_id = 2;
|
|
|
|
|
|
+ SELECT t1.id AS 'id', t1.media_id AS 'mediaId', t1.advertiser_id AS 'advertiser_id', t1.account_id AS 'accountId', (CASE
|
|
|
|
+ WHEN t3.access_token IS NOT NULL
|
|
|
|
+ THEN t3.access_token
|
|
|
|
+ ELSE t1.access_token END) AS 'accessToken', (CASE
|
|
|
|
+ WHEN t3.refresh_token IS NOT NULL
|
|
|
|
+ THEN t3.refresh_token
|
|
|
|
+ ELSE t1.refresh_token END) AS 'refreshToken', t1.agent_type AS 'agentType', t1.app_id AS 'appId', t1.access_token_expires_in as 'accessTokenExpiresIn', t1.refresh_token_expires_in as 'refreshTokenExpiresIn', t1.create_time as 'createTime', t1.update_time as 'updateTime'
|
|
|
|
+ FROM ctop_oauth_token t1
|
|
|
|
+ LEFT JOIN ctop_user_allocation t2 ON t1.account_id = t2.account_id
|
|
|
|
+ LEFT JOIN ctop_oauth_agent_token t3 ON t1.app_id = t3.app_id
|
|
|
|
+ WHERE t2.account_status = 0
|
|
|
|
+ AND t1.media_id = 2;
|
|
|
|
|
|
</select>
|
|
</select>
|
|
|
|
|
|
<select id="selectKuaiShouTokenBefore" resultType="cn.com.ctop.common.module.entity.CtopOauthToken">
|
|
<select id="selectKuaiShouTokenBefore" resultType="cn.com.ctop.common.module.entity.CtopOauthToken">
|
|
- select t1.*
|
|
|
|
|
|
+ select t1.*
|
|
from ctop_oauth_token t1
|
|
from ctop_oauth_token t1
|
|
- left join ctop_user_allocation t2
|
|
|
|
- on t1.account_id = t2.account_id
|
|
|
|
|
|
+ left join ctop_user_allocation t2
|
|
|
|
+ on t1.account_id = t2.account_id
|
|
where t1.media_id = 2
|
|
where t1.media_id = 2
|
|
- and date_format(t2.create_time, '%Y-%m-%d') = date_sub(curdate(),interval 1 day)
|
|
|
|
|
|
+ and date_format(t2.create_time, '%Y-%m-%d') = date_sub(curdate(), interval 1 day)
|
|
</select>
|
|
</select>
|
|
|
|
|
|
<select id="selectToutiaoToken" resultType="cn.com.ctop.common.module.entity.CtopOauthToken">
|
|
<select id="selectToutiaoToken" resultType="cn.com.ctop.common.module.entity.CtopOauthToken">
|
|
select t1.*
|
|
select t1.*
|
|
from ctop_oauth_token t1
|
|
from ctop_oauth_token t1
|
|
- left join ctop_user_allocation t2
|
|
|
|
- on t1.account_id = t2.account_id
|
|
|
|
- where t1.media_id in (1,3) and t2.account_status = 0
|
|
|
|
|
|
+ left join ctop_user_allocation t2
|
|
|
|
+ on t1.account_id = t2.account_id
|
|
|
|
+ where t1.media_id in (1, 3)
|
|
|
|
+ and t2.account_status = 0
|
|
group by account_id
|
|
group by account_id
|
|
</select>
|
|
</select>
|
|
|
|
|
|
<select id="getAccessTokenByAccountIdAndMediaId" resultType="cn.com.ctop.common.module.entity.CtopOauthToken">
|
|
<select id="getAccessTokenByAccountIdAndMediaId" resultType="cn.com.ctop.common.module.entity.CtopOauthToken">
|
|
- select
|
|
|
|
- *
|
|
|
|
- from
|
|
|
|
- ctop_oauth_token
|
|
|
|
|
|
+ select *
|
|
|
|
+ from ctop_oauth_token
|
|
where media_id = #{mediaId}
|
|
where media_id = #{mediaId}
|
|
- and account_id = #{accountId}
|
|
|
|
|
|
+ and account_id = #{accountId}
|
|
</select>
|
|
</select>
|
|
|
|
|
|
<!-- 根据mediaType 和 账户绑定助手时间createTime 获取accountId -->
|
|
<!-- 根据mediaType 和 账户绑定助手时间createTime 获取accountId -->
|
|
<select id="getToutiaoTokenByCreateTime" resultType="cn.com.ctop.common.module.entity.CtopOauthToken">
|
|
<select id="getToutiaoTokenByCreateTime" resultType="cn.com.ctop.common.module.entity.CtopOauthToken">
|
|
- select t1.*
|
|
|
|
|
|
+ select t1.*
|
|
from ctop_oauth_token t1
|
|
from ctop_oauth_token t1
|
|
- left join ctop_user_allocation t2
|
|
|
|
- on t1.account_id = t2.account_id
|
|
|
|
|
|
+ left join ctop_user_allocation t2
|
|
|
|
+ on t1.account_id = t2.account_id
|
|
where t2.account_status = 0
|
|
where t2.account_status = 0
|
|
- and t1.media_id in (1,3)
|
|
|
|
- and date_format(t2.create_time, '%Y-%m-%d') = #{createTime}
|
|
|
|
|
|
+ and t1.media_id in (1, 3)
|
|
|
|
+ and date_format(t2.create_time, '%Y-%m-%d') = #{createTime}
|
|
group by account_id
|
|
group by account_id
|
|
</select>
|
|
</select>
|
|
|
|
|
|
<select id="queryKsValidRuleAccountsToken" resultType="cn.com.ctop.common.module.entity.CtopOauthToken">
|
|
<select id="queryKsValidRuleAccountsToken" resultType="cn.com.ctop.common.module.entity.CtopOauthToken">
|
|
- SELECT * FROM ctop_oauth_token
|
|
|
|
|
|
+ SELECT *
|
|
|
|
+ FROM ctop_oauth_token
|
|
WHERE account_id IN
|
|
WHERE account_id IN
|
|
- (SELECT t2.account_id FROM ctop_rule_template t1
|
|
|
|
- INNER JOIN ctop_rule_account_template t2 ON t1.id = t2.template_id
|
|
|
|
|
|
+ (SELECT t2.account_id
|
|
|
|
+ FROM ctop_rule_template t1
|
|
|
|
+ INNER JOIN ctop_rule_account_template t2 ON t1.id = t2.template_id
|
|
WHERE t1.media_type = 2
|
|
WHERE t1.media_type = 2
|
|
AND t2.template_status = 0
|
|
AND t2.template_status = 0
|
|
GROUP BY t2.account_id
|
|
GROUP BY t2.account_id
|
|
@@ -163,11 +157,13 @@
|
|
</select>
|
|
</select>
|
|
|
|
|
|
<select id="queryTtValidRuleAccountsToken" resultType="cn.com.ctop.common.module.entity.CtopOauthToken">
|
|
<select id="queryTtValidRuleAccountsToken" resultType="cn.com.ctop.common.module.entity.CtopOauthToken">
|
|
- SELECT * FROM ctop_oauth_token
|
|
|
|
|
|
+ SELECT *
|
|
|
|
+ FROM ctop_oauth_token
|
|
WHERE account_id IN
|
|
WHERE account_id IN
|
|
- (SELECT t2.account_id FROM ctop_rule_template t1
|
|
|
|
- INNER JOIN ctop_rule_account_template t2 ON t1.id = t2.template_id
|
|
|
|
- WHERE t1.media_type IN (1,3)
|
|
|
|
|
|
+ (SELECT t2.account_id
|
|
|
|
+ FROM ctop_rule_template t1
|
|
|
|
+ INNER JOIN ctop_rule_account_template t2 ON t1.id = t2.template_id
|
|
|
|
+ WHERE t1.media_type IN (1, 3)
|
|
AND t2.template_status = 0
|
|
AND t2.template_status = 0
|
|
GROUP BY t2.account_id
|
|
GROUP BY t2.account_id
|
|
)
|
|
)
|
|
@@ -183,4 +179,41 @@
|
|
group by account_id
|
|
group by account_id
|
|
</select>
|
|
</select>
|
|
|
|
|
|
|
|
+ <select id="queryBytedanceAgentTokens" resultType="com.alibaba.fastjson.JSONObject">
|
|
|
|
+ select *
|
|
|
|
+ FROM ctop_bytedance_agent_token
|
|
|
|
+ </select>
|
|
|
|
+
|
|
|
|
+ <select id="queryBytedanceAgentTokenByAccountId" resultType="com.alibaba.fastjson.JSONObject">
|
|
|
|
+ SELECT *
|
|
|
|
+ FROM ctop_bytedance_agent_token
|
|
|
|
+ WHERE agent_id = #{agentId}
|
|
|
|
+ </select>
|
|
|
|
+
|
|
|
|
+ <insert id="replace">
|
|
|
|
+ replace
|
|
|
|
+ into ctop_bytedance_agent_token(
|
|
|
|
+ id,
|
|
|
|
+ agent_id,
|
|
|
|
+ agent_name,
|
|
|
|
+ access_token,
|
|
|
|
+ access_token_expires_in,
|
|
|
|
+ refresh_token,
|
|
|
|
+ refresh_token_expires_in,
|
|
|
|
+ agent_type,
|
|
|
|
+ app_id )
|
|
|
|
+ values
|
|
|
|
+ (
|
|
|
|
+ #{data.id},
|
|
|
|
+ #{data.agentId},
|
|
|
|
+ #{data.agentName},
|
|
|
|
+ #{data.accessToken},
|
|
|
|
+ #{data.accessTokenExpiresIn},
|
|
|
|
+ #{data.refreshToken},
|
|
|
|
+ #{data.refreshTokenExpiresIn},
|
|
|
|
+ #{data.agentType},
|
|
|
|
+ #{data.appId}
|
|
|
|
+ )
|
|
|
|
+ </insert>
|
|
|
|
+
|
|
</mapper>
|
|
</mapper>
|