fix🐛 :修复内容模块问题(#357)
This commit is contained in:
1 parent
9023b620fb
commit
91c9a2c7f9
4 files changed
+25
-132
No files matched your search
@@ -8,8 +8,8 @@ type SysCategory struct {
|
||||
models.Model
|
||||
Name string `json:"name" gorm:"type:varchar(255);comment:名称"` //
|
||||
Img string `json:"img" gorm:"type:varchar(255);comment:图标"` //
|
||||
Sort string `json:"sort" gorm:"type:int(4);comment:排序"` //
|
||||
Status string `json:"status" gorm:"type:int(1);comment:状态"` //
|
||||
Sort int `json:"sort" gorm:"type:int(4);comment:排序"` //
|
||||
Status int `json:"status" gorm:"type:int(1);comment:状态"` //
|
||||
Remark string `json:"remark" gorm:"type:varchar(255);comment:备注"` //
|
||||
models.ControlBy
|
||||
models.ModelTime
|
||||
@@ -26,4 +26,4 @@ func (e *SysCategory) Generate() models.ActiveRecord {
|
||||
|
||||
func (e *SysCategory) GetId() interface{} {
|
||||
return e.Id
|
||||
}
|
||||
}
|
||||
@@ -5,22 +5,24 @@ import (
|
||||
)
|
||||
|
||||
type SysContent struct {
|
||||
Id int `json:"id" gorm:"type:int(11);primaryKey;autoIncrement"` // id
|
||||
CateId string `json:"cateId" gorm:"type:int(11);comment:分类id"`
|
||||
models.Model
|
||||
CateId int `json:"cateId" gorm:"type:int(11);comment:分类id"`
|
||||
Name string `json:"name" gorm:"type:varchar(255);comment:名称"`
|
||||
Status string `json:"status" gorm:"type:int(1);comment:状态"`
|
||||
Status int `json:"status" gorm:"type:int(1);comment:状态"`
|
||||
Img string `json:"img" gorm:"type:varchar(255);comment:图片"`
|
||||
Content string `json:"content" gorm:"type:text;comment:内容"`
|
||||
Remark string `json:"remark" gorm:"type:varchar(255);comment:备注"`
|
||||
Sort string `json:"sort" gorm:"type:int(4);comment:排序"`
|
||||
Sort int `json:"sort" gorm:"type:int(4);comment:排序"`
|
||||
models.ControlBy
|
||||
models.ModelTime
|
||||
}
|
||||
|
||||
// TableName
|
||||
func (SysContent) TableName() string {
|
||||
return "sys_content"
|
||||
}
|
||||
|
||||
// Generate
|
||||
func (e *SysContent) Generate() models.ActiveRecord {
|
||||
o := *e
|
||||
return &o
|
||||
@@ -28,110 +30,4 @@ func (e *SysContent) Generate() models.ActiveRecord {
|
||||
|
||||
func (e *SysContent) GetId() interface{} {
|
||||
return e.Id
|
||||
}
|
||||
|
||||
//// 创建SysContent
|
||||
//func (e *SysContent) Create() (SysContent, error) {
|
||||
// var doc SysContent
|
||||
// result := orm.Eloquent.Table(e.TableName()).Create(&e)
|
||||
// if result.Error != nil {
|
||||
// err := result.Error
|
||||
// return doc, err
|
||||
// }
|
||||
// doc = *e
|
||||
// return doc, nil
|
||||
//}
|
||||
//
|
||||
//// 获取SysContent
|
||||
//func (e *SysContent) Get() (SysContent, error) {
|
||||
// var doc SysContent
|
||||
// table := orm.Eloquent.Table(e.TableName())
|
||||
//
|
||||
// if e.Id != 0 {
|
||||
// table = table.Where("id = ?", e.Id)
|
||||
// }
|
||||
//
|
||||
// if e.CateId != "" {
|
||||
// table = table.Where("cate_id = ?", e.CateId)
|
||||
// }
|
||||
//
|
||||
// if e.Name != "" {
|
||||
// table = table.Where("name like ?", "%"+e.Name+"%")
|
||||
// }
|
||||
//
|
||||
// if e.Status != "" {
|
||||
// table = table.Where("status = ?", e.Status)
|
||||
// }
|
||||
//
|
||||
// if err := table.First(&doc).Error; err != nil {
|
||||
// return doc, err
|
||||
// }
|
||||
// return doc, nil
|
||||
//}
|
||||
//
|
||||
//// 获取SysContent带分页
|
||||
//func (e *SysContent) GetPage(pageSize int, pageIndex int) ([]SysContent, int, error) {
|
||||
// var doc []SysContent
|
||||
//
|
||||
// table := orm.Eloquent.Table(e.TableName())
|
||||
//
|
||||
// if e.CateId != "" {
|
||||
// table = table.Where("cate_id = ?", e.CateId)
|
||||
// }
|
||||
//
|
||||
// if e.Name != "" {
|
||||
// table = table.Where("name like ?", "%"+e.Name+"%")
|
||||
// }
|
||||
//
|
||||
// if e.Status != "" {
|
||||
// table = table.Where("status = ?", e.Status)
|
||||
// }
|
||||
//
|
||||
// // 数据权限控制(如果不需要数据权限请将此处去掉)
|
||||
// dataPermission := new(system.DataPermission)
|
||||
// dataPermission.UserId, _ = tools.StringToInt(e.DataScope)
|
||||
// table, err := dataPermission.GetDataScope(e.TableName(), table)
|
||||
// if err != nil {
|
||||
// return nil, 0, err
|
||||
// }
|
||||
// var count int64
|
||||
//
|
||||
// if err := table.Offset((pageIndex - 1) * pageSize).Limit(pageSize).Find(&doc).Offset(-1).Limit(-1).Count(&count).Error; err != nil {
|
||||
// return nil, 0, err
|
||||
// }
|
||||
// //table.Where("`deleted_at` IS NULL").Count(&count)
|
||||
// return doc, int(count), nil
|
||||
//}
|
||||
//
|
||||
//// 更新SysContent
|
||||
//func (e *SysContent) Update(id int) (update SysContent, err error) {
|
||||
// if err = orm.Eloquent.Table(e.TableName()).Where("id = ?", id).First(&update).Error; err != nil {
|
||||
// return
|
||||
// }
|
||||
//
|
||||
// //参数1:是要修改的数据
|
||||
// //参数2:是修改的数据
|
||||
// if err = orm.Eloquent.Table(e.TableName()).Model(&update).Where("id = ?", id).Updates(&e).Error; err != nil {
|
||||
// return
|
||||
// }
|
||||
// return
|
||||
//}
|
||||
//
|
||||
//// 删除SysContent
|
||||
//func (e *SysContent) Delete(id int) (success bool, err error) {
|
||||
// if err = orm.Eloquent.Table(e.TableName()).Where("id = ?", id).Delete(&SysContent{}).Error; err != nil {
|
||||
// success = false
|
||||
// return
|
||||
// }
|
||||
// success = true
|
||||
// return
|
||||
//}
|
||||
//
|
||||
////批量删除
|
||||
//func (e *SysContent) BatchDelete(id []int) (Result bool, err error) {
|
||||
// if err = orm.Eloquent.Table(e.TableName()).Where("id in (?)", id).Delete(&SysContent{}).Error; err != nil {
|
||||
// return
|
||||
// }
|
||||
// Result = true
|
||||
// return
|
||||
//}
|
||||
}
|
||||
@@ -12,8 +12,8 @@ import (
|
||||
type SysCategorySearch struct {
|
||||
dto.Pagination `search:"-"`
|
||||
Name string `form:"name" search:"type:exact;column:name;table:sys_category" comment:"名称"`
|
||||
|
||||
Status string `form:"status" search:"type:exact;column:status;table:sys_category" comment:"状态"`
|
||||
Status string `form:"status" search:"type:exact;column:status;table:sys_category" comment:"状态"`
|
||||
CateId int `form:"cateId" search:"type:exact;column:cate_id;table:sys_category" comment:"分类id"`
|
||||
}
|
||||
|
||||
func (m *SysCategorySearch) GetNeedSearch() interface{} {
|
||||
@@ -35,16 +35,11 @@ func (m *SysCategorySearch) Generate() dto.Index {
|
||||
}
|
||||
|
||||
type SysCategoryControl struct {
|
||||
ID int `uri:"Id" comment:"标识"` // 标识
|
||||
|
||||
Name string `json:"name" comment:"名称"`
|
||||
|
||||
Img string `json:"img" comment:"图标"`
|
||||
|
||||
Sort string `json:"sort" comment:"排序"`
|
||||
|
||||
Status string `json:"status" comment:"状态"`
|
||||
|
||||
ID int `uri:"Id" comment:"标识"`
|
||||
Name string `json:"name" comment:"名称"`
|
||||
Img string `json:"img" comment:"图标"`
|
||||
Sort int `json:"sort" comment:"排序"`
|
||||
Status int `json:"status" comment:"状态"`
|
||||
Remark string `json:"remark" comment:"备注"`
|
||||
}
|
||||
|
||||
@@ -93,4 +88,4 @@ func (s *SysCategoryById) Generate() dto.Control {
|
||||
|
||||
func (s *SysCategoryById) GenerateM() (common.ActiveRecord, error) {
|
||||
return &models.SysCategory{}, nil
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,8 @@ import (
|
||||
|
||||
type SysContentSearch struct {
|
||||
dto.Pagination `search:"-"`
|
||||
Name string `form:"name" search:"type:exact;column:name;table:sys_category" comment:"名称"`
|
||||
Status string `form:"status" search:"type:exact;column:status;table:sys_category" comment:"状态"`
|
||||
}
|
||||
|
||||
func (m *SysContentSearch) GetNeedSearch() interface{} {
|
||||
@@ -33,13 +35,13 @@ func (m *SysContentSearch) Generate() dto.Index {
|
||||
|
||||
type SysContentControl struct {
|
||||
ID int `uri:"ID" comment:""` //
|
||||
CateId string `json:"cateId" comment:""`
|
||||
CateId int `json:"cateId" comment:""`
|
||||
Name string `json:"name" comment:""`
|
||||
Status string `json:"status" comment:""`
|
||||
Status int `json:"status" comment:""`
|
||||
Img string `json:"img" comment:""`
|
||||
Content string `json:"content" comment:""`
|
||||
Remark string `json:"remark" comment:""`
|
||||
Sort string `json:"sort" comment:""`
|
||||
Sort int `json:"sort" comment:""`
|
||||
}
|
||||
|
||||
func (s *SysContentControl) Bind(ctx *gin.Context) error {
|
||||
@@ -63,7 +65,7 @@ func (s *SysContentControl) Generate() dto.Control {
|
||||
|
||||
func (s *SysContentControl) GenerateM() (common.ActiveRecord, error) {
|
||||
return &models.SysContent{
|
||||
Id: s.ID,
|
||||
Model: common.Model{s.ID},
|
||||
CateId: s.CateId,
|
||||
Name: s.Name,
|
||||
Status: s.Status,
|
||||
@@ -89,4 +91,4 @@ func (s *SysContentById) Generate() dto.Control {
|
||||
|
||||
func (s *SysContentById) GenerateM() (common.ActiveRecord, error) {
|
||||
return &models.SysContent{}, nil
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user