Commit 67fec37f authored by qinhaitao's avatar qinhaitao

feat: 🎸 解构编译

parent 8023dc86
......@@ -2,6 +2,8 @@
const fs = require('fs-extra')
const config = require('./config.json')
const { getDecorators, getPreChecks, getPreUpdates } = require('./utils/formatConfg')
const serverTemplatePath = 'templates'
const controllerImport = (controller = {}) => {
......@@ -16,7 +18,6 @@ const controllerImport = (controller = {}) => {
result.services[main.type][main.service] = true
}
}
console.log(result)
return result
}
......@@ -136,6 +137,7 @@ const run = async (gulp, nunjucksRender, rename, nunjucksRenderConfig) => {
.pipe(rename(`index.ts`))
.pipe(gulp.dest(nunjucksRenderConfig.ServerFullPath + '/service/custom'))
//编译controller.common
for (let commonController in config.controllers.common) {
await gulp
.src(`${serverTemplatePath}/controller.njk`)
......@@ -145,7 +147,13 @@ const run = async (gulp, nunjucksRender, rename, nunjucksRenderConfig) => {
data: {
name: commonController,
model: config.controllers.common[commonController],
...controllerImport(config.controllers.common[commonController])
...controllerImport(config.controllers.common[commonController]),
commmonDecorators: getDecorators(config.controllers.common[commonController], 'common'),
customDecorators: getDecorators(config.controllers.common[commonController], 'custom'),
commonPreChecks: getPreChecks(config.controllers.common[commonController], 'common'),
customPreChecks: getPreChecks(config.controllers.common[commonController], 'custom'),
commonPreUpdates: getPreUpdates(config.controllers.common[commonController], 'common'),
customPreUpdates: getPreUpdates(config.controllers.common[commonController], 'custom')
}
})
)
......@@ -162,7 +170,13 @@ const run = async (gulp, nunjucksRender, rename, nunjucksRenderConfig) => {
data: {
name: customController,
model: config.controllers.custom[customController],
...controllerImport(config.controllers.custom[customController])
...controllerImport(config.controllers.custom[customController]),
commmonDecorators: getDecorators(config.controllers.custom[customController], 'common'),
customDecorators: getDecorators(config.controllers.custom[customController], 'custom'),
commonPreChecks: getPreChecks(config.controllers.custom[customController], 'common'),
customPreChecks: getPreChecks(config.controllers.custom[customController], 'custom'),
commonPreUpdates: getPreUpdates(config.controllers.custom[customController], 'common'),
customPreUpdates: getPreUpdates(config.controllers.custom[customController], 'custom')
}
})
)
......
/** @format */
{% import "macro.njk" as macro -%}
import commonDecorator, { services } from '../../decorator/common'
import commonUtilCheck from '../../utils/common/check'
import commonUtilUpdate from '../../utils/common/update'
import customDecorator from '../../decorator/custom'
import { {{ commmonDecorators }} } from '../../decorator/common'
{%if commonPreChecks and commonPreChecks.length -%}
import { {{commonPreChecks}} } from '../../utils/common/check'
{% endif -%}
{%if commonPreUpdates and commonPreUpdates.length -%}
import { {{commonPreUpdates}} } from '../../utils/common/update'
{% endif -%}
{%if customDecorators.length -%}
import { {{customDecorators}} } from '../../decorator/custom'
{% endif -%}
import customUtil from '../../utils/custom'
import { resultsModel } from '../../sdk'
{{macro.genControllerService(services)}}
{# import commonService from '../../service/common'
import customService from '../../service/custom' #}
import { resultsModel } from '../../sdk'
{{-macro.genControllerService(services)-}}
export default class {{name | capitalize}}Controller {
{%- for fn, item in model %}
......
{# 生成控制器引用的服务 #}
{% macro genControllerService(services)%}
{% for type, type_item in services %}
{%- for type, type_item in services -%}
import { {%for service, service_item in type_item %}{{type|capitalize}}{{service|capitalize}}Service{%- if loop.last %}{% else %}, {% endif %}{% endfor %} } from '../../service/{{type}}'
{% endfor%}
{% endmacro %}
......@@ -8,9 +8,9 @@ import { {%for service, service_item in type_item %}{{type|capitalize}}{{service
{# 生成装饰器 #}
{% macro genDecorator(decorators) %}
{%- for decorator in decorators %}
@{{ decorator.type }}Decorator.{{ decorator.name }}
@{{ decorator.name }}
{%- if decorator.name == 'preCheck' or decorator.name == 'preUpdate' -%}
([{%- for param in decorator.params -%}{{param.type}}Util{{param.behave | capitalize}}.{{param.name}}{%- if loop.last %}{% else %}, {% endif %}{%- endfor -%}])
([{%- for param in decorator.params -%}{{param.name}}{%- if loop.last %}{% else %}, {% endif %}{%- endfor -%}])
{%- elif decorator.name == 'noCatch' or decorator.name == 'noCheckUser' -%}
{%- else -%}
([{%- for param in decorator.params -%}'{{ param }}'{%- if loop.last %}{% else %}, {% endif %}{%- endfor -%}])
......
/** @format */
// 获取去重后的装饰器
function getDecorators(controller, decoratorType) {
let decorators = decoratorType === 'common' ? [{ type: 'common', name: 'services' }] : []
decorators = [...decorators, ...Object.values(controller).map(v => v.decorators)].flat()
return [...new Set(decorators.filter(v => v.type === (decoratorType || 'common')).map(v => v.name))]
}
function getPreChecks(controller, checkType) {
checkType = checkType || 'common'
let decorators = []
decorators = [...decorators, ...Object.values(controller).map(v => v.decorators)].reduce(
(r, item) => r.concat(item),
[]
)
const preChecks = [...decorators.filter(v => v.type === 'common' && v.name === 'preCheck').map(v => v.params)].flat()
return [...new Set(preChecks.filter(v => v.type === checkType && v.behave === 'check').map(v => v.name))]
}
function getPreUpdates(controller, updateType) {
updateType = updateType || 'common'
let decorators = []
decorators = [...decorators, ...Object.values(controller).map(v => v.decorators)].reduce(
(r, item) => r.concat(item),
[]
)
const preUpdates = [
...decorators.filter(v => v.type === 'common' && v.name === 'preUpdate').map(v => v.params)
].flat()
return [...new Set(preUpdates.filter(v => v.type === updateType && v.behave === 'update').map(v => v.name))]
}
module.exports = {
getDecorators,
getPreChecks,
getPreUpdates
}
/** @format */
import commonDecorator, { services } from '../../decorator/common'
import commonUtilCheck from '../../utils/common/check'
import commonUtilUpdate from '../../utils/common/update'
import customDecorator from '../../decorator/custom'
import { services, checkParams, preCheck, registeInfos } from '../../decorator/common'
import {
checkPrizeExpired,
checkValidObjectPrize,
checkValidEnamePrize,
checkActivityTime
} from '../../utils/common/check'
import customUtil from '../../utils/custom'
import { resultsModel } from '../../sdk'
import { CommonAwardsService } from '../../service/common'
export default class AwardsController {
/**
* 我的奖品列表
*/
@commonDecorator.checkParams(['activityId'])
@checkParams(['activityId'])
@services([CommonAwardsService])
async getMyPrizeList(
context: IContext<IParams>,
......@@ -28,18 +29,8 @@ export default class AwardsController {
/**
* 领取实物
*/
@commonDecorator.checkParams([
'activityId',
'id',
'name',
'phone',
'province',
'city',
'area',
'addressDetail',
'streetName'
])
@commonDecorator.preCheck([commonUtilCheck.checkPrizeExpired, commonUtilCheck.checkValidObjectPrize])
@checkParams(['activityId', 'id', 'name', 'phone', 'province', 'city', 'area', 'addressDetail', 'streetName'])
@preCheck([checkPrizeExpired, checkValidObjectPrize])
@services([CommonAwardsService])
async receiveObjectPrize(
context: IContext<IParams>,
......@@ -55,9 +46,9 @@ export default class AwardsController {
/**
* 领取权益
*/
@commonDecorator.checkParams(['activityId', 'id'])
@commonDecorator.registeInfos(['session'])
@commonDecorator.preCheck([commonUtilCheck.checkPrizeExpired, commonUtilCheck.checkValidEnamePrize])
@checkParams(['activityId', 'id'])
@registeInfos(['session'])
@preCheck([checkPrizeExpired, checkValidEnamePrize])
@services([CommonAwardsService])
async receiveEnamePrize(
context: IContext<IParams>,
......@@ -77,9 +68,9 @@ export default class AwardsController {
/**
* 概率抽奖
*/
@commonDecorator.checkParams(['activityId', 'prizeDataType'])
@commonDecorator.registeInfos(['session'])
@commonDecorator.preCheck([commonUtilCheck.checkActivityTime])
@checkParams(['activityId', 'prizeDataType'])
@registeInfos(['session'])
@preCheck([checkActivityTime])
@services([CommonAwardsService])
async drawLotteryPrize(
context: IContext<IParams>,
......
/** @format */
import commonDecorator, { services } from '../../decorator/common'
import commonUtilCheck from '../../utils/common/check'
import commonUtilUpdate from '../../utils/common/update'
import customDecorator from '../../decorator/custom'
import { services, checkParams, noCheckUser } from '../../decorator/common'
import customUtil from '../../utils/custom'
import { resultsModel } from '../../sdk'
import { CommonBaseService } from '../../service/common'
export default class BaseController {
/**
* 活动基本信息
*/
@commonDecorator.checkParams(['activityId'])
@commonDecorator.noCheckUser
@checkParams(['activityId'])
@noCheckUser
@services([CommonBaseService])
async getActivityBaseInfoById(
context: IContext<IParams>,
{ activityInfo, userInfo }: IControllerInfos,
[commonBaseService]: [CommonBaseService],
[commonBaseService]: [CommonBaseService]
) {
const commonBaseGetBaseInfoResult1 = await commonBaseService.getBaseInfo(context.data.activityId)
return resultsModel.success({
......
/** @format */
import commonDecorator, { services } from '../../decorator/common'
import commonUtilCheck from '../../utils/common/check'
import commonUtilUpdate from '../../utils/common/update'
import customDecorator from '../../decorator/custom'
import { services, checkParams, noCheckUser, registeInfos } from '../../decorator/common'
import customUtil from '../../utils/custom'
import { resultsModel } from '../../sdk'
import { CommonUserService, CommonAccessService } from '../../service/common'
export default class LoginController {
/**
* 登录接口, 初始化/更新用户信息
*/
@commonDecorator.checkParams(['activityId', 'userNick', 'avatar', 'isFollow'])
@commonDecorator.noCheckUser
@commonDecorator.registeInfos(['vipInfo'])
@checkParams(['activityId', 'userNick', 'avatar', 'isFollow'])
@noCheckUser
@registeInfos(['vipInfo'])
@services([CommonUserService, CommonAccessService])
async login(
context: IContext<IParams>,
{ activityInfo, userInfo, vipInfo }: IControllerInfos,
[commonUserService, commonAccessService]: [CommonUserService, CommonAccessService],
[commonUserService, commonAccessService]: [CommonUserService, CommonAccessService]
) {
const commonUserDoLoginResult1 = await commonUserService.doLogin(userInfo, vipInfo, activityInfo)
const commonAccessAddAccessResult2 = await commonAccessService.addAccess(commonUserDoLoginResult1, vipInfo)
......
/** @format */
import commonDecorator, { services } from '../../decorator/common'
import commonUtilCheck from '../../utils/common/check'
import commonUtilUpdate from '../../utils/common/update'
import customDecorator from '../../decorator/custom'
import { services, checkParams, registeInfos, preCheck } from '../../decorator/common'
import { checkActivityTime, checkInviteId, checkNewVip, checkHelpRecord } from '../../utils/common/check'
import customUtil from '../../utils/custom'
import { resultsModel } from '../../sdk'
import { CommonUserService, CommonTaskService, CommonStatService } from '../../service/common'
export default class ShareController {
/**
* 获取邀请信息
*/
@commonDecorator.checkParams(['activityId'])
@checkParams(['activityId'])
@services([CommonUserService])
async getShareInfo(
context: IContext<IParams>,
{ activityInfo, userInfo }: IControllerInfos,
[commonUserService]: [CommonUserService],
[commonUserService]: [CommonUserService]
) {
const commonUserQueryDataByKeyResult1 = await commonUserService.queryDataByKey('remainTimes.invites', userInfo, 'rewards')
const commonUserQueryDataByKeyResult1 = await commonUserService.queryDataByKey(
'remainTimes.invites',
userInfo,
'rewards'
)
return resultsModel.success({
...commonUserQueryDataByKeyResult1
})
......@@ -28,9 +28,9 @@ export default class ShareController {
/**
* 完成分享
*/
@commonDecorator.checkParams(['activityId', 'inviteId'])
@commonDecorator.registeInfos(['vipInfo'])
@commonDecorator.preCheck([commonUtilCheck.checkActivityTime, commonUtilCheck.checkInviteId, commonUtilCheck.checkNewVip, commonUtilCheck.checkHelpRecord])
@checkParams(['activityId', 'inviteId'])
@registeInfos(['vipInfo'])
@preCheck([checkActivityTime, checkInviteId, checkNewVip, checkHelpRecord])
@services([CommonTaskService, CommonStatService])
async doHelp(
context: IContext<IParams>,
......
/** @format */
import commonDecorator, { services } from '../../decorator/common'
import commonUtilCheck from '../../utils/common/check'
import commonUtilUpdate from '../../utils/common/update'
import customDecorator from '../../decorator/custom'
import { services, checkParams } from '../../decorator/common'
import customUtil from '../../utils/custom'
import { resultsModel } from '../../sdk'
import { CommonStatService } from '../../service/common'
export default class StatController {
/**
* 增加埋点记录
*/
@commonDecorator.checkParams(['activityId', 'type'])
@checkParams(['activityId', 'type'])
@services([CommonStatService])
async addStat(
context: IContext<IParams>,
{ activityInfo, userInfo }: IControllerInfos,
[commonStatService]: [CommonStatService],
[commonStatService]: [CommonStatService]
) {
const commonStatAddStatResult1 = await commonStatService.addStat(context.data.type, userInfo)
return resultsModel.success({
......@@ -28,15 +23,23 @@ export default class StatController {
/**
* 统计数据
*/
@commonDecorator.checkParams(['activityId', 'startDay', 'endDay'])
@checkParams(['activityId', 'startDay', 'endDay'])
@services([CommonStatService])
async getStats(
context: IContext<IParams>,
{ activityInfo, userInfo }: IControllerInfos,
[commonStatService]: [CommonStatService],
[commonStatService]: [CommonStatService]
) {
const commonStatGetStatsResult1 = await commonStatService.getStats(context.data.activityId, context.data.startDay, context.data.endDay)
const commonStatBuildExcelResult2 = await commonStatService.buildExcel(context.data.startDay, context.data.endDay, commonStatGetStatsResult1)
const commonStatGetStatsResult1 = await commonStatService.getStats(
context.data.activityId,
context.data.startDay,
context.data.endDay
)
const commonStatBuildExcelResult2 = await commonStatService.buildExcel(
context.data.startDay,
context.data.endDay,
commonStatGetStatsResult1
)
return resultsModel.success({
...commonStatBuildExcelResult2
})
......
/** @format */
import commonDecorator, { services } from '../../decorator/common'
import commonUtilCheck from '../../utils/common/check'
import commonUtilUpdate from '../../utils/common/update'
import customDecorator from '../../decorator/custom'
import { services, checkParams, registeInfos, preCheck, preUpdate } from '../../decorator/common'
import { checkActivityTime, checkTaskLimit, checkExchangeCreditsTask, checkRemainTimes } from '../../utils/common/check'
import { updateVip, updateSignTask, updateOrderGoods } from '../../utils/common/update'
import customUtil from '../../utils/custom'
import { resultsModel } from '../../sdk'
import { CommonTaskService, CommonBaseService } from '../../service/common'
export default class TaskController {
/**
* 任务列表
*/
@commonDecorator.checkParams(['activityId'])
@commonDecorator.registeInfos(['vipInfo'])
@commonDecorator.preCheck([commonUtilCheck.checkActivityTime])
@commonDecorator.preUpdate([commonUtilUpdate.updateVip, commonUtilUpdate.updateSignTask, commonUtilUpdate.updateOrderGoods])
@checkParams(['activityId'])
@registeInfos(['vipInfo'])
@preCheck([checkActivityTime])
@preUpdate([updateVip, updateSignTask, updateOrderGoods])
@services([CommonTaskService])
async getTaskList(
context: IContext<IParams>,
{ activityInfo, userInfo, vipInfo }: IControllerInfos,
[commonTaskService]: [CommonTaskService],
[commonTaskService]: [CommonTaskService]
) {
const commonTaskInitTaskListResult1 = await commonTaskService.initTaskList(userInfo, activityInfo)
return resultsModel.success({
......@@ -31,16 +28,20 @@ export default class TaskController {
/**
* 完成任务
*/
@commonDecorator.checkParams(['activityId', 'taskType'])
@commonDecorator.registeInfos(['session'])
@commonDecorator.preCheck([commonUtilCheck.checkActivityTime, commonUtilCheck.checkTaskLimit, commonUtilCheck.checkExchangeCreditsTask])
@checkParams(['activityId', 'taskType'])
@registeInfos(['session'])
@preCheck([checkActivityTime, checkTaskLimit, checkExchangeCreditsTask])
@services([CommonTaskService])
async doCompleteTask(
context: IContext<IParams>,
{ activityInfo, userInfo, session }: IControllerInfos,
[commonTaskService]: [CommonTaskService],
[commonTaskService]: [CommonTaskService]
) {
const commonTaskCompleteTaskResult1 = await commonTaskService.completeTask(context.data.taskType, activityInfo, userInfo)
const commonTaskCompleteTaskResult1 = await commonTaskService.completeTask(
context.data.taskType,
activityInfo,
userInfo
)
return resultsModel.success({
...commonTaskCompleteTaskResult1
})
......@@ -48,15 +49,19 @@ export default class TaskController {
/**
* 领取任务奖励
*/
@commonDecorator.checkParams(['activityId', 'taskType', 'rewardsKey'])
@commonDecorator.preCheck([commonUtilCheck.checkActivityTime, commonUtilCheck.checkRemainTimes])
@checkParams(['activityId', 'taskType', 'rewardsKey'])
@preCheck([checkActivityTime, checkRemainTimes])
@services([CommonTaskService])
async receiveTaskRewards(
context: IContext<IParams>,
{ activityInfo, userInfo }: IControllerInfos,
[commonTaskService]: [CommonTaskService],
[commonTaskService]: [CommonTaskService]
) {
const commonTaskReceiveTaskRewardsResult1 = await commonTaskService.receiveTaskRewards(context.data.taskType, context.data.rewardsKey, userInfo)
const commonTaskReceiveTaskRewardsResult1 = await commonTaskService.receiveTaskRewards(
context.data.taskType,
context.data.rewardsKey,
userInfo
)
return resultsModel.success({
...commonTaskReceiveTaskRewardsResult1
})
......@@ -64,16 +69,19 @@ export default class TaskController {
/**
* 获取收藏商品列表
*/
@commonDecorator.checkParams(['activityId', 'itemIds'])
@commonDecorator.registeInfos(['session'])
@checkParams(['activityId', 'itemIds'])
@registeInfos(['session'])
@services([CommonBaseService, CommonTaskService])
async getCollectGoodsList(
context: IContext<IParams>,
{ activityInfo, userInfo, session }: IControllerInfos,
[commonBaseService, commonTaskService]: [CommonBaseService, CommonTaskService],
[commonBaseService, commonTaskService]: [CommonBaseService, CommonTaskService]
) {
const commonBaseGetItemListByIdsResult1 = await commonBaseService.getItemListByIds(context.data.itemIds, session)
const commonTaskGetItemListWithCollectStatusResult2 = await commonTaskService.getItemListWithCollectStatus(commonBaseGetItemListByIdsResult1, userInfo)
const commonTaskGetItemListWithCollectStatusResult2 = await commonTaskService.getItemListWithCollectStatus(
commonBaseGetItemListByIdsResult1,
userInfo
)
return resultsModel.success({
...commonTaskGetItemListWithCollectStatusResult2
})
......
/** @format */
import commonDecorator, { services } from '../../decorator/common'
import commonUtilCheck from '../../utils/common/check'
import commonUtilUpdate from '../../utils/common/update'
import customDecorator from '../../decorator/custom'
import { services, checkParams } from '../../decorator/common'
import customUtil from '../../utils/custom'
import { resultsModel } from '../../sdk'
import { CommonUserService } from '../../service/common'
export default class UserController {
/**
* 获取会员信息
*/
@commonDecorator.checkParams(['activityId'])
@checkParams(['activityId'])
@services([CommonUserService])
async getVipInfo(
context: IContext<IParams>,
{ activityInfo, userInfo }: IControllerInfos,
[commonUserService]: [CommonUserService],
[commonUserService]: [CommonUserService]
) {
const commonUserGetShopVipResult1 = await commonUserService.getShopVip(context, activityInfo)
return resultsModel.success({
......@@ -28,15 +23,23 @@ export default class UserController {
/**
* 获取排行榜
*/
@commonDecorator.checkParams(['activityId', 'key', 'timeKey', 'limit'])
@checkParams(['activityId', 'key', 'timeKey', 'limit'])
@services([CommonUserService])
async getRankList(
context: IContext<IParams>,
{ activityInfo, userInfo }: IControllerInfos,
[commonUserService]: [CommonUserService],
[commonUserService]: [CommonUserService]
) {
const commonUserGetMyRankInfoResult1 = await commonUserService.getMyRankInfo(context.data.key, context.data.timeKey, userInfo)
const commonUserGetRankResult2 = await commonUserService.getRank(context.data.key, context.data.timeKey, context.data.limit)
const commonUserGetMyRankInfoResult1 = await commonUserService.getMyRankInfo(
context.data.key,
context.data.timeKey,
userInfo
)
const commonUserGetRankResult2 = await commonUserService.getRank(
context.data.key,
context.data.timeKey,
context.data.limit
)
return resultsModel.success({
...commonUserGetMyRankInfoResult1,
...commonUserGetRankResult2
......
/** @format */
import commonDecorator, { services } from '../../decorator/common'
import commonUtilCheck from '../../utils/common/check'
import commonUtilUpdate from '../../utils/common/update'
import customDecorator from '../../decorator/custom'
import { services, checkParams } from '../../decorator/common'
import { test1 } from '../../decorator/custom'
import customUtil from '../../utils/custom'
import { resultsModel } from '../../sdk'
import { CommonStatService } from '../../service/common'
import { CustomTestService } from '../../service/custom'
export default class Test1Controller {
/**
* 增加埋点记录
*/
@commonDecorator.checkParams(['activityId', 'type'])
@customDecorator.test1(['tt'])
@checkParams(['activityId', 'type'])
@test1(['tt'])
@services([CommonStatService, CustomTestService])
async addStat(
context: IContext<IParams>,
{ activityInfo, userInfo }: IControllerInfos,
[commonStatService, customTestService]: [CommonStatService, CustomTestService],
[commonStatService, customTestService]: [CommonStatService, CustomTestService]
) {
const commonStatAddStatResult1 = await commonStatService.addStat(context.data.type, userInfo)
const customTestTest1Result2 = await customTestService.test1()
......@@ -33,15 +28,23 @@ export default class Test1Controller {
/**
* 统计数据
*/
@commonDecorator.checkParams(['activityId', 'startDay', 'endDay'])
@checkParams(['activityId', 'startDay', 'endDay'])
@services([CommonStatService])
async getStats(
context: IContext<IParams>,
{ activityInfo, userInfo }: IControllerInfos,
[commonStatService]: [CommonStatService],
[commonStatService]: [CommonStatService]
) {
const commonStatGetStatsResult1 = await commonStatService.getStats(context.data.activityId, context.data.startDay, context.data.endDay)
const commonStatBuildExcelResult2 = await commonStatService.buildExcel(context.data.startDay, context.data.endDay, commonStatGetStatsResult1)
const commonStatGetStatsResult1 = await commonStatService.getStats(
context.data.activityId,
context.data.startDay,
context.data.endDay
)
const commonStatBuildExcelResult2 = await commonStatService.buildExcel(
context.data.startDay,
context.data.endDay,
commonStatGetStatsResult1
)
return resultsModel.success({
...commonStatBuildExcelResult2
})
......
/** @format */
import commonDecorator, { services } from '../../decorator/common'
import commonUtilCheck from '../../utils/common/check'
import commonUtilUpdate from '../../utils/common/update'
import customDecorator from '../../decorator/custom'
import { services, checkParams } from '../../decorator/common'
import customUtil from '../../utils/custom'
import { resultsModel } from '../../sdk'
import { CommonStatService } from '../../service/common'
export default class Test2Controller {
/**
* 增加埋点记录
*/
@commonDecorator.checkParams(['activityId', 'type'])
@checkParams(['activityId', 'type'])
@services([CommonStatService])
async addStat(
context: IContext<IParams>,
{ activityInfo, userInfo }: IControllerInfos,
[commonStatService]: [CommonStatService],
[commonStatService]: [CommonStatService]
) {
const commonStatAddStatResult1 = await commonStatService.addStat(context.data.type, userInfo)
return resultsModel.success({
......@@ -28,15 +23,23 @@ export default class Test2Controller {
/**
* 统计数据
*/
@commonDecorator.checkParams(['activityId', 'startDay', 'endDay'])
@checkParams(['activityId', 'startDay', 'endDay'])
@services([CommonStatService])
async getStats(
context: IContext<IParams>,
{ activityInfo, userInfo }: IControllerInfos,
[commonStatService]: [CommonStatService],
[commonStatService]: [CommonStatService]
) {
const commonStatGetStatsResult1 = await commonStatService.getStats(context.data.activityId, context.data.startDay, context.data.endDay)
const commonStatBuildExcelResult2 = await commonStatService.buildExcel(context.data.startDay, context.data.endDay, commonStatGetStatsResult1)
const commonStatGetStatsResult1 = await commonStatService.getStats(
context.data.activityId,
context.data.startDay,
context.data.endDay
)
const commonStatBuildExcelResult2 = await commonStatService.buildExcel(
context.data.startDay,
context.data.endDay,
commonStatGetStatsResult1
)
return resultsModel.success({
...commonStatBuildExcelResult2
})
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment