| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- const API = require("../../lib/API.js")
- const { axiosWithQgOutbound } = require("../../lib/Lepao/qgOutboundAxios")
- const { BaseStdResponse } = require("../../BaseStdResponse.js")
- // 获取楼栋
- class GetDyList extends API {
- constructor() {
- super()
- this.setPath("/Power/GetPowerData")
- this.setMethod("POST")
- }
- async onRequest(req, res) {
- try {
- const { type, pid } = req.body
- if ([type].some(value => value === '' || value === null || value === undefined))
- return res.json({
- ...BaseStdResponse.MISSING_PARAMETER
- })
- if (type !== 'buildlist')
- if ([pid].some(value => value === '' || value === null || value === undefined))
- return res.json({
- ...BaseStdResponse.MISSING_PARAMETER
- })
- const url = `https://hqpay.ctbu.edu.cn/weixin/ashx/frmuser.ashx?test=${type}${type !== 'buildlist' ? '&pid=' + pid : ''}`
- const response = await axiosWithQgOutbound({
- method: 'get',
- url,
- timeout: 15000,
- logger: this.logger,
- scene: 'PowerGetData'
- })
- if (!response || !response.data)
- return res.json({
- ...BaseStdResponse.ERR,
- msg: "请稍后再试"
- })
- res.json({
- ...BaseStdResponse.OK,
- data: response.data ?? []
- })
- } catch (error) {
- this.logger?.error(`${error.stack}`)
- return res.json({
- ...BaseStdResponse.ERR,
- msg: `${error.message ?? "请稍后再试"}`
- })
- }
- }
- }
- module.exports.GetDyList = GetDyList
|