mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-09 15:05:50 +01:00
Create java.util.Date TypeMapper. And add the currentDate method.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package service
|
||||
|
||||
import model._
|
||||
import Accounts._
|
||||
import scala.slick.driver.H2Driver.simple._
|
||||
import Database.threadLocalSession
|
||||
|
||||
@@ -11,7 +12,7 @@ trait AccountService {
|
||||
|
||||
def getAllUsers(): List[Account] = Query(Accounts) sortBy(_.userName) list
|
||||
|
||||
def createAccount(account: Account): Unit = Accounts.* insert account
|
||||
def createAccount(account: Account): Unit = Accounts insert account
|
||||
|
||||
def updateAccount(account: Account): Unit =
|
||||
Query(Accounts)
|
||||
@@ -21,14 +22,13 @@ trait AccountService {
|
||||
account.password,
|
||||
account.mailAddress,
|
||||
account.isAdmin,
|
||||
account.url,
|
||||
account.url,
|
||||
account.registeredDate,
|
||||
account.updatedDate,
|
||||
currentDate,
|
||||
account.lastLoginDate)
|
||||
|
||||
def updateLastLoginDate(userName: String): Unit =
|
||||
// TODO make a common function to get the current timestamp.
|
||||
Query(Accounts).filter(_.userName is userName.bind).map(_.lastLoginDate)
|
||||
.update(new java.sql.Timestamp(System.currentTimeMillis))
|
||||
.update(currentDate)
|
||||
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import scala.slick.jdbc.{StaticQuery => Q}
|
||||
import Q.interpolation
|
||||
|
||||
import model._
|
||||
import Issues._
|
||||
|
||||
trait IssuesService {
|
||||
def getIssue(owner: String, repository: String, issueId: String) =
|
||||
@@ -41,8 +42,8 @@ trait IssuesService {
|
||||
title,
|
||||
content,
|
||||
false,
|
||||
new java.sql.Date(System.currentTimeMillis), // TODO
|
||||
new java.sql.Date(System.currentTimeMillis))
|
||||
currentDate,
|
||||
currentDate)
|
||||
|
||||
// increment issue id
|
||||
IssueId.filter { t =>
|
||||
@@ -51,9 +52,8 @@ trait IssuesService {
|
||||
} get
|
||||
|
||||
def createMilestone(owner: String, repository: String,
|
||||
title: String, description: Option[String], dueDate: Option[java.sql.Date]): Unit = {
|
||||
Milestones.ins insert (owner, repository, title, description, dueDate, None)
|
||||
}
|
||||
title: String, description: Option[String], dueDate: Option[java.util.Date]) =
|
||||
Milestones.autoInc insert (owner, repository, title, description, dueDate, None)
|
||||
|
||||
def updateMilestone(milestone: Milestone): Unit =
|
||||
Query(Milestones)
|
||||
|
||||
@@ -1,13 +1,10 @@
|
||||
package service
|
||||
|
||||
import model._
|
||||
import Repositories._
|
||||
import scala.slick.driver.H2Driver.simple._
|
||||
import Database.threadLocalSession
|
||||
import util.JGitUtil
|
||||
import scala.Some
|
||||
import model.Repository
|
||||
import model.Account
|
||||
import model.Collaborator
|
||||
|
||||
trait RepositoryService { self: AccountService =>
|
||||
import RepositoryService._
|
||||
@@ -27,9 +24,6 @@ trait RepositoryService { self: AccountService =>
|
||||
|
||||
// TODO insert default labels.
|
||||
|
||||
// TODO make a common function to get the current timestamp.
|
||||
val currentDate = new java.sql.Timestamp(System.currentTimeMillis)
|
||||
|
||||
Repositories insert
|
||||
Repository(
|
||||
repositoryName = repositoryName,
|
||||
@@ -160,22 +154,20 @@ trait RepositoryService { self: AccountService =>
|
||||
* Updates the last activity date of the repository.
|
||||
*/
|
||||
def updateLastActivityDate(userName: String, repositoryName: String): Unit =
|
||||
// TODO make a common function to get the current timestamp.
|
||||
Query(Repositories)
|
||||
.filter { r => (r.userName is userName.bind) && (r.repositoryName is repositoryName.bind) }
|
||||
.map { _.lastActivityDate }
|
||||
.update (new java.sql.Timestamp(System.currentTimeMillis))
|
||||
.update (currentDate)
|
||||
|
||||
/**
|
||||
* Save repository options.
|
||||
*/
|
||||
def saveRepositoryOptions(userName: String, repositoryName: String,
|
||||
description: Option[String], defaultBranch: String, isPrivate: Boolean): Unit =
|
||||
// TODO make a common function to get the current timestamp.
|
||||
Query(Repositories)
|
||||
.filter { r => (r.userName is userName.bind) && (r.repositoryName is repositoryName.bind) }
|
||||
.map { r => r.description.? ~ r.defaultBranch ~ r.isPrivate ~ r.updatedDate }
|
||||
.update (description, defaultBranch, isPrivate, new java.sql.Timestamp(System.currentTimeMillis))
|
||||
.update (description, defaultBranch, isPrivate, currentDate)
|
||||
|
||||
/**
|
||||
* Add collaborator to the repository.
|
||||
|
||||
Reference in New Issue
Block a user