app.go 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. package ut
  2. import (
  3. "go-common/library/time"
  4. "sync"
  5. )
  6. // TableName .
  7. func (*App) TableName() string {
  8. return "ut_app"
  9. }
  10. // App ..
  11. type App struct {
  12. ID int64 `gorm:"column:id" json:"id"`
  13. Path string `gorm:"column:path" json:"path"`
  14. Owner string `gorm:"column:owner" json:"owner"`
  15. HasUt int `gorm:"column:has_ut" json:"has_ut"`
  16. Link string `gorm:"-" json:"link"`
  17. Coverage float64 `gorm:"coverage"`
  18. CTime time.Time `gorm:"column:ctime" json:"ctime"`
  19. MTime time.Time `gorm:"column:mtime" json:"mtime"`
  20. }
  21. // AppReq .
  22. type AppReq struct {
  23. HasUt int `form:"has_ut"`
  24. Path string `form:"path"`
  25. Pn int `form:"pn" default:"1"`
  26. Ps int `form:"ps" defalut:"20"`
  27. }
  28. // Department .
  29. type Department struct {
  30. Name string
  31. Total int64
  32. Access int64
  33. Coverage float64
  34. }
  35. // AppsCache apps cache.
  36. type AppsCache struct {
  37. Slice []*App
  38. Map map[string]*App
  39. Owner map[string][]*App
  40. Dept map[string]*Department
  41. sync.Mutex
  42. }
  43. //PathsByOwner get app paths by owner.
  44. func (apps *AppsCache) PathsByOwner(owner string) (paths []string) {
  45. for _, app := range apps.Owner[owner] {
  46. paths = append(paths, app.Path)
  47. }
  48. return
  49. }