const dashboardService = require('../service/dashboard.service'); const util = require('../utils/util'); module.exports = { async getDashBoard(ctx) { const { total: totalProjects } = await dashboardService.getTotalProjects(); const { total: totalUpdatesProjects } = await dashboardService.getTotalUpdatesByToday(); const { total: totalCreatedProjects } = await dashboardService.getTotalCreatedByToday(); const { total: totalPages } = await dashboardService.getTotalPages(); const { total: createdPages } = await dashboardService.getCreatedPagesByToday(); const { total: updatedPages } = await dashboardService.getUpdatedPagesByToday(); const { total: totalLibs } = await dashboardService.getTotalLibs(); const { total: createdLibs } = await dashboardService.getCreatedLibsByToday(); const { total: updatedLibs } = await dashboardService.getUpdatedLibsByToday(); const { total: totalUsers } = await dashboardService.getTotalUsers(); const { total: totalUsersByToday } = await dashboardService.getTotalUsersByToday(); const { total: loginUsersByToday } = await dashboardService.getLoginUsersByToday(); const res = await dashboardService.getUsersByWeek(); const { total: totalMoney } = await dashboardService.getTotalRecharge(); const { total: todayRecharge } = await dashboardService.getTotalRechargeByToday(); // 页面发布次数 const { total: pagesPublish } = await dashboardService.getPagesPublish(); // 组件发布次数 const { total: libsPublish } = await dashboardService.getLibsPublish(); util.success(ctx, { totalProjects, totalUpdatesProjects, totalCreatedProjects, totalPages, createdPages, updatedPages, totalLibs, createdLibs, updatedLibs, totalUsers, totalUsersByToday, loginUsersByToday, getUsersByWeek: res, recharge: { totalMoney: totalMoney / 100, todayRecharge: todayRecharge / 100, }, charts1: [ { name: '项目总数', value: totalProjects, }, { name: '页面总数', value: totalPages, }, { name: '组件总数', value: totalLibs, }, { name: '用户总数', value: totalUsers, }, ], charts2: [ { name: '页面发布次数', value: pagesPublish, }, { name: '组件发布次数', value: libsPublish, }, ], }); }, async getUserList(ctx) { const { pageNum = 1, pageSize = 10, userId } = ctx.request.query; const { total } = await dashboardService.getUserCount(Number(userId || 0)); if (total == 0) { return util.success(ctx, { list: [], total: 0, pageSize, pageNum, }); } const list = await dashboardService.getUserList(pageNum, pageSize, Number(userId || 0)); util.success(ctx, { list, total, pageSize: +pageSize, pageNum: +pageNum, }); }, };