feat✨优化字典数据错误判断写法

This commit is contained in:
zhangwenjian authored and wenjianzhang committed 2021-05-08 13:53:27 +08:00
1 parent c6d94c03fb
commit c6a52134b3
69 files changed
+591 -479

No files matched your search

@@ -0,0 +1,97 @@
package dto
import (
models2 "go-admin/app/other/models"
"time"
"github.com/gin-gonic/gin"
"github.com/go-admin-team/go-admin-core/sdk/api"
"go-admin/common/dto"
common "go-admin/common/models"
)
type SysChinaAreaDataSearch struct {
dto.Pagination `search:"-"`
PId string `form:"pId" search:"type:exact;column:p_id;table:sys_china_area_data" comment:"上级编码"`
Name string `form:"name" search:"type:exact;column:name;table:sys_china_area_data" comment:"名称"`
}
func (m *SysChinaAreaDataSearch) GetNeedSearch() interface{} {
return *m
}
func (m *SysChinaAreaDataSearch) Bind(ctx *gin.Context) error {
log := api.GetRequestLogger(ctx)
err := ctx.ShouldBind(m)
if err != nil {
log.Debugf("ShouldBind error: %s", err.Error())
}
return err
}
type SysChinaAreaDataControl struct {
Id int `uri:"id" comment:"编码"` // 编码
PId string `json:"pId" comment:"上级编码"`
Name string `json:"name" comment:"名称"`
CreateTime time.Time `json:"createTime" comment:""`
UpdateTime time.Time `json:"updateTime" comment:""`
DeleteTime time.Time `json:"deleteTime" comment:""`
}
func (s *SysChinaAreaDataControl) Bind(ctx *gin.Context) error {
log := api.GetRequestLogger(ctx)
err := ctx.ShouldBindUri(s)
if err != nil {
log.Debugf("ShouldBindUri error: %s", err.Error())
return err
}
err = ctx.ShouldBind(s)
if err != nil {
log.Debugf("ShouldBind error: %s", err.Error())
}
return err
}
func (s *SysChinaAreaDataControl) Generate() (*models2.SysChinaAreaData, error) {
return &models2.SysChinaAreaData{
Model: common.Model{Id: s.Id},
PId: s.PId,
Name: s.Name,
}, nil
}
func (s *SysChinaAreaDataControl) GetId() interface{} {
return s.Id
}
type SysChinaAreaDataById struct {
Id int `uri:"id"`
Ids []int `json:"ids"`
}
func (s *SysChinaAreaDataById) GetId() interface{} {
if len(s.Ids) > 0 {
s.Ids = append(s.Ids, s.Id)
return s.Ids
}
return s.Id
}
func (s *SysChinaAreaDataById) Bind(ctx *gin.Context) error {
log := api.GetRequestLogger(ctx)
err := ctx.ShouldBindUri(s)
if err != nil {
log.Debugf("ShouldBindUri error: %s", err.Error())
return err
}
err = ctx.ShouldBind(s)
if err != nil {
log.Debugf("ShouldBind error: %s", err.Error())
}
return err
}
func (s *SysChinaAreaDataById) SetUpdateBy(id int) {
}
+99
View File
@@ -0,0 +1,99 @@
package dto
import (
"github.com/gin-gonic/gin"
"github.com/go-admin-team/go-admin-core/sdk/api"
"go-admin/app/other/models"
"go-admin/common/dto"
common "go-admin/common/models"
)
type SysFileDirSearch struct {
dto.Pagination `search:"-"`
ID int `form:"Id" search:"type:exact;column:id;table:sys_file_dir" comment:"标识"`
Label string `form:"label" search:"type:exact;column:label;table:sys_file_dir" comment:"目录名称"`
PId string `form:"pId" search:"type:exact;column:p_id;table:sys_file_dir" comment:"上级目录"`
//Sort string `form:"sort" search:"type:exact;column:sort;table:sys_file_dir" comment:"排序"`
Path string `form:"path" search:"type:exact;column:path;table:sys_file_dir" comment:"路径"`
}
func (m *SysFileDirSearch) GetNeedSearch() interface{} {
return *m
}
func (m *SysFileDirSearch) Bind(ctx *gin.Context) error {
log := api.GetRequestLogger(ctx)
err := ctx.ShouldBind(m)
if err != nil {
log.Debugf("ShouldBind error: %s", err.Error())
}
return err
}
func (m *SysFileDirSearch) Generate() dto.Index {
o := *m
return &o
}
type SysFileDirControl struct {
Id int `uri:"Id" comment:"标识"` // 标识
Label string `json:"label" comment:"目录名称"`
PId int `json:"pId" comment:"上级目录"`
Sort string `json:"sort" comment:"排序"`
Path string `json:"path" comment:"路径"`
CreateBy int `json:"-"`
UpdateBy int `json:"-"`
}
func (s *SysFileDirControl) Bind(ctx *gin.Context) error {
log := api.GetRequestLogger(ctx)
err := ctx.ShouldBindUri(s)
if err != nil {
log.Debugf("ShouldBindUri error: %s", err.Error())
return err
}
err = ctx.ShouldBind(s)
if err != nil {
log.Debugf("ShouldBind error: %s", err.Error())
}
return err
}
func (s *SysFileDirControl) Generate() dto.Control {
cp := *s
return &cp
}
func (s *SysFileDirControl) GenerateM() (common.ActiveRecord, error) {
return &models.SysFileDir{
Model: common.Model{Id: s.Id},
Label: s.Label,
PId: s.PId,
//Sort: s.Sort,
Path: s.Path,
ControlBy: common.ControlBy{
CreateBy: s.CreateBy,
UpdateBy: s.UpdateBy,
},
}, nil
}
func (s *SysFileDirControl) GetId() interface{} {
return s.Id
}
type SysFileDirById struct {
dto.ObjectById
UpdateBy int `json:"-"`
}
func (s *SysFileDirById) Generate() dto.Control {
cp := *s
return &cp
}
func (s *SysFileDirById) GenerateM() (common.ActiveRecord, error) {
return &models.SysFileDir{}, nil
}
+52
View File
@@ -0,0 +1,52 @@
package dto
import (
"go-admin/app/other/models"
"go-admin/common/dto"
common "go-admin/common/models"
)
type SysFileInfoSearch struct {
dto.Pagination `search:"-"`
ID int `form:"Id" search:"type:exact;column:id;table:sys_file_info" comment:"标识"`
Type string `form:"type" search:"type:exact;column:type;table:sys_file_info" comment:"类型"`
Name string `form:"name" search:"type:exact;column:name;table:sys_file_info" comment:"名称"`
PId string `form:"pId" search:"type:exact;column:p_id;table:sys_file_info" comment:"目录"`
Source string `form:"source" search:"type:exact;column:source;table:sys_file_info" comment:"来源"`
}
func (m *SysFileInfoSearch) GetNeedSearch() interface{} {
return *m
}
type SysFileInfoControl struct {
Id int `uri:"id" comment:"标识"` // 标识
Type string `json:"type" comment:"类型"`
Name string `json:"name" comment:"名称"`
Size string `json:"size" comment:"大小"`
PId int `json:"pId" comment:"目录"`
Source string `json:"source" comment:"来源"`
Url string `json:"url" comment:"地址"`
FullUrl string `json:"fullUrl" comment:"全地址"`
CreateBy int `json:"-"`
UpdateBy int `json:"-"`
}
func (s *SysFileInfoControl) Generate() (*models.SysFileInfo, error) {
return &models.SysFileInfo{
Model: common.Model{Id: s.Id},
Type: s.Type,
Name: s.Name,
Size: s.Size,
PId: s.PId,
Source: s.Source,
Url: s.Url,
FullUrl: s.FullUrl,
ControlBy: common.ControlBy{CreateBy: s.CreateBy, UpdateBy: s.UpdateBy},
}, nil
}
type SysFileInfoById struct {
dto.ObjectById
UpdateBy int `json:"-"`
}