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
eb0d4012
Commit
eb0d4012
authored
Nov 05, 2020
by
maggie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save
parent
fee2d5a8
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
190 additions
and
334 deletions
+190
-334
config.json
v2.0/compileServer/config.json
+60
-11
task.controller.njk
...leServer/templates/controllers/common/task.controller.njk
+16
-111
user.controller.njk
...leServer/templates/controllers/common/user.controller.njk
+13
-49
custom.controller.njk
...compileServer/templates/controllers/custom.controller.njk
+63
-0
macro.njk
v2.0/compileServer/templates/macro.njk
+10
-6
task.controller.ts
v2.0/src/controller/common/task.controller.ts
+17
-110
user.controller.ts
v2.0/src/controller/common/user.controller.ts
+11
-47
No files found.
v2.0/compileServer/config.json
View file @
eb0d4012
...
...
@@ -3,6 +3,7 @@
"common"
:
{
"user"
:
{
"getVipInfo"
:
{
"desc"
:
"获取会员信息"
,
"decorators"
:
[
{
"type"
:
"common"
,
...
...
@@ -25,15 +26,15 @@
"service"
:
"user"
,
"function"
:
"getShopVip"
,
"params"
:
[
"context"
,
"session"
,
"activityUserNick"
{
"type"
:
"var"
,
"value"
:
"context"
},
{
"type"
:
"var"
,
"value"
:
"session"
}
],
"return"
:
true
}
]
},
"getRankList"
:
{
"desc"
:
"获取排行榜"
,
"decorators"
:
[
{
"type"
:
"common"
,
...
...
@@ -52,9 +53,9 @@
"service"
:
"user"
,
"function"
:
"getMyRankInfo"
,
"params"
:
[
"context.data.key"
,
"context.data.timeKey"
,
"userInfo"
{
"type"
:
"var"
,
"value"
:
"context.data.key"
}
,
{
"type"
:
"var"
,
"value"
:
"context.data.timeKey"
}
,
{
"type"
:
"var"
,
"value"
:
"userInfo"
}
],
"return"
:
true
},
...
...
@@ -63,9 +64,9 @@
"service"
:
"user"
,
"function"
:
"getRank"
,
"params"
:
[
"context.data.key"
,
"context.data.timeKey"
,
"context.data.limit"
{
"type"
:
"var"
,
"value"
:
"context.data.key"
}
,
{
"type"
:
"var"
,
"value"
:
"context.data.timeKey"
}
,
{
"type"
:
"var"
,
"value"
:
"context.data.limit"
}
],
"return"
:
true
}
...
...
@@ -94,12 +95,60 @@
"name"
:
"preCheck"
,
"params"
:
[
{
"type"
:
"common"
"type"
:
"common"
,
"behave"
:
"check"
,
"name"
:
"checkActivityTime"
}
]
},
{
"type"
:
"common"
,
"name"
:
"preUpdate"
,
"params"
:
[
{
"type"
:
"common"
,
"behave"
:
"update"
,
"name"
:
"updateVip"
},
{
"type"
:
"common"
,
"behave"
:
"update"
,
"name"
:
"updateSignTask"
},
{
"type"
:
"common"
,
"behave"
:
"update"
,
"name"
:
"updateOrderGoods"
}
]
}
],
"main"
:
[]
"main"
:
[
{
"type"
:
"common"
,
"service"
:
"task"
,
"function"
:
"initTask"
,
"params"
:
[
{
"type"
:
"string"
,
"value"
:
"member"
},
{
"type"
:
"string"
,
"value"
:
"加入会员"
},
{
"type"
:
"var"
,
"value"
:
"activityInfo"
},
{
"type"
:
"var"
,
"value"
:
"userInfo"
}
],
"return"
:
true
},
{
"type"
:
"common"
,
"service"
:
"task"
,
"function"
:
"initTask"
,
"params"
:
[
{
"type"
:
"string"
,
"value"
:
"follow"
},
{
"type"
:
"string"
,
"value"
:
"关注店铺"
},
{
"type"
:
"var"
,
"value"
:
"activityInfo"
},
{
"type"
:
"var"
,
"value"
:
"userInfo"
}
],
"return"
:
true
}
]
}
}
}
...
...
v2.0/compileServer/templates/controllers/common/task.controller.njk
View file @
eb0d4012
/** @format */
{% import "macro.njk" as macro -%}
import { CODE_TYPES } from './../constants'
import { checkParams, services, registeInfos, preCheck } from '../decorator/common'
import { resultsModel } from '../sdk'
import { TaskService, BaseService } from '../service'
import { ITaskInfo } from '../service/task.service'
import { checkActivityTime } from '../utils/common/check/checkActivityTime'
import { getTotalCompleteTask } from '../utils/common/task'
import { update } from '../decorator/common/update'
import { updateVip } from '../utils/common/update/updateVip'
import { checkTaskLimit } from '../utils/common/check/checkTaskLimit'
import { checkExchangeCreditsTask } from '../utils/common/check/checkExchangeCreditsTask'
import { checkRemainTimes } from '../utils/common/check/checkRemainTimes'
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 Task {
{%- for fn, item in model %}
/**
*
任务列表
*
{{item.desc}}
*/
@checkParams(['activityId'])
@registeInfos(['vipInfo'])
@services([TaskService])
@preCheck([checkActivityTime])
@update([updateVip])
async getTaskList(
context: IContext<{ activityId: string }>,
{ userInfo, activityInfo }: IControllerInfos,
[taskService]: [TaskService]
): Promise<IResult<ITaskInfo[]>> {
return resultsModel.success([
taskService.initTask('member', '加入会员', activityInfo, userInfo),
taskService.initTask('follow', '关注店铺', activityInfo, userInfo)
// taskService.initTask('sign', '签到', activityInfo, userInfo),
// taskService.initTask('orderGoods', '购买商品', activityInfo, userInfo),
// taskService.initTask('browseGoods', '浏览商品', activityInfo, userInfo),
// taskService.initTask('collectGoods', '收藏商品', activityInfo, userInfo),
// taskService.initTask('jumpLink', '浏览页面', activityInfo, userInfo),
// taskService.initTask('invites', '邀请好友', activityInfo, userInfo)
// taskService.initTask('exchangeCredits', '积分兑换', activityInfo, updatedUserInfo)
])
}
/**
* 完成任务
*
* 商品相关任务 需要传itemId参数
* 积分兑换任务 需要传credits参数
*/
@checkParams(['activityId', 'taskType'])
@registeInfos(['session'])
@services([TaskService])
@preCheck([checkActivityTime, checkTaskLimit, checkExchangeCreditsTask])
async doCompleteTask(
context: IContext<{
activityId: string
taskType: ITaskType
itemId?: string // 涉及到商品的任务需传itemId
credits?: number
}>,
{ userInfo, activityInfo }: IControllerInfos,
[taskService]: [TaskService]
): Promise<IResult<boolean>> {
const { taskType, itemId } = context.data
// 更新user表
const result = await taskService.completeTask(taskType, activityInfo, userInfo, { itemId })
return result ? resultsModel.success(true) : resultsModel.error(CODE_TYPES.SYSTEM_ERROR, '任务完成失败')
}
/**
* 领取任务奖励
*/
@checkParams(['activityId', 'taskType', 'rewardsKey'])
@services([TaskService])
@preCheck([checkActivityTime, checkRemainTimes])
async receiveTaskRewards(
context: IContext<{
activityId: string
taskType: ITaskType
rewardsKey: string //领取的奖励增加的key值 如: gameTimes 前端传入
}>,
{ userInfo }: IControllerInfos,
[taskService]: [TaskService]
): Promise<IResult<{ rewards: number }>> {
const { rewardsKey } = context.data
const { taskType } = context.data
const rewards = await taskService.receiveTaskRewards(taskType, rewardsKey, userInfo)
return resultsModel.success({
rewards
})
}
/**
* 获取收藏商品列表
*/
@checkParams(['activityId', 'itemIds'])
@registeInfos(['session'])
@services([BaseService])
async getCollectGoodsList(
{{-macro.genDecorator(model[fn].decorators)}}
@services([{{-macro.genServicesDecorator(model[fn].main)}}])
async {{fn}}(
context: IContext<IParams>,
{
session, userInfo
}: IControllerInfos,
[baseService]: [BaseService]
{
activityInfo, userInfo{{-macro.genRegisteInfosParams(model[fn].decorators)}}
}: IControllerInfos,
{{-macro.genServicesParams(model[fn].main)}}
) {
const { itemIds } = context.data
const list = await baseService.getItemListByIds(itemIds, session)
const { taskInfo } = getTotalCompleteTask('collectGoods', userInfo)
const listWithCollectStatus = list.map(v => {
return {
...v,
// 完成列表是否含有itemId
collected: taskInfo.some(completeItem => completeItem.itemId === v.itemId)
}
})
{{-macro.genMain(model[fn].main)}}
return resultsModel.success(listWithCollectStatus)
{{-macro.genReturn(model[fn].main)}}
}
{%- endfor %}
}
v2.0/compileServer/templates/controllers/common/user.controller.njk
View file @
eb0d4012
...
...
@@ -2,62 +2,26 @@
{% 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 interface IVipParams {
activityId: string
callbackUrl?: string
inviteId?: string // 需要助力回调时请求该接口
}
interface IRankList {
userNick: string
avatar: string
score: any
rank: number
}
export interface IRankResult {
rank: number
userNick: string
avatar: string
score: number
list: IRankList[]
}
export default class User {
{%- for fn, item in model %}
/**
* 获取会员信息
*/
{{-macro.genDecorator(model.getVipInfo.decorators)}}
@services([{{-macro.genServicesDecorator(model.getVipInfo.main)}}])
async getVipInfo(
context: IContext<IVipParams>,
{ activityInfo, userInfo{{-macro.genRegisteInfosParams(model.getVipInfo.decorators)}} }: IControllerInfos,
{{-macro.genServicesParams(model.getVipInfo.main)}}
): Promise<IResult<IVipInfo>> {
{{-macro.genMain(model.getVipInfo.main)}}
{{-macro.genReturn(model.getVipInfo.main)}}
}
/**
* 获取排行榜
* {{item.desc}}
*/
{{-macro.genDecorator(model.getRankList.decorators)}}
@services([{{-macro.genServicesDecorator(model.getRankList.main)}}])
async getRankList(
context: IContext<{
activityId: string
key: string // 排序的key值 如 score
timeKey: string // 排序时间的key值 如:updateScoreTime
limit: number
}>,
{ activityInfo, userInfo{{-macro.genRegisteInfosParams(model.getRankList.decorators)}} }: IControllerInfos,
{{-macro.genServicesParams(model.getRankList.main)}}
{{-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
.getRankList
.main)}}
{{-macro.genMain(model
[fn]
.main)}}
{{-macro.genReturn(model
.getRankList
.main)}}
{{-macro.genReturn(model
[fn]
.main)}}
}
{%- endfor %}
}
v2.0/compileServer/templates/controllers/custom.controller.njk
View file @
eb0d4012
/** @format */
{# {% import "macro.njk" as macro -%} #}
import commonDecorator, { services } from '../../decorator/common'
import { resultsModel } from '../../sdk'
{# {{-macro.genControllerService(service)}} #}
export interface IVipParams {
activityId: string
callbackUrl?: string
inviteId?: string // 需要助力回调时请求该接口
}
interface IRankList {
userNick: string
avatar: string
score: any
rank: number
}
export interface IRankResult {
rank: number
userNick: string
avatar: string
score: number
list: IRankList[]
}
{# export default class User {
/**
* 获取会员信息
*/
{{-macro.genDecorator(model.getVipInfo.decorators)}}
@services([{{-macro.genServicesDecorator(model.getVipInfo.main)}}])
async getVipInfo(
context: IContext<IVipParams>,
{ activityInfo, userInfo{{-macro.genRegisteInfosParams(model.getVipInfo.decorators)}} }: IControllerInfos,
{{-macro.genServicesParams(model.getVipInfo.main)}}
): Promise<IResult<IVipInfo>> {
{{-macro.genMain(model.getVipInfo.main)}}
{{-macro.genReturn(model.getVipInfo.main)}}
}
/**
* 获取排行榜
*/
{{-macro.genDecorator(model.getRankList.decorators)}}
@services([{{-macro.genServicesDecorator(model.getRankList.main)}}])
async getRankList(
context: IContext<{
activityId: string
key: string // 排序的key值 如 score
timeKey: string // 排序时间的key值 如:updateScoreTime
limit: number
}>,
{ activityInfo, userInfo{{-macro.genRegisteInfosParams(model.getRankList.decorators)}} }: IControllerInfos,
{{-macro.genServicesParams(model.getRankList.main)}}
) {
{{-macro.genMain(model.getRankList.main)}}
{{-macro.genReturn(model.getRankList.main)}}
}
} #}
\ No newline at end of file
v2.0/compileServer/templates/macro.njk
View file @
eb0d4012
...
...
@@ -9,7 +9,11 @@ import { {% for s, item2 in item1 %}{{s | capitalize}}Service{%- if loop.last %}
{% macro genDecorator(decorators) %}
{%- for decorator in decorators %}
@{{ decorator.type }}Decorator.{{ 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 -%}
{%- else -%}
{%- for param in decorator.params -%}'{{ param }}'{%- if loop.last %}{% else %}, {% endif %}{%- endfor -%}
{%- endif -%}
])
{%- endfor -%}
{% endmacro %}
...
...
@@ -48,10 +52,10 @@ import { {% for s, item2 in item1 %}{{s | capitalize}}Service{%- if loop.last %}
{# 生成函数体 #}
{% macro genMain(mains) %}
{%- for main in mains %}
const {{main.type}}{{main.service|capitalize}}{{main.function|capitalize}}Result = await {{main.service}}Service.{{main.function}}(
{%- for param in main.params %}
{
{param}}{% if loop.last %}{% else %},
{% endif %}
{%- endfor %}
const {{main.type}}{{main.service|capitalize}}{{main.function|capitalize}}Result
{{loop.index}}
= await {{main.service}}Service.{{main.function}}(
{%- for param in main.params
-
%}
{
% if param.type == 'var' %}{{param.value}}{% else %}'{{param.value}}'{% endif %}{% if loop.last %}{% else %},
{% endif %}
{%- endfor
-
%}
)
{%- endfor -%}
{%- endmacro %}
...
...
@@ -61,7 +65,7 @@ import { {% for s, item2 in item1 %}{{s | capitalize}}Service{%- if loop.last %}
return resultsModel.success({
{%- for main in mains -%}
{% if main.return %}
...{{main.type}}{{main.service|capitalize}}{{main.function|capitalize}}Result{% if loop.last %}{% else %},{% endif %}
...{{main.type}}{{main.service|capitalize}}{{main.function|capitalize}}Result{
{loop.index}}{
% if loop.last %}{% else %},{% endif %}
{%- endif -%}
{%- endfor %}
})
...
...
v2.0/src/controller/common/task.controller.ts
View file @
eb0d4012
/** @format */
import
{
CODE_TYPES
}
from
'./../constants'
import
{
checkParams
,
services
,
registeInfos
,
preCheck
}
from
'../decorator/common'
import
{
resultsModel
}
from
'../sdk'
import
{
TaskService
,
BaseService
}
from
'../service'
import
{
ITaskInfo
}
from
'../service/task.service'
import
{
checkActivityTime
}
from
'../utils/common/check/checkActivityTime'
import
{
getTotalCompleteTask
}
from
'../utils/common/task'
import
{
update
}
from
'../decorator/common/update'
import
{
updateVip
}
from
'../utils/common/update/updateVip'
import
{
checkTaskLimit
}
from
'../utils/common/check/checkTaskLimit'
import
{
checkExchangeCreditsTask
}
from
'../utils/common/check/checkExchangeCreditsTask'
import
{
checkRemainTimes
}
from
'../utils/common/check/checkRemainTimes'
import
commonDecorator
,
{
services
}
from
'../../decorator/common'
import
commonUtilCheck
from
'../../utils/common/check'
import
commonUtilUpdate
from
'../../utils/common/update'
import
{
resultsModel
}
from
'../../sdk'
import
{
TaskService
}
from
'../../service'
export
default
class
Task
{
/**
* 任务列表
*/
@
checkParams
([
'activityId'
])
@
registeInfos
([
'vipInfo'
])
@
services
([
TaskService
])
@
preCheck
([
checkActivityTime
])
@
update
([
updateVip
])
async
getTaskList
(
context
:
IContext
<
{
activityId
:
string
}
>
,
{
userInfo
,
activityInfo
}:
IControllerInfos
,
[
taskService
]:
[
TaskService
]
):
Promise
<
IResult
<
ITaskInfo
[]
>>
{
return
resultsModel
.
success
([
taskService
.
initTask
(
'member'
,
'加入会员'
,
activityInfo
,
userInfo
),
taskService
.
initTask
(
'follow'
,
'关注店铺'
,
activityInfo
,
userInfo
)
// taskService.initTask('sign', '签到', activityInfo, userInfo),
// taskService.initTask('orderGoods', '购买商品', activityInfo, userInfo),
// taskService.initTask('browseGoods', '浏览商品', activityInfo, userInfo),
// taskService.initTask('collectGoods', '收藏商品', activityInfo, userInfo),
// taskService.initTask('jumpLink', '浏览页面', activityInfo, userInfo),
// taskService.initTask('invites', '邀请好友', activityInfo, userInfo)
// taskService.initTask('exchangeCredits', '积分兑换', activityInfo, updatedUserInfo)
])
}
/**
* 完成任务
*
* 商品相关任务 需要传itemId参数
* 积分兑换任务 需要传credits参数
*/
@
checkParams
([
'activityId'
,
'taskType'
])
@
registeInfos
([
'session'
])
@
services
([
TaskService
])
@
preCheck
([
checkActivityTime
,
checkTaskLimit
,
checkExchangeCreditsTask
])
async
doCompleteTask
(
context
:
IContext
<
{
activityId
:
string
taskType
:
ITaskType
itemId
?:
string
// 涉及到商品的任务需传itemId
credits
?:
number
}
>
,
{
userInfo
,
activityInfo
}:
IControllerInfos
,
[
taskService
]:
[
TaskService
]
):
Promise
<
IResult
<
boolean
>>
{
const
{
taskType
,
itemId
}
=
context
.
data
// 更新user表
const
result
=
await
taskService
.
completeTask
(
taskType
,
activityInfo
,
userInfo
,
{
itemId
})
return
result
?
resultsModel
.
success
(
true
)
:
resultsModel
.
error
(
CODE_TYPES
.
SYSTEM_ERROR
,
'任务完成失败'
)
}
/**
* 领取任务奖励
*/
@
checkParams
([
'activityId'
,
'taskType'
,
'rewardsKey'
])
@
commonDecorator
.
checkParams
([
'activityId'
])
@
commonDecorator
.
registeInfos
([
'vipInfo'
])
@
commonDecorator
.
preCheck
([
commonUtilCheck
.
checkActivityTime
])
@
commonDecorator
.
preUpdate
([
commonUtilUpdate
.
updateVip
,
commonUtilUpdate
.
updateSignTask
,
commonUtilUpdate
.
updateOrderGoods
])
@
services
([
TaskService
])
@
preCheck
([
checkActivityTime
,
checkRemainTimes
])
async
receiveTaskRewards
(
context
:
IContext
<
{
activityId
:
string
taskType
:
ITaskType
rewardsKey
:
string
//领取的奖励增加的key值 如: gameTimes 前端传入
}
>
,
{
userInfo
}:
IControllerInfos
,
[
taskService
]:
[
TaskService
]
):
Promise
<
IResult
<
{
rewards
:
number
}
>>
{
const
{
rewardsKey
}
=
context
.
data
const
{
taskType
}
=
context
.
data
const
rewards
=
await
taskService
.
receiveTaskRewards
(
taskType
,
rewardsKey
,
userInfo
)
return
resultsModel
.
success
({
rewards
})
}
/**
* 获取收藏商品列表
*/
@
checkParams
([
'activityId'
,
'itemIds'
])
@
registeInfos
([
'session'
])
@
services
([
BaseService
])
async
getCollectGoodsList
(
async
getTaskList
(
context
:
IContext
<
IParams
>
,
{
session
,
user
Info
}:
IControllerInfos
,
[
baseService
]:
[
Base
Service
]
{
activityInfo
,
userInfo
,
vip
Info
}:
IControllerInfos
,
[
taskService
]:
[
Task
Service
]
)
{
const
{
itemIds
}
=
context
.
data
const
list
=
await
baseService
.
getItemListByIds
(
itemIds
,
session
)
const
{
taskInfo
}
=
getTotalCompleteTask
(
'collectGoods'
,
userInfo
)
const
listWithCollectStatus
=
list
.
map
(
v
=>
{
return
{
...
v
,
// 完成列表是否含有itemId
collected
:
taskInfo
.
some
(
completeItem
=>
completeItem
.
itemId
===
v
.
itemId
)
}
const
commonTaskInittaskResult1
=
await
taskService
.
initTask
(
'member'
,
'加入会员'
,
activityInfo
,
userInfo
)
const
commonTaskInittaskResult2
=
await
taskService
.
initTask
(
'follow'
,
'关注店铺'
,
activityInfo
,
userInfo
)
return
resultsModel
.
success
({
...
commonTaskInittaskResult1
,
...
commonTaskInittaskResult2
})
return
resultsModel
.
success
(
listWithCollectStatus
)
}
}
v2.0/src/controller/common/user.controller.ts
View file @
eb0d4012
/** @format */
import
commonDecorator
,
{
services
}
from
'../../decorator/common'
import
commonUtilCheck
from
'../../utils/common/check'
import
commonUtilUpdate
from
'../../utils/common/update'
import
{
resultsModel
}
from
'../../sdk'
import
{
UserService
}
from
'../../service'
export
interface
IVipParams
{
activityId
:
string
callbackUrl
?:
string
inviteId
?:
string
// 需要助力回调时请求该接口
}
interface
IRankList
{
userNick
:
string
avatar
:
string
score
:
any
rank
:
number
}
export
interface
IRankResult
{
rank
:
number
userNick
:
string
avatar
:
string
score
:
number
list
:
IRankList
[]
}
export
default
class
User
{
/**
* 获取会员信息
...
...
@@ -31,48 +13,30 @@ export default class User {
@
commonDecorator
.
registeInfos
([
'session'
])
@
services
([
UserService
])
async
getVipInfo
(
context
:
IContext
<
I
Vip
Params
>
,
context
:
IContext
<
IParams
>
,
{
activityInfo
,
userInfo
,
session
}:
IControllerInfos
,
[
userService
]:
[
UserService
]
):
Promise
<
IResult
<
IVipInfo
>>
{
const
commonUserGetshopvipResult
=
await
userService
.
getShopVip
(
context
,
session
,
activityUserNick
)
)
{
const
commonUserGetshopvipResult1
=
await
userService
.
getShopVip
(
context
,
session
)
return
resultsModel
.
success
({
...
commonUserGetshopvipResult
...
commonUserGetshopvipResult
1
})
}
/**
* 获取排行榜
*/
@
commonDecorator
.
checkParams
([
'activityId'
,
'key'
,
'timeKey'
,
'limit'
])
@
services
([
UserService
])
async
getRankList
(
context
:
IContext
<
{
activityId
:
string
key
:
string
// 排序的key值 如 score
timeKey
:
string
// 排序时间的key值 如:updateScoreTime
limit
:
number
}
>
,
context
:
IContext
<
IParams
>
,
{
activityInfo
,
userInfo
}:
IControllerInfos
,
[
userService
]:
[
UserService
]
)
{
const
commonUserGetmyrankinfoResult
=
await
userService
.
getMyRankInfo
(
context
.
data
.
key
,
context
.
data
.
timeKey
,
userInfo
)
const
commonUserGetrankResult
=
await
userService
.
getRank
(
context
.
data
.
key
,
context
.
data
.
timeKey
,
context
.
data
.
limit
)
const
commonUserGetmyrankinfoResult1
=
await
userService
.
getMyRankInfo
(
context
.
data
.
key
,
context
.
data
.
timeKey
,
userInfo
)
const
commonUserGetrankResult2
=
await
userService
.
getRank
(
context
.
data
.
key
,
context
.
data
.
timeKey
,
context
.
data
.
limit
)
return
resultsModel
.
success
({
...
commonUserGetmyrankinfoResult
,
...
commonUserGetrankResult
...
commonUserGetmyrankinfoResult
1
,
...
commonUserGetrankResult
2
})
}
}
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