Documentation ¶
Index ¶
- Constants
- Variables
- func InitRoutes(route fiber.Router)
- type CreateInput
- type DeleteInput
- type Dictionary
- type DictionaryOutput
- type Handler
- type Repository
- func (r *Repository) Create(e *Dictionary, db *sqlx.DB) error
- func (r *Repository) Delete(e *Dictionary, db *sqlx.DB) error
- func (r *Repository) QueryByCode(c string, db *sqlx.DB) ([]*dictionary_item.DictionaryItem, error)
- func (r *Repository) QueryCount(w *WhereParams, db *sqlx.DB) (uint64, error)
- func (r *Repository) QueryPage(w *WhereParams, db *sqlx.DB) ([]*Dictionary, error)
- func (r *Repository) Update(e *Dictionary, db *sqlx.DB) error
- func (r *Repository) ValidationFields(e *Dictionary, db *sqlx.DB) (*Dictionary, error)
- type Service
- func (s *Service) Create(r *CreateInput) error
- func (s *Service) Delete(r *DeleteInput) error
- func (s *Service) QueryByCode(code string) ([]*dictionary_item.DictionaryItemOutput, error)
- func (s *Service) QueryPage(w *WhereParams) ([]*DictionaryOutput, uint64, error)
- func (s *Service) Update(r *UpdateInput) error
- type UpdateInput
- type WhereParams
Constants ¶
View Source
const ( CreatedSuccess = "添加字典成功!" CreatedFail = "添加字典失败!" UpdatedSuccess = "修改字典成功!" UpdatedFail = "修改字典失败!" DeletedSuccess = "删除字典成功!" DeletedFail = "删除字典失败!" ErrorNotExist = "字典不存在!" ErrorNameRepeat = "字典名称重复,请重新输入!" ErrorCodeRepeat = "字典编码重复,请重新输入!" ErrorExistChildren = "此字典下有选项,请删除其所有选项后再操作!" )
View Source
const ( FieldID = "id" FieldName = "name" FieldCode = "code" FieldStatus = "status" FieldSort = "sort" FieldRemark = "remark" FieldCreatedAt = "created_at" FieldUpdatedAt = "updated_at" FieldCreatedBy = "created_by" FieldUpdatedBy = "updated_by" Table = "system_dictionaries" ItemsTable = "system_dictionary_items" )
Variables ¶
View Source
var SelectFields = []string{FieldID, FieldName, FieldCode, FieldStatus, FieldSort, FieldRemark}
Functions ¶
func InitRoutes ¶
func InitRoutes(route fiber.Router)
Types ¶
type CreateInput ¶
type CreateInput struct { Name string `zh:"字典名称" json:"name" validate:"required,min=2,max=32"` Code string `zh:"字典编码" json:"code" validate:"required,min=2,max=64"` Status string `zh:"状态" json:"status" validate:"omitempty,oneof=Disable Enable"` Sort int32 `zh:"排序" json:"sort" validate:"omitempty,number,gt=0"` Remark string `zh:"备注" json:"remark" validate:"omitempty,max=128"` CreatedBy string `zh:"创建人员" json:"created_by" validate:"omitempty"` }
type DeleteInput ¶
type DeleteInput struct {
ID string `zh:"唯一标识符" json:"id" validate:"required"`
}
type Dictionary ¶
type Dictionary struct { ID string `db:"id" json:"id"` Name string `db:"name" json:"name"` Code string `db:"code" json:"code"` Status string `db:"status" json:"status"` Sort int32 `db:"sort" json:"sort"` Remark string `db:"remark" json:"remark,omitempty"` CreatedAt int64 `db:"created_at" json:"-"` UpdatedAt int64 `db:"updated_at" json:"updated_at"` CreatedBy string `db:"created_by" json:"-"` UpdatedBy string `db:"updated_by" json:"-"` }
type DictionaryOutput ¶
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
func NewHandler ¶
func NewHandler() *Handler
func (*Handler) QueryByCode ¶
type Repository ¶
type Repository struct{}
func NewRepository ¶
func NewRepository() *Repository
func (*Repository) Create ¶
func (r *Repository) Create(e *Dictionary, db *sqlx.DB) error
func (*Repository) Delete ¶
func (r *Repository) Delete(e *Dictionary, db *sqlx.DB) error
func (*Repository) QueryByCode ¶
func (r *Repository) QueryByCode(c string, db *sqlx.DB) ([]*dictionary_item.DictionaryItem, error)
func (*Repository) QueryCount ¶
func (r *Repository) QueryCount(w *WhereParams, db *sqlx.DB) (uint64, error)
func (*Repository) QueryPage ¶
func (r *Repository) QueryPage(w *WhereParams, db *sqlx.DB) ([]*Dictionary, error)
func (*Repository) Update ¶
func (r *Repository) Update(e *Dictionary, db *sqlx.DB) error
func (*Repository) ValidationFields ¶
func (r *Repository) ValidationFields(e *Dictionary, db *sqlx.DB) (*Dictionary, error)
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
func NewService ¶
func NewService() *Service
func (*Service) Create ¶
func (s *Service) Create(r *CreateInput) error
func (*Service) Delete ¶
func (s *Service) Delete(r *DeleteInput) error
func (*Service) QueryByCode ¶
func (s *Service) QueryByCode(code string) ([]*dictionary_item.DictionaryItemOutput, error)
func (*Service) QueryPage ¶
func (s *Service) QueryPage(w *WhereParams) ([]*DictionaryOutput, uint64, error)
func (*Service) Update ¶
func (s *Service) Update(r *UpdateInput) error
type UpdateInput ¶
type UpdateInput struct { ID string `zh:"唯一标识符" json:"id" validate:"required"` Name string `zh:"字典名称" json:"name" validate:"omitempty,min=2,max=32"` Code string `zh:"字典编码" json:"code" validate:"omitempty,min=2,max=64"` Status string `zh:"状态" json:"status" validate:"omitempty,oneof=Disable Enable"` Sort int32 `zh:"排序" json:"sort" validate:"omitempty,number,gt=0"` Remark string `zh:"备注" json:"remark" validate:"omitempty,max=128"` UpdatedBy string `zh:"更新人员" json:"updated_by" validate:"omitempty"` }
type WhereParams ¶
type WhereParams struct { Name string `zh:"字典名称" query:"name" json:"name" validate:"omitempty,max=32"` Code string `zh:"字典编码" query:"code" json:"code" validate:"omitempty,max=64"` Status string `zh:"状态" query:"status" json:"status" validate:"omitempty,oneof=Disable Enable"` Remark string `zh:"备注" query:"remark" json:"remark" validate:"omitempty,max=128"` PageSize uint64 `zh:"分页数量" query:"pageSize" json:"pageSize" validate:"omitempty,number,gt=0,max=50"` Current uint64 `zh:"页数" query:"current" json:"current" validate:"omitempty,number,gt=0"` }
Click to show internal directories.
Click to hide internal directories.