Documentation
¶
Index ¶
- Constants
- Variables
- func InitRoutes(route fiber.Router)
- type CreateInput
- type DeleteInput
- type Handler
- type Organization
- type OrganizationOutput
- type Repository
- func (r *Repository) Create(e *Organization, db *sqlx.DB) error
- func (r *Repository) Delete(e *Organization, db *sqlx.DB) error
- func (r *Repository) Exist(e *Organization, db *sqlx.DB) (bool, error)
- func (r *Repository) QueryAll(w *WhereParams, db *sqlx.DB) ([]*Organization, error)
- func (r *Repository) Update(e *Organization, db *sqlx.DB) error
- func (r *Repository) ValidationFields(c *Organization, db *sqlx.DB) (*Organization, error)
- type Service
- type UpdateInput
- type WhereParams
Constants ¶
View Source
const ( CreatedSuccess = "添加组织成功!" CreatedFail = "添加组织失败!" UpdatedSuccess = "修改组织成功!" UpdatedFail = "修改组织失败!" DeletedSuccess = "删除组织成功!" DeletedFail = "删除组织失败!" ErrorNotExist = "组织不存在!" ErrorPidNotExist = "父级组织不存在!" ErrorNameRepeat = "组织名称重复,请重新输入!" ErrorCodeRepeat = "组织编码重复,请重新输入!" ErrorExistChildren = "此组织下有子组织,请删除其所有子组织后再操作!" ErrorExistStaff = "该组织或其子组织下有员工关联,无法删除!" ErrorPidCantEqSelfAndChildId = "父节点不能为自己和其子节点,请重新选择父节点!" ErrorMustInParentIds = "该组织的父节点只能在其原有上级组织链下选择!" )
View Source
const ( FieldID = "id" FieldName = "name" FieldCode = "code" FieldParentID = "parent_id" FieldStatus = "status" FieldSort = "sort" FieldRemark = "remark" FieldCreatedAt = "created_at" FieldUpdatedAt = "updated_at" FieldCreatedBy = "created_by" FieldUpdatedBy = "updated_by" Table = "system_organizations" )
Variables ¶
View Source
var SelectFields = []string{ FieldID, FieldName, FieldCode, FieldParentID, 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"` ParentID string `zh:"父级ID" json:"parent_id" validate:"omitempty"` Status string `zh:"状态" json:"status" validate:"required,oneof=Disable Enable"` Sort int32 `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 Organization ¶
type Organization struct { ID string `db:"id" json:"id"` Name string `db:"name" json:"name"` Code string `db:"code" json:"code"` ParentID string `db:"parent_id" json:"parent_id"` 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:"updated_by"` }
type OrganizationOutput ¶
type Repository ¶
type Repository struct{}
func NewRepository ¶
func NewRepository() *Repository
func (*Repository) Create ¶
func (r *Repository) Create(e *Organization, db *sqlx.DB) error
func (*Repository) Delete ¶
func (r *Repository) Delete(e *Organization, db *sqlx.DB) error
func (*Repository) Exist ¶
func (r *Repository) Exist(e *Organization, db *sqlx.DB) (bool, error)
func (*Repository) QueryAll ¶
func (r *Repository) QueryAll(w *WhereParams, db *sqlx.DB) ([]*Organization, error)
func (*Repository) Update ¶
func (r *Repository) Update(e *Organization, db *sqlx.DB) error
func (*Repository) ValidationFields ¶
func (r *Repository) ValidationFields(c *Organization, db *sqlx.DB) (*Organization, 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) QueryTree ¶
func (s *Service) QueryTree(w *WhereParams) ([]*OrganizationOutput, 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"` ParentID string `zh:"父级组织" json:"parent_id" validate:"omitempty"` 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 { ID string `zh:"唯一标识符" query:"id" json:"id" validate:"omitempty"` Name string `zh:"组织名称" query:"name" json:"name" validate:"omitempty,max=32"` ParentID string `zh:"父级菜单" query:"parent_id" json:"parent_id" validate:"omitempty"` 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 int `zh:"分页数量" query:"pageSize" json:"pageSize" validate:"omitempty,number,gt=0,max=50"` Current int `zh:"页数" query:"current" json:"current" validate:"omitempty,number,gt=0"` }
Click to show internal directories.
Click to hide internal directories.