Skip to content

Commit

Permalink
fix: script 生成测略
Browse files Browse the repository at this point in the history
  • Loading branch information
2637309949 committed Oct 21, 2020
1 parent b7aca5e commit 0bd6cf1
Show file tree
Hide file tree
Showing 34 changed files with 1,671 additions and 547 deletions.
6 changes: 3 additions & 3 deletions cmd/dolphin/gen/template/assets.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 18 additions & 6 deletions cmd/dolphin/gen/template/assets/apis.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,34 @@ const axios = require('@/utils/request').default
{{range .Controller.APIS}}
{{- $tn := .ToUpperCase .Name}}
// {{.LcFirst $tn}} {{.Desc}}
module.exports.{{.LcFirst $tn}} = (data) => {
module.exports.{{.LcFirst $tn}} = (data = {}, opt = {}) => {
{{- if eq .Method "get"}}
let url = '{{- if and (ne $.Controller.Prefix "") (ne $.Controller.Prefix "/")}}{{$.Controller.Prefix}}{{- else if ne $.Controller.Prefix "/"}}{{$.Viper.GetString "http.prefix"}}{{- end}}{{.APIPrefix .Version}}{{.APIPath $.Controller.Name .Name .Path}}?'
let url = opt.url || '{{- if and (ne $.Controller.Prefix "") (ne $.Controller.Prefix "/")}}{{$.Controller.Prefix}}{{- else if ne $.Controller.Prefix "/"}}{{$.Viper.GetString "http.prefix"}}{{- end}}{{.APIPrefix .Version}}{{.APIPath $.Controller.Name .Name .Path}}?'
for (var key in data) {
url += key + '=' + encodeURIComponent(data[key]) + '&'
}
return axios({
url: url,
method: '{{.Method}}'
method: '{{.Method}}',
...opt
})
{{- else}}
const url = '{{- if and (ne $.Controller.Prefix "") (ne $.Controller.Prefix "/")}}{{$.Controller.Prefix}}{{- else if ne $.Controller.Prefix "/"}}{{$.Viper.GetString "http.prefix"}}{{- end}}{{.APIPrefix .Version}}{{.APIPath $.Controller.Name .Name .Path}}'
{{- else }}
const url = opt.url || '{{- if and (ne $.Controller.Prefix "") (ne $.Controller.Prefix "/")}}{{$.Controller.Prefix}}{{- else if ne $.Controller.Prefix "/"}}{{$.Viper.GetString "http.prefix"}}{{- end}}{{.APIPrefix .Version}}{{.APIPath $.Controller.Name .Name .Path}}'
if ((opt.url || '{{.Method}}') === 'get') {
for (var key in data) {
url += key + '=' + encodeURIComponent(data[key]) + '&'
}
return axios({
url: url,
method: 'get',
...opt
})
}
return axios({
url: url,
method: '{{.Method}}',
data
data,
...opt
})
{{- end}}
}
Expand Down
72 changes: 54 additions & 18 deletions platform/script/apis/sys_app_fun.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,68 +2,104 @@
const axios = require('@/utils/request').default

// add 添加APP功能
module.exports.add = (data) => {
const url = '/api/sys/app/fun/add'
module.exports.add = (data = {}, opt = {}) => {
const url = opt.url || '/api/sys/app/fun/add'
if ((opt.url || 'post') === 'get') {
for (var key in data) {
url += key + '=' + encodeURIComponent(data[key]) + '&'
}
return axios({
url: url,
method: 'get',
...opt
})
}
return axios({
url: url,
method: 'post',
data
data,
...opt
})
}

// del 删除APP功能
module.exports.del = (data) => {
const url = '/api/sys/app/fun/del'
module.exports.del = (data = {}, opt = {}) => {
const url = opt.url || '/api/sys/app/fun/del'
if ((opt.url || 'delete') === 'get') {
for (var key in data) {
url += key + '=' + encodeURIComponent(data[key]) + '&'
}
return axios({
url: url,
method: 'get',
...opt
})
}
return axios({
url: url,
method: 'delete',
data
data,
...opt
})
}

// update 更新APP功能
module.exports.update = (data) => {
const url = '/api/sys/app/fun/update'
module.exports.update = (data = {}, opt = {}) => {
const url = opt.url || '/api/sys/app/fun/update'
if ((opt.url || 'put') === 'get') {
for (var key in data) {
url += key + '=' + encodeURIComponent(data[key]) + '&'
}
return axios({
url: url,
method: 'get',
...opt
})
}
return axios({
url: url,
method: 'put',
data
data,
...opt
})
}

// page APP功能分页查询
module.exports.page = (data) => {
let url = '/api/sys/app/fun/page?'
module.exports.page = (data = {}, opt = {}) => {
let url = opt.url || '/api/sys/app/fun/page?'
for (var key in data) {
url += key + '=' + encodeURIComponent(data[key]) + '&'
}
return axios({
url: url,
method: 'get'
method: 'get',
...opt
})
}

// tree 菜单树形结构
module.exports.tree = (data) => {
let url = '/api/sys/app/fun/tree?'
module.exports.tree = (data = {}, opt = {}) => {
let url = opt.url || '/api/sys/app/fun/tree?'
for (var key in data) {
url += key + '=' + encodeURIComponent(data[key]) + '&'
}
return axios({
url: url,
method: 'get'
method: 'get',
...opt
})
}

// get 获取APP功能信息
module.exports.get = (data) => {
let url = '/api/sys/app/fun/get?'
module.exports.get = (data = {}, opt = {}) => {
let url = opt.url || '/api/sys/app/fun/get?'
for (var key in data) {
url += key + '=' + encodeURIComponent(data[key]) + '&'
}
return axios({
url: url,
method: 'get'
method: 'get',
...opt
})
}

65 changes: 50 additions & 15 deletions platform/script/apis/sys_area.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,56 +2,91 @@
const axios = require('@/utils/request').default

// add 添加区域
module.exports.add = (data) => {
const url = '/api/sys/area/add'
module.exports.add = (data = {}, opt = {}) => {
const url = opt.url || '/api/sys/area/add'
if ((opt.url || 'post') === 'get') {
for (var key in data) {
url += key + '=' + encodeURIComponent(data[key]) + '&'
}
return axios({
url: url,
method: 'get',
...opt
})
}
return axios({
url: url,
method: 'post',
data
data,
...opt
})
}

// del 删除区域
module.exports.del = (data) => {
const url = '/api/sys/area/del'
module.exports.del = (data = {}, opt = {}) => {
const url = opt.url || '/api/sys/area/del'
if ((opt.url || 'delete') === 'get') {
for (var key in data) {
url += key + '=' + encodeURIComponent(data[key]) + '&'
}
return axios({
url: url,
method: 'get',
...opt
})
}
return axios({
url: url,
method: 'delete',
data
data,
...opt
})
}

// update 更新区域
module.exports.update = (data) => {
const url = '/api/sys/area/update'
module.exports.update = (data = {}, opt = {}) => {
const url = opt.url || '/api/sys/area/update'
if ((opt.url || 'put') === 'get') {
for (var key in data) {
url += key + '=' + encodeURIComponent(data[key]) + '&'
}
return axios({
url: url,
method: 'get',
...opt
})
}
return axios({
url: url,
method: 'put',
data
data,
...opt
})
}

// page 区域分页查询
module.exports.page = (data) => {
let url = '/api/sys/area/page?'
module.exports.page = (data = {}, opt = {}) => {
let url = opt.url || '/api/sys/area/page?'
for (var key in data) {
url += key + '=' + encodeURIComponent(data[key]) + '&'
}
return axios({
url: url,
method: 'get'
method: 'get',
...opt
})
}

// get 获取区域信息
module.exports.get = (data) => {
let url = '/api/sys/area/get?'
module.exports.get = (data = {}, opt = {}) => {
let url = opt.url || '/api/sys/area/get?'
for (var key in data) {
url += key + '=' + encodeURIComponent(data[key]) + '&'
}
return axios({
url: url,
method: 'get'
method: 'get',
...opt
})
}

Loading

0 comments on commit 0bd6cf1

Please sign in to comment.