sys_post.go 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. package model
  2. import (
  3. model2 "cold-delivery/common/model"
  4. "errors"
  5. "gorm.io/gorm"
  6. )
  7. // SysPost 岗位表
  8. type SysPost struct {
  9. model2.Model
  10. PostName string `json:"postName" gorm:"size:128;not null;comment:岗位名称"`
  11. PostCode string `json:"postCode" gorm:"size:128;not null;comment:岗位编码"`
  12. Sort int `json:"sort" gorm:"size:4;default:0;comment:排序"`
  13. Status string `json:"status" gorm:"size:4;not null;default:'2';comment:状态 1停用 2正常"`
  14. Remark string `json:"remark" gorm:"size:255;comment:备注"`
  15. MenuIds []int `json:"menuIds" gorm:"-"`
  16. model2.ControlBy
  17. model2.ModelTime
  18. model2.DeptBy
  19. }
  20. func (SysPost) TableName() string {
  21. return "sys_post"
  22. }
  23. func (e *SysPost) Generate() model2.ActiveRecord {
  24. o := *e
  25. return &o
  26. }
  27. func (e *SysPost) GetId() interface{} {
  28. return e.Id
  29. }
  30. var (
  31. ErrForbidUpdateSysPost = errors.New("禁止修改系统岗位")
  32. ErrForbidDeleteSysPost = errors.New("禁止删除系统岗位")
  33. )
  34. func (e *SysPost) BeforeDelete(_ *gorm.DB) (err error) {
  35. if e.PostCode == "admin" {
  36. return ErrForbidDeleteSysPost
  37. }
  38. return
  39. }
  40. func (e *SysPost) BeforeUpdate(_ *gorm.DB) (err error) {
  41. if e.PostCode == "admin" {
  42. return ErrForbidUpdateSysPost
  43. }
  44. return
  45. }