mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-06 13:35:50 +01:00
Move userName and repositoryName to the base table class.
This commit is contained in:
15
src/main/scala/model/BaseTable.scala
Normal file
15
src/main/scala/model/BaseTable.scala
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
package model
|
||||||
|
|
||||||
|
import scala.slick.driver.H2Driver.simple._
|
||||||
|
|
||||||
|
protected[model] abstract class BaseTable[T](_tableName: String) extends Table[T](_tableName) {
|
||||||
|
def userName = column[String]("USER_NAME")
|
||||||
|
def repositoryName = column[String]("REPOSITORY_NAME")
|
||||||
|
def base = userName ~ repositoryName
|
||||||
|
|
||||||
|
def repository(owner: String, repository: String) =
|
||||||
|
(userName is owner.bind) && (repositoryName is repository.bind)
|
||||||
|
|
||||||
|
def repository(other: BaseTable[T]) =
|
||||||
|
(userName is other.userName) && (repositoryName is other.repositoryName)
|
||||||
|
}
|
||||||
@@ -1,12 +1,11 @@
|
|||||||
package model
|
package model
|
||||||
|
|
||||||
import scala.slick.driver.H2Driver.simple._
|
import scala.slick.driver.H2Driver.simple._
|
||||||
|
import model.{BaseTable => Table}
|
||||||
|
|
||||||
object Collaborators extends Table[Collaborator]("COLLABORATOR") {
|
object Collaborators extends Table[Collaborator]("COLLABORATOR") {
|
||||||
def userName = column[String]("USER_NAME", O PrimaryKey)
|
|
||||||
def repositoryName = column[String]("REPOSITORY_NAME")
|
|
||||||
def collaboratorName = column[String]("COLLABORATOR_NAME")
|
def collaboratorName = column[String]("COLLABORATOR_NAME")
|
||||||
def * = userName ~ repositoryName ~ collaboratorName <> (Collaborator, Collaborator.unapply _)
|
def * = base ~ collaboratorName <> (Collaborator, Collaborator.unapply _)
|
||||||
}
|
}
|
||||||
|
|
||||||
case class Collaborator(
|
case class Collaborator(
|
||||||
|
|||||||
@@ -1,18 +1,15 @@
|
|||||||
package model
|
package model
|
||||||
|
|
||||||
import scala.slick.driver.H2Driver.simple._
|
import scala.slick.driver.H2Driver.simple._
|
||||||
|
import model.{BaseTable => Table}
|
||||||
|
|
||||||
object IssueId extends Table[(String, String, Int)]("ISSUE_ID") {
|
object IssueId extends Table[(String, String, Int)]("ISSUE_ID") {
|
||||||
def userName = column[String]("USER_NAME", O PrimaryKey)
|
|
||||||
def repositoryName = column[String]("REPOSITORY_NAME", O PrimaryKey)
|
|
||||||
def issueId = column[Int]("ISSUE_ID")
|
def issueId = column[Int]("ISSUE_ID")
|
||||||
def * = userName ~ repositoryName ~ issueId
|
def * = base ~ issueId
|
||||||
}
|
}
|
||||||
|
|
||||||
object Issues extends Table[Issue]("ISSUE") with Functions {
|
object Issues extends Table[Issue]("ISSUE") with Functions {
|
||||||
def userName = column[String]("USER_NAME", O PrimaryKey)
|
def issueId = column[Int]("ISSUE_ID")
|
||||||
def repositoryName = column[String]("REPOSITORY_NAME", O PrimaryKey)
|
|
||||||
def issueId = column[Int]("ISSUE_ID", O PrimaryKey)
|
|
||||||
def openedUserName = column[String]("OPENED_USER_NAME")
|
def openedUserName = column[String]("OPENED_USER_NAME")
|
||||||
def milestoneId = column[Int]("MILESTONE_ID")
|
def milestoneId = column[Int]("MILESTONE_ID")
|
||||||
def assignedUserName = column[String]("ASSIGNED_USER_NAME")
|
def assignedUserName = column[String]("ASSIGNED_USER_NAME")
|
||||||
@@ -21,7 +18,7 @@ object Issues extends Table[Issue]("ISSUE") with Functions {
|
|||||||
def closed = column[Boolean]("CLOSED")
|
def closed = column[Boolean]("CLOSED")
|
||||||
def registeredDate = column[java.util.Date]("REGISTERED_DATE")
|
def registeredDate = column[java.util.Date]("REGISTERED_DATE")
|
||||||
def updatedDate = column[java.util.Date]("UPDATED_DATE")
|
def updatedDate = column[java.util.Date]("UPDATED_DATE")
|
||||||
def * = userName ~ repositoryName ~ issueId ~ openedUserName ~ milestoneId.? ~ assignedUserName.? ~ title ~ content.? ~ closed ~ registeredDate ~ updatedDate <> (Issue, Issue.unapply _)
|
def * = base ~ issueId ~ openedUserName ~ milestoneId.? ~ assignedUserName.? ~ title ~ content.? ~ closed ~ registeredDate ~ updatedDate <> (Issue, Issue.unapply _)
|
||||||
}
|
}
|
||||||
|
|
||||||
case class Issue(
|
case class Issue(
|
||||||
|
|||||||
@@ -1,19 +1,18 @@
|
|||||||
package model
|
package model
|
||||||
|
|
||||||
import scala.slick.driver.H2Driver.simple._
|
import scala.slick.driver.H2Driver.simple._
|
||||||
|
import model.{BaseTable => Table}
|
||||||
|
|
||||||
object IssueComments extends Table[IssueComment]("ISSUE_COMMENT") with Functions {
|
object IssueComments extends Table[IssueComment]("ISSUE_COMMENT") with Functions {
|
||||||
def userName = column[String]("USER_NAME")
|
|
||||||
def repositoryName = column[String]("REPOSITORY_NAME")
|
|
||||||
def issueId = column[Int]("ISSUE_ID")
|
def issueId = column[Int]("ISSUE_ID")
|
||||||
def commentId = column[Int]("COMMENT_ID", O PrimaryKey, O AutoInc)
|
def commentId = column[Int]("COMMENT_ID", O AutoInc)
|
||||||
def commentedUserName = column[String]("COMMENTED_USER_NAME")
|
def commentedUserName = column[String]("COMMENTED_USER_NAME")
|
||||||
def content = column[String]("CONTENT")
|
def content = column[String]("CONTENT")
|
||||||
def registeredDate = column[java.util.Date]("REGISTERED_DATE")
|
def registeredDate = column[java.util.Date]("REGISTERED_DATE")
|
||||||
def updatedDate = column[java.util.Date]("UPDATED_DATE")
|
def updatedDate = column[java.util.Date]("UPDATED_DATE")
|
||||||
def * = userName ~ repositoryName ~ issueId ~ commentId ~ commentedUserName ~ content ~ registeredDate ~ updatedDate <> (IssueComment, IssueComment.unapply _)
|
def * = base ~ issueId ~ commentId ~ commentedUserName ~ content ~ registeredDate ~ updatedDate <> (IssueComment, IssueComment.unapply _)
|
||||||
|
|
||||||
def autoInc = userName ~ repositoryName ~ issueId ~ commentedUserName ~ content ~ registeredDate ~ updatedDate returning commentId
|
def autoInc = base ~ issueId ~ commentedUserName ~ content ~ registeredDate ~ updatedDate returning commentId
|
||||||
}
|
}
|
||||||
|
|
||||||
case class IssueComment(
|
case class IssueComment(
|
||||||
|
|||||||
@@ -1,13 +1,12 @@
|
|||||||
package model
|
package model
|
||||||
|
|
||||||
import scala.slick.driver.H2Driver.simple._
|
import scala.slick.driver.H2Driver.simple._
|
||||||
|
import model.{BaseTable => Table}
|
||||||
|
|
||||||
object IssueLabels extends Table[IssueLabel]("ISSUE_LABEL") with Functions {
|
object IssueLabels extends Table[IssueLabel]("ISSUE_LABEL") {
|
||||||
def userName = column[String]("USER_NAME", O PrimaryKey)
|
def issueId = column[Int]("ISSUE_ID")
|
||||||
def repositoryName = column[String]("REPOSITORY_NAME", O PrimaryKey)
|
def labelId = column[Int]("LABEL_ID")
|
||||||
def issueId = column[Int]("ISSUE_ID", O PrimaryKey)
|
def * = base ~ issueId ~ labelId <> (IssueLabel, IssueLabel.unapply _)
|
||||||
def labelId = column[Int]("LABEL_ID", O PrimaryKey)
|
|
||||||
def * = userName ~ repositoryName ~ issueId ~ labelId <> (IssueLabel, IssueLabel.unapply _)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
case class IssueLabel(
|
case class IssueLabel(
|
||||||
|
|||||||
@@ -1,15 +1,14 @@
|
|||||||
package model
|
package model
|
||||||
|
|
||||||
import scala.slick.driver.H2Driver.simple._
|
import scala.slick.driver.H2Driver.simple._
|
||||||
|
import model.{BaseTable => Table}
|
||||||
|
|
||||||
object Labels extends Table[Label]("LABEL") with Functions {
|
object Labels extends Table[Label]("LABEL") {
|
||||||
def userName = column[String]("USER_NAME", O PrimaryKey)
|
def labelId = column[Int]("LABEL_ID", O AutoInc)
|
||||||
def repositoryName = column[String]("REPOSITORY_NAME", O PrimaryKey)
|
|
||||||
def labelId = column[Int]("LABEL_ID", O PrimaryKey, O AutoInc)
|
|
||||||
def labelName = column[String]("LABEL_NAME")
|
def labelName = column[String]("LABEL_NAME")
|
||||||
def color = column[String]("COLOR")
|
def color = column[String]("COLOR")
|
||||||
def * = userName ~ repositoryName ~ labelId ~ labelName ~ color <> (Label, Label.unapply _)
|
def * = base ~ labelId ~ labelName ~ color <> (Label, Label.unapply _)
|
||||||
def ins = userName ~ repositoryName ~ labelName ~ color
|
def ins = base ~ labelName ~ color
|
||||||
}
|
}
|
||||||
|
|
||||||
case class Label(
|
case class Label(
|
||||||
|
|||||||
@@ -1,18 +1,17 @@
|
|||||||
package model
|
package model
|
||||||
|
|
||||||
import scala.slick.driver.H2Driver.simple._
|
import scala.slick.driver.H2Driver.simple._
|
||||||
|
import model.{BaseTable => Table}
|
||||||
|
|
||||||
object Milestones extends Table[Milestone]("MILESTONE") with Functions {
|
object Milestones extends Table[Milestone]("MILESTONE") with Functions {
|
||||||
def userName = column[String]("USER_NAME", O PrimaryKey)
|
def milestoneId = column[Int]("MILESTONE_ID", O AutoInc)
|
||||||
def repositoryName = column[String]("REPOSITORY_NAME", O PrimaryKey)
|
|
||||||
def milestoneId = column[Int]("MILESTONE_ID", O PrimaryKey, O AutoInc)
|
|
||||||
def title = column[String]("TITLE")
|
def title = column[String]("TITLE")
|
||||||
def description = column[String]("DESCRIPTION")
|
def description = column[String]("DESCRIPTION")
|
||||||
def dueDate = column[java.util.Date]("DUE_DATE")
|
def dueDate = column[java.util.Date]("DUE_DATE")
|
||||||
def closedDate = column[java.util.Date]("CLOSED_DATE")
|
def closedDate = column[java.util.Date]("CLOSED_DATE")
|
||||||
def * = userName ~ repositoryName ~ milestoneId ~ title ~ description.? ~ dueDate.? ~ closedDate.? <> (Milestone, Milestone.unapply _)
|
def * = base ~ milestoneId ~ title ~ description.? ~ dueDate.? ~ closedDate.? <> (Milestone, Milestone.unapply _)
|
||||||
|
|
||||||
def autoInc = userName ~ repositoryName ~ title ~ description.? ~ dueDate.? ~ closedDate.? returning milestoneId
|
def autoInc = base ~ title ~ description.? ~ dueDate.? ~ closedDate.? returning milestoneId
|
||||||
}
|
}
|
||||||
|
|
||||||
case class Milestone(
|
case class Milestone(
|
||||||
|
|||||||
@@ -1,22 +1,21 @@
|
|||||||
package model
|
package model
|
||||||
|
|
||||||
import scala.slick.driver.H2Driver.simple._
|
import scala.slick.driver.H2Driver.simple._
|
||||||
|
import model.{BaseTable => Table}
|
||||||
|
|
||||||
object Repositories extends Table[Repository]("REPOSITORY") with Functions {
|
object Repositories extends Table[Repository]("REPOSITORY") with Functions {
|
||||||
def repositoryName= column[String]("REPOSITORY_NAME", O PrimaryKey)
|
|
||||||
def userName = column[String]("USER_NAME", O PrimaryKey)
|
|
||||||
def isPrivate = column[Boolean]("PRIVATE")
|
def isPrivate = column[Boolean]("PRIVATE")
|
||||||
def description = column[String]("DESCRIPTION")
|
def description = column[String]("DESCRIPTION")
|
||||||
def defaultBranch = column[String]("DEFAULT_BRANCH")
|
def defaultBranch = column[String]("DEFAULT_BRANCH")
|
||||||
def registeredDate = column[java.util.Date]("REGISTERED_DATE")
|
def registeredDate = column[java.util.Date]("REGISTERED_DATE")
|
||||||
def updatedDate = column[java.util.Date]("UPDATED_DATE")
|
def updatedDate = column[java.util.Date]("UPDATED_DATE")
|
||||||
def lastActivityDate = column[java.util.Date]("LAST_ACTIVITY_DATE")
|
def lastActivityDate = column[java.util.Date]("LAST_ACTIVITY_DATE")
|
||||||
def * = repositoryName ~ userName ~ isPrivate ~ description.? ~ defaultBranch ~ registeredDate ~ updatedDate ~ lastActivityDate <> (Repository, Repository.unapply _)
|
def * = base ~ isPrivate ~ description.? ~ defaultBranch ~ registeredDate ~ updatedDate ~ lastActivityDate <> (Repository, Repository.unapply _)
|
||||||
}
|
}
|
||||||
|
|
||||||
case class Repository(
|
case class Repository(
|
||||||
repositoryName: String,
|
|
||||||
userName: String,
|
userName: String,
|
||||||
|
repositoryName: String,
|
||||||
isPrivate: Boolean,
|
isPrivate: Boolean,
|
||||||
description: Option[String],
|
description: Option[String],
|
||||||
defaultBranch: String,
|
defaultBranch: String,
|
||||||
|
|||||||
@@ -26,8 +26,8 @@ trait RepositoryService { self: AccountService =>
|
|||||||
|
|
||||||
Repositories insert
|
Repositories insert
|
||||||
Repository(
|
Repository(
|
||||||
repositoryName = repositoryName,
|
|
||||||
userName = userName,
|
userName = userName,
|
||||||
|
repositoryName = repositoryName,
|
||||||
isPrivate = false,
|
isPrivate = false,
|
||||||
description = description,
|
description = description,
|
||||||
defaultBranch = "master",
|
defaultBranch = "master",
|
||||||
|
|||||||
Reference in New Issue
Block a user