|
@@ -344,10 +344,12 @@ func (s *StoreEntry) BarnTypeOptions(ctx context.Context) (*pasturePb.ConfigOpti
|
|
|
}
|
|
|
func (s *StoreEntry) BarnListOptions(ctx context.Context, penType int) (*pasturePb.ConfigOptionsListResponse, error) {
|
|
|
penList := make([]*model.Pen, 0)
|
|
|
- if err := s.DB.Table(new(model.Pen).TableName()).
|
|
|
- Where("is_delete = ?", pasturePb.IsShow_Ok).
|
|
|
- Where("pen_type = ?", penType).
|
|
|
- Find(&penList).Error; err != nil {
|
|
|
+ pref := s.DB.Table(new(model.Pen).TableName()).
|
|
|
+ Where("is_delete = ?", pasturePb.IsShow_Ok)
|
|
|
+ if penType != -1 {
|
|
|
+ pref.Where("pen_type = ?", penType)
|
|
|
+ }
|
|
|
+ if err := pref.Find(&penList).Error; err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
|
|
@@ -406,7 +408,9 @@ func (s *StoreEntry) CowTransferPenReasonOptions(ctx context.Context) (*pastureP
|
|
|
|
|
|
func (s *StoreEntry) SystemUserOptions(ctx context.Context, depId int) (*pasturePb.ConfigOptionsListResponse, error) {
|
|
|
systemUserList := make([]*model.SystemUser, 0)
|
|
|
- pref := s.DB.Table(new(model.SystemUser).TableName())
|
|
|
+ pref := s.DB.Table(new(model.SystemUser).TableName()).
|
|
|
+ Where("is_delete = ?", pasturePb.IsShow_Ok).
|
|
|
+ Where("is_show =? ", pasturePb.IsShow_Ok)
|
|
|
if depId != -1 && depId > 0 {
|
|
|
pref = pref.Where("dep_id = ?", depId)
|
|
|
}
|