dictionary

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 24, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewDictionaryModule

func NewDictionaryModule(logger logging.Logger, deps *core.Dependencies) core.Module

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 获取可选项

func (*DictionaryComponent) Name

func (c *DictionaryComponent) Name() string

Name 返回组件名称

func (*DictionaryComponent) PopulateDisplay

func (c *DictionaryComponent) PopulateDisplay(
	ctx context.Context,
	config map[string]any,
	values []any,
) (map[any]component.Display, error)

PopulateDisplay 填充显示信息

func (*DictionaryComponent) Validate

func (c *DictionaryComponent) Validate(
	ctx context.Context,
	config map[string]any,
	value any,
) error

Validate 验证字段值

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

func (s *DictionaryService) DeleteDetail(ctx context.Context, id uuid.UUID) error

DeleteDetail deletes a dictionary item

func (*DictionaryService) DeleteDictionary

func (s *DictionaryService) DeleteDictionary(ctx context.Context, id uuid.UUID) error

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL