upd
This commit is contained in:
1 parent
330c160122
commit
f9feaeab0b
3 files changed
+11
-3
No files matched your search
@@ -23,15 +23,18 @@ type config struct {
|
||||
// @Tags Конфигурация
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param body body domain.GetByModuleIdRequest true "название модуля"
|
||||
// @Param body body domain.GetByModuleNameRequest true "название модуля"
|
||||
// @Success 200 {object} entity.Config
|
||||
// @Failure 404 {object} structure.GrpcError "если конфигурация не найдена"
|
||||
// @Failure 500 {object} structure.GrpcError
|
||||
// @Router /config/get_active_config_by_module_name [POST]
|
||||
func (c *config) GetActiveConfigByModuleName(request domain.GetByModuleIdRequest) (*entity.Config, error) {
|
||||
func (c *config) GetActiveConfigByModuleName(request domain.GetByModuleNameRequest) (*entity.Config, error) {
|
||||
var response *entity.Config
|
||||
c.rstore.VisitReadonlyState(func(state state.ReadonlyState) {
|
||||
response = state.Configs().GetActiveByModuleId(request.ModuleId)
|
||||
module := state.Modules().GetByName(request.ModuleName)
|
||||
if module != nil {
|
||||
response = state.Configs().GetActiveByModuleId(module.Id)
|
||||
}
|
||||
})
|
||||
if response == nil {
|
||||
return nil, status.Error(codes.NotFound, utils.ValidationError)
|
||||
|
||||
@@ -7,3 +7,7 @@ type ConfigIdRequest struct {
|
||||
type GetByModuleIdRequest struct {
|
||||
ModuleId string `valid:"required~Required"`
|
||||
}
|
||||
|
||||
type GetByModuleNameRequest struct {
|
||||
ModuleName string `valid:"required~Required"`
|
||||
}
|
||||
@@ -19,6 +19,7 @@ type WriteableConfigStore interface {
|
||||
|
||||
type ReadonlyConfigStore interface {
|
||||
GetActiveByModuleId(moduleId string) *entity.Config
|
||||
GetActiveByModuleName(moduleId string) *entity.Config
|
||||
GetByIds(ids []string) []entity.Config
|
||||
GetByModuleIds(ids []string) []entity.Config
|
||||
FilterByCommonConfigs(commonIds []string) []entity.Config
|
||||
|
||||
Reference in new issue
Block a user