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
7248fe8e
Commit
7248fe8e
authored
Nov 06, 2020
by
maggie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
导出接口
parent
897acef5
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
16 deletions
+30
-16
generate.js
v2.0/compileServer/generate.js
+13
-16
controller.export.njk
v2.0/compileServer/templates/controller.export.njk
+17
-0
No files found.
v2.0/compileServer/generate.js
View file @
7248fe8e
...
@@ -18,22 +18,6 @@ const controllerImport = (controller = {}) => {
...
@@ -18,22 +18,6 @@ const controllerImport = (controller = {}) => {
}
}
const
run
=
async
(
gulp
,
nunjucksRender
,
rename
,
nunjucksRenderConfig
)
=>
{
const
run
=
async
(
gulp
,
nunjucksRender
,
rename
,
nunjucksRenderConfig
)
=>
{
// //生成控制器service
// const controllerServices = {
// common: {},
// custom: {}
// }
// for (let customController in config.controllers.common) {
// controllerServices.common[commonController] = {}
// for (let fn in config.controllers.common[commonController]) {
// for (let main of config.controllers.common[commonController][fn].main) {
// if (!controllerServices.common[commonController][main.type]) {
// controllerServices.common[commonController][main.type] = {}
// }
// controllerServices.common[commonController][main.type][main.service] = true
// }
// }
// }
//编译controller.common
//编译controller.common
for
(
let
commonController
in
config
.
controllers
.
common
)
{
for
(
let
commonController
in
config
.
controllers
.
common
)
{
await
gulp
await
gulp
...
@@ -68,6 +52,19 @@ const run = async (gulp, nunjucksRender, rename, nunjucksRenderConfig) => {
...
@@ -68,6 +52,19 @@ const run = async (gulp, nunjucksRender, rename, nunjucksRenderConfig) => {
.
pipe
(
rename
(
`
${
customController
}
.controller.ts`
))
.
pipe
(
rename
(
`
${
customController
}
.controller.ts`
))
.
pipe
(
gulp
.
dest
(
nunjucksRenderConfig
.
ServerFullPath
+
'/controller/custom'
))
.
pipe
(
gulp
.
dest
(
nunjucksRenderConfig
.
ServerFullPath
+
'/controller/custom'
))
}
}
//接口导出
await
gulp
.
src
(
`
${
serverTemplatePath
}
/controller.export.njk`
)
.
pipe
(
nunjucksRender
({
...
nunjucksRenderConfig
,
data
:
{
controllers
:
config
.
controllers
}
})
)
.
pipe
(
rename
(
`index.ts`
))
.
pipe
(
gulp
.
dest
(
nunjucksRenderConfig
.
ServerFullPath
))
}
}
module
.
exports
=
{
module
.
exports
=
{
...
...
v2.0/compileServer/templates/controller.export.njk
0 → 100644
View file @
7248fe8e
{%- for type, type_item in controllers -%}
{%- for controller, controller_item in type_item %}
import {{type | capitalize}}{{controller | capitalize}}Controller from './controller/{{type}}/{{controller}}.controller'
const {{type | capitalize}}{{controller | capitalize}}ControllerInstance = new {{type | capitalize}}{{controller | capitalize}}Controller()
{%- endfor -%}
{%- endfor %}
export default {
{%- for type, type_item in controllers -%}
{%- for controller, controller_item in type_item -%}
{%- for function, fucntion_item in controller_item %}
{{type}}{{controller | capitalize}}{{function | capitalize}}: {{type | capitalize}}{{controller | capitalize}}ControllerInstance.{{function}}
{%-if loop.last-%}{%else%},{%-endif-%}
{%- endfor -%}
{%- endfor -%}
{%- endfor %}
}
\ No newline at end of file
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