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
|
||||
|
||||
import scala.slick.driver.H2Driver.simple._
|
||||
import model.{BaseTable => Table}
|
||||
|
||||
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 * = userName ~ repositoryName ~ collaboratorName <> (Collaborator, Collaborator.unapply _)
|
||||
def * = base ~ collaboratorName <> (Collaborator, Collaborator.unapply _)
|
||||
}
|
||||
|
||||
case class Collaborator(
|
||||
|
||||
@@ -1,18 +1,15 @@
|
||||
package model
|
||||
|
||||
import scala.slick.driver.H2Driver.simple._
|
||||
import model.{BaseTable => Table}
|
||||
|
||||
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 * = userName ~ repositoryName ~ issueId
|
||||
def * = base ~ issueId
|
||||
}
|
||||
|
||||
object Issues extends Table[Issue]("ISSUE") with Functions {
|
||||
def userName = column[String]("USER_NAME", O PrimaryKey)
|
||||
def repositoryName = column[String]("REPOSITORY_NAME", O PrimaryKey)
|
||||
def issueId = column[Int]("ISSUE_ID", O PrimaryKey)
|
||||
def issueId = column[Int]("ISSUE_ID")
|
||||
def openedUserName = column[String]("OPENED_USER_NAME")
|
||||
def milestoneId = column[Int]("MILESTONE_ID")
|
||||
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 registeredDate = column[java.util.Date]("REGISTERED_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(
|
||||
|
||||
@@ -1,19 +1,18 @@
|
||||
package model
|
||||
|
||||
import scala.slick.driver.H2Driver.simple._
|
||||
import model.{BaseTable => Table}
|
||||
|
||||
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 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 content = column[String]("CONTENT")
|
||||
def registeredDate = column[java.util.Date]("REGISTERED_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(
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
package model
|
||||
|
||||
import scala.slick.driver.H2Driver.simple._
|
||||
import model.{BaseTable => Table}
|
||||
|
||||
object IssueLabels extends Table[IssueLabel]("ISSUE_LABEL") with Functions {
|
||||
def userName = column[String]("USER_NAME", O PrimaryKey)
|
||||
def repositoryName = column[String]("REPOSITORY_NAME", O PrimaryKey)
|
||||
def issueId = column[Int]("ISSUE_ID", O PrimaryKey)
|
||||
def labelId = column[Int]("LABEL_ID", O PrimaryKey)
|
||||
def * = userName ~ repositoryName ~ issueId ~ labelId <> (IssueLabel, IssueLabel.unapply _)
|
||||
object IssueLabels extends Table[IssueLabel]("ISSUE_LABEL") {
|
||||
def issueId = column[Int]("ISSUE_ID")
|
||||
def labelId = column[Int]("LABEL_ID")
|
||||
def * = base ~ issueId ~ labelId <> (IssueLabel, IssueLabel.unapply _)
|
||||
}
|
||||
|
||||
case class IssueLabel(
|
||||
|
||||
@@ -1,15 +1,14 @@
|
||||
package model
|
||||
|
||||
import scala.slick.driver.H2Driver.simple._
|
||||
import model.{BaseTable => Table}
|
||||
|
||||
object Labels extends Table[Label]("LABEL") with Functions {
|
||||
def userName = column[String]("USER_NAME", O PrimaryKey)
|
||||
def repositoryName = column[String]("REPOSITORY_NAME", O PrimaryKey)
|
||||
def labelId = column[Int]("LABEL_ID", O PrimaryKey, O AutoInc)
|
||||
object Labels extends Table[Label]("LABEL") {
|
||||
def labelId = column[Int]("LABEL_ID", O AutoInc)
|
||||
def labelName = column[String]("LABEL_NAME")
|
||||
def color = column[String]("COLOR")
|
||||
def * = userName ~ repositoryName ~ labelId ~ labelName ~ color <> (Label, Label.unapply _)
|
||||
def ins = userName ~ repositoryName ~ labelName ~ color
|
||||
def * = base ~ labelId ~ labelName ~ color <> (Label, Label.unapply _)
|
||||
def ins = base ~ labelName ~ color
|
||||
}
|
||||
|
||||
case class Label(
|
||||
|
||||
@@ -1,18 +1,17 @@
|
||||
package model
|
||||
|
||||
import scala.slick.driver.H2Driver.simple._
|
||||
import model.{BaseTable => Table}
|
||||
|
||||
object Milestones extends Table[Milestone]("MILESTONE") with Functions {
|
||||
def userName = column[String]("USER_NAME", O PrimaryKey)
|
||||
def repositoryName = column[String]("REPOSITORY_NAME", O PrimaryKey)
|
||||
def milestoneId = column[Int]("MILESTONE_ID", O PrimaryKey, O AutoInc)
|
||||
def milestoneId = column[Int]("MILESTONE_ID", O AutoInc)
|
||||
def title = column[String]("TITLE")
|
||||
def description = column[String]("DESCRIPTION")
|
||||
def dueDate = column[java.util.Date]("DUE_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(
|
||||
|
||||
@@ -1,22 +1,21 @@
|
||||
package model
|
||||
|
||||
import scala.slick.driver.H2Driver.simple._
|
||||
import model.{BaseTable => Table}
|
||||
|
||||
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 description = column[String]("DESCRIPTION")
|
||||
def defaultBranch = column[String]("DEFAULT_BRANCH")
|
||||
def registeredDate = column[java.util.Date]("REGISTERED_DATE")
|
||||
def updatedDate = column[java.util.Date]("UPDATED_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(
|
||||
repositoryName: String,
|
||||
userName: String,
|
||||
repositoryName: String,
|
||||
isPrivate: Boolean,
|
||||
description: Option[String],
|
||||
defaultBranch: String,
|
||||
|
||||
@@ -26,8 +26,8 @@ trait RepositoryService { self: AccountService =>
|
||||
|
||||
Repositories insert
|
||||
Repository(
|
||||
repositoryName = repositoryName,
|
||||
userName = userName,
|
||||
repositoryName = repositoryName,
|
||||
isPrivate = false,
|
||||
description = description,
|
||||
defaultBranch = "master",
|
||||
|
||||
Reference in New Issue
Block a user