api.go 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. package model
  2. import (
  3. "dy-admin/internal/pcmserver/common"
  4. )
  5. type Api struct {
  6. common.Model
  7. Path string `json:"path" form:"path" gorm:"size:128;comment:地址"`
  8. Action string `json:"action" form:"action" gorm:"size:16;comment:请求类型"`
  9. Type string `json:"type" form:"type" gorm:"size:16;comment:接口类型[SYS BUS]"`
  10. Description string `json:"description" form:"description" gorm:"size:128;comment:api中文描述"`
  11. ApiGroup string `json:"apiGroup" form:"apiGroup" gorm:"size:32;comment:api组"`
  12. common.ModelTime
  13. }
  14. func (Api) TableName() string {
  15. return "sys_apis"
  16. }
  17. func (Api) AllowOrderField() map[string]struct{} {
  18. orderMap := make(map[string]struct{}, 6)
  19. orderMap["id"] = struct{}{}
  20. orderMap["path"] = struct{}{}
  21. orderMap["api_group"] = struct{}{}
  22. orderMap["description"] = struct{}{}
  23. orderMap["method"] = struct{}{}
  24. orderMap["type"] = struct{}{}
  25. return orderMap
  26. }
  27. func DefaultAPIs() []Api {
  28. return []Api{
  29. {Path: "/sys/v1/menu/role/tree", Action: "GET"},
  30. {Path: "/sys/v1/user/setSelfInfo", Action: "PUT"},
  31. {Path: "/sys/v1/user/changePassword", Action: "PUT"},
  32. {Path: "/sys/v1/operation", Action: "POST"},
  33. {Path: "/sys/v1/user/getInfo", Action: "GET"},
  34. {Path: "/sys/v1/dept/tree", Action: "GET"},
  35. {Path: "/sys/v1/dept/one", Action: "GET"},
  36. }
  37. }