Commit bd634c74 authored by qinhaitao's avatar qinhaitao

feat: 🎸 config.json

parent cde4439e
......@@ -416,6 +416,242 @@
}
]
}
},
"awards": {
"getMyPrizeList": {
"desc": "我的奖品列表",
"decorators": [
{
"type": "common",
"name": "checkParams",
"params": [ "activityId" ]
}
],
"main": [
{
"type": "common",
"service": "awards",
"function": "getMyPrizeList",
"params": [
{ "type": "var", "value": "activityInfo" }
],
"return": true
}
]
},
"receiveObjectPrize": {
"desc": "领取实物",
"decorators": [
{
"type": "common",
"name": "checkParams",
"params": [ "activityId","id", "name", "phone", "province", "city", "area", "addressDetail", "streetName" ]
},
{
"type": "common",
"name": "preCheck",
"params": [
{
"type": "common",
"behave": "check",
"name": "checkPrizeExpired"
},
{
"type": "common",
"behave": "check",
"name": "checkValidObjectPrize"
}
]
}
],
"main": [
{
"type": "common",
"service": "awards",
"function": "recieveObjectPrize",
"params": [
{ "type": "var", "value": "context" }
],
"return": true
}
]
},
"receiveEnamePrize": {
"desc": "领取权益",
"decorators": [
{
"type": "common",
"name": "checkParams",
"params": [ "activityId", "id" ]
},
{
"type": "common",
"name": "registeInfos",
"params": [ "session"]
},
{
"type": "common",
"name": "preCheck",
"params": [
{
"type": "common",
"behave": "check",
"name": "checkPrizeExpired"
},
{
"type": "common",
"behave": "check",
"name": "checkValidEnamePrize"
}
]
}
],
"main": [
{
"type": "common",
"service": "awards",
"function": "recieveEnamePrize",
"params": [
{ "type": "var", "value": "context.data.id" },
{ "type": "var", "value": "awardInfo" },
{ "type": "var", "value": "session" }
],
"return": true
}
]
},
"drawLotteryPrize": {
"desc": "概率抽奖",
"decorators": [
{
"type": "common",
"name": "checkParams",
"params": [ "activityId", "prizeDataType" ]
},
{
"type": "common",
"name": "registeInfos",
"params": [ "session"]
},
{
"type": "common",
"name": "preCheck",
"params": [
{
"type": "common",
"behave": "check",
"name": "checkActivityTime"
}
]
}
],
"main": [
{
"type": "common",
"service": "awards",
"function": "drawLottery",
"params": [
{ "type": "var", "value": "context.data.activityId" },
{ "type": "var", "value": "context.data.prizeDataType" },
{ "type": "var", "value": "userInfo" }
],
"return": true
}
]
}
},
"share": {
"getShareInfo": {
"desc": "获取邀请信息",
"decorators": [
{
"type": "common",
"name": "checkParams",
"params": [ "activityId" ]
}
],
"main": [
{
"type": "common",
"service": "user",
"function": "queryDataByKey",
"params": [
{ "value": "remainTimes.invites" },
{ "type": "var", "value": "userInfo" },
{ "value": "rewards" }
],
"return": true
}
]
},
"doHelp": {
"desc": "完成分享",
"decorators": [
{
"type": "common",
"name": "checkParams",
"params": [
"activityId",
"inviteId"
]
},
{
"type": "common",
"name": "registeInfos",
"params": [
"vipInfo"
]
},
{
"type": "common",
"name": "preCheck",
"params": [
{
"type": "common",
"behave": "check",
"name": "checkActivityTime"
},
{
"type": "common",
"behave": "check",
"name": "checkInviteId"
},
{
"type": "common",
"behave": "check",
"name": "checkNewVip"
},
{
"type": "common",
"behave": "check",
"name": "checkHelpRecord"
}
]
}
],
"main": [
{
"type": "common",
"service": "task",
"function": "completeTask",
"params": [
{ "value": "invites" },
{ "type": "var", "value": "activityInfo" },
{ "type": "var", "value": "inviteUserInfo" }
]
},
{
"type": "common",
"service": "stat",
"function": "addStat",
"params": [
{ "type": "var", "value": "0" },
{ "type": "var", "value": "userInfo" }
],
"return": true
}
]
}
}
},
"custom": {
......
......@@ -21,7 +21,8 @@ export default class {{name | capitalize}}Controller {
async {{fn}}(
context: IContext<IParams>,
{ activityInfo, userInfo{{-macro.genRegisteInfosParams(model[fn].decorators)}} }: IControllerInfos,
{{-macro.genServicesParams(model[fn].main)}}
{{-macro.genServicesParams(model[fn].main)-}},
{{-macro.genPreCheckDataParams(model[fn].decorators)-}}
) {
{{-macro.genMain(model[fn].main)}}
......
......@@ -58,6 +58,25 @@ import { {%for service, service_item in type_item %}{{type|capitalize}}{{service
{%- endfor -%}
{%- endmacro %}
{# 生成common preCheck返回数据 #}
{% macro genPreCheckDataParams(decorators) %}
{% set preChecks = {'checkInviteId':'inviteUserInfo','checkValidObjectPrize':'awardInfo','checkValidEnamePrize':'awardInfo'} -%}
{%- set preCheckData = [] -%}
{% for decorator in decorators -%}
{%- if decorator.type == 'common' and decorator.name== 'preCheck' -%}
{%- for param in decorator.params -%}
{%- for key, data in preChecks -%}
{%- if key === param.name%} {% set preCheckData = preCheckData.concat(data)%} {% endif %}
{%- endfor -%}
{%- endfor -%}
{%- endif -%}
{%- endfor -%}
{%- if preCheckData.length -%}
{ {{preCheckData | join(',')}} }: IPreCheckData
{% endif %}
{%- endmacro %}
{# 生成函数体 #}
{% macro genMain(mains) %}
{%- for main in mains %}
......
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