feat:完善项目
This commit is contained in:
@ -38,15 +38,15 @@ type (
|
||||
}
|
||||
// EquipmentParams 装备参数信息
|
||||
EquipmentParams struct {
|
||||
ID uint64
|
||||
Title, Image, Config, Remark string
|
||||
ID uint64
|
||||
Code, Title, Image, Config, Remark string
|
||||
}
|
||||
)
|
||||
|
||||
func (c *EquipmentParams) isExist(iModel model2.IModel) (bool, error) {
|
||||
func (c *EquipmentParams) isExist(iModel model2.IModel, tenantID uint64) (bool, error) {
|
||||
var count int64
|
||||
|
||||
if err := model2.Count(iModel, &count, model2.NewWhere("title", c.Title)); err != nil {
|
||||
if err := model2.Count(iModel, &count, model2.NewWhere("tenant_id", tenantID), model2.NewWhere("code", c.Code)); err != nil {
|
||||
return false, err
|
||||
}
|
||||
return count > 0, nil
|
||||
@ -71,7 +71,7 @@ func (c *Equipment) tree(src []*model2.ManageEquipment, parentID uint64) []*Equi
|
||||
}
|
||||
|
||||
// List 列表信息
|
||||
func (c *Equipment) List(title string, page, pageSize int) ([]*EquipmentInfo, error) {
|
||||
func (c *Equipment) List(parentID uint64, title string, page, pageSize int) ([]*EquipmentInfo, error) {
|
||||
mManageEquipment := model.NewManageEquipment()
|
||||
|
||||
out := make([]*model2.ManageEquipment, 0)
|
||||
@ -81,6 +81,11 @@ func (c *Equipment) List(title string, page, pageSize int) ([]*EquipmentInfo, er
|
||||
Order: model2.NewOrder("id", model2.OrderModeToDesc),
|
||||
},
|
||||
}
|
||||
if parentID > 0 {
|
||||
where = append(where, &model2.ModelWhereOrder{
|
||||
Where: model2.NewWhere("parentID", parentID),
|
||||
})
|
||||
}
|
||||
if title != "" {
|
||||
where = append(where, &model2.ModelWhereOrder{
|
||||
Where: model2.NewWhereLike("title", title),
|
||||
@ -106,7 +111,6 @@ func (c *Equipment) Detail(id uint64) (*EquipmentDetail, error) {
|
||||
} else if !isExist {
|
||||
return nil, errors.New("操作错误,数据不存在")
|
||||
}
|
||||
|
||||
out := &EquipmentDetail{
|
||||
CommonIDString: basic.CommonIDString{ID: mManageEquipment.GetEncodeID()},
|
||||
ManageEquipment: mManageEquipment.ManageEquipment,
|
||||
@ -147,14 +151,15 @@ func (c *Equipment) Form(params *EquipmentParams) error {
|
||||
return errors.New("操作错误,装备信息不存在")
|
||||
}
|
||||
|
||||
if params.Title != mManageEquipment.Title {
|
||||
if isExist, err = params.isExist(mManageEquipment.ManageEquipment); err != nil {
|
||||
if params.Code != mManageEquipment.Code {
|
||||
if isExist, err = params.isExist(mManageEquipment.ManageEquipment, c.TenantID); err != nil {
|
||||
return err
|
||||
} else if isExist {
|
||||
return errors.New("操作错误,已存在相应的装备信息")
|
||||
}
|
||||
}
|
||||
}
|
||||
mManageEquipment.Code = params.Code
|
||||
mManageEquipment.Title = params.Title
|
||||
mManageEquipment.Image.Image = params.Image
|
||||
mManageEquipment.Config = params.Config
|
||||
@ -165,7 +170,7 @@ func (c *Equipment) Form(params *EquipmentParams) error {
|
||||
return model2.Updates(mManageEquipment.ManageEquipment, mManageEquipment.ManageEquipment)
|
||||
}
|
||||
// 查询装备信息是否存在
|
||||
if isExist, err := params.isExist(mManageEquipment.ManageEquipment); err != nil {
|
||||
if isExist, err := params.isExist(mManageEquipment.ManageEquipment, c.TenantID); err != nil {
|
||||
return err
|
||||
} else if isExist {
|
||||
return errors.New("操作错误,已存在相应的装备信息")
|
||||
|
@ -38,11 +38,14 @@ func (c *MaterialParams) isExistForCode(iModel model2.IModel, tenantID uint64) (
|
||||
}
|
||||
|
||||
// List 列表信息
|
||||
func (c *Material) List(supplierID uint64, code, title string, page, pageSize int) (*basic.PageDataResponse, error) {
|
||||
func (c *Material) List(manufacturerID, supplierID uint64, code, title string, page, pageSize int) (*basic.PageDataResponse, error) {
|
||||
mManageMaterial := model.NewManageMaterial()
|
||||
|
||||
where := make([]*model2.ModelWhere, 0)
|
||||
|
||||
if manufacturerID > 0 {
|
||||
where = append(where, model2.NewWhere("m.manufacturer_id", manufacturerID))
|
||||
}
|
||||
if supplierID > 0 {
|
||||
where = append(where, model2.NewWhere("m.supplier_id", supplierID))
|
||||
}
|
||||
|
Reference in New Issue
Block a user