channel.go 695 B

1234567891011121314151617181920212223242526272829
  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. Description string `bson:"description" json:"description"`
  12. Status bool `bson:"status" json:"status"`
  13. }
  14. // CollectionName 指定 MongoDB 集合名
  15. func (Channel) CollectionName() string {
  16. return "channels"
  17. }
  18. // GetCreateTime 返回格式化的创建时间,供前端使用
  19. func (c *Channel) GetCreateTime() string {
  20. if c.CreatedAt.IsZero() {
  21. return ""
  22. }
  23. return c.CreatedAt.In(time.Local).Format("2006-01-02 15:04:05")
  24. }