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
fee2d5a8
Commit
fee2d5a8
authored
Nov 05, 2020
by
maggie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
user.controller编译通过
parent
b921b1cd
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
11 deletions
+20
-11
user.controller.njk
...leServer/templates/controllers/common/user.controller.njk
+4
-4
macro.njk
v2.0/compileServer/templates/macro.njk
+14
-5
user.controller.ts
v2.0/src/controller/common/user.controller.ts
+2
-2
No files found.
v2.0/compileServer/templates/controllers/common/user.controller.njk
View file @
fee2d5a8
...
@@ -30,10 +30,10 @@ export default class User {
...
@@ -30,10 +30,10 @@ export default class User {
* 获取会员信息
* 获取会员信息
*/
*/
{{-macro.genDecorator(model.getVipInfo.decorators)}}
{{-macro.genDecorator(model.getVipInfo.decorators)}}
{{-macro.genServicesDecorator(model.getVipInfo.main)}}
@services([{{-macro.genServicesDecorator(model.getVipInfo.main)}}])
async getVipInfo(
async getVipInfo(
context: IContext<IVipParams>,
context: IContext<IVipParams>,
{
session, activityUserNick
}: IControllerInfos,
{
activityInfo, userInfo{{-macro.genRegisteInfosParams(model.getVipInfo.decorators)}}
}: IControllerInfos,
{{-macro.genServicesParams(model.getVipInfo.main)}}
{{-macro.genServicesParams(model.getVipInfo.main)}}
): Promise<IResult<IVipInfo>> {
): Promise<IResult<IVipInfo>> {
{{-macro.genMain(model.getVipInfo.main)}}
{{-macro.genMain(model.getVipInfo.main)}}
...
@@ -45,7 +45,7 @@ export default class User {
...
@@ -45,7 +45,7 @@ export default class User {
* 获取排行榜
* 获取排行榜
*/
*/
{{-macro.genDecorator(model.getRankList.decorators)}}
{{-macro.genDecorator(model.getRankList.decorators)}}
{{-macro.genServicesDecorator(model.getRankList.main)}}
@services([{{-macro.genServicesDecorator(model.getRankList.main)}}])
async getRankList(
async getRankList(
context: IContext<{
context: IContext<{
activityId: string
activityId: string
...
@@ -53,7 +53,7 @@ export default class User {
...
@@ -53,7 +53,7 @@ export default class User {
timeKey: string // 排序时间的key值 如:updateScoreTime
timeKey: string // 排序时间的key值 如:updateScoreTime
limit: number
limit: number
}>,
}>,
{
userInfo
}: IControllerInfos,
{
activityInfo, userInfo{{-macro.genRegisteInfosParams(model.getRankList.decorators)}}
}: IControllerInfos,
{{-macro.genServicesParams(model.getRankList.main)}}
{{-macro.genServicesParams(model.getRankList.main)}}
) {
) {
{{-macro.genMain(model.getRankList.main)}}
{{-macro.genMain(model.getRankList.main)}}
...
...
v2.0/compileServer/templates/macro.njk
View file @
fee2d5a8
...
@@ -16,11 +16,9 @@ import { {% for s, item2 in item1 %}{{s | capitalize}}Service{%- if loop.last %}
...
@@ -16,11 +16,9 @@ import { {% for s, item2 in item1 %}{{s | capitalize}}Service{%- if loop.last %}
{# 生成services装饰器 #}
{# 生成services装饰器 #}
{% macro genServicesDecorator(mains) %}
{% macro genServicesDecorator(mains) %}
@services([
{%- for service, main in mains|groupby("service") -%}
{%- for service, main in mains|groupby("service") -%}
{{ service | capitalize }}Service{%- if loop.last %}{% else %}, {% endif %}
{{ service | capitalize }}Service{%- if loop.last %}{% else %}, {% endif %}
{%- endfor -%}
{%- endfor -%}
])
{%- endmacro %}
{%- endmacro %}
{# 生成services参数 #}
{# 生成services参数 #}
...
@@ -36,6 +34,17 @@ import { {% for s, item2 in item1 %}{{s | capitalize}}Service{%- if loop.last %}
...
@@ -36,6 +34,17 @@ import { {% for s, item2 in item1 %}{{s | capitalize}}Service{%- if loop.last %}
]
]
{%- endmacro %}
{%- endmacro %}
{# 生成注入参数 #}
{% macro genRegisteInfosParams(decorators) %}
{%- for decorator in decorators -%}
{% if decorator.type == 'common' and decorator.name == 'registeInfos' %}
{%- for param in decorator.params -%}
{%- if loop.first %}, {% else %}{% endif %}{{ param }}{%- if loop.last %}{% else %}, {% endif %}
{%- endfor -%}
{% endif %}
{%- endfor -%}
{%- endmacro %}
{# 生成函数体 #}
{# 生成函数体 #}
{% macro genMain(mains) %}
{% macro genMain(mains) %}
{%- for main in mains %}
{%- for main in mains %}
...
...
v2.0/src/controller/common/user.controller.ts
View file @
fee2d5a8
...
@@ -32,7 +32,7 @@ export default class User {
...
@@ -32,7 +32,7 @@ export default class User {
@
services
([
UserService
])
@
services
([
UserService
])
async
getVipInfo
(
async
getVipInfo
(
context
:
IContext
<
IVipParams
>
,
context
:
IContext
<
IVipParams
>
,
{
session
,
activityUserNick
}:
IControllerInfos
,
{
activityInfo
,
userInfo
,
session
}:
IControllerInfos
,
[
userService
]:
[
UserService
]
[
userService
]:
[
UserService
]
):
Promise
<
IResult
<
IVipInfo
>>
{
):
Promise
<
IResult
<
IVipInfo
>>
{
const
commonUserGetshopvipResult
=
await
userService
.
getShopVip
(
const
commonUserGetshopvipResult
=
await
userService
.
getShopVip
(
...
@@ -57,7 +57,7 @@ export default class User {
...
@@ -57,7 +57,7 @@ export default class User {
timeKey
:
string
// 排序时间的key值 如:updateScoreTime
timeKey
:
string
// 排序时间的key值 如:updateScoreTime
limit
:
number
limit
:
number
}
>
,
}
>
,
{
userInfo
}:
IControllerInfos
,
{
activityInfo
,
userInfo
}:
IControllerInfos
,
[
userService
]:
[
UserService
]
[
userService
]:
[
UserService
]
)
{
)
{
const
commonUserGetmyrankinfoResult
=
await
userService
.
getMyRankInfo
(
const
commonUserGetmyrankinfoResult
=
await
userService
.
getMyRankInfo
(
...
...
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