feat:完善项目
This commit is contained in:
@ -24,6 +24,7 @@ type (
|
||||
// EquipmentInfo 装备信息
|
||||
EquipmentInfo struct {
|
||||
basic.CommonIDString
|
||||
ParentID string `json:"parent_id"`
|
||||
Code string `json:"code"`
|
||||
Title string `json:"title"`
|
||||
Image string `json:"image"`
|
||||
@ -39,7 +40,7 @@ type (
|
||||
}
|
||||
// EquipmentMaterialDetail 装备器材信息
|
||||
EquipmentMaterialDetail struct {
|
||||
*model.ManageEquipmentMaterialInfo
|
||||
*model.ManageMaterialBasic
|
||||
ID string `json:"id"`
|
||||
}
|
||||
// EquipmentParams 装备参数信息
|
||||
@ -63,8 +64,15 @@ func (c *Equipment) tree(iModel model2.IModel, src []*model2.ManageEquipment, pa
|
||||
|
||||
for _, v := range src {
|
||||
if v.ParentID == parentID {
|
||||
parentID := ""
|
||||
|
||||
if v.ParentID > 0 {
|
||||
iModel.SetID(v.ParentID)
|
||||
parentID = iModel.GetEncodeID()
|
||||
}
|
||||
out = append(out, &EquipmentInfo{
|
||||
CommonIDString: basic.CommonIDString{ID: v.GetEncodeID()},
|
||||
ParentID: parentID,
|
||||
Code: v.Code,
|
||||
Title: v.Title,
|
||||
Image: v.Analysis(config.SettingInfo.Domain),
|
||||
@ -95,23 +103,26 @@ func (c *Equipment) List(parentID uint64, title string, page, pageSize int) (*ba
|
||||
}
|
||||
var count int64
|
||||
|
||||
if err := model2.PagesFields(mManageEquipment.ManageEquipment, &out, []string{"id", "code", "title", "image", "created_at"},
|
||||
if err := model2.PagesFields(mManageEquipment.ManageEquipment, &out, []string{"id", "parent_id", "code", "title", "image", "created_at"},
|
||||
page, pageSize, &count, where...); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &basic.PageDataResponse{
|
||||
Data: c.tree(mManageEquipment.ManageEquipment, out, 0),
|
||||
Data: c.tree(mManageEquipment.ManageEquipment, out, parentID),
|
||||
Count: count,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// Select 筛选信息
|
||||
func (c *Equipment) Select() ([]*EquipmentBasic, error) {
|
||||
func (c *Equipment) Select(parentID uint64) ([]*EquipmentBasic, error) {
|
||||
mManageEquipment := model.NewManageEquipment()
|
||||
|
||||
out := make([]*model2.ManageEquipment, 0)
|
||||
|
||||
if err := model2.ScanFields(mManageEquipment.ManageEquipment, &out, []string{"id", "code", "title"}); err != nil {
|
||||
where := []*model2.ModelWhereOrder{
|
||||
&model2.ModelWhereOrder{Where: model2.NewWhere("parent_id", parentID)},
|
||||
}
|
||||
if err := model2.ScanFields(mManageEquipment.ManageEquipment, &out, []string{"id", "code", "title"}, where...); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
list := make([]*EquipmentBasic, 0)
|
||||
@ -119,8 +130,7 @@ func (c *Equipment) Select() ([]*EquipmentBasic, error) {
|
||||
for _, v := range out {
|
||||
list = append(list, &EquipmentBasic{
|
||||
CommonIDString: basic.CommonIDString{ID: v.GetEncodeID()},
|
||||
Code: v.Code,
|
||||
Title: v.Title,
|
||||
Code: v.Code, Title: v.Title,
|
||||
})
|
||||
}
|
||||
return list, nil
|
||||
@ -146,7 +156,7 @@ func (c *Equipment) Detail(id uint64) (*EquipmentDetail, error) {
|
||||
}
|
||||
mManageEquipmentMaterial := model.NewManageEquipmentMaterial()
|
||||
|
||||
materials := make([]*model.ManageEquipmentMaterialInfo, 0)
|
||||
materials := make([]*model.ManageMaterialBasic, 0)
|
||||
|
||||
if materials, err = mManageEquipmentMaterial.Materials(id); err != nil {
|
||||
return nil, err
|
||||
@ -156,8 +166,8 @@ func (c *Equipment) Detail(id uint64) (*EquipmentDetail, error) {
|
||||
mManageEquipmentMaterial.ID = v.ID
|
||||
|
||||
out.Materials = append(out.Materials, &EquipmentMaterialDetail{
|
||||
ManageEquipmentMaterialInfo: v,
|
||||
ID: mManageEquipmentMaterial.GetEncodeID(),
|
||||
ManageMaterialBasic: v,
|
||||
ID: mManageEquipmentMaterial.GetEncodeID(),
|
||||
})
|
||||
}
|
||||
return out, nil
|
||||
|
Reference in New Issue
Block a user