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
67fec37f
Commit
67fec37f
authored
Nov 11, 2020
by
qinhaitao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat:
🎸
解构编译
parent
8023dc86
Changes
13
Show whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
203 additions
and
142 deletions
+203
-142
generate.js
v2.0/compileServer/generate.js
+17
-3
controller.njk
v2.0/compileServer/templates/controller.njk
+13
-6
macro.njk
v2.0/compileServer/templates/macro.njk
+3
-3
formatConfg.js
v2.0/compileServer/utils/formatConfg.js
+39
-0
awards.controller.ts
v2.0/src/controller/common/awards.controller.ts
+16
-25
base.controller.ts
v2.0/src/controller/common/base.controller.ts
+4
-9
login.controller.ts
v2.0/src/controller/common/login.controller.ts
+5
-10
share.controller.ts
v2.0/src/controller/common/share.controller.ts
+12
-12
stat.controller.ts
v2.0/src/controller/common/stat.controller.ts
+15
-12
task.controller.ts
v2.0/src/controller/common/task.controller.ts
+32
-24
user.controller.ts
v2.0/src/controller/common/user.controller.ts
+15
-12
test1.controller.ts
v2.0/src/controller/custom/test1.controller.ts
+17
-14
test2.controller.ts
v2.0/src/controller/custom/test2.controller.ts
+15
-12
No files found.
v2.0/compileServer/generate.js
View file @
67fec37f
...
...
@@ -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'
)
}
})
)
...
...
v2.0/compileServer/templates/controller.njk
View file @
67fec37f
/** @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 %}
...
...
v2.0/compileServer/templates/macro.njk
View file @
67fec37f
{# 生成控制器引用的服务 #}
{% 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 -%}])
...
...
v2.0/compileServer/utils/formatConfg.js
0 → 100644
View file @
67fec37f
/** @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
}
v2.0/src/controller/common/awards.controller.ts
View file @
67fec37f
/** @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
{
/**
* 我的奖品列表
*/
@
c
ommonDecorator
.
c
heckParams
([
'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 {
/**
* 领取权益
*/
@
c
ommonDecorator
.
c
heckParams
([
'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 {
/**
* 概率抽奖
*/
@
c
ommonDecorator
.
c
heckParams
([
'activityId'
,
'prizeDataType'
])
@
commonDecorator
.
registeInfos
([
'session'
])
@
commonDecorator
.
preCheck
([
commonUtilCheck
.
checkActivityTime
])
@
checkParams
([
'activityId'
,
'prizeDataType'
])
@
registeInfos
([
'session'
])
@
preCheck
([
checkActivityTime
])
@
services
([
CommonAwardsService
])
async
drawLotteryPrize
(
context
:
IContext
<
IParams
>
,
...
...
v2.0/src/controller/common/base.controller.ts
View file @
67fec37f
/** @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
{
/**
* 活动基本信息
*/
@
c
ommonDecorator
.
c
heckParams
([
'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
({
...
...
v2.0/src/controller/common/login.controller.ts
View file @
67fec37f
/** @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
{
/**
* 登录接口, 初始化/更新用户信息
*/
@
c
ommonDecorator
.
c
heckParams
([
'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
)
...
...
v2.0/src/controller/common/share.controller.ts
View file @
67fec37f
/** @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
{
/**
* 获取邀请信息
*/
@
c
ommonDecorator
.
c
heckParams
([
'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 {
/**
* 完成分享
*/
@
c
ommonDecorator
.
c
heckParams
([
'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
>
,
...
...
v2.0/src/controller/common/stat.controller.ts
View file @
67fec37f
/** @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
{
/**
* 增加埋点记录
*/
@
c
ommonDecorator
.
c
heckParams
([
'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 {
/**
* 统计数据
*/
@
c
ommonDecorator
.
c
heckParams
([
'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
})
...
...
v2.0/src/controller/common/task.controller.ts
View file @
67fec37f
/** @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
{
/**
* 任务列表
*/
@
c
ommonDecorator
.
c
heckParams
([
'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 {
/**
* 完成任务
*/
@
c
ommonDecorator
.
c
heckParams
([
'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 {
/**
* 领取任务奖励
*/
@
c
ommonDecorator
.
c
heckParams
([
'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 {
/**
* 获取收藏商品列表
*/
@
c
ommonDecorator
.
c
heckParams
([
'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
})
...
...
v2.0/src/controller/common/user.controller.ts
View file @
67fec37f
/** @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
{
/**
* 获取会员信息
*/
@
c
ommonDecorator
.
c
heckParams
([
'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 {
/**
* 获取排行榜
*/
@
c
ommonDecorator
.
c
heckParams
([
'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
...
...
v2.0/src/controller/custom/test1.controller.ts
View file @
67fec37f
/** @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
{
/**
* 增加埋点记录
*/
@
c
ommonDecorator
.
c
heckParams
([
'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 {
/**
* 统计数据
*/
@
c
ommonDecorator
.
c
heckParams
([
'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
})
...
...
v2.0/src/controller/custom/test2.controller.ts
View file @
67fec37f
/** @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
{
/**
* 增加埋点记录
*/
@
c
ommonDecorator
.
c
heckParams
([
'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 {
/**
* 统计数据
*/
@
c
ommonDecorator
.
c
heckParams
([
'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
})
...
...
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