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
f58b6761
Commit
f58b6761
authored
Nov 06, 2020
by
maggie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save
parent
ec44152d
Changes
14
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
112 additions
and
0 deletions
+112
-0
config.json
v2.0/compileServer/config.json
+7
-0
generate.js
v2.0/compileServer/generate.js
+48
-0
controller.njk
v2.0/compileServer/templates/controller.njk
+1
-0
decorator.export.njk
v2.0/compileServer/templates/decorator.export.njk
+13
-0
decorator.njk
v2.0/compileServer/templates/decorator.njk
+14
-0
util.export.njk
v2.0/compileServer/templates/util.export.njk
+0
-0
util.njk
v2.0/compileServer/templates/util.njk
+0
-0
stat.controller.ts
v2.0/src/controller/common/stat.controller.ts
+1
-0
task.controller.ts
v2.0/src/controller/common/task.controller.ts
+1
-0
user.controller.ts
v2.0/src/controller/common/user.controller.ts
+2
-0
test1.controller.ts
v2.0/src/controller/custom/test1.controller.ts
+1
-0
test2.controller.ts
v2.0/src/controller/custom/test2.controller.ts
+1
-0
index.ts
v2.0/src/decorator/custom/index.ts
+9
-0
test.ts
v2.0/src/decorator/custom/test.ts
+14
-0
No files found.
v2.0/compileServer/config.json
View file @
f58b6761
...
...
@@ -18,6 +18,13 @@
"params"
:
[
"session"
]
},
{
"type"
:
"custom"
,
"name"
:
"test"
,
"params"
:
[
"tt"
]
}
],
"main"
:
[
...
...
v2.0/compileServer/generate.js
View file @
f58b6761
...
...
@@ -17,7 +17,55 @@ const controllerImport = (controller = {}) => {
return
result
}
const
customFileMap
=
(
controllers
=
{})
=>
{
const
result
=
{
decorators
:
{},
utils
:
{},
services
:
{}
}
for
(
let
controllerType
in
controllers
)
{
for
(
let
controller
in
controllers
[
controllerType
])
{
for
(
let
fn
in
controllers
[
controllerType
][
controller
])
{
for
(
let
decorator
of
controllers
[
controllerType
][
controller
][
fn
].
decorators
)
{
if
(
decorator
.
type
===
'custom'
)
{
result
.
decorators
[
decorator
.
name
]
=
true
}
}
}
}
}
return
result
}
const
run
=
async
(
gulp
,
nunjucksRender
,
rename
,
nunjucksRenderConfig
)
=>
{
//编译自定义文件
const
{
decorators
}
=
customFileMap
(
config
.
controllers
)
for
(
let
decorator
in
decorators
)
{
await
gulp
.
src
(
`
${
serverTemplatePath
}
/decorator.njk`
)
.
pipe
(
nunjucksRender
({
...
nunjucksRenderConfig
,
data
:
{
name
:
decorator
}
})
)
.
pipe
(
rename
(
`
${
decorator
}
.ts`
))
.
pipe
(
gulp
.
dest
(
nunjucksRenderConfig
.
ServerFullPath
+
'/decorator/custom'
))
}
await
gulp
.
src
(
`
${
serverTemplatePath
}
/decorator.export.njk`
)
.
pipe
(
nunjucksRender
({
...
nunjucksRenderConfig
,
data
:
{
decorators
}
})
)
.
pipe
(
rename
(
`index.ts`
))
.
pipe
(
gulp
.
dest
(
nunjucksRenderConfig
.
ServerFullPath
+
'/decorator/custom'
))
//编译controller.common
for
(
let
commonController
in
config
.
controllers
.
common
)
{
await
gulp
...
...
v2.0/compileServer/templates/controller.njk
View file @
f58b6761
...
...
@@ -4,6 +4,7 @@
import commonDecorator, { services } from '../../decorator/common'
import commonUtilCheck from '../../utils/common/check'
import commonUtilUpdate from '../../utils/common/update'
import customDecorator from '../../decorator/custom'
import { resultsModel } from '../../sdk'
{{-macro.genControllerService(service)-}}
...
...
v2.0/compileServer/templates/decorator.export.njk
0 → 100644
View file @
f58b6761
/** @format */
{%for decorator, decorator_item in decorators-%}
import {{decorator}} from './{{decorator}}'
{%-endfor%}
const custom = {
{%-for decorator, decorator_item in decorators%}
{{decorator}}{%if loop.last%}{%else%},{%endif%}
{%-endfor%}
}
export default custom
v2.0/compileServer/templates/decorator.njk
0 → 100644
View file @
f58b6761
/** @format */
import { resultsModel } from '../../sdk'
import { CODE_TYPES } from '../../constants'
export default function {{name}}(params) {
return function (target: Object, name: string, descriptor: PropertyDescriptor) {
const method = descriptor.value
descriptor.value = function (...args: any[]) {
const [context, otherArgs = {}] = args
return method.apply(target, [context, { ...otherArgs }])
}
}
}
v2.0/compileServer/templates/util.export.njk
0 → 100644
View file @
f58b6761
v2.0/compileServer/templates/util.njk
0 → 100644
View file @
f58b6761
v2.0/src/controller/common/stat.controller.ts
View file @
f58b6761
...
...
@@ -2,6 +2,7 @@
import
commonDecorator
,
{
services
}
from
'../../decorator/common'
import
commonUtilCheck
from
'../../utils/common/check'
import
commonUtilUpdate
from
'../../utils/common/update'
import
customDecorator
from
'../../decorator/custom'
import
{
resultsModel
}
from
'../../sdk'
import
{
StatService
}
from
'../../service'
export
default
class
StatController
{
...
...
v2.0/src/controller/common/task.controller.ts
View file @
f58b6761
...
...
@@ -2,6 +2,7 @@
import
commonDecorator
,
{
services
}
from
'../../decorator/common'
import
commonUtilCheck
from
'../../utils/common/check'
import
commonUtilUpdate
from
'../../utils/common/update'
import
customDecorator
from
'../../decorator/custom'
import
{
resultsModel
}
from
'../../sdk'
import
{
TaskService
,
BaseService
}
from
'../../service'
export
default
class
TaskController
{
...
...
v2.0/src/controller/common/user.controller.ts
View file @
f58b6761
...
...
@@ -2,6 +2,7 @@
import
commonDecorator
,
{
services
}
from
'../../decorator/common'
import
commonUtilCheck
from
'../../utils/common/check'
import
commonUtilUpdate
from
'../../utils/common/update'
import
customDecorator
from
'../../decorator/custom'
import
{
resultsModel
}
from
'../../sdk'
import
{
UserService
}
from
'../../service'
export
default
class
UserController
{
...
...
@@ -10,6 +11,7 @@ export default class UserController {
*/
@
commonDecorator
.
checkParams
([
'activityId'
])
@
commonDecorator
.
registeInfos
([
'session'
])
@
customDecorator
.
test
([
'tt'
])
@
services
([
UserService
])
async
getVipInfo
(
context
:
IContext
<
IParams
>
,
...
...
v2.0/src/controller/custom/test1.controller.ts
View file @
f58b6761
...
...
@@ -2,6 +2,7 @@
import
commonDecorator
,
{
services
}
from
'../../decorator/common'
import
commonUtilCheck
from
'../../utils/common/check'
import
commonUtilUpdate
from
'../../utils/common/update'
import
customDecorator
from
'../../decorator/custom'
import
{
resultsModel
}
from
'../../sdk'
import
{
StatService
}
from
'../../service'
export
default
class
Test1Controller
{
...
...
v2.0/src/controller/custom/test2.controller.ts
View file @
f58b6761
...
...
@@ -2,6 +2,7 @@
import
commonDecorator
,
{
services
}
from
'../../decorator/common'
import
commonUtilCheck
from
'../../utils/common/check'
import
commonUtilUpdate
from
'../../utils/common/update'
import
customDecorator
from
'../../decorator/custom'
import
{
resultsModel
}
from
'../../sdk'
import
{
StatService
}
from
'../../service'
export
default
class
Test2Controller
{
...
...
v2.0/src/decorator/custom/index.ts
0 → 100644
View file @
f58b6761
/** @format */
import
test
from
'./test'
const
custom
=
{
test
}
export
default
custom
v2.0/src/decorator/custom/test.ts
0 → 100644
View file @
f58b6761
/** @format */
import
{
resultsModel
}
from
'../../sdk'
import
{
CODE_TYPES
}
from
'../../constants'
export
default
function
test
(
params
)
{
return
function
(
target
:
Object
,
name
:
string
,
descriptor
:
PropertyDescriptor
)
{
const
method
=
descriptor
.
value
descriptor
.
value
=
function
(...
args
:
any
[])
{
const
[
context
,
otherArgs
=
{}]
=
args
return
method
.
apply
(
target
,
[
context
,
{
...
otherArgs
}])
}
}
}
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