增加行业凭证后台 token 配置
This commit is contained in:
@@ -0,0 +1,78 @@
|
||||
import { Router } from 'express'
|
||||
|
||||
import {
|
||||
getAdminKuaishouIndustrySourceConfig,
|
||||
refreshAdminKuaishouIndustryAccessToken,
|
||||
updateAdminKuaishouIndustrySourceConfig,
|
||||
} from '../../../services/admin/platform-config/kuaishou-industry-service.js'
|
||||
import type {
|
||||
AdminKuaishouIndustrySourceConfigRouteBody,
|
||||
} from '../../../types/admin/route-inputs.js'
|
||||
import { createJsonHandler } from '../session.js'
|
||||
import type { JsonRecord } from '../../../types/json.js'
|
||||
|
||||
const router = Router()
|
||||
|
||||
router.get(
|
||||
'/kuaishou-industry-source',
|
||||
createJsonHandler(() => getAdminKuaishouIndustrySourceConfig(), {
|
||||
successMessage: 'ok',
|
||||
errorMessage: '读取快手行业电子凭证配置失败',
|
||||
scope: '[admin/platform-config/kuaishou-industry-source]',
|
||||
}),
|
||||
)
|
||||
|
||||
router.post(
|
||||
'/kuaishou-industry-source',
|
||||
createJsonHandler(
|
||||
(req) =>
|
||||
updateAdminKuaishouIndustrySourceConfig(
|
||||
req.body as AdminKuaishouIndustrySourceConfigRouteBody,
|
||||
),
|
||||
{
|
||||
successMessage: '快手行业电子凭证配置已保存',
|
||||
errorMessage: '保存快手行业电子凭证配置失败',
|
||||
scope: '[admin/platform-config/kuaishou-industry-source]',
|
||||
audit: (_req, data) => {
|
||||
const result = data as JsonRecord
|
||||
return {
|
||||
action: 'platform_kuaishou_industry_source_updated',
|
||||
targetType: 'platform_config',
|
||||
targetId: 'kuaishou_industry_source',
|
||||
data: {
|
||||
filePath: String(result.filePath || '').trim(),
|
||||
enabled: Boolean(result.source?.enabled),
|
||||
sendCallbackEnabled: Boolean(result.source?.sendCallbackEnabled),
|
||||
hasAccessToken: Boolean(result.source?.hasAccessToken),
|
||||
hasRefreshToken: Boolean(result.source?.hasRefreshToken),
|
||||
accessTokenStatus: String(result.source?.accessTokenStatus || '').trim(),
|
||||
},
|
||||
}
|
||||
},
|
||||
},
|
||||
),
|
||||
)
|
||||
|
||||
router.post(
|
||||
'/kuaishou-industry-source/refresh-token',
|
||||
createJsonHandler(() => refreshAdminKuaishouIndustryAccessToken(), {
|
||||
successMessage: '快手行业电子凭证 accessToken 已刷新',
|
||||
errorMessage: '刷新快手行业电子凭证 accessToken 失败',
|
||||
scope: '[admin/platform-config/kuaishou-industry-source/refresh-token]',
|
||||
audit: (_req, data) => {
|
||||
const result = data as JsonRecord
|
||||
return {
|
||||
action: 'platform_kuaishou_industry_access_token_refreshed',
|
||||
targetType: 'platform_config',
|
||||
targetId: 'kuaishou_industry_source',
|
||||
data: {
|
||||
refreshed: Boolean(result.refreshed),
|
||||
accessTokenExpiresAt: String(result.source?.accessTokenExpiresAt || '').trim(),
|
||||
accessTokenStatus: String(result.source?.accessTokenStatus || '').trim(),
|
||||
},
|
||||
}
|
||||
},
|
||||
}),
|
||||
)
|
||||
|
||||
export default router
|
||||
Reference in New Issue
Block a user