Implemented the registration of the issue.

This commit is contained in:
shimamoto
2013-06-20 19:43:13 +09:00
parent 9a22fbc175
commit a05ad4641f
3 changed files with 43 additions and 27 deletions

View File

@@ -9,26 +9,26 @@ import model._
trait IssuesService {
def saveIssue(owner: String, repository: String, loginUser: String,
title: String, content: String) = {
title: String, content: Option[String]) =
// next id number
val id = sql"SELECT ISSUE_ID + 1 FROM ISSUE_ID WHERE USER_NAME = $owner AND REPOSITORY_NAME = $repository FOR UPDATE".as[Int].first
sql"SELECT ISSUE_ID + 1 FROM ISSUE_ID WHERE USER_NAME = $owner AND REPOSITORY_NAME = $repository FOR UPDATE".as[Int]
.firstOption.filter { id =>
Issues insert Issue(
owner,
repository,
id,
loginUser,
None,
None,
title,
content,
new java.sql.Date(System.currentTimeMillis), // TODO
new java.sql.Date(System.currentTimeMillis))
Issues insert Issue(
owner,
repository,
id,
loginUser,
None,
None,
title,
content,
new java.sql.Date(System.currentTimeMillis), // TODO
new java.sql.Date(System.currentTimeMillis))
// increment id
IssueId filter { t =>
(t.userName is owner.bind) && (t.repositoryName is repository.bind)
} map (_.issueId) update(id)
}
// increment issue id
IssueId.filter { t =>
(t.userName is owner.bind) && (t.repositoryName is repository.bind)
}.map(_.issueId).update(id) > 0
} get
}