GetDownloadCenter.js 1.0 KB

123456789101112131415161718192021222324252627282930
  1. const API = require("../../../lib/API");
  2. const db = require("../../../plugin/DataBase/db");
  3. const { BaseStdResponse } = require("../../../BaseStdResponse");
  4. class GetDownloadCenter extends API {
  5. constructor() {
  6. super();
  7. this.setPath('/Public/GetDownloadCenter');
  8. this.setMethod('GET');
  9. }
  10. async onRequest(req, res) {
  11. const sql = `
  12. SELECT title, description, download_url, version, icon,
  13. button_text, button_color, platform, extract_code, changelog_html, sort_order
  14. FROM download_item
  15. WHERE is_active = 1
  16. ORDER BY sort_order ASC, id ASC
  17. `;
  18. try {
  19. const rows = await db.query(sql);
  20. res.json({ ...BaseStdResponse.OK, data: rows || [] });
  21. } catch (err) {
  22. this.logger.error(`获取下载中心失败!${err.stack}`);
  23. res.json({ ...BaseStdResponse.ERR, msg: '获取下载中心失败!' });
  24. }
  25. }
  26. }
  27. module.exports.GetDownloadCenter = GetDownloadCenter;