|
@@ -137,14 +137,14 @@ func (s *StoreEntry) PastureInit(ctx context.Context, pastureId int64) error {
|
|
|
}
|
|
|
|
|
|
pasture := &model.AppPastureList{}
|
|
|
- if err := s.DB.Model(new(model.AppPastureList)).
|
|
|
+ if err = s.DB.Model(new(model.AppPastureList)).
|
|
|
Where("id = ?", pastureId).
|
|
|
First(pasture).Error; err != nil {
|
|
|
return xerr.Customf("该牧场不存在:%d", pastureId)
|
|
|
}
|
|
|
|
|
|
deptList := make([]*model.SystemDept, 0)
|
|
|
- if err := s.DB.Model(new(model.SystemDept)).
|
|
|
+ if err = s.DB.Model(new(model.SystemDept)).
|
|
|
Where("id = ?", pasture.Id).
|
|
|
Find(&deptList).Error; err != nil {
|
|
|
return xerr.Customf("牧场初始化数据失败:%s", err.Error())
|
|
@@ -157,41 +157,41 @@ func (s *StoreEntry) PastureInit(ctx context.Context, pastureId int64) error {
|
|
|
dataWaringTypeEnumList := s.DataWaringTypeEnumList(userModel, "all")
|
|
|
dataWarningList := model.DataWarningInitData(pastureId, dataWaringTypeEnumList)
|
|
|
|
|
|
- if err := s.DB.Transaction(func(tx *gorm.DB) error {
|
|
|
+ if err = s.DB.Transaction(func(tx *gorm.DB) error {
|
|
|
for _, dataWarning := range dataWarningList {
|
|
|
- if err := tx.Model(new(model.DataWarning)).
|
|
|
+ if err = tx.Model(new(model.DataWarning)).
|
|
|
Create(dataWarning).Error; err != nil {
|
|
|
zaplog.Error("PastureInit-DataWarning", zap.Any("error", err))
|
|
|
}
|
|
|
dataWarningItemsList := model.DataWarningItemsInitData(pastureId, dataWarning)
|
|
|
- if err := tx.Model(new(model.DataWarningItems)).
|
|
|
+ if err = tx.Model(new(model.DataWarningItems)).
|
|
|
Create(dataWarningItemsList).Error; err != nil {
|
|
|
zaplog.Error("PastureInit-DataWarningItems", zap.Any("error", err))
|
|
|
}
|
|
|
}
|
|
|
|
|
|
nackRingConfigureList := model.NeckRingConfigureInit(pastureId)
|
|
|
- if err := tx.Model(new(model.NeckRingConfigure)).
|
|
|
+ if err = tx.Model(new(model.NeckRingConfigure)).
|
|
|
Create(nackRingConfigureList).Error; err != nil {
|
|
|
zaplog.Error("PastureInit-NeckRingConfigure", zap.Any("error", err))
|
|
|
}
|
|
|
|
|
|
// 初始化牧场和部门数据
|
|
|
newSystemPastureDept := model.NewSystemPastureDeptInit(pasture)
|
|
|
- if err := tx.Model(new(model.SystemDept)).
|
|
|
+ if err = tx.Model(new(model.SystemDept)).
|
|
|
Create(newSystemPastureDept).Error; err != nil {
|
|
|
zaplog.Error("PastureInit-SystemDept", zap.Any("error", err))
|
|
|
}
|
|
|
|
|
|
newSystemDept := model.NewSystemDeptInit(pasture.Id, newSystemPastureDept.Id)
|
|
|
- if err := tx.Model(new(model.SystemDept)).
|
|
|
+ if err = tx.Model(new(model.SystemDept)).
|
|
|
Create(newSystemDept).Error; err != nil {
|
|
|
zaplog.Error("PastureInit-SystemDept", zap.Any("error", err))
|
|
|
}
|
|
|
|
|
|
// 初始化菜单
|
|
|
systemMenuList := make([]*model.SystemPastureMenu, 0)
|
|
|
- if err := tx.Model(new(model.SystemPastureMenu)).
|
|
|
+ if err = tx.Model(new(model.SystemPastureMenu)).
|
|
|
Where("pasture_id = ?", 0).
|
|
|
Find(&systemMenuList).Error; err != nil {
|
|
|
zaplog.Error("PastureInit-SystemMenu", zap.Any("error", err))
|
|
@@ -206,12 +206,12 @@ func (s *StoreEntry) PastureInit(ctx context.Context, pastureId int64) error {
|
|
|
newSystemMenuList = append(newSystemMenuList, newSystemMenu)
|
|
|
}
|
|
|
|
|
|
- if err := tx.Model(new(model.SystemPastureMenu)).
|
|
|
+ if err = tx.Model(new(model.SystemPastureMenu)).
|
|
|
Create(newSystemMenuList).Error; err != nil {
|
|
|
zaplog.Error("PastureInit-SystemMenu", zap.Any("error", err))
|
|
|
}
|
|
|
|
|
|
- // 初始化用户和角色
|
|
|
+ // 初始化用户和角色 todo
|
|
|
|
|
|
return nil
|
|
|
}); err != nil {
|