mirror of
https://github.com/go-admin-team/go-admin.git
synced 2026-09-22 02:27:57 +00:00
test
This commit is contained in:
@@ -0,0 +1,89 @@
|
||||
package dto
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"gorm.io/gorm"
|
||||
|
||||
"go-admin/app/admin/models"
|
||||
"go-admin/common/dto"
|
||||
"go-admin/common/log"
|
||||
common "go-admin/common/models"
|
||||
"go-admin/tools"
|
||||
)
|
||||
|
||||
type ScolSearch struct {
|
||||
dto.Pagination `search:"-"`
|
||||
Name string `form:"name" search:"type:contains;column:name;table:scol" comment:"名称"`
|
||||
|
||||
|
||||
}
|
||||
|
||||
func (m *ScolSearch) GetNeedSearch() interface{} {
|
||||
return *m
|
||||
}
|
||||
|
||||
func (m *ScolSearch) Bind(ctx *gin.Context) error {
|
||||
msgID := tools.GenerateMsgIDFromContext(ctx)
|
||||
err := ctx.ShouldBind(m)
|
||||
if err != nil {
|
||||
log.Debugf("MsgID[%s] ShouldBind error: %s", msgID, err.Error())
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func (m *ScolSearch) Generate() dto.Index {
|
||||
o := *m
|
||||
return &o
|
||||
}
|
||||
|
||||
type ScolControl struct {
|
||||
|
||||
ID uint `uri:"ID" comment:""` //
|
||||
|
||||
Name string `json:"name" comment:"名称"`
|
||||
|
||||
}
|
||||
|
||||
func (s *ScolControl) Bind(ctx *gin.Context) error {
|
||||
msgID := tools.GenerateMsgIDFromContext(ctx)
|
||||
err := ctx.ShouldBindUri(s)
|
||||
if err != nil {
|
||||
log.Debugf("MsgID[%s] ShouldBindUri error: %s", msgID, err.Error())
|
||||
return err
|
||||
}
|
||||
err = ctx.ShouldBind(s)
|
||||
if err != nil {
|
||||
log.Debugf("MsgID[%s] ShouldBind error: %#v", msgID, err.Error())
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func (s *ScolControl) Generate() dto.Control {
|
||||
cp := *s
|
||||
return &cp
|
||||
}
|
||||
|
||||
func (s *ScolControl) GenerateM() (common.ActiveRecord, error) {
|
||||
return &models.Scol{
|
||||
|
||||
Model: gorm.Model{ID: s.ID},
|
||||
Name: s.Name,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (s *ScolControl) GetId() interface{} {
|
||||
return s.ID
|
||||
}
|
||||
|
||||
type ScolById struct {
|
||||
dto.ObjectById
|
||||
}
|
||||
|
||||
func (s *ScolById) Generate() dto.Control {
|
||||
cp := *s
|
||||
return &cp
|
||||
}
|
||||
|
||||
func (s *ScolById) GenerateM() (common.ActiveRecord, error) {
|
||||
return &models.Scol{}, nil
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
package dto
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"gorm.io/gorm"
|
||||
|
||||
"go-admin/app/admin/models"
|
||||
"go-admin/common/dto"
|
||||
"go-admin/common/log"
|
||||
common "go-admin/common/models"
|
||||
)
|
||||
|
||||
type StudentSearch struct {
|
||||
dto.Pagination `search:"-"`
|
||||
Name string `form:"name" search:"type:exact;column:name;table:student" comment:"姓名"`
|
||||
}
|
||||
|
||||
func (m *StudentSearch) GetNeedSearch() interface{} {
|
||||
return *m
|
||||
}
|
||||
|
||||
func (m *StudentSearch) Bind(ctx *gin.Context) error {
|
||||
err := ctx.Bind(m)
|
||||
if err != nil {
|
||||
log.Errorf("MsgID[%s] Bind error: %#v", err)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func (m *StudentSearch) Generate() dto.Index {
|
||||
o := *m
|
||||
return &o
|
||||
}
|
||||
|
||||
type StudentControl struct {
|
||||
ID uint `uri:"ID" comment:""` //
|
||||
Name string `json:"name" comment:"姓名"`
|
||||
}
|
||||
|
||||
func (s *StudentControl) Bind(ctx *gin.Context) error {
|
||||
err := ctx.BindUri(s)
|
||||
if err != nil {
|
||||
log.Errorf("MsgID[%s] Bind error: %#v", err)
|
||||
return err
|
||||
}
|
||||
err = ctx.Bind(s)
|
||||
if err != nil {
|
||||
log.Errorf("MsgID[%s] Bind error: %#v", err)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func (s *StudentControl) Generate() dto.Control {
|
||||
cp := *s
|
||||
return &cp
|
||||
}
|
||||
|
||||
func (s *StudentControl) GenerateM() (common.ActiveRecord, error) {
|
||||
return &models.Student{
|
||||
|
||||
Model: gorm.Model{ID: s.ID},
|
||||
Name: s.Name,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (s *StudentControl) GetId() interface{} {
|
||||
return s.ID
|
||||
}
|
||||
|
||||
type StudentById struct {
|
||||
dto.ObjectById
|
||||
}
|
||||
|
||||
func (s *StudentById) Generate() dto.Control {
|
||||
cp := *s
|
||||
return &cp
|
||||
}
|
||||
|
||||
func (s *StudentById) GenerateM() (common.ActiveRecord, error) {
|
||||
return &models.Student{}, nil
|
||||
}
|
||||
|
||||
type StudentItem struct {
|
||||
gorm.Model
|
||||
common.ControlBy
|
||||
Name string `json:"name" gorm:"type:varchar(255);comment:姓名"` //
|
||||
}
|
||||
@@ -37,7 +37,7 @@ func (m *SysJobSearch) Generate() dto.Index {
|
||||
}
|
||||
|
||||
type SysJobControl struct {
|
||||
JobId int `json:"jobId"`
|
||||
JobId uint `json:"jobId"`
|
||||
JobName string `json:"jobName" validate:"required"` // 名称
|
||||
JobGroup string `json:"jobGroup"` // 任务分组
|
||||
JobType int `json:"jobType"` // 任务类型
|
||||
@@ -93,7 +93,7 @@ func (s *SysJobById) GenerateM() (common.ActiveRecord, error) {
|
||||
}
|
||||
|
||||
type SysJobItem struct {
|
||||
JobId int `json:"jobId"`
|
||||
JobId uint `json:"jobId"`
|
||||
JobName string `json:"jobName" validate:"required"` // 名称
|
||||
JobGroup string `json:"jobGroup"` // 任务分组
|
||||
JobType int `json:"jobType"` // 任务类型
|
||||
|
||||
Reference in New Issue
Block a user