routerAdd('POST', '/api/platform/login', function (e) {
    const guards = require(`${__hooks}/bai_api_pb_hooks/bai_api_shared/middlewares/requestGuards.js`)
    const userService = require(`${__hooks}/bai_api_pb_hooks/bai_api_shared/services/userService.js`)
    const logger = require(`${__hooks}/bai_api_pb_hooks/bai_api_shared/utils/logger.js`)
    const { successWithToken } = require(`${__hooks}/bai_api_pb_hooks/bai_api_shared/utils/response.js`)

    try {
        guards.requireJson(e)
        guards.duplicateGuard(e)

        const payload = guards.validatePlatformLoginBody(e)
        const data = userService.authenticatePlatformUser(payload)

        return successWithToken(e, '登录成功', data.meta.data, userService.ensureAuthToken(data.token))
    } catch (err) {
        const status =
            (err && typeof err.statusCode === 'number' && err.statusCode)
            || (err && typeof err.status === 'number' && err.status)
            || 400

        logger.error('平台登录失败', {
            status: status,
            message: (err && err.message) || '未知错误',
            data: (err && err.data) || {},
        })

        return e.json(status, {
            code: status,
            msg: (err && err.message) || '平台登录失败',
            data: (err && err.data) || {},
        })
    }
})