MCPcopy Create free account
hub / github.com/GoSimplicity/LinkMe / toDAOComment

Method toDAOComment

internal/repository/comment.go:107–136  ·  view source on GitHub ↗

toDAOComment 将领域模型评论转换为DAO评论

(comment domain.Comment)

Source from the content-addressed store, hash-verified

105
106// toDAOComment 将领域模型评论转换为DAO评论
107func (c *commentRepository) toDAOComment(comment domain.Comment) dao.Comment {
108 now := time.Now().UnixMilli()
109 daoComment := dao.Comment{
110 Id: comment.Id,
111 UserId: comment.UserId,
112 Biz: comment.Biz,
113 BizId: comment.BizId,
114 PostId: comment.PostId,
115 Content: comment.Content,
116 CreatedAt: now,
117 UpdatedAt: now,
118 Status: comment.Status,
119 }
120
121 if comment.ParentComment != nil {
122 daoComment.PID = sql.NullInt64{
123 Int64: comment.ParentComment.Id,
124 Valid: true,
125 }
126 }
127
128 if comment.RootComment != nil {
129 daoComment.RootId = sql.NullInt64{
130 Int64: comment.RootComment.Id,
131 Valid: true,
132 }
133 }
134
135 return daoComment
136}
137
138// toDomainComment 将DAO评论转换为领域模型评论
139func (c *commentRepository) toDomainComment(daoComment dao.Comment) domain.Comment {

Callers 2

CreateCommentMethod · 0.95
UpdateCommentMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected