channel.go 754 B

123456789101112131415161718192021222324252627282930
  1. package channel
  2. import (
  3. "time"
  4. "github.com/kamva/mgm/v3"
  5. )
  6. // Channel 渠道模型
  7. type Channel struct {
  8. mgm.DefaultModel `bson:",inline"`
  9. Name string `bson:"name" json:"name"`
  10. Code string `bson:"code" json:"code"`
  11. Platform string `bson:"platform" json:"platform"`
  12. Description string `bson:"description" json:"description"`
  13. Status bool `bson:"status" json:"status"`
  14. }
  15. // CollectionName 指定 MongoDB 集合名
  16. func (Channel) CollectionName() string {
  17. return "channels"
  18. }
  19. // GetCreateTime 返回格式化的创建时间,供前端使用
  20. func (c *Channel) GetCreateTime() string {
  21. if c.CreatedAt.IsZero() {
  22. return ""
  23. }
  24. return c.CreatedAt.In(time.Local).Format("2006-01-02 15:04:05")
  25. }