domain

package
v0.0.0-...-d13da26 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 3, 2023 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const BizArticle = "article"

Variables

View Source
var (
	ArticleStatusV1Unknown = ArticleStatusV1{Val: 0, Name: "unknown"}
)

Functions

This section is empty.

Types

type Article

type Article struct {
	Id      int64
	Title   string
	Content string
	// Author 要从用户来
	Author Author
	Status ArticleStatus
	Ctime  time.Time
	Utime  time.Time
}

Article 可以同时表达线上库和制作库的概念吗? 可以同时表达,作者眼中的 Article 和读者眼中的 Article 吗?

func (Article) Abstract

func (a Article) Abstract() string

type ArticleStatus

type ArticleStatus uint8
const (
	// ArticleStatusUnknown 为了避免零值之类的问题
	ArticleStatusUnknown ArticleStatus = iota
	ArticleStatusUnpublished
	ArticleStatusPublished
	ArticleStatusPrivate
)

func (ArticleStatus) NonPublished

func (s ArticleStatus) NonPublished() bool

func (ArticleStatus) String

func (s ArticleStatus) String() string

func (ArticleStatus) ToUint8

func (s ArticleStatus) ToUint8() uint8

type ArticleStatusV1

type ArticleStatusV1 struct {
	Val  uint8
	Name string
}

ArticleStatusV1 如果你的状态很复杂,有很多行为(就是你要搞很多方法),状态里面需要一些额外字段 就用这个版本

type ArticleStatusV2

type ArticleStatusV2 string

type Author

type Author struct {
	Id   int64
	Name string
}

Author 在帖子这个领域内,是一个值对象

type Collection

type Collection struct {
	Name  string
	Uid   int64
	Items []Resource
}

type Interactive

type Interactive struct {
	Biz   string
	BizId int64

	ReadCnt    int64 `json:"read_cnt"`
	LikeCnt    int64 `json:"like_cnt"`
	CollectCnt int64 `json:"collect_cnt"`
	// 这个是当下这个资源,你有没有点赞或者收集
	// 你也可以考虑把这两个字段分离出去,作为一个单独的结构体
	Liked     bool `json:"liked"`
	Collected bool `json:"collected"`
}

Interactive 这个是总体交互的计数

type Job

type Job struct {
	Id int64
	// 比如说 ranking
	Name string

	Cron     string
	Executor string
	// 通用的任务的抽象,我们也不知道任务的具体细节,所以就搞一个 Cfg
	// 具体任务设置具体的值
	Cfg string

	CancelFunc func() error
}

func (Job) NextTime

func (j Job) NextTime() time.Time

type Resource

type Resource struct {
	Biz   string
	BizId int64
}

type Self

type Self struct {
	Liked     bool `json:"liked"`
	Collected bool `json:"collected"`
}

type User

type User struct {
	Id       int64
	Email    string
	Password string
	Phone    string
	Nickname string

	// 不要组合,万一你将来可能还有 DingDingInfo,里面有同名字段 UnionID
	WechatInfo WechatInfo
	Ctime      time.Time
}

User 领域对象,是 DDD 中的 entity BO(business object)

type WechatInfo

type WechatInfo struct {
	OpenID  string
	UnionID string
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL