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 - // AddConfigGroup -
func (a *ApplicationAction) AddConfigGroup(appID string, req *model.ApplicationConfigGroup) (*model.ApplicationConfigGroupResp, error) { func (a *ApplicationAction) AddConfigGroup(appID string, req *model.ApplicationConfigGroup) (*model.ApplicationConfigGroupResp, error) {
var serviceResp []dbmodel.ServiceConfigGroup var serviceResp []dbmodel.ServiceConfigGroup
services, err := db.GetManager().TenantServiceDao().GetServicesByServiceIDs(req.ServiceIDs)
if err != nil {
return nil, err
}
// Create application configGroup-services // Create application configGroup-services
for _, sid := range req.ServiceIDs { for _, s := range services {
services, _ := db.GetManager().TenantServiceDao().GetServiceByID(sid)
serviceConfigGroup := dbmodel.ServiceConfigGroup{ serviceConfigGroup := dbmodel.ServiceConfigGroup{
AppID: appID, AppID: appID,
ConfigGroupName: req.ConfigGroupName, ConfigGroupName: req.ConfigGroupName,
ServiceID: sid, ServiceID: s.ServiceID,
ServiceAlias: services.ServiceAlias, ServiceAlias: s.ServiceAlias,
} }
serviceResp = append(serviceResp, serviceConfigGroup) serviceResp = append(serviceResp, serviceConfigGroup)
if err := db.GetManager().AppConfigGroupServiceDao().AddModel(&serviceConfigGroup); err != nil { 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 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 var resp *model.ApplicationConfigGroupResp
resp = &model.ApplicationConfigGroupResp{ resp = &model.ApplicationConfigGroupResp{
CreateTime: appconfig.CreatedAt, CreateTime: appconfig.CreatedAt,

View File

@ -123,6 +123,7 @@ type TenantServiceDao interface {
GetServicesInfoByAppID(appID string, page, pageSize int) ([]*model.TenantServices, int64, error) GetServicesInfoByAppID(appID string, page, pageSize int) ([]*model.TenantServices, int64, error)
CountServiceByAppID(appID string) (int64, error) CountServiceByAppID(appID string) (int64, error)
GetServiceIDsByAppID(appID string) (re []model.ServiceID) GetServiceIDsByAppID(appID string) (re []model.ServiceID)
GetServicesByServiceIDs(serviceIDs []string) ([]*model.TenantServices, error)
DeleteServiceByServiceID(serviceID string) error DeleteServiceByServiceID(serviceID string) error
GetServiceMemoryByTenantIDs(tenantIDs, serviceIDs []string) (map[string]map[string]interface{}, error) GetServiceMemoryByTenantIDs(tenantIDs, serviceIDs []string) (map[string]map[string]interface{}, error)
GetServiceMemoryByServiceIDs(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 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 //SetTenantServiceStatus SetTenantServiceStatus
func (t *TenantServicesDaoImpl) SetTenantServiceStatus(serviceID, status string) error { func (t *TenantServicesDaoImpl) SetTenantServiceStatus(serviceID, status string) error {
var service model.TenantServices var service model.TenantServices