Documentation
¶
Index ¶
- Constants
- Variables
- func InitRoutes(route fiber.Router)
- type CreateInput
- type DeleteInput
- type Handler
- type Menu
- type MenuOutput
- type Repository
- func (r *Repository) Create(e *Menu, db *sqlx.DB) error
- func (r *Repository) Delete(e *Menu, db *sqlx.DB) error
- func (r *Repository) Exist(e *Menu, db *sqlx.DB) (bool, error)
- func (r *Repository) QueryAll(w *WhereParams, db *sqlx.DB) ([]*Menu, error)
- func (r *Repository) QueryAllByIDs(ids []string, db *sqlx.DB) ([]*Menu, error)
- func (r *Repository) QueryByStaffID(id string, db *sqlx.DB) ([]*Menu, error)
- func (r *Repository) Update(e *Menu, db *sqlx.DB) error
- type Service
- type UpdateInput
- type WhereParams
Constants ¶
View Source
const ( CreatedSuccess = "添加菜单成功!" CreatedFail = "添加菜单失败!" UpdatedSuccess = "修改菜单成功!" UpdatedFail = "修改菜单失败!" DeletedSuccess = "删除菜单成功!" DeletedFail = "删除菜单失败!" ErrorNotExist = "菜单或权限不存在!" ErrorPidNotExist = "父级菜单或权限不存在!" ErrorNameRepeat = "菜单名称重复,请重新输入!" ErrorExistChildren = "菜单下存在子菜单,不能删除!" ErrorPidCantEqSelfAndChildId = "父节点不能为自己和其子节点,请重新选择父节点!" )
View Source
const ( FieldID = "id" FieldName = "name" FieldParentID = "parent_id" FieldIcon = "icon" FieldPath = "path" FieldType = "type" FieldMethod = "method" FieldComponent = "component" FieldVisible = "visible" FieldStatus = "status" FieldSort = "sort" FieldRemark = "remark" FieldCreatedAt = "created_at" FieldUpdatedAt = "updated_at" FieldCreatedBy = "created_by" FieldUpdatedBy = "updated_by" Table = "system_menus" )
Variables ¶
View Source
var SelectFields = []string{ FieldID, FieldName, FieldParentID, FieldIcon, FieldPath, FieldType, FieldMethod, FieldComponent, FieldVisible, 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"` ParentID string `zh:"父级菜单" json:"parent_id" validate:"omitempty"` Icon string `zh:"菜单图标" json:"icon"` Path string `zh:"路径" json:"path" validate:"required"` Type string `zh:"类型" json:"type" validate:"required,oneof=Catalog Menu Button"` Method string `zh:"方法" json:"method"` Component string `zh:"组件" json:"component"` Visible string `zh:"是否隐藏" json:"visible" validate:"omitempty"` Status string `zh:"状态" json:"status" validate:"omitempty,oneof=Disable Enable"` Sort uint32 `zh:"排序" json:"sort" validate:"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 Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
func NewHandler ¶
func NewHandler() *Handler
type Menu ¶
type Menu struct { ID string `db:"id" json:"id"` Name string `db:"name" json:"name"` ParentID string `db:"parent_id" json:"parent_id"` Icon string `db:"icon" json:"icon"` Path string `db:"path" json:"path"` Type string `zh:"类型" json:"type"` Method string `zh:"方法" json:"method"` Component string `db:"component" json:"component"` Visible string `db:"visible" json:"visible"` Status string `db:"status" json:"status"` Sort uint32 `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 MenuOutput ¶
type MenuOutput struct { ID string `json:"id"` Name string `json:"name"` ParentID string `json:"parent_id,omitempty"` Icon string `json:"icon,omitempty"` Path string `json:"path,omitempty"` Type string `json:"type"` Method string `json:"method,omitempty"` Component string `json:"component,omitempty"` Visible string `json:"visible"` Status string `json:"status"` Sort uint32 `json:"sort"` Remark string `json:"remark"` Children []*MenuOutput `json:"children,omitempty"` }
type Repository ¶
type Repository struct{}
func NewRepository ¶
func NewRepository() *Repository
func (*Repository) QueryAll ¶
func (r *Repository) QueryAll(w *WhereParams, db *sqlx.DB) ([]*Menu, error)
func (*Repository) QueryAllByIDs ¶
func (*Repository) QueryByStaffID ¶
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) QueryByStaffID ¶
func (s *Service) QueryByStaffID(id string) ([]*MenuOutput, []string, error)
func (*Service) QueryTree ¶
func (s *Service) QueryTree(w *WhereParams) ([]*MenuOutput, 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:"required,min=2,max=32"` ParentID string `zh:"父级菜单" json:"parent_id" validate:"omitempty"` Icon string `zh:"菜单图标" json:"icon"` Path string `zh:"路径" json:"path"` Type string `zh:"类型" json:"type" validate:"required,oneof=Catalog Menu Button"` Method string `zh:"方法" json:"method"` Component string `zh:"组件" json:"component"` Visible string `zh:"是否隐藏" json:"visible" validate:"omitempty"` Status string `zh:"状态" json:"status" validate:"omitempty,oneof=Disable Enable"` Sort uint32 `zh:"排序" json:"sort" validate:"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"` ParentID string `zh:"父级菜单" query:"parent_id" json:"parent_id" validate:"omitempty"` Status string `zh:"状态" query:"status" json:"status" validate:"omitempty,oneof=Disable Enable"` Visible string `zh:"显示" query:"visible" json:"visible" validate:"omitempty"` 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.