added wrong judgement

This commit is contained in:
yangk 2020-09-23 15:51:34 +08:00
parent 9641a41541
commit 1d71a5f40e
3 changed files with 24 additions and 5 deletions

View File

@ -11,14 +11,17 @@ import (
// AddConfigGroup -
func (a *ApplicationAction) AddConfigGroup(appID string, req *model.ApplicationConfigGroup) (*model.ApplicationConfigGroupResp, error) {
var serviceResp []dbmodel.ServiceConfigGroup
services, err := db.GetManager().TenantServiceDao().GetServicesByServiceIDs(req.ServiceIDs)
if err != nil {
return nil, err
}
// Create application configGroup-services
for _, sid := range req.ServiceIDs {
services, _ := db.GetManager().TenantServiceDao().GetServiceByID(sid)
for _, s := range services {
serviceConfigGroup := dbmodel.ServiceConfigGroup{
AppID: appID,
ConfigGroupName: req.ConfigGroupName,
ServiceID: sid,
ServiceAlias: services.ServiceAlias,
ServiceID: s.ServiceID,
ServiceAlias: s.ServiceAlias,
}
serviceResp = append(serviceResp, serviceConfigGroup)
if err := db.GetManager().AppConfigGroupServiceDao().AddModel(&serviceConfigGroup); err != nil {
@ -57,7 +60,10 @@ func (a *ApplicationAction) AddConfigGroup(appID string, req *model.ApplicationC
return nil, err
}
appconfig, _ := db.GetManager().AppConfigGroupDao().GetConfigByID(appID, req.ConfigGroupName)
appconfig, err := db.GetManager().AppConfigGroupDao().GetConfigByID(appID, req.ConfigGroupName)
if err != nil {
return nil, err
}
var resp *model.ApplicationConfigGroupResp
resp = &model.ApplicationConfigGroupResp{
CreateTime: appconfig.CreatedAt,

View File

@ -123,6 +123,7 @@ type TenantServiceDao interface {
GetServicesInfoByAppID(appID string, page, pageSize int) ([]*model.TenantServices, int64, error)
CountServiceByAppID(appID string) (int64, error)
GetServiceIDsByAppID(appID string) (re []model.ServiceID)
GetServicesByServiceIDs(serviceIDs []string) ([]*model.TenantServices, error)
DeleteServiceByServiceID(serviceID string) error
GetServiceMemoryByTenantIDs(tenantIDs, serviceIDs []string) (map[string]map[string]interface{}, error)
GetServiceMemoryByServiceIDs(serviceIDs []string) (map[string]map[string]interface{}, error)

View File

@ -492,6 +492,18 @@ func (t *TenantServicesDaoImpl) GetServiceIDsByAppID(appID string) (re []model.S
return
}
//GetServicesByServiceIDs Get Services By ServiceIDs
func (t *TenantServicesDaoImpl) GetServicesByServiceIDs(serviceIDs []string) ([]*model.TenantServices, error) {
var services []*model.TenantServices
if err := t.DB.Where("service_id in (?)", serviceIDs).Find(&services).Error; err != nil {
if err == gorm.ErrRecordNotFound {
return services, nil
}
return nil, err
}
return services, nil
}
//SetTenantServiceStatus SetTenantServiceStatus
func (t *TenantServicesDaoImpl) SetTenantServiceStatus(serviceID, status string) error {
var service model.TenantServices