mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-09 06:55:54 +01:00
Delete LABEL_ISSUE before deleting LABEL.
This commit is contained in:
@@ -2,23 +2,20 @@ package service
|
|||||||
|
|
||||||
import scala.slick.driver.H2Driver.simple._
|
import scala.slick.driver.H2Driver.simple._
|
||||||
import Database.threadLocalSession
|
import Database.threadLocalSession
|
||||||
import scala.slick.jdbc.{StaticQuery => Q}
|
|
||||||
import Q.interpolation
|
|
||||||
|
|
||||||
import model._
|
import model._
|
||||||
import Labels._
|
|
||||||
|
|
||||||
trait LabelsService {
|
trait LabelsService {
|
||||||
|
|
||||||
def getLabels(owner: String, repository: String): List[Label] =
|
def getLabels(owner: String, repository: String): List[Label] =
|
||||||
Query(Labels)
|
Query(Labels)
|
||||||
.filter(l => (l.userName is owner.bind) && (l.repositoryName is repository.bind))
|
.filter(t => (t.userName is owner.bind) && (t.repositoryName is repository.bind))
|
||||||
.sortBy(_.labelName asc)
|
.sortBy(_.labelName asc)
|
||||||
.list
|
.list
|
||||||
|
|
||||||
def getLabel(owner: String, repository: String, labelId: Int): Option[Label] =
|
def getLabel(owner: String, repository: String, labelId: Int): Option[Label] =
|
||||||
Query(Labels)
|
Query(Labels)
|
||||||
.filter(l => (l.userName is owner.bind) && (l.repositoryName is repository.bind) && (l.labelId is labelId.bind))
|
.filter(t => (t.userName is owner.bind) && (t.repositoryName is repository.bind) && (t.labelId is labelId.bind))
|
||||||
.firstOption
|
.firstOption
|
||||||
|
|
||||||
def createLabel(owner: String, repository: String, labelName: String, color: String): Unit =
|
def createLabel(owner: String, repository: String, labelName: String, color: String): Unit =
|
||||||
@@ -26,19 +23,17 @@ trait LabelsService {
|
|||||||
|
|
||||||
def updateLabel(owner: String, repository: String, labelId: Int, labelName: String, color: String): Unit =
|
def updateLabel(owner: String, repository: String, labelId: Int, labelName: String, color: String): Unit =
|
||||||
Query(Labels)
|
Query(Labels)
|
||||||
.filter { l => (l.userName is owner.bind) && (l.repositoryName is repository.bind) && (l.labelId is labelId.bind)}
|
.filter { t => (t.userName is owner.bind) && (t.repositoryName is repository.bind) && (t.labelId is labelId.bind)}
|
||||||
.map { l => l.labelName ~ l.color }
|
.map { t => t.labelName ~ t.color }
|
||||||
.update (labelName, color)
|
.update (labelName, color)
|
||||||
|
|
||||||
def deleteLabel(owner: String, repository: String, labelId: Int): Unit = {
|
def deleteLabel(owner: String, repository: String, labelId: Int): Unit = {
|
||||||
// TODO delete ISSUE_LABEL
|
Query(IssueLabels)
|
||||||
// Query(Issues)
|
.filter { t => (t.userName is owner.bind) && (t.repositoryName is repository.bind) && (t.labelId is labelId.bind)}
|
||||||
// .filter { i => (i.userName is owner.bind) && (i.repositoryName is repository.bind) && (i.milestoneId is milestoneId.bind)}
|
.delete
|
||||||
// .map { i => i.milestoneId.? }
|
|
||||||
// .update(None)
|
|
||||||
|
|
||||||
Query(Labels)
|
Query(Labels)
|
||||||
.filter { i => (i.userName is owner.bind) && (i.repositoryName is repository.bind) && (i.labelId is labelId.bind)}
|
.filter { t => (t.userName is owner.bind) && (t.repositoryName is repository.bind) && (t.labelId is labelId.bind)}
|
||||||
.delete
|
.delete
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user