Documentation
¶
Index ¶
- func NewDictionaryModule(logger logging.Logger, deps *core.Dependencies) core.Module
- type DictionaryComponent
- func (c *DictionaryComponent) GetOptions(ctx context.Context, config map[string]any) ([]component.Option, error)
- func (c *DictionaryComponent) Name() string
- func (c *DictionaryComponent) PopulateDisplay(ctx context.Context, config map[string]any, values []any) (map[any]component.Display, error)
- func (c *DictionaryComponent) Validate(ctx context.Context, config map[string]any, value any) error
- type DictionaryConfig
- type DictionaryHandler
- func (h *DictionaryHandler) CreateDetail(w http.ResponseWriter, r *http.Request)
- func (h *DictionaryHandler) CreateDictionary(w http.ResponseWriter, r *http.Request)
- func (h *DictionaryHandler) DeleteDetail(w http.ResponseWriter, r *http.Request)
- func (h *DictionaryHandler) DeleteDictionary(w http.ResponseWriter, r *http.Request)
- func (h *DictionaryHandler) GetDictionaryByCode(w http.ResponseWriter, r *http.Request)
- func (h *DictionaryHandler) ListDictionaries(w http.ResponseWriter, r *http.Request)
- func (h *DictionaryHandler) UpdateDetail(w http.ResponseWriter, r *http.Request)
- func (h *DictionaryHandler) UpdateDictionary(w http.ResponseWriter, r *http.Request)
- type DictionaryModule
- type DictionaryService
- func (s *DictionaryService) CreateDetail(ctx context.Context, dictID uuid.UUID, input *ent.DictionaryDetail) (*ent.DictionaryDetail, error)
- func (s *DictionaryService) CreateDictionary(ctx context.Context, input *ent.Dictionary) (*ent.Dictionary, error)
- func (s *DictionaryService) DeleteDetail(ctx context.Context, id uuid.UUID) error
- func (s *DictionaryService) DeleteDictionary(ctx context.Context, id uuid.UUID) error
- func (s *DictionaryService) GetDetailsByCode(ctx context.Context, code string) ([]*ent.DictionaryDetail, error)
- func (s *DictionaryService) ListDictionaries(ctx context.Context) ([]*ent.Dictionary, error)
- func (s *DictionaryService) UpdateDetail(ctx context.Context, id uuid.UUID, input *ent.DictionaryDetail) (*ent.DictionaryDetail, error)
- func (s *DictionaryService) UpdateDictionary(ctx context.Context, id uuid.UUID, input *ent.Dictionary) (*ent.Dictionary, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewDictionaryModule ¶
Types ¶
type DictionaryComponent ¶
type DictionaryComponent struct {
// contains filtered or unexported fields
}
DictionaryComponent 字典组件实现
func NewDictionaryComponent ¶
func NewDictionaryComponent(client *ent.Client) *DictionaryComponent
NewDictionaryComponent 创建字典组件
func (*DictionaryComponent) GetOptions ¶
func (c *DictionaryComponent) GetOptions( ctx context.Context, config map[string]any, ) ([]component.Option, error)
GetOptions 获取可选项
type DictionaryConfig ¶
type DictionaryConfig struct {
Code string `json:"code"`
}
DictionaryConfig 字典组件配置
type DictionaryHandler ¶
type DictionaryHandler struct {
// contains filtered or unexported fields
}
func NewDictionaryHandler ¶
func NewDictionaryHandler(dictService *DictionaryService, logger logging.Logger) *DictionaryHandler
func (*DictionaryHandler) CreateDetail ¶
func (h *DictionaryHandler) CreateDetail(w http.ResponseWriter, r *http.Request)
CreateDetail creates a new dictionary item @Summary Create a dictionary detail item @Tags Dictionaries @Accept json @Produce json @Param id path string true "Dictionary ID" @Param request body ent.DictionaryDetail true "Dictionary detail data" @Success 201 {object} ent.DictionaryDetail @Failure 400 {object} responder.Error @Failure 500 {object} responder.Error @Router /dictionaries/{id}/details [post]
func (*DictionaryHandler) CreateDictionary ¶
func (h *DictionaryHandler) CreateDictionary(w http.ResponseWriter, r *http.Request)
CreateDictionary creates a new dictionary category @Summary Create a new dictionary @Tags Dictionaries @Accept json @Produce json @Param request body ent.Dictionary true "Dictionary data" @Success 201 {object} ent.Dictionary @Failure 400 {object} responder.Error @Failure 500 {object} responder.Error @Router /dictionaries [post]
func (*DictionaryHandler) DeleteDetail ¶
func (h *DictionaryHandler) DeleteDetail(w http.ResponseWriter, r *http.Request)
DeleteDetail deletes a dictionary item @Summary Delete a dictionary detail item @Tags Dictionaries @Accept json @Produce json @Param id path string true "Dictionary Detail ID" @Success 200 {object} map[string]string @Failure 400 {object} responder.Error @Failure 500 {object} responder.Error @Router /dictionary-details/{id} [delete]
func (*DictionaryHandler) DeleteDictionary ¶
func (h *DictionaryHandler) DeleteDictionary(w http.ResponseWriter, r *http.Request)
DeleteDictionary deletes a dictionary category @Summary Delete a dictionary @Tags Dictionaries @Accept json @Produce json @Param id path string true "Dictionary ID" @Success 200 {object} map[string]string @Failure 400 {object} responder.Error @Failure 500 {object} responder.Error @Router /dictionaries/{id} [delete]
func (*DictionaryHandler) GetDictionaryByCode ¶
func (h *DictionaryHandler) GetDictionaryByCode(w http.ResponseWriter, r *http.Request)
GetDictionaryByCode returns dictionary items by code (Public API) @Summary Get dictionary by code @Tags Dictionaries @Accept json @Produce json @Param code path string true "Dictionary code" @Success 200 {object} []ent.DictionaryDetail @Failure 400 {object} responder.Error @Failure 500 {object} responder.Error @Router /dictionaries/{code}/details [get]
func (*DictionaryHandler) ListDictionaries ¶
func (h *DictionaryHandler) ListDictionaries(w http.ResponseWriter, r *http.Request)
ListDictionaries returns all dictionaries @Summary List all dictionaries @Tags Dictionaries @Accept json @Produce json @Success 200 {object} []ent.Dictionary @Failure 500 {object} responder.Error @Router /dictionaries [get]
func (*DictionaryHandler) UpdateDetail ¶
func (h *DictionaryHandler) UpdateDetail(w http.ResponseWriter, r *http.Request)
UpdateDetail updates a dictionary item @Summary Update a dictionary detail item @Tags Dictionaries @Accept json @Produce json @Param id path string true "Dictionary Detail ID" @Param request body ent.DictionaryDetail true "Dictionary detail data" @Success 200 {object} ent.DictionaryDetail @Failure 400 {object} responder.Error @Failure 500 {object} responder.Error @Router /dictionary-details/{id} [put]
func (*DictionaryHandler) UpdateDictionary ¶
func (h *DictionaryHandler) UpdateDictionary(w http.ResponseWriter, r *http.Request)
UpdateDictionary updates a dictionary category @Summary Update a dictionary @Tags Dictionaries @Accept json @Produce json @Param id path string true "Dictionary ID" @Param request body ent.Dictionary true "Dictionary data" @Success 200 {object} ent.Dictionary @Failure 400 {object} responder.Error @Failure 500 {object} responder.Error @Router /dictionaries/{id} [put]
type DictionaryModule ¶
type DictionaryModule struct {
// contains filtered or unexported fields
}
func (*DictionaryModule) Name ¶
func (m *DictionaryModule) Name() string
func (*DictionaryModule) RegisterPrivateRoutes ¶
func (m *DictionaryModule) RegisterPrivateRoutes(r chi.Router)
RegisterPrivateRoutes registers protected dictionary endpoints (admin management)
func (*DictionaryModule) RegisterPublicRoutes ¶
func (m *DictionaryModule) RegisterPublicRoutes(r chi.Router)
RegisterPublicRoutes registers public dictionary endpoints
type DictionaryService ¶
type DictionaryService struct {
// contains filtered or unexported fields
}
func NewDictionaryService ¶
func NewDictionaryService(client *ent.Client, logger logging.Logger) *DictionaryService
func (*DictionaryService) CreateDetail ¶
func (s *DictionaryService) CreateDetail(ctx context.Context, dictID uuid.UUID, input *ent.DictionaryDetail) (*ent.DictionaryDetail, error)
CreateDetail creates a new dictionary item
func (*DictionaryService) CreateDictionary ¶
func (s *DictionaryService) CreateDictionary(ctx context.Context, input *ent.Dictionary) (*ent.Dictionary, error)
CreateDictionary creates a new dictionary
func (*DictionaryService) DeleteDetail ¶
DeleteDetail deletes a dictionary item
func (*DictionaryService) DeleteDictionary ¶
DeleteDictionary deletes a dictionary and its items
func (*DictionaryService) GetDetailsByCode ¶
func (s *DictionaryService) GetDetailsByCode(ctx context.Context, code string) ([]*ent.DictionaryDetail, error)
GetDetailsByCode returns dictionary details by dictionary code
func (*DictionaryService) ListDictionaries ¶
func (s *DictionaryService) ListDictionaries(ctx context.Context) ([]*ent.Dictionary, error)
ListDictionaries returns all dictionaries
func (*DictionaryService) UpdateDetail ¶
func (s *DictionaryService) UpdateDetail(ctx context.Context, id uuid.UUID, input *ent.DictionaryDetail) (*ent.DictionaryDetail, error)
UpdateDetail updates a dictionary item
func (*DictionaryService) UpdateDictionary ¶
func (s *DictionaryService) UpdateDictionary(ctx context.Context, id uuid.UUID, input *ent.Dictionary) (*ent.Dictionary, error)
UpdateDictionary updates a dictionary