toDAOComment 将领域模型评论转换为DAO评论
(comment domain.Comment)
| 105 | |
| 106 | // toDAOComment 将领域模型评论转换为DAO评论 |
| 107 | func (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评论转换为领域模型评论 |
| 139 | func (c *commentRepository) toDomainComment(daoComment dao.Comment) domain.Comment { |
no outgoing calls
no test coverage detected