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
9f2a025a
Commit
9f2a025a
authored
Nov 03, 2020
by
maggie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save
parent
0e1d8117
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
296 additions
and
0 deletions
+296
-0
config.json
v2.0/ compileServer/config.json
+70
-0
generate.js
v2.0/ compileServer/generate.js
+116
-0
gulpfile.js
v2.0/ compileServer/gulpfile.js
+34
-0
package.json
v2.0/ compileServer/package.json
+20
-0
custom.controller.njk
...compileServer/templates/controllers/custom.controller.njk
+0
-0
custom.decorator.njk
.../ compileServer/templates/decorators/custom.decorator.njk
+9
-0
index.njk
v2.0/ compileServer/templates/index.njk
+0
-0
custom.service.njk
v2.0/ compileServer/templates/services/custom.service.njk
+47
-0
custom.util.njk
v2.0/ compileServer/templates/utils/custom.util.njk
+0
-0
No files found.
v2.0/ compileServer/config.json
0 → 100644
View file @
9f2a025a
{
"controllers"
:
{
"common"
:
{
"awards"
:
{
"getMyPrizeList"
:
{
"decorators"
:
[
{
"type"
:
"common"
,
"name"
:
"checkParams"
,
"params"
:
[
"activityId"
]
},
{
"type"
:
"common"
,
"name"
:
"registeInfos"
,
"params"
:
[
"activityInfo"
]
}
]
},
"receiveObjectPrize"
:
{
"decorators"
:
[
{
"type"
:
"common"
,
"name"
:
"checkParams"
,
"params"
:
[
"activityId"
,
"id"
,
"name"
,
"phone"
,
"province"
,
"city"
,
"addressDetail"
,
"streetName"
]
},
{
"type"
:
"common"
,
"name"
:
"registeInfos"
,
"params"
:
[
"activityInfo"
]
},
{
"type"
:
"common"
,
"name"
:
"preCheck"
,
"params"
:
[
{
"type"
:
"common"
,
"behave"
:
"check"
,
"name"
:
"checkAwardReceiveExpired"
},
{
"type"
:
"common"
,
"behave"
:
"check"
,
"name"
:
"checkReceivePrize"
,
"params"
:
{
"prizeType"
:
5
}
}
]
}
]
}
}
}
}
}
\ No newline at end of file
v2.0/ compileServer/generate.js
0 → 100644
View file @
9f2a025a
/** @format */
const
fs
=
require
(
'fs-extra'
)
const
CodeGenerateConfig
=
require
(
'./config'
)
const
Model
=
CodeGenerateConfig
.
model
const
run
=
async
(
gulp
,
nunjucksRender
,
rename
,
nunjucksRenderConfig
)
=>
{
nunjucksRenderConfig
.
data
=
{
model
:
{},
config
:
111
}
}
export
default
{
run
}
// module.exports = {
// run: async function(gulp, nunjucksRender, rename, nunjucksRenderConfig) {
// nunjucksRenderConfig.data = {
// model: CodeGenerateConfig.model,
// config: CodeGenerateConfig.config
// }
// const ServerProjectRootPath = nunjucksRenderConfig.ServerFullPath
// //server
// const serverTemplatePath = 'templates/taobao_mini'
// const customService = {}
// for(let controller in Model) {
// const fnServices = {}
// for(let fn in Model[controller]) {
// fnServices[fn] = {}
// for(let decorator of Model[controller][fn].decorator) {
// if(decorator.type === 'custom') {
// await gulp.src(`${serverTemplatePath}/decorator/decorator.njk`)
// .pipe(nunjucksRender({
// ...nunjucksRenderConfig,
// data: {
// model: decorator,
// }
// }))
// .pipe(rename(`${decorator.name}.ts`))
// .pipe(
// gulp.dest(
// ServerProjectRootPath +
// CodeGenerateConfig.config.CustomDecoratorRelativePath
// )
// )
// }
// }
// for(let main of Model[controller][fn].main) {
// if(main.type === 'custom') {
// if(!customService[main.service]) {
// customService[main.service] = {}
// }
// if(!customService[main.service][main.function]) {
// customService[main.service][main.function] = main
// }
// }
// fnServices[fn][`${main.type}_${main.service}`] = main
// }
// }
// // 编译common/controller
// await gulp.src(`${serverTemplatePath}/controller/${controller}.controller.njk`)
// .pipe(nunjucksRender({
// ...nunjucksRenderConfig,
// data: {
// model: CodeGenerateConfig.model[controller],
// config: CodeGenerateConfig.config,
// services: fnServices
// }
// }))
// .pipe(rename(`${controller}.controller.ts`))
// .pipe(
// gulp.dest(
// ServerProjectRootPath +
// CodeGenerateConfig.config.ControllerRelativePath + 'common/'
// )
// )
// }
// // 编译custom/service
// for(let service in customService) {
// await gulp.src(`${serverTemplatePath}/service/service.njk`)
// .pipe(nunjucksRender({
// ...nunjucksRenderConfig,
// data: {
// model: {
// name: service,
// functions: customService[service]
// },
// }
// }))
// .pipe(rename(`${service}.service.ts`))
// .pipe(
// gulp.dest(
// ServerProjectRootPath +
// CodeGenerateConfig.config.CustomServiceRelativePath
// )
// )
// }
// await gulp.src(`${serverTemplatePath}/service/index.njk`)
// .pipe(nunjucksRender({
// ...nunjucksRenderConfig,
// data: {
// model: {
// customService
// }
// }
// }))
// .pipe(rename(`index.ts`))
// .pipe(
// gulp.dest(
// ServerProjectRootPath +
// CodeGenerateConfig.config.CustomServiceRelativePath
// )
// )
// }
// }
\ No newline at end of file
v2.0/ compileServer/gulpfile.js
0 → 100644
View file @
9f2a025a
/** @format */
const
gulp
=
require
(
'gulp'
)
const
rename
=
require
(
'gulp-rename'
)
const
nunjucksRender
=
require
(
'gulp-nunjucks-render'
)
const
codeGenerate
=
require
(
'./templates/generate'
)
var
jsScript
=
'node'
if
(
process
.
env
.
npm_config_argv
!==
undefined
&&
process
.
env
.
npm_config_argv
.
indexOf
(
'debug'
)
>
0
)
{
jsScript
=
'node debug'
}
const
ServerFullPath
=
require
(
'./package.json'
).
ServerFullPath
//const FrontendFullPath = require('./package.json').FrontendFullPath;
const
nunjucksRenderConfig
=
{
path
:
'templates/server'
,
envOptions
:
{
tags
:
{
blockStart
:
'<%'
,
blockEnd
:
'%>'
,
variableStart
:
'<$'
,
variableEnd
:
'$>'
,
commentStart
:
'<#'
,
commentEnd
:
'#>'
}
},
ext
:
'.ts'
,
ServerFullPath
}
gulp
.
task
(
'code'
,
function
()
{
require
(
'events'
).
EventEmitter
.
defaultMaxListeners
=
0
return
codeGenerate
.
run
(
gulp
,
nunjucksRender
,
rename
,
nunjucksRenderConfig
)
})
v2.0/ compileServer/package.json
0 → 100644
View file @
9f2a025a
{
"name"
:
"nunjucks-test"
,
"version"
:
"1.0.0"
,
"description"
:
""
,
"main"
:
"index.js"
,
"scripts"
:
{
"test"
:
"echo
\"
Error: no test specified
\"
&& exit 1"
},
"author"
:
""
,
"license"
:
"ISC"
,
"ServerFullPath"
:
"lazy-mock"
,
"devDependencies"
:
{
"gulp"
:
"^4.0.2"
,
"gulp-nunjucks-render"
:
"^2.2.3"
,
"gulp-rename"
:
"^2.0.0"
},
"dependencies"
:
{
"fs-extra"
:
"^9.0.1"
}
}
v2.0/ compileServer/templates/controllers/custom.controller.njk
0 → 100644
View file @
9f2a025a
v2.0/ compileServer/templates/decorators/custom.decorator.njk
0 → 100644
View file @
9f2a025a
/** @format */
export const <$ decoratorName $> = (target: any, name: string, descriptor: PropertyDescriptor) => {
const method = descriptor.value
descriptor.value = async function (...args: any[]) {
const [context, otherArgs = {}] = args
return method.apply(this, [context, { ...otherArgs }])
}
}
\ No newline at end of file
v2.0/ compileServer/templates/index.njk
0 → 100644
View file @
9f2a025a
v2.0/ compileServer/templates/services/custom.service.njk
0 → 100644
View file @
9f2a025a
/**
* @format
*/
export default class <$ serviceName $> {
context: IContext<any>
constructor(context: IContext<any>) {
this.context = context
}
/**
* @desc 活动基本信息
* @param {活动id} activityId
* @returns 返回活动详情,若不存在活动,返回为null
*/
async getBaseInfo(activityId: string): Promise<IActivityInfo> {
return await this.activitydao.findOne({ _id: activityId, deleteStatus: ACTIVITY_STATUS.NORMAL })
}
/**
*
* 根据itemIds获取商品列表
*
* @param {string} itemIds
* @param {string} session
* @return {Array}
* @memberof BaseService
*/
async getItemListByIds(itemIds: string, session: string): Promise<Array<ITaoBaoItems>> {
const GOODSINFO =
'detail_url,approve_status,num_iid,title,nick,type,cid,pic_url,num,props,valid_thru,list_time,desc,price,has_discount,has_invoice,has_warranty,has_showcase,modified,delist_time,postage_id,seller_cids,outer_id,sold_quantity'
const result = await TBAPIS.getItemListByItemIds(this.context, session, itemIds, { fields: GOODSINFO })
const items = result?.items?.item || []
const list = items.map(
(v: { num_iid: string; title: string; price: string; detail_url: string; pic_url: string; desc: string }) => {
return {
itemId: v.num_iid,
name: v.title,
price: v.price,
url: v.detail_url,
image: v.pic_url,
desc: v.desc
}
}
)
return list
}
}
\ No newline at end of file
v2.0/ compileServer/templates/utils/custom.util.njk
0 → 100644
View file @
9f2a025a
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