签入脚本
This commit is contained in:
@@ -0,0 +1,159 @@
|
||||
package v1
|
||||
|
||||
import (
|
||||
{{- if .HasImport}}
|
||||
"github.com/gogf/gf/v2/net/ghttp"
|
||||
{{- end}}
|
||||
{{- if .NeedGtime}}
|
||||
"github.com/gogf/gf/v2/os/gtime"
|
||||
{{- end}}
|
||||
"github.com/gogf/gf/v2/util/gmeta"
|
||||
)
|
||||
|
||||
// ============================== {{.ModuleComment}}模块({{.TableNameFull}}) ==============================
|
||||
|
||||
// {{.ModelClass}}Item {{.ModuleComment}}行数据
|
||||
// 用于分页列表等场景的基础信息
|
||||
type {{.ModelClass}}Item struct {
|
||||
{{- range .ListFields}}
|
||||
{{.CamelExport}} {{.GoType}} `json:"{{.CamelName}}"` // {{.Label}}
|
||||
{{- end}}
|
||||
{{- if .HasCreateUser}}
|
||||
CreateUser string `json:"createUser"` // 创建人
|
||||
{{- end}}
|
||||
{{- if .HasCreateTime}}
|
||||
CreateTime *gtime.Time `json:"createTime"` // 创建时间
|
||||
{{- end}}
|
||||
{{- if .HasStatus}}
|
||||
StatusText string `json:"statusText"` // 状态显示名(dict_item 解析)
|
||||
{{- end}}
|
||||
}
|
||||
|
||||
// {{.ModelClass}}PageReq {{.ModuleComment}}分页请求
|
||||
type {{.ModelClass}}PageReq struct {
|
||||
gmeta.Meta `method:"get" path:"/api/{{.RoutePrefix}}/page" summary:"{{.ModuleComment}}分页" permission:"{{.PermissionPrefix}}:page" log:"{{.ModuleComment}}-查询分页记录" logType:"query"`
|
||||
PageReq
|
||||
{{- range .FilterFields}}
|
||||
{{.CamelExport}} {{.GoType}} `json:"{{.CamelName}}" dc:"{{.Label}}"` // {{.Label}}
|
||||
{{- end}}
|
||||
Keyword string `json:"keyword" dc:"关键词"` // 关键词
|
||||
}
|
||||
|
||||
// {{.ModelClass}}PageRes {{.ModuleComment}}分页结果
|
||||
// 统一壳:records/total/size/current/pages
|
||||
type {{.ModelClass}}PageRes = PageData[{{.ModelClass}}Item]
|
||||
|
||||
// {{.ModelClass}}ListReq {{.ModuleComment}}列表请求
|
||||
type {{.ModelClass}}ListReq struct {
|
||||
gmeta.Meta `method:"get" path:"/api/{{.RoutePrefix}}/list" summary:"{{.ModuleComment}}列表" permission:"{{.PermissionPrefix}}:list" log:"{{.ModuleComment}}-查询列表" logType:"query"`
|
||||
Keyword string `json:"keyword" dc:"关键词"` // 关键词
|
||||
Limit int `json:"limit" dc:"条数上限"` // 条数上限
|
||||
}
|
||||
|
||||
// {{.ModelClass}}ListRes {{.ModuleComment}}平铺列表结果
|
||||
// data 直接为数组,树形结构由前端 buildTree 构建
|
||||
type {{.ModelClass}}ListRes = []{{.ModelClass}}Item
|
||||
|
||||
// {{.ModelClass}}DetailReq {{.ModuleComment}}详情请求
|
||||
type {{.ModelClass}}DetailReq struct {
|
||||
gmeta.Meta `method:"get" path:"/api/{{.RoutePrefix}}/detail/:id" summary:"{{.ModuleComment}}详情" permission:"{{.PermissionPrefix}}:detail" log:"{{.ModuleComment}}-查询详情" logType:"query"`
|
||||
Id int64 `json:"id" v:"required#缺少ID" dc:"记录ID"` // 记录ID
|
||||
}
|
||||
|
||||
// {{.ModelClass}}DetailRes {{.ModuleComment}}详情结果
|
||||
type {{.ModelClass}}DetailRes struct {
|
||||
Id int64 `json:"id"` // 主键ID
|
||||
{{- range .FormFields}}
|
||||
{{.CamelExport}} {{.GoType}} `json:"{{.CamelName}}"` // {{.Label}}
|
||||
{{- end}}
|
||||
{{- if .HasStatus}}
|
||||
StatusText string `json:"statusText"` // 状态显示名(dict_item 解析)
|
||||
{{- end}}
|
||||
}
|
||||
|
||||
// {{.ModelClass}}AddReq 新增{{.ModuleComment}}请求
|
||||
type {{.ModelClass}}AddReq struct {
|
||||
gmeta.Meta `method:"post" path:"/api/{{.RoutePrefix}}/add" summary:"新增{{.ModuleComment}}" permission:"{{.PermissionPrefix}}:add" log:"{{.ModuleComment}}-新增记录" logType:"add"`
|
||||
{{- range .FormFields}}
|
||||
{{.CamelExport}} {{.GoType}} `json:"{{.CamelName}}"{{if .Required}} v:"required#请输入{{.Label}}"{{end}} dc:"{{.Label}}"` // {{.Label}}
|
||||
{{- end}}
|
||||
}
|
||||
|
||||
// {{.ModelClass}}IdRes 新增返回ID结构
|
||||
type {{.ModelClass}}IdRes struct {
|
||||
Id int64 `json:"id"` // 主键ID
|
||||
}
|
||||
|
||||
// {{.ModelClass}}UpdateReq 修改{{.ModuleComment}}请求
|
||||
type {{.ModelClass}}UpdateReq struct {
|
||||
gmeta.Meta `method:"put" path:"/api/{{.RoutePrefix}}/update" summary:"修改{{.ModuleComment}}" permission:"{{.PermissionPrefix}}:update" log:"{{.ModuleComment}}-修改记录" logType:"update"`
|
||||
Id int64 `json:"id" v:"required#缺少ID" dc:"记录ID"` // 记录ID
|
||||
{{- range .FormFields}}
|
||||
{{.CamelExport}} {{.GoType}} `json:"{{.CamelName}}"{{if .Required}} v:"required#请输入{{.Label}}"{{end}} dc:"{{.Label}}"` // {{.Label}}
|
||||
{{- end}}
|
||||
}
|
||||
|
||||
// {{.ModelClass}}UpdateRes 修改{{.ModuleComment}}结果
|
||||
type {{.ModelClass}}UpdateRes struct{}
|
||||
{{- if .HasStatus}}
|
||||
|
||||
// {{.ModelClass}}StatusReq {{.ModuleComment}}状态请求
|
||||
type {{.ModelClass}}StatusReq struct {
|
||||
gmeta.Meta `method:"put" path:"/api/{{.RoutePrefix}}/status" summary:"{{.ModuleComment}}状态" permission:"{{.PermissionPrefix}}:status" log:"{{.ModuleComment}}-设置状态" logType:"update"`
|
||||
Id int64 `json:"id" v:"required#缺少ID" dc:"记录ID"` // 记录ID
|
||||
Status int `json:"status" v:"required#缺少状态" dc:"状态"` // 状态
|
||||
}
|
||||
|
||||
// {{.ModelClass}}StatusRes {{.ModuleComment}}状态结果
|
||||
type {{.ModelClass}}StatusRes struct{}
|
||||
{{- end}}
|
||||
|
||||
// {{.ModelClass}}DeleteReq 删除{{.ModuleComment}}请求
|
||||
type {{.ModelClass}}DeleteReq struct {
|
||||
gmeta.Meta `method:"delete" path:"/api/{{.RoutePrefix}}/delete/:id" summary:"删除{{.ModuleComment}}" permission:"{{.PermissionPrefix}}:delete" log:"{{.ModuleComment}}-删除记录" logType:"delete"`
|
||||
Id int64 `json:"id" v:"required#缺少ID" dc:"记录ID"` // 记录ID
|
||||
}
|
||||
|
||||
// {{.ModelClass}}DeleteRes 删除{{.ModuleComment}}结果
|
||||
type {{.ModelClass}}DeleteRes struct{}
|
||||
|
||||
// {{.ModelClass}}BatchDeleteReq 批量删除{{.ModuleComment}}请求
|
||||
type {{.ModelClass}}BatchDeleteReq struct {
|
||||
gmeta.Meta `method:"delete" path:"/api/{{.RoutePrefix}}/batchDelete" summary:"批量删除{{.ModuleComment}}" permission:"{{.PermissionPrefix}}:batchDelete" log:"{{.ModuleComment}}-批量删除记录" logType:"delete"`
|
||||
Ids []int64 `json:"ids" v:"required#请选择要删除的记录" dc:"ID列表"` // ID列表
|
||||
}
|
||||
|
||||
// {{.ModelClass}}BatchDeleteRes 批量删除结果
|
||||
type {{.ModelClass}}BatchDeleteRes struct{}
|
||||
{{- if .HasImport}}
|
||||
|
||||
// {{.ModelClass}}ImportReq 导入{{.ModuleComment}}请求
|
||||
type {{.ModelClass}}ImportReq struct {
|
||||
gmeta.Meta `method:"post" path:"/api/{{.RoutePrefix}}/import" summary:"导入{{.ModuleComment}}" permission:"{{.PermissionPrefix}}:import" log:"{{.ModuleComment}}-导入数据" logType:"import"`
|
||||
File *ghttp.UploadFile `p:"file" v:"required#请选择文件" dc:"xls/xlsx 文件"` // 上传文件
|
||||
}
|
||||
|
||||
// {{.ModelClass}}ImportRes 导入结果
|
||||
// 返回导入总数、成功数、失败数及失败原因
|
||||
type {{.ModelClass}}ImportRes struct {
|
||||
Total int `json:"total"` // 导入总数
|
||||
Success int `json:"success"` // 成功数
|
||||
Failed int `json:"failed"` // 失败数
|
||||
Reasons []string `json:"reasons"` // 失败原因列表
|
||||
}
|
||||
{{- end}}
|
||||
{{- if .HasExport}}
|
||||
|
||||
// {{.ModelClass}}ExportReq 导出{{.ModuleComment}}请求
|
||||
type {{.ModelClass}}ExportReq struct {
|
||||
gmeta.Meta `method:"get" path:"/api/{{.RoutePrefix}}/export" summary:"导出{{.ModuleComment}}" permission:"{{.PermissionPrefix}}:export" log:"{{.ModuleComment}}-导出数据" logType:"export"`
|
||||
Keyword string `json:"keyword" dc:"关键词"` // 关键词
|
||||
{{- range .FilterFields}}
|
||||
{{.CamelExport}} {{.GoType}} `json:"{{.CamelName}}" dc:"{{.Label}}"` // {{.Label}}
|
||||
{{- end}}
|
||||
}
|
||||
|
||||
// {{.ModelClass}}ExportRes 导出结果
|
||||
// data 直接为文件访问 URL 字符串,前端可 window.open(data)
|
||||
type {{.ModelClass}}ExportRes = string
|
||||
{{- end}}
|
||||
Reference in New Issue
Block a user