mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-06 13:35:50 +01:00
33 lines
786 B
Scala
33 lines
786 B
Scala
package model
|
|
|
|
import scala.slick.driver.H2Driver.simple._
|
|
|
|
object Labels extends Table[Label]("LABEL") with LabelTemplate {
|
|
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 byPrimaryKey = byLabel _
|
|
}
|
|
|
|
case class Label(
|
|
userName: String,
|
|
repositoryName: String,
|
|
labelId: Int,
|
|
labelName: String,
|
|
color: String){
|
|
|
|
val fontColor = {
|
|
val r = color.substring(0, 2)
|
|
val g = color.substring(2, 4)
|
|
val b = color.substring(4, 6)
|
|
|
|
if(Integer.parseInt(r, 16) + Integer.parseInt(g, 16) + Integer.parseInt(b, 16) > 408){
|
|
"000000"
|
|
} else {
|
|
"FFFFFF"
|
|
}
|
|
}
|
|
|
|
} |