Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
taobao-mini-template
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
2
Issues
2
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
qinhaitao
taobao-mini-template
Commits
03ceceb4
Commit
03ceceb4
authored
Nov 05, 2020
by
maggie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save
parent
03c6bb44
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
215 additions
and
15 deletions
+215
-15
config.json
v2.0/compileServer/config.json
+130
-5
stat.controller.njk
...leServer/templates/controllers/common/stat.controller.njk
+27
-0
task.controller.ts
v2.0/src/controller/common/task.controller.ts
+54
-6
user.controller.ts
v2.0/src/controller/common/user.controller.ts
+4
-4
No files found.
v2.0/compileServer/config.json
View file @
03ceceb4
...
@@ -75,6 +75,7 @@
...
@@ -75,6 +75,7 @@
},
},
"task"
:
{
"task"
:
{
"getTaskList"
:
{
"getTaskList"
:
{
"desc"
:
"任务列表"
,
"decorators"
:
[
"decorators"
:
[
{
{
"type"
:
"common"
,
"type"
:
"common"
,
...
@@ -129,26 +130,150 @@
...
@@ -129,26 +130,150 @@
"service"
:
"task"
,
"service"
:
"task"
,
"function"
:
"initTask"
,
"function"
:
"initTask"
,
"params"
:
[
"params"
:
[
{
"type"
:
"string"
,
"value"
:
"member"
},
{
"type"
:
"string"
,
"value"
:
"加入会员"
},
{
"type"
:
"var"
,
"value"
:
"activityInfo"
},
{
"type"
:
"var"
,
"value"
:
"activityInfo"
},
{
"type"
:
"var"
,
"value"
:
"userInfo"
}
{
"type"
:
"var"
,
"value"
:
"userInfo"
}
],
],
"return"
:
true
"return"
:
true
}
]
},
"doCompleteTask"
:
{
"desc"
:
"完成任务"
,
"decorators"
:
[
{
"type"
:
"common"
,
"name"
:
"checkParams"
,
"params"
:
[
"activityId"
,
"taskType"
]
},
},
{
"type"
:
"common"
,
"name"
:
"registeInfos"
,
"params"
:
[
"session"
]
},
{
"type"
:
"common"
,
"name"
:
"preCheck"
,
"params"
:
[
{
"type"
:
"common"
,
"behave"
:
"check"
,
"name"
:
"checkActivityTime"
},
{
"type"
:
"common"
,
"behave"
:
"check"
,
"name"
:
"checkTaskLimit"
},
{
"type"
:
"common"
,
"behave"
:
"check"
,
"name"
:
"checkExchangeCreditsTask"
}
]
}
],
"main"
:
[
{
{
"type"
:
"common"
,
"type"
:
"common"
,
"service"
:
"task"
,
"service"
:
"task"
,
"function"
:
"
init
Task"
,
"function"
:
"
complete
Task"
,
"params"
:
[
"params"
:
[
{
"type"
:
"string"
,
"value"
:
"follow"
},
{
"type"
:
"var"
,
"value"
:
"context.data.taskType"
},
{
"type"
:
"string"
,
"value"
:
"关注店铺"
},
{
"type"
:
"var"
,
"value"
:
"activityInfo"
},
{
"type"
:
"var"
,
"value"
:
"activityInfo"
},
{
"type"
:
"var"
,
"value"
:
"userInfo"
}
{
"type"
:
"var"
,
"value"
:
"userInfo"
}
],
],
"return"
:
true
"return"
:
true
}
}
]
]
},
"receiveTaskRewards"
:
{
"desc"
:
"领取任务奖励"
,
"decorators"
:
[
{
"type"
:
"common"
,
"name"
:
"checkParams"
,
"params"
:
[
"activityId"
,
"taskType"
,
"rewardsKey"
]
},
{
"type"
:
"common"
,
"name"
:
"preCheck"
,
"params"
:
[
{
"type"
:
"common"
,
"behave"
:
"check"
,
"name"
:
"checkActivityTime"
},
{
"type"
:
"common"
,
"behave"
:
"check"
,
"name"
:
"checkRemainTimes"
}
]
}
],
"main"
:
[
{
"type"
:
"common"
,
"service"
:
"task"
,
"function"
:
"receiveTaskRewards"
,
"params"
:
[
{
"type"
:
"var"
,
"value"
:
"context.data.taskType"
},
{
"type"
:
"var"
,
"value"
:
"context.data.rewardsKey"
},
{
"type"
:
"var"
,
"value"
:
"userInfo"
}
],
"return"
:
true
}
]
},
"getCollectGoodsList"
:
{
"desc"
:
"获取收藏商品列表"
,
"decorators"
:
[
{
"type"
:
"common"
,
"name"
:
"checkParams"
,
"params"
:
[
"activityId"
,
"itemIds"
]
},
{
"type"
:
"common"
,
"name"
:
"registeInfos"
,
"params"
:
[
"session"
]
}
],
"main"
:
[
{
"type"
:
"common"
,
"service"
:
"base"
,
"function"
:
"getItemListByIds"
,
"params"
:
[
{
"type"
:
"var"
,
"value"
:
"context.data.itemIds"
},
{
"type"
:
"var"
,
"value"
:
"session"
}
]
},
{
"type"
:
"common"
,
"service"
:
"task"
,
"function"
:
"getItemListWithCollectStatus"
,
"params"
:
[
{
"type"
:
"var"
,
"value"
:
"commonBaseGetitemlistbyidsResult1"
},
{
"type"
:
"var"
,
"value"
:
"userInfo"
}
],
"return"
:
true
}
]
}
}
}
}
}
}
...
...
v2.0/compileServer/templates/controllers/common/stat.controller.njk
0 → 100644
View file @
03ceceb4
/** @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 { resultsModel } from '../../sdk'
{{-macro.genControllerService(service)}}
export default class Stat {
{%- for fn, item in model %}
/**
* {{item.desc}}
*/
{{-macro.genDecorator(model[fn].decorators)}}
@services([{{-macro.genServicesDecorator(model[fn].main)}}])
async {{fn}}(
context: IContext<IParams>,
{ activityInfo, userInfo{{-macro.genRegisteInfosParams(model[fn].decorators)}} }: IControllerInfos,
{{-macro.genServicesParams(model[fn].main)}}
) {
{{-macro.genMain(model[fn].main)}}
{{-macro.genReturn(model[fn].main)}}
}
{%- endfor %}
}
v2.0/src/controller/common/task.controller.ts
View file @
03ceceb4
...
@@ -3,11 +3,11 @@ import commonDecorator, { services } from '../../decorator/common'
...
@@ -3,11 +3,11 @@ import commonDecorator, { services } from '../../decorator/common'
import
commonUtilCheck
from
'../../utils/common/check'
import
commonUtilCheck
from
'../../utils/common/check'
import
commonUtilUpdate
from
'../../utils/common/update'
import
commonUtilUpdate
from
'../../utils/common/update'
import
{
resultsModel
}
from
'../../sdk'
import
{
resultsModel
}
from
'../../sdk'
import
{
TaskService
}
from
'../../service'
import
{
TaskService
,
BaseService
}
from
'../../service'
export
default
class
Task
{
export
default
class
Task
{
/**
/**
*
*
任务列表
*/
*/
@
commonDecorator
.
checkParams
([
'activityId'
])
@
commonDecorator
.
checkParams
([
'activityId'
])
@
commonDecorator
.
registeInfos
([
'vipInfo'
])
@
commonDecorator
.
registeInfos
([
'vipInfo'
])
...
@@ -19,11 +19,59 @@ export default class Task {
...
@@ -19,11 +19,59 @@ export default class Task {
{
activityInfo
,
userInfo
,
vipInfo
}:
IControllerInfos
,
{
activityInfo
,
userInfo
,
vipInfo
}:
IControllerInfos
,
[
taskService
]:
[
TaskService
]
[
taskService
]:
[
TaskService
]
)
{
)
{
const
commonTaskInittaskResult1
=
await
taskService
.
initTask
(
'member'
,
'加入会员'
,
activityInfo
,
userInfo
)
const
commonTaskInittaskResult1
=
await
taskService
.
initTask
(
activityInfo
,
userInfo
)
const
commonTaskInittaskResult2
=
await
taskService
.
initTask
(
'follow'
,
'关注店铺'
,
activityInfo
,
userInfo
)
return
resultsModel
.
success
({
return
resultsModel
.
success
({
...
commonTaskInittaskResult1
,
...
commonTaskInittaskResult1
...
commonTaskInittaskResult2
})
}
/**
* 完成任务
*/
@
commonDecorator
.
checkParams
([
'activityId'
,
'taskType'
])
@
commonDecorator
.
registeInfos
([
'session'
])
@
commonDecorator
.
preCheck
([
commonUtilCheck
.
checkActivityTime
,
commonUtilCheck
.
checkTaskLimit
,
commonUtilCheck
.
checkExchangeCreditsTask
])
@
services
([
TaskService
])
async
doCompleteTask
(
context
:
IContext
<
IParams
>
,
{
activityInfo
,
userInfo
,
session
}:
IControllerInfos
,
[
taskService
]:
[
TaskService
]
)
{
const
commonTaskCompletetaskResult1
=
await
taskService
.
completeTask
(
context
.
data
.
taskType
,
activityInfo
,
userInfo
)
return
resultsModel
.
success
({
...
commonTaskCompletetaskResult1
})
}
/**
* 领取任务奖励
*/
@
commonDecorator
.
checkParams
([
'activityId'
,
'taskType'
,
'rewardsKey'
])
@
commonDecorator
.
preCheck
([
commonUtilCheck
.
checkActivityTime
,
commonUtilCheck
.
checkRemainTimes
])
@
services
([
TaskService
])
async
receiveTaskRewards
(
context
:
IContext
<
IParams
>
,
{
activityInfo
,
userInfo
}:
IControllerInfos
,
[
taskService
]:
[
TaskService
]
)
{
const
commonTaskReceivetaskrewardsResult1
=
await
taskService
.
receiveTaskRewards
(
context
.
data
.
taskType
,
context
.
data
.
rewardsKey
,
userInfo
)
return
resultsModel
.
success
({
...
commonTaskReceivetaskrewardsResult1
})
}
/**
* 获取收藏商品列表
*/
@
commonDecorator
.
checkParams
([
'activityId'
,
'itemIds'
])
@
commonDecorator
.
registeInfos
([
'session'
])
@
services
([
BaseService
,
TaskService
])
async
getCollectGoodsList
(
context
:
IContext
<
IParams
>
,
{
activityInfo
,
userInfo
,
session
}:
IControllerInfos
,
[
baseService
,
taskService
]:
[
BaseService
,
TaskService
]
)
{
const
commonBaseGetitemlistbyidsResult1
=
await
baseService
.
getItemListByIds
(
context
.
data
.
itemIds
,
session
)
const
commonTaskGetitemlistwithcollectstatusResult2
=
await
taskService
.
getItemListWithCollectStatus
(
commonBaseGetitemlistbyidsResult1
,
userInfo
)
return
resultsModel
.
success
({
...
commonTaskGetitemlistwithcollectstatusResult2
})
})
}
}
}
}
v2.0/src/controller/common/user.controller.ts
View file @
03ceceb4
...
@@ -13,11 +13,11 @@ export default class User {
...
@@ -13,11 +13,11 @@ export default class User {
@
commonDecorator
.
registeInfos
([
'session'
])
@
commonDecorator
.
registeInfos
([
'session'
])
@
services
([
UserService
])
@
services
([
UserService
])
async
getVipInfo
(
async
getVipInfo
(
context
:
IContext
<
I
Vip
Params
>
,
context
:
IContext
<
IParams
>
,
{
activityInfo
}:
IControllerInfos
,
{
activityInfo
,
userInfo
,
session
}:
IControllerInfos
,
[
userService
]:
[
UserService
]
[
userService
]:
[
UserService
]
)
:
Promise
<
IResult
<
IVipInfo
>>
{
)
{
const
commonUserGetshopvipResult
=
await
userService
.
getShopVip
(
context
,
activityInfo
)
const
commonUserGetshopvipResult
1
=
await
userService
.
getShopVip
(
context
,
session
)
return
resultsModel
.
success
({
return
resultsModel
.
success
({
...
commonUserGetshopvipResult1
...
commonUserGetshopvipResult1
})
})
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment