-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
129 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
#!lang:ts#!name:API和定义文件 | ||
#!target:vue/{{name_path .table.Name}}/api.ts | ||
import request from '@/utils/request' | ||
{{$columns := .columns}} | ||
{{$path := join .global.base_path (name_path .table.Name) "/"}}\ | ||
|
||
// {{.table.Comment}}对象 | ||
export interface I{{.table.Title}} { | ||
{{range $i,$c := .columns}}// {{$c.Comment}} | ||
{{$c.Prop}}: {{type "ts" $c.Type}}{{if not (is_last $i $columns)}},{{end}} | ||
{{end}} | ||
} | ||
|
||
export const default{{.table.Title}}:()=>I{{.table.Title}} = () => { | ||
return { | ||
{{range $i,$c := .columns}} | ||
{{if eq $c.Render.Element "radio"}}{{$c.Prop}}: {{default "ts" $c.Type}} + 1, | ||
{{else}}{{$c.Prop}}: {{default "ts" $c.Type}}{{if not (is_last $i $columns)}},{{end}}\ | ||
{{end}}{{end}} | ||
} | ||
} | ||
|
||
export const get{{.table.Title}} = (id: any, params: any = {}) => request({ | ||
url: `{{$path}}/${id}`, | ||
method: 'GET', | ||
params: { ...params } | ||
}) | ||
|
||
export const query{{.table.Title}}List = (params: any = {}) => request({ | ||
url: '{{$path}}', | ||
method: 'GET', | ||
params: { ...params } | ||
}) | ||
|
||
export const create{{.table.Title}} = (data: any) => request({ | ||
url: '{{$path}}', | ||
method: 'POST', | ||
data | ||
}) | ||
|
||
export const update{{.table.Title}} = (id: any, data: any) => request({ | ||
url: `{{$path}}/${id}`, | ||
method: 'PUT', | ||
data | ||
}) | ||
|
||
export const delete{{.table.Title}} = (id: any) => request({ | ||
url: `{{$path}}/${id}`, | ||
method: 'DELETE' | ||
}) | ||
|
||
export const batchDelete{{.table.Title}} = (arr: any[]) => request({ | ||
url: '{{$path}}', | ||
method: 'DELETE', | ||
data: arr | ||
}) | ||
|
||
export const queryPaging{{.table.Title}} = (page:number, size:number, params: any) => request({ | ||
url: '{{$path}}/paging', | ||
method: 'GET', | ||
params: { page, size,...params } | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.