aboutsummaryrefslogtreecommitdiffstats
path: root/models/issue.go
diff options
context:
space:
mode:
authorUnknown <joe2010xtmf@163.com>2014-03-26 12:31:01 -0400
committerUnknown <joe2010xtmf@163.com>2014-03-26 12:31:01 -0400
commit4b9eef50c9bf91e6ca2d85d9e63dc69b0ffba737 (patch)
tree15c5fd6dd9b72ba61e306ec8b068b35d3bc19239 /models/issue.go
parent8c2f751bbb22ebf06c7f7f9621614b6e46130210 (diff)
downloadgitea-4b9eef50c9bf91e6ca2d85d9e63dc69b0ffba737.tar.gz
gitea-4b9eef50c9bf91e6ca2d85d9e63dc69b0ffba737.zip
Add comment of issue
Diffstat (limited to 'models/issue.go')
-rw-r--r--models/issue.go22
1 files changed, 21 insertions, 1 deletions
diff --git a/models/issue.go b/models/issue.go
index 2de6568589..47ec4edd0b 100644
--- a/models/issue.go
+++ b/models/issue.go
@@ -163,9 +163,29 @@ type Milestone struct {
type Comment struct {
Id int64
PosterId int64
+ Poster *User `xorm:"-"`
IssueId int64
CommitId int64
- Line int
+ Line int64
Content string
Created time.Time `xorm:"created"`
}
+
+// CreateComment creates comment of issue or commit.
+func CreateComment(userId, issueId, commitId, line int64, content string) error {
+ _, err := orm.Insert(&Comment{
+ PosterId: userId,
+ IssueId: issueId,
+ CommitId: commitId,
+ Line: line,
+ Content: content,
+ })
+ return err
+}
+
+// GetIssueComments returns list of comment by given issue id.
+func GetIssueComments(issueId int64) ([]Comment, error) {
+ comments := make([]Comment, 0, 10)
+ err := orm.Asc("created").Find(&comments, &Comment{IssueId: issueId})
+ return comments, err
+}