mirror of
https://gitcode.com/flipped-aurora/gin-vue-admin.git
synced 2026-05-19 13:47:52 +00:00
规范自动化插件包功能
* 规范自动化插件包功能 Co-authored-by: longzhang83 <38556219+longzhang83@users.noreply.github.com>
This commit is contained in:
@@ -15,7 +15,7 @@ type AutoCodeStruct struct {
|
||||
Description string `json:"description"` // Struct中文名称
|
||||
AutoCreateApiToSql bool `json:"autoCreateApiToSql"` // 是否自动创建api
|
||||
AutoMoveFile bool `json:"autoMoveFile"` // 是否自动移动文件
|
||||
Fields []*Field `json:"fields"`
|
||||
Fields []*Field `json:"fields,omitempty"`
|
||||
DictTypes []string `json:"-"`
|
||||
Package string `json:"package"`
|
||||
PackageT string `json:"-"`
|
||||
@@ -43,26 +43,40 @@ type SysAutoCode struct {
|
||||
}
|
||||
|
||||
type AutoPlugReq struct {
|
||||
PlugName string `json:"plugName"` // 必然大写开头
|
||||
Snake string `json:"snake"` // 后端自动转为 snake
|
||||
RouterGroup string `json:"routerGroup"`
|
||||
HasGlobal bool `json:"hasGlobal"`
|
||||
HasRequest bool `json:"hasRequest"`
|
||||
HasResponse bool `json:"hasResponse"`
|
||||
NeedModel bool `json:"needModel"`
|
||||
Global []struct {
|
||||
Key string `json:"key"`
|
||||
Type string `json:"type"`
|
||||
Desc string `json:"desc"`
|
||||
} `json:"global"`
|
||||
Request []struct {
|
||||
Key string `json:"key"`
|
||||
Type string `json:"type"`
|
||||
Desc string `json:"desc"`
|
||||
} `json:"request"`
|
||||
Response []struct {
|
||||
Key string `json:"key"`
|
||||
Type string `json:"type"`
|
||||
Desc string `json:"desc"`
|
||||
} `json:"response"`
|
||||
PlugName string `json:"plugName"` // 必然大写开头
|
||||
Snake string `json:"snake"` // 后端自动转为 snake
|
||||
RouterGroup string `json:"routerGroup"`
|
||||
HasGlobal bool `json:"hasGlobal"`
|
||||
HasRequest bool `json:"hasRequest"`
|
||||
HasResponse bool `json:"hasResponse"`
|
||||
NeedModel bool `json:"needModel"`
|
||||
Global []AutoPlugInfo `json:"global,omitempty"`
|
||||
Request []AutoPlugInfo `json:"request,omitempty"`
|
||||
Response []AutoPlugInfo `json:"response,omitempty"`
|
||||
}
|
||||
|
||||
func (a *AutoPlugReq) CheckList() {
|
||||
a.Global = bind(a.Global)
|
||||
a.Request = bind(a.Request)
|
||||
a.Response = bind(a.Response)
|
||||
|
||||
}
|
||||
func bind(req []AutoPlugInfo) []AutoPlugInfo {
|
||||
var r []AutoPlugInfo
|
||||
for _, info := range req {
|
||||
if info.Effective() {
|
||||
r = append(r, info)
|
||||
}
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
type AutoPlugInfo struct {
|
||||
Key string `json:"key"`
|
||||
Type string `json:"type"`
|
||||
Desc string `json:"desc"`
|
||||
}
|
||||
|
||||
func (a AutoPlugInfo) Effective() bool {
|
||||
return a.Key != "" && a.Type != "" && a.Desc != ""
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user