MSP-5014 Rename entity to model

This commit is contained in:
Синельник Тимур Романович committed 2025-03-21 10:08:25 +03:00
1 parent 69319f0d2b
commit 418c4e757f
6 files changed
+43 -43

No files matched your search

+11 -11
View File
@@ -3,7 +3,7 @@ package service
import (
"encoding/json"
"ispctl/entity"
"ispctl/model"
"ispctl/repository"
"github.com/pkg/errors"
@@ -26,18 +26,18 @@ func (c *ConfigService) ReceiveConfiguration(host string) error {
return nil
}
func (c *ConfigService) GetAvailableConfigs() ([]entity.ModuleInfo, error) {
func (c *ConfigService) GetAvailableConfigs() ([]model.ModuleInfo, error) {
return c.configRepo.GetAvailableConfigs()
}
func (c *ConfigService) GetConfigurationByModuleName(moduleName string) (*entity.Config, error) {
func (c *ConfigService) GetConfigurationByModuleName(moduleName string) (*model.Config, error) {
if moduleName == "" {
return nil, errors.New("need module name")
}
moduleConfiguration, err := c.configRepo.GetConfigByModuleName(moduleName)
switch {
case errors.Is(err, entity.ErrModuleNotFound):
case errors.Is(err, model.ErrModuleNotFound):
return nil, errors.Errorf("module [%s] not found", moduleName)
default:
return moduleConfiguration, err
@@ -52,7 +52,7 @@ func (c *ConfigService) GetSchemaByModuleId(moduleId string) (schema.Schema, err
return configSchema.Schema, nil
}
func (c *ConfigService) CreateUpdateConfig(stringToChange string, configuration *entity.Config) (map[string]any, error) {
func (c *ConfigService) CreateUpdateConfig(stringToChange string, configuration *model.Config) (map[string]any, error) {
newData := make(map[string]any)
if stringToChange != "" {
err := json.Unmarshal([]byte(stringToChange), &newData)
@@ -65,7 +65,7 @@ func (c *ConfigService) CreateUpdateConfig(stringToChange string, configuration
return c.CreateUpdateConfigV2(configuration)
}
func (c *ConfigService) CreateUpdateConfigV2(configuration *entity.Config) (map[string]any, error) {
func (c *ConfigService) CreateUpdateConfigV2(configuration *model.Config) (map[string]any, error) {
configuration.Unsafe = c.UnsafeEnable
resp, err := c.configRepo.CreateUpdateConfig(*configuration)
if err != nil {
@@ -74,18 +74,18 @@ func (c *ConfigService) CreateUpdateConfigV2(configuration *entity.Config) (map[
return resp.Data, nil
}
func (c *ConfigService) GetAllVariables() ([]entity.Variable, error) {
func (c *ConfigService) GetAllVariables() ([]model.Variable, error) {
return c.configRepo.GetAllVariables()
}
func (c *ConfigService) GetVariableByName(variableName string) (*entity.Variable, error) {
func (c *ConfigService) GetVariableByName(variableName string) (*model.Variable, error) {
if variableName == "" {
return nil, errors.New("need variable name")
}
variable, err := c.configRepo.GetVariableByName(variableName)
switch {
case errors.Is(err, entity.ErrVariableNotFound):
case errors.Is(err, model.ErrVariableNotFound):
return nil, errors.Errorf("variable [%s] not found", variableName)
case err != nil:
return nil, err
@@ -101,13 +101,13 @@ func (c *ConfigService) DeleteVariable(variableName string) error {
err := c.configRepo.DeleteVariable(variableName)
switch {
case errors.Is(err, entity.ErrVariableNotFound):
case errors.Is(err, model.ErrVariableNotFound):
return errors.Errorf("variable [%s] not found", variableName)
default:
return err
}
}
func (c *ConfigService) UpsertVariables(vars []entity.UpsertVariableRequest) error {
func (c *ConfigService) UpsertVariables(vars []model.UpsertVariableRequest) error {
return c.configRepo.UpsertVariables(vars)
}