feat:完善项目
This commit is contained in:
@ -15,6 +15,12 @@ type Equipment struct{ *service.Session }
|
||||
type EquipmentHandle func(session *service.Session) *Equipment
|
||||
|
||||
type (
|
||||
// EquipmentBasic 装备基本信息
|
||||
EquipmentBasic struct {
|
||||
basic.CommonIDString
|
||||
Code string `json:"code"`
|
||||
Title string `json:"title"`
|
||||
}
|
||||
// EquipmentInfo 装备信息
|
||||
EquipmentInfo struct {
|
||||
basic.CommonIDString
|
||||
@ -57,12 +63,6 @@ func (c *Equipment) tree(iModel model2.IModel, src []*model2.ManageEquipment, pa
|
||||
|
||||
for _, v := range src {
|
||||
if v.ParentID == parentID {
|
||||
//parentID := "0"
|
||||
//
|
||||
//if v.ParentID > 0 {
|
||||
// iModel.SetID(v.ParentID)
|
||||
// parentID = iModel.GetEncodeID()
|
||||
//}
|
||||
out = append(out, &EquipmentInfo{
|
||||
CommonIDString: basic.CommonIDString{ID: v.GetEncodeID()},
|
||||
Code: v.Code,
|
||||
@ -93,10 +93,6 @@ func (c *Equipment) List(parentID uint64, title string, page, pageSize int) (*ba
|
||||
Where: model2.NewWhereLike("title", title),
|
||||
})
|
||||
}
|
||||
//if err := model2.ScanFields(mManageEquipment.ManageEquipment, &out, []string{"id", "code", "title", "image", "created_at"},
|
||||
// where...); err != nil {
|
||||
// return nil, err
|
||||
//}
|
||||
var count int64
|
||||
|
||||
if err := model2.PagesFields(mManageEquipment.ManageEquipment, &out, []string{"id", "code", "title", "image", "created_at"},
|
||||
@ -109,6 +105,27 @@ func (c *Equipment) List(parentID uint64, title string, page, pageSize int) (*ba
|
||||
}, nil
|
||||
}
|
||||
|
||||
// Select 筛选信息
|
||||
func (c *Equipment) Select() ([]*EquipmentBasic, error) {
|
||||
mManageEquipment := model.NewManageEquipment()
|
||||
|
||||
out := make([]*model2.ManageEquipment, 0)
|
||||
|
||||
if err := model2.ScanFields(mManageEquipment.ManageEquipment, &out, []string{"id", "code", "title"}); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
list := make([]*EquipmentBasic, 0)
|
||||
|
||||
for _, v := range out {
|
||||
list = append(list, &EquipmentBasic{
|
||||
CommonIDString: basic.CommonIDString{ID: v.GetEncodeID()},
|
||||
Code: v.Code,
|
||||
Title: v.Title,
|
||||
})
|
||||
}
|
||||
return list, nil
|
||||
}
|
||||
|
||||
// Detail 详细信息
|
||||
func (c *Equipment) Detail(id uint64) (*EquipmentDetail, error) {
|
||||
mManageEquipment := model.NewManageEquipment()
|
||||
|
Reference in New Issue
Block a user