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
Hide 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 @@
...
@@ -2,6 +2,8 @@
const
fs
=
require
(
'fs-extra'
)
const
fs
=
require
(
'fs-extra'
)
const
config
=
require
(
'./config.json'
)
const
config
=
require
(
'./config.json'
)
const
{
getDecorators
,
getPreChecks
,
getPreUpdates
}
=
require
(
'./utils/formatConfg'
)
const
serverTemplatePath
=
'templates'
const
serverTemplatePath
=
'templates'
const
controllerImport
=
(
controller
=
{})
=>
{
const
controllerImport
=
(
controller
=
{})
=>
{
...
@@ -16,7 +18,6 @@ const controllerImport = (controller = {}) => {
...
@@ -16,7 +18,6 @@ const controllerImport = (controller = {}) => {
result
.
services
[
main
.
type
][
main
.
service
]
=
true
result
.
services
[
main
.
type
][
main
.
service
]
=
true
}
}
}
}
console
.
log
(
result
)
return
result
return
result
}
}
...
@@ -136,6 +137,7 @@ const run = async (gulp, nunjucksRender, rename, nunjucksRenderConfig) => {
...
@@ -136,6 +137,7 @@ const run = async (gulp, nunjucksRender, rename, nunjucksRenderConfig) => {
.
pipe
(
rename
(
`index.ts`
))
.
pipe
(
rename
(
`index.ts`
))
.
pipe
(
gulp
.
dest
(
nunjucksRenderConfig
.
ServerFullPath
+
'/service/custom'
))
.
pipe
(
gulp
.
dest
(
nunjucksRenderConfig
.
ServerFullPath
+
'/service/custom'
))
//编译controller.common
//编译controller.common
for
(
let
commonController
in
config
.
controllers
.
common
)
{
for
(
let
commonController
in
config
.
controllers
.
common
)
{
await
gulp
await
gulp
.
src
(
`
${
serverTemplatePath
}
/controller.njk`
)
.
src
(
`
${
serverTemplatePath
}
/controller.njk`
)
...
@@ -145,7 +147,13 @@ const run = async (gulp, nunjucksRender, rename, nunjucksRenderConfig) => {
...
@@ -145,7 +147,13 @@ const run = async (gulp, nunjucksRender, rename, nunjucksRenderConfig) => {
data
:
{
data
:
{
name
:
commonController
,
name
:
commonController
,
model
:
config
.
controllers
.
common
[
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) => {
...
@@ -162,7 +170,13 @@ const run = async (gulp, nunjucksRender, rename, nunjucksRenderConfig) => {
data
:
{
data
:
{
name
:
customController
,
name
:
customController
,
model
:
config
.
controllers
.
custom
[
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 */
/** @format */
{% import "macro.njk" as macro -%}
{% import "macro.njk" as macro -%}
import commonDecorator, { services } from '../../decorator/common'
import { {{ commmonDecorators }} } from '../../decorator/common'
import commonUtilCheck from '../../utils/common/check'
{%if commonPreChecks and commonPreChecks.length -%}
import commonUtilUpdate from '../../utils/common/update'
import { {{commonPreChecks}} } from '../../utils/common/check'
import customDecorator from '../../decorator/custom'
{% 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 customUtil from '../../utils/custom'
import { resultsModel } from '../../sdk'
{{macro.genControllerService(services)}}
{# import commonService from '../../service/common'
{# import commonService from '../../service/common'
import customService from '../../service/custom' #}
import customService from '../../service/custom' #}
import { resultsModel } from '../../sdk'
{{-macro.genControllerService(services)-}}
export default class {{name | capitalize}}Controller {
export default class {{name | capitalize}}Controller {
{%- for fn, item in model %}
{%- for fn, item in model %}
...
...
v2.0/compileServer/templates/macro.njk
View file @
67fec37f
{# 生成控制器引用的服务 #}
{# 生成控制器引用的服务 #}
{% macro genControllerService(services)%}
{% 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}}'
import { {%for service, service_item in type_item %}{{type|capitalize}}{{service|capitalize}}Service{%- if loop.last %}{% else %}, {% endif %}{% endfor %} } from '../../service/{{type}}'
{% endfor%}
{% endfor%}
{% endmacro %}
{% endmacro %}
...
@@ -8,9 +8,9 @@ import { {%for service, service_item in type_item %}{{type|capitalize}}{{service
...
@@ -8,9 +8,9 @@ import { {%for service, service_item in type_item %}{{type|capitalize}}{{service
{# 生成装饰器 #}
{# 生成装饰器 #}
{% macro genDecorator(decorators) %}
{% macro genDecorator(decorators) %}
{%- for decorator in decorators %}
{%- for decorator in decorators %}
@{{ decorator.
type }}Decorator.{{ decorator.
name }}
@{{ decorator.name }}
{%- if decorator.name == 'preCheck' or decorator.name == 'preUpdate' -%}
{%- 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' -%}
{%- elif decorator.name == 'noCatch' or decorator.name == 'noCheckUser' -%}
{%- else -%}
{%- else -%}
([{%- for param in decorator.params -%}'{{ param }}'{%- if loop.last %}{% else %}, {% endif %}{%- endfor -%}])
([{%- 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 */
/** @format */
import
commonDecorator
,
{
services
}
from
'../../decorator/common'
import
{
services
,
checkParams
,
preCheck
,
registeInfos
}
from
'../../decorator/common'
import
commonUtilCheck
from
'../../utils/common/check'
import
{
import
commonUtilUpdate
from
'../../utils/common/update'
checkPrizeExpired
,
import
customDecorator
from
'../../decorator/custom'
checkValidObjectPrize
,
checkValidEnamePrize
,
checkActivityTime
}
from
'../../utils/common/check'
import
customUtil
from
'../../utils/custom'
import
customUtil
from
'../../utils/custom'
import
{
resultsModel
}
from
'../../sdk'
import
{
resultsModel
}
from
'../../sdk'
import
{
CommonAwardsService
}
from
'../../service/common'
import
{
CommonAwardsService
}
from
'../../service/common'
export
default
class
AwardsController
{
export
default
class
AwardsController
{
/**
/**
* 我的奖品列表
* 我的奖品列表
*/
*/
@
c
ommonDecorator
.
c
heckParams
([
'activityId'
])
@
checkParams
([
'activityId'
])
@
services
([
CommonAwardsService
])
@
services
([
CommonAwardsService
])
async
getMyPrizeList
(
async
getMyPrizeList
(
context
:
IContext
<
IParams
>
,
context
:
IContext
<
IParams
>
,
...
@@ -28,18 +29,8 @@ export default class AwardsController {
...
@@ -28,18 +29,8 @@ export default class AwardsController {
/**
/**
* 领取实物
* 领取实物
*/
*/
@
commonDecorator
.
checkParams
([
@
checkParams
([
'activityId'
,
'id'
,
'name'
,
'phone'
,
'province'
,
'city'
,
'area'
,
'addressDetail'
,
'streetName'
])
'activityId'
,
@
preCheck
([
checkPrizeExpired
,
checkValidObjectPrize
])
'id'
,
'name'
,
'phone'
,
'province'
,
'city'
,
'area'
,
'addressDetail'
,
'streetName'
])
@
commonDecorator
.
preCheck
([
commonUtilCheck
.
checkPrizeExpired
,
commonUtilCheck
.
checkValidObjectPrize
])
@
services
([
CommonAwardsService
])
@
services
([
CommonAwardsService
])
async
receiveObjectPrize
(
async
receiveObjectPrize
(
context
:
IContext
<
IParams
>
,
context
:
IContext
<
IParams
>
,
...
@@ -55,9 +46,9 @@ export default class AwardsController {
...
@@ -55,9 +46,9 @@ export default class AwardsController {
/**
/**
* 领取权益
* 领取权益
*/
*/
@
c
ommonDecorator
.
c
heckParams
([
'activityId'
,
'id'
])
@
checkParams
([
'activityId'
,
'id'
])
@
commonDecorator
.
registeInfos
([
'session'
])
@
registeInfos
([
'session'
])
@
commonDecorator
.
preCheck
([
commonUtilCheck
.
checkPrizeExpired
,
commonUtilCheck
.
checkValidEnamePrize
])
@
preCheck
([
checkPrizeExpired
,
checkValidEnamePrize
])
@
services
([
CommonAwardsService
])
@
services
([
CommonAwardsService
])
async
receiveEnamePrize
(
async
receiveEnamePrize
(
context
:
IContext
<
IParams
>
,
context
:
IContext
<
IParams
>
,
...
@@ -77,9 +68,9 @@ export default class AwardsController {
...
@@ -77,9 +68,9 @@ export default class AwardsController {
/**
/**
* 概率抽奖
* 概率抽奖
*/
*/
@
c
ommonDecorator
.
c
heckParams
([
'activityId'
,
'prizeDataType'
])
@
checkParams
([
'activityId'
,
'prizeDataType'
])
@
commonDecorator
.
registeInfos
([
'session'
])
@
registeInfos
([
'session'
])
@
commonDecorator
.
preCheck
([
commonUtilCheck
.
checkActivityTime
])
@
preCheck
([
checkActivityTime
])
@
services
([
CommonAwardsService
])
@
services
([
CommonAwardsService
])
async
drawLotteryPrize
(
async
drawLotteryPrize
(
context
:
IContext
<
IParams
>
,
context
:
IContext
<
IParams
>
,
...
...
v2.0/src/controller/common/base.controller.ts
View file @
67fec37f
/** @format */
/** @format */
import
commonDecorator
,
{
services
}
from
'../../decorator/common'
import
{
services
,
checkParams
,
noCheckUser
}
from
'../../decorator/common'
import
commonUtilCheck
from
'../../utils/common/check'
import
commonUtilUpdate
from
'../../utils/common/update'
import
customDecorator
from
'../../decorator/custom'
import
customUtil
from
'../../utils/custom'
import
customUtil
from
'../../utils/custom'
import
{
resultsModel
}
from
'../../sdk'
import
{
resultsModel
}
from
'../../sdk'
import
{
CommonBaseService
}
from
'../../service/common'
import
{
CommonBaseService
}
from
'../../service/common'
export
default
class
BaseController
{
export
default
class
BaseController
{
/**
/**
* 活动基本信息
* 活动基本信息
*/
*/
@
c
ommonDecorator
.
c
heckParams
([
'activityId'
])
@
checkParams
([
'activityId'
])
@
commonDecorator
.
noCheckUser
@
noCheckUser
@
services
([
CommonBaseService
])
@
services
([
CommonBaseService
])
async
getActivityBaseInfoById
(
async
getActivityBaseInfoById
(
context
:
IContext
<
IParams
>
,
context
:
IContext
<
IParams
>
,
{
activityInfo
,
userInfo
}:
IControllerInfos
,
{
activityInfo
,
userInfo
}:
IControllerInfos
,
[
commonBaseService
]:
[
CommonBaseService
]
,
[
commonBaseService
]:
[
CommonBaseService
]
)
{
)
{
const
commonBaseGetBaseInfoResult1
=
await
commonBaseService
.
getBaseInfo
(
context
.
data
.
activityId
)
const
commonBaseGetBaseInfoResult1
=
await
commonBaseService
.
getBaseInfo
(
context
.
data
.
activityId
)
return
resultsModel
.
success
({
return
resultsModel
.
success
({
...
...
v2.0/src/controller/common/login.controller.ts
View file @
67fec37f
/** @format */
/** @format */
import
commonDecorator
,
{
services
}
from
'../../decorator/common'
import
{
services
,
checkParams
,
noCheckUser
,
registeInfos
}
from
'../../decorator/common'
import
commonUtilCheck
from
'../../utils/common/check'
import
commonUtilUpdate
from
'../../utils/common/update'
import
customDecorator
from
'../../decorator/custom'
import
customUtil
from
'../../utils/custom'
import
customUtil
from
'../../utils/custom'
import
{
resultsModel
}
from
'../../sdk'
import
{
resultsModel
}
from
'../../sdk'
import
{
CommonUserService
,
CommonAccessService
}
from
'../../service/common'
import
{
CommonUserService
,
CommonAccessService
}
from
'../../service/common'
export
default
class
LoginController
{
export
default
class
LoginController
{
/**
/**
* 登录接口, 初始化/更新用户信息
* 登录接口, 初始化/更新用户信息
*/
*/
@
c
ommonDecorator
.
c
heckParams
([
'activityId'
,
'userNick'
,
'avatar'
,
'isFollow'
])
@
checkParams
([
'activityId'
,
'userNick'
,
'avatar'
,
'isFollow'
])
@
commonDecorator
.
noCheckUser
@
noCheckUser
@
commonDecorator
.
registeInfos
([
'vipInfo'
])
@
registeInfos
([
'vipInfo'
])
@
services
([
CommonUserService
,
CommonAccessService
])
@
services
([
CommonUserService
,
CommonAccessService
])
async
login
(
async
login
(
context
:
IContext
<
IParams
>
,
context
:
IContext
<
IParams
>
,
{
activityInfo
,
userInfo
,
vipInfo
}:
IControllerInfos
,
{
activityInfo
,
userInfo
,
vipInfo
}:
IControllerInfos
,
[
commonUserService
,
commonAccessService
]:
[
CommonUserService
,
CommonAccessService
]
,
[
commonUserService
,
commonAccessService
]:
[
CommonUserService
,
CommonAccessService
]
)
{
)
{
const
commonUserDoLoginResult1
=
await
commonUserService
.
doLogin
(
userInfo
,
vipInfo
,
activityInfo
)
const
commonUserDoLoginResult1
=
await
commonUserService
.
doLogin
(
userInfo
,
vipInfo
,
activityInfo
)
const
commonAccessAddAccessResult2
=
await
commonAccessService
.
addAccess
(
commonUserDoLoginResult1
,
vipInfo
)
const
commonAccessAddAccessResult2
=
await
commonAccessService
.
addAccess
(
commonUserDoLoginResult1
,
vipInfo
)
...
...
v2.0/src/controller/common/share.controller.ts
View file @
67fec37f
/** @format */
/** @format */
import
commonDecorator
,
{
services
}
from
'../../decorator/common'
import
{
services
,
checkParams
,
registeInfos
,
preCheck
}
from
'../../decorator/common'
import
commonUtilCheck
from
'../../utils/common/check'
import
{
checkActivityTime
,
checkInviteId
,
checkNewVip
,
checkHelpRecord
}
from
'../../utils/common/check'
import
commonUtilUpdate
from
'../../utils/common/update'
import
customDecorator
from
'../../decorator/custom'
import
customUtil
from
'../../utils/custom'
import
customUtil
from
'../../utils/custom'
import
{
resultsModel
}
from
'../../sdk'
import
{
resultsModel
}
from
'../../sdk'
import
{
CommonUserService
,
CommonTaskService
,
CommonStatService
}
from
'../../service/common'
import
{
CommonUserService
,
CommonTaskService
,
CommonStatService
}
from
'../../service/common'
export
default
class
ShareController
{
export
default
class
ShareController
{
/**
/**
* 获取邀请信息
* 获取邀请信息
*/
*/
@
c
ommonDecorator
.
c
heckParams
([
'activityId'
])
@
checkParams
([
'activityId'
])
@
services
([
CommonUserService
])
@
services
([
CommonUserService
])
async
getShareInfo
(
async
getShareInfo
(
context
:
IContext
<
IParams
>
,
context
:
IContext
<
IParams
>
,
{
activityInfo
,
userInfo
}:
IControllerInfos
,
{
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
({
return
resultsModel
.
success
({
...
commonUserQueryDataByKeyResult1
...
commonUserQueryDataByKeyResult1
})
})
...
@@ -28,9 +28,9 @@ export default class ShareController {
...
@@ -28,9 +28,9 @@ export default class ShareController {
/**
/**
* 完成分享
* 完成分享
*/
*/
@
c
ommonDecorator
.
c
heckParams
([
'activityId'
,
'inviteId'
])
@
checkParams
([
'activityId'
,
'inviteId'
])
@
commonDecorator
.
registeInfos
([
'vipInfo'
])
@
registeInfos
([
'vipInfo'
])
@
commonDecorator
.
preCheck
([
commonUtilCheck
.
checkActivityTime
,
commonUtilCheck
.
checkInviteId
,
commonUtilCheck
.
checkNewVip
,
commonUtilCheck
.
checkHelpRecord
])
@
preCheck
([
checkActivityTime
,
checkInviteId
,
checkNewVip
,
checkHelpRecord
])
@
services
([
CommonTaskService
,
CommonStatService
])
@
services
([
CommonTaskService
,
CommonStatService
])
async
doHelp
(
async
doHelp
(
context
:
IContext
<
IParams
>
,
context
:
IContext
<
IParams
>
,
...
...
v2.0/src/controller/common/stat.controller.ts
View file @
67fec37f
/** @format */
/** @format */
import
commonDecorator
,
{
services
}
from
'../../decorator/common'
import
{
services
,
checkParams
}
from
'../../decorator/common'
import
commonUtilCheck
from
'../../utils/common/check'
import
commonUtilUpdate
from
'../../utils/common/update'
import
customDecorator
from
'../../decorator/custom'
import
customUtil
from
'../../utils/custom'
import
customUtil
from
'../../utils/custom'
import
{
resultsModel
}
from
'../../sdk'
import
{
resultsModel
}
from
'../../sdk'
import
{
CommonStatService
}
from
'../../service/common'
import
{
CommonStatService
}
from
'../../service/common'
export
default
class
StatController
{
export
default
class
StatController
{
/**
/**
* 增加埋点记录
* 增加埋点记录
*/
*/
@
c
ommonDecorator
.
c
heckParams
([
'activityId'
,
'type'
])
@
checkParams
([
'activityId'
,
'type'
])
@
services
([
CommonStatService
])
@
services
([
CommonStatService
])
async
addStat
(
async
addStat
(
context
:
IContext
<
IParams
>
,
context
:
IContext
<
IParams
>
,
{
activityInfo
,
userInfo
}:
IControllerInfos
,
{
activityInfo
,
userInfo
}:
IControllerInfos
,
[
commonStatService
]:
[
CommonStatService
]
,
[
commonStatService
]:
[
CommonStatService
]
)
{
)
{
const
commonStatAddStatResult1
=
await
commonStatService
.
addStat
(
context
.
data
.
type
,
userInfo
)
const
commonStatAddStatResult1
=
await
commonStatService
.
addStat
(
context
.
data
.
type
,
userInfo
)
return
resultsModel
.
success
({
return
resultsModel
.
success
({
...
@@ -28,15 +23,23 @@ export default class StatController {
...
@@ -28,15 +23,23 @@ export default class StatController {
/**
/**
* 统计数据
* 统计数据
*/
*/
@
c
ommonDecorator
.
c
heckParams
([
'activityId'
,
'startDay'
,
'endDay'
])
@
checkParams
([
'activityId'
,
'startDay'
,
'endDay'
])
@
services
([
CommonStatService
])
@
services
([
CommonStatService
])
async
getStats
(
async
getStats
(
context
:
IContext
<
IParams
>
,
context
:
IContext
<
IParams
>
,
{
activityInfo
,
userInfo
}:
IControllerInfos
,
{
activityInfo
,
userInfo
}:
IControllerInfos
,
[
commonStatService
]:
[
CommonStatService
]
,
[
commonStatService
]:
[
CommonStatService
]
)
{
)
{
const
commonStatGetStatsResult1
=
await
commonStatService
.
getStats
(
context
.
data
.
activityId
,
context
.
data
.
startDay
,
context
.
data
.
endDay
)
const
commonStatGetStatsResult1
=
await
commonStatService
.
getStats
(
const
commonStatBuildExcelResult2
=
await
commonStatService
.
buildExcel
(
context
.
data
.
startDay
,
context
.
data
.
endDay
,
commonStatGetStatsResult1
)
context
.
data
.
activityId
,
context
.
data
.
startDay
,
context
.
data
.
endDay
)
const
commonStatBuildExcelResult2
=
await
commonStatService
.
buildExcel
(
context
.
data
.
startDay
,
context
.
data
.
endDay
,
commonStatGetStatsResult1
)
return
resultsModel
.
success
({
return
resultsModel
.
success
({
...
commonStatBuildExcelResult2
...
commonStatBuildExcelResult2
})
})
...
...
v2.0/src/controller/common/task.controller.ts
View file @
67fec37f
/** @format */
/** @format */
import
commonDecorator
,
{
services
}
from
'../../decorator/common'
import
{
services
,
checkParams
,
registeInfos
,
preCheck
,
preUpdate
}
from
'../../decorator/common'
import
commonUtilCheck
from
'../../utils/common/check'
import
{
checkActivityTime
,
checkTaskLimit
,
checkExchangeCreditsTask
,
checkRemainTimes
}
from
'../../utils/common/check'
import
commonUtilUpdate
from
'../../utils/common/update'
import
{
updateVip
,
updateSignTask
,
updateOrderGoods
}
from
'../../utils/common/update'
import
customDecorator
from
'../../decorator/custom'
import
customUtil
from
'../../utils/custom'
import
customUtil
from
'../../utils/custom'
import
{
resultsModel
}
from
'../../sdk'
import
{
resultsModel
}
from
'../../sdk'
import
{
CommonTaskService
,
CommonBaseService
}
from
'../../service/common'
import
{
CommonTaskService
,
CommonBaseService
}
from
'../../service/common'
export
default
class
TaskController
{
export
default
class
TaskController
{
/**
/**
* 任务列表
* 任务列表
*/
*/
@
c
ommonDecorator
.
c
heckParams
([
'activityId'
])
@
checkParams
([
'activityId'
])
@
commonDecorator
.
registeInfos
([
'vipInfo'
])
@
registeInfos
([
'vipInfo'
])
@
commonDecorator
.
preCheck
([
commonUtilCheck
.
checkActivityTime
])
@
preCheck
([
checkActivityTime
])
@
commonDecorator
.
preUpdate
([
commonUtilUpdate
.
updateVip
,
commonUtilUpdate
.
updateSignTask
,
commonUtilUpdate
.
updateOrderGoods
])
@
preUpdate
([
updateVip
,
updateSignTask
,
updateOrderGoods
])
@
services
([
CommonTaskService
])
@
services
([
CommonTaskService
])
async
getTaskList
(
async
getTaskList
(
context
:
IContext
<
IParams
>
,
context
:
IContext
<
IParams
>
,
{
activityInfo
,
userInfo
,
vipInfo
}:
IControllerInfos
,
{
activityInfo
,
userInfo
,
vipInfo
}:
IControllerInfos
,
[
commonTaskService
]:
[
CommonTaskService
]
,
[
commonTaskService
]:
[
CommonTaskService
]
)
{
)
{
const
commonTaskInitTaskListResult1
=
await
commonTaskService
.
initTaskList
(
userInfo
,
activityInfo
)
const
commonTaskInitTaskListResult1
=
await
commonTaskService
.
initTaskList
(
userInfo
,
activityInfo
)
return
resultsModel
.
success
({
return
resultsModel
.
success
({
...
@@ -31,16 +28,20 @@ export default class TaskController {
...
@@ -31,16 +28,20 @@ export default class TaskController {
/**
/**
* 完成任务
* 完成任务
*/
*/
@
c
ommonDecorator
.
c
heckParams
([
'activityId'
,
'taskType'
])
@
checkParams
([
'activityId'
,
'taskType'
])
@
commonDecorator
.
registeInfos
([
'session'
])
@
registeInfos
([
'session'
])
@
commonDecorator
.
preCheck
([
commonUtilCheck
.
checkActivityTime
,
commonUtilCheck
.
checkTaskLimit
,
commonUtilCheck
.
checkExchangeCreditsTask
])
@
preCheck
([
checkActivityTime
,
checkTaskLimit
,
checkExchangeCreditsTask
])
@
services
([
CommonTaskService
])
@
services
([
CommonTaskService
])
async
doCompleteTask
(
async
doCompleteTask
(
context
:
IContext
<
IParams
>
,
context
:
IContext
<
IParams
>
,
{
activityInfo
,
userInfo
,
session
}:
IControllerInfos
,
{
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
({
return
resultsModel
.
success
({
...
commonTaskCompleteTaskResult1
...
commonTaskCompleteTaskResult1
})
})
...
@@ -48,15 +49,19 @@ export default class TaskController {
...
@@ -48,15 +49,19 @@ export default class TaskController {
/**
/**
* 领取任务奖励
* 领取任务奖励
*/
*/
@
c
ommonDecorator
.
c
heckParams
([
'activityId'
,
'taskType'
,
'rewardsKey'
])
@
checkParams
([
'activityId'
,
'taskType'
,
'rewardsKey'
])
@
commonDecorator
.
preCheck
([
commonUtilCheck
.
checkActivityTime
,
commonUtilCheck
.
checkRemainTimes
])
@
preCheck
([
checkActivityTime
,
checkRemainTimes
])
@
services
([
CommonTaskService
])
@
services
([
CommonTaskService
])
async
receiveTaskRewards
(
async
receiveTaskRewards
(
context
:
IContext
<
IParams
>
,
context
:
IContext
<
IParams
>
,
{
activityInfo
,
userInfo
}:
IControllerInfos
,
{
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
({
return
resultsModel
.
success
({
...
commonTaskReceiveTaskRewardsResult1
...
commonTaskReceiveTaskRewardsResult1
})
})
...
@@ -64,16 +69,19 @@ export default class TaskController {
...
@@ -64,16 +69,19 @@ export default class TaskController {
/**
/**
* 获取收藏商品列表
* 获取收藏商品列表
*/
*/
@
c
ommonDecorator
.
c
heckParams
([
'activityId'
,
'itemIds'
])
@
checkParams
([
'activityId'
,
'itemIds'
])
@
commonDecorator
.
registeInfos
([
'session'
])
@
registeInfos
([
'session'
])
@
services
([
CommonBaseService
,
CommonTaskService
])
@
services
([
CommonBaseService
,
CommonTaskService
])
async
getCollectGoodsList
(
async
getCollectGoodsList
(
context
:
IContext
<
IParams
>
,
context
:
IContext
<
IParams
>
,
{
activityInfo
,
userInfo
,
session
}:
IControllerInfos
,
{
activityInfo
,
userInfo
,
session
}:
IControllerInfos
,
[
commonBaseService
,
commonTaskService
]:
[
CommonBaseService
,
CommonTaskService
]
,
[
commonBaseService
,
commonTaskService
]:
[
CommonBaseService
,
CommonTaskService
]
)
{
)
{
const
commonBaseGetItemListByIdsResult1
=
await
commonBaseService
.
getItemListByIds
(
context
.
data
.
itemIds
,
session
)
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
({
return
resultsModel
.
success
({
...
commonTaskGetItemListWithCollectStatusResult2
...
commonTaskGetItemListWithCollectStatusResult2
})
})
...
...
v2.0/src/controller/common/user.controller.ts
View file @
67fec37f
/** @format */
/** @format */
import
commonDecorator
,
{
services
}
from
'../../decorator/common'
import
{
services
,
checkParams
}
from
'../../decorator/common'
import
commonUtilCheck
from
'../../utils/common/check'
import
commonUtilUpdate
from
'../../utils/common/update'
import
customDecorator
from
'../../decorator/custom'
import
customUtil
from
'../../utils/custom'
import
customUtil
from
'../../utils/custom'
import
{
resultsModel
}
from
'../../sdk'
import
{
resultsModel
}
from
'../../sdk'
import
{
CommonUserService
}
from
'../../service/common'
import
{
CommonUserService
}
from
'../../service/common'
export
default
class
UserController
{
export
default
class
UserController
{
/**
/**
* 获取会员信息
* 获取会员信息
*/
*/
@
c
ommonDecorator
.
c
heckParams
([
'activityId'
])
@
checkParams
([
'activityId'
])
@
services
([
CommonUserService
])
@
services
([
CommonUserService
])
async
getVipInfo
(
async
getVipInfo
(
context
:
IContext
<
IParams
>
,
context
:
IContext
<
IParams
>
,
{
activityInfo
,
userInfo
}:
IControllerInfos
,
{
activityInfo
,
userInfo
}:
IControllerInfos
,
[
commonUserService
]:
[
CommonUserService
]
,
[
commonUserService
]:
[
CommonUserService
]
)
{
)
{
const
commonUserGetShopVipResult1
=
await
commonUserService
.
getShopVip
(
context
,
activityInfo
)
const
commonUserGetShopVipResult1
=
await
commonUserService
.
getShopVip
(
context
,
activityInfo
)
return
resultsModel
.
success
({
return
resultsModel
.
success
({
...
@@ -28,15 +23,23 @@ export default class UserController {
...
@@ -28,15 +23,23 @@ export default class UserController {
/**
/**
* 获取排行榜
* 获取排行榜
*/
*/
@
c
ommonDecorator
.
c
heckParams
([
'activityId'
,
'key'
,
'timeKey'
,
'limit'
])
@
checkParams
([
'activityId'
,
'key'
,
'timeKey'
,
'limit'
])
@
services
([
CommonUserService
])
@
services
([
CommonUserService
])
async
getRankList
(
async
getRankList
(
context
:
IContext
<
IParams
>
,
context
:
IContext
<
IParams
>
,
{
activityInfo
,
userInfo
}:
IControllerInfos
,
{
activityInfo
,
userInfo
}:
IControllerInfos
,
[
commonUserService
]:
[
CommonUserService
]
,
[
commonUserService
]:
[
CommonUserService
]
)
{
)
{
const
commonUserGetMyRankInfoResult1
=
await
commonUserService
.
getMyRankInfo
(
context
.
data
.
key
,
context
.
data
.
timeKey
,
userInfo
)
const
commonUserGetMyRankInfoResult1
=
await
commonUserService
.
getMyRankInfo
(
const
commonUserGetRankResult2
=
await
commonUserService
.
getRank
(
context
.
data
.
key
,
context
.
data
.
timeKey
,
context
.
data
.
limit
)
context
.
data
.
key
,
context
.
data
.
timeKey
,
userInfo
)
const
commonUserGetRankResult2
=
await
commonUserService
.
getRank
(
context
.
data
.
key
,
context
.
data
.
timeKey
,
context
.
data
.
limit
)
return
resultsModel
.
success
({
return
resultsModel
.
success
({
...
commonUserGetMyRankInfoResult1
,
...
commonUserGetMyRankInfoResult1
,
...
commonUserGetRankResult2
...
commonUserGetRankResult2
...
...
v2.0/src/controller/custom/test1.controller.ts
View file @
67fec37f
/** @format */
/** @format */
import
commonDecorator
,
{
services
}
from
'../../decorator/common'
import
{
services
,
checkParams
}
from
'../../decorator/common'
import
commonUtilCheck
from
'../../utils/common/check'
import
{
test1
}
from
'../../decorator/custom'
import
commonUtilUpdate
from
'../../utils/common/update'
import
customDecorator
from
'../../decorator/custom'
import
customUtil
from
'../../utils/custom'
import
customUtil
from
'../../utils/custom'
import
{
resultsModel
}
from
'../../sdk'
import
{
resultsModel
}
from
'../../sdk'
import
{
CommonStatService
}
from
'../../service/common'
import
{
CommonStatService
}
from
'../../service/common'
import
{
CustomTestService
}
from
'../../service/custom'
import
{
CustomTestService
}
from
'../../service/custom'
export
default
class
Test1Controller
{
export
default
class
Test1Controller
{
/**
/**
* 增加埋点记录
* 增加埋点记录
*/
*/
@
c
ommonDecorator
.
c
heckParams
([
'activityId'
,
'type'
])
@
checkParams
([
'activityId'
,
'type'
])
@
customDecorator
.
test1
([
'tt'
])
@
test1
([
'tt'
])
@
services
([
CommonStatService
,
CustomTestService
])
@
services
([
CommonStatService
,
CustomTestService
])
async
addStat
(
async
addStat
(
context
:
IContext
<
IParams
>
,
context
:
IContext
<
IParams
>
,
{
activityInfo
,
userInfo
}:
IControllerInfos
,
{
activityInfo
,
userInfo
}:
IControllerInfos
,
[
commonStatService
,
customTestService
]:
[
CommonStatService
,
CustomTestService
]
,
[
commonStatService
,
customTestService
]:
[
CommonStatService
,
CustomTestService
]
)
{
)
{
const
commonStatAddStatResult1
=
await
commonStatService
.
addStat
(
context
.
data
.
type
,
userInfo
)
const
commonStatAddStatResult1
=
await
commonStatService
.
addStat
(
context
.
data
.
type
,
userInfo
)
const
customTestTest1Result2
=
await
customTestService
.
test1
()
const
customTestTest1Result2
=
await
customTestService
.
test1
()
...
@@ -33,15 +28,23 @@ export default class Test1Controller {
...
@@ -33,15 +28,23 @@ export default class Test1Controller {
/**
/**
* 统计数据
* 统计数据
*/
*/
@
c
ommonDecorator
.
c
heckParams
([
'activityId'
,
'startDay'
,
'endDay'
])
@
checkParams
([
'activityId'
,
'startDay'
,
'endDay'
])
@
services
([
CommonStatService
])
@
services
([
CommonStatService
])
async
getStats
(
async
getStats
(
context
:
IContext
<
IParams
>
,
context
:
IContext
<
IParams
>
,
{
activityInfo
,
userInfo
}:
IControllerInfos
,
{
activityInfo
,
userInfo
}:
IControllerInfos
,
[
commonStatService
]:
[
CommonStatService
]
,
[
commonStatService
]:
[
CommonStatService
]
)
{
)
{
const
commonStatGetStatsResult1
=
await
commonStatService
.
getStats
(
context
.
data
.
activityId
,
context
.
data
.
startDay
,
context
.
data
.
endDay
)
const
commonStatGetStatsResult1
=
await
commonStatService
.
getStats
(
const
commonStatBuildExcelResult2
=
await
commonStatService
.
buildExcel
(
context
.
data
.
startDay
,
context
.
data
.
endDay
,
commonStatGetStatsResult1
)
context
.
data
.
activityId
,
context
.
data
.
startDay
,
context
.
data
.
endDay
)
const
commonStatBuildExcelResult2
=
await
commonStatService
.
buildExcel
(
context
.
data
.
startDay
,
context
.
data
.
endDay
,
commonStatGetStatsResult1
)
return
resultsModel
.
success
({
return
resultsModel
.
success
({
...
commonStatBuildExcelResult2
...
commonStatBuildExcelResult2
})
})
...
...
v2.0/src/controller/custom/test2.controller.ts
View file @
67fec37f
/** @format */
/** @format */
import
commonDecorator
,
{
services
}
from
'../../decorator/common'
import
{
services
,
checkParams
}
from
'../../decorator/common'
import
commonUtilCheck
from
'../../utils/common/check'
import
commonUtilUpdate
from
'../../utils/common/update'
import
customDecorator
from
'../../decorator/custom'
import
customUtil
from
'../../utils/custom'
import
customUtil
from
'../../utils/custom'
import
{
resultsModel
}
from
'../../sdk'
import
{
resultsModel
}
from
'../../sdk'
import
{
CommonStatService
}
from
'../../service/common'
import
{
CommonStatService
}
from
'../../service/common'
export
default
class
Test2Controller
{
export
default
class
Test2Controller
{
/**
/**
* 增加埋点记录
* 增加埋点记录
*/
*/
@
c
ommonDecorator
.
c
heckParams
([
'activityId'
,
'type'
])
@
checkParams
([
'activityId'
,
'type'
])
@
services
([
CommonStatService
])
@
services
([
CommonStatService
])
async
addStat
(
async
addStat
(
context
:
IContext
<
IParams
>
,
context
:
IContext
<
IParams
>
,
{
activityInfo
,
userInfo
}:
IControllerInfos
,
{
activityInfo
,
userInfo
}:
IControllerInfos
,
[
commonStatService
]:
[
CommonStatService
]
,
[
commonStatService
]:
[
CommonStatService
]
)
{
)
{
const
commonStatAddStatResult1
=
await
commonStatService
.
addStat
(
context
.
data
.
type
,
userInfo
)
const
commonStatAddStatResult1
=
await
commonStatService
.
addStat
(
context
.
data
.
type
,
userInfo
)
return
resultsModel
.
success
({
return
resultsModel
.
success
({
...
@@ -28,15 +23,23 @@ export default class Test2Controller {
...
@@ -28,15 +23,23 @@ export default class Test2Controller {
/**
/**
* 统计数据
* 统计数据
*/
*/
@
c
ommonDecorator
.
c
heckParams
([
'activityId'
,
'startDay'
,
'endDay'
])
@
checkParams
([
'activityId'
,
'startDay'
,
'endDay'
])
@
services
([
CommonStatService
])
@
services
([
CommonStatService
])
async
getStats
(
async
getStats
(
context
:
IContext
<
IParams
>
,
context
:
IContext
<
IParams
>
,
{
activityInfo
,
userInfo
}:
IControllerInfos
,
{
activityInfo
,
userInfo
}:
IControllerInfos
,
[
commonStatService
]:
[
CommonStatService
]
,
[
commonStatService
]:
[
CommonStatService
]
)
{
)
{
const
commonStatGetStatsResult1
=
await
commonStatService
.
getStats
(
context
.
data
.
activityId
,
context
.
data
.
startDay
,
context
.
data
.
endDay
)
const
commonStatGetStatsResult1
=
await
commonStatService
.
getStats
(
const
commonStatBuildExcelResult2
=
await
commonStatService
.
buildExcel
(
context
.
data
.
startDay
,
context
.
data
.
endDay
,
commonStatGetStatsResult1
)
context
.
data
.
activityId
,
context
.
data
.
startDay
,
context
.
data
.
endDay
)
const
commonStatBuildExcelResult2
=
await
commonStatService
.
buildExcel
(
context
.
data
.
startDay
,
context
.
data
.
endDay
,
commonStatGetStatsResult1
)
return
resultsModel
.
success
({
return
resultsModel
.
success
({
...
commonStatBuildExcelResult2
...
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