|
@@ -100,8 +100,8 @@ class BugController(
|
|
|
val output = bugs.map {
|
|
|
BugOutput(
|
|
|
id = it.id,
|
|
|
- created = SimpleDateFormat("dd-MM-yyyy").format(it.created),
|
|
|
- description = it.description.trim(),
|
|
|
+ created = SimpleDateFormat("dd-MMM-yy HH:mm:ss").format(it.created),
|
|
|
+ description = it.description,
|
|
|
qc = it.qc!!.name,
|
|
|
dev = it.dev!!.name,
|
|
|
platform = it.platform!!.name,
|
|
@@ -136,8 +136,8 @@ class BugController(
|
|
|
val output = bugData.map {
|
|
|
BugOutput(
|
|
|
id = it.id,
|
|
|
- created = SimpleDateFormat("dd-MM-yyyy").format(it.created),
|
|
|
- description = it.description.trim(),
|
|
|
+ created = SimpleDateFormat("dd-MMM-yy HH:mm:ss").format(it.created),
|
|
|
+ description = it.description,
|
|
|
qc = it.qc!!.name,
|
|
|
dev = it.dev!!.name,
|
|
|
platform = it.platform!!.name,
|
|
@@ -166,18 +166,20 @@ class BugController(
|
|
|
val found = bugRepository.count(specBug)
|
|
|
val userId = userRepository.getUserByUsername(SecurityContextHolder.getContext().authentication.name)
|
|
|
val countPlat = platformRepository.findPlatform2(userId.id.toString(), bugInput.platform)
|
|
|
- val countQc = userRepository.findById(bugInput.qc)
|
|
|
- val countDev = userRepository.findById(bugInput.dev)
|
|
|
+ val countQc = memberRepository.validRoleByPlatform(bugInput.qc.toString(), bugInput.platform, 0.toString())
|
|
|
+ val countDev = memberRepository.validRoleByPlatform(bugInput.dev.toString(), bugInput.platform, 1.toString())
|
|
|
if (!enumValues<Enum.Level>().any {
|
|
|
it.name == bugInput.level.uppercase()
|
|
|
} || !enumValues<Enum.Status>().any {
|
|
|
it.name == bugInput.status.uppercase()
|
|
|
} || !enumValues<Enum.Dev_Status>().any { it.name == bugInput.dev_status.uppercase() }) {
|
|
|
ResponseEntity(HttpStatus.BAD_REQUEST)
|
|
|
- } else if (!regex(bugInput.goodday_url) || !regex(bugInput.image_url)) {
|
|
|
+ } else if (!regex(bugInput.goodday_url.trim()) || !regex(bugInput.image_url.trim())) {
|
|
|
ResponseEntity(HttpStatus.BAD_REQUEST)
|
|
|
- } else if (countPlat == 0 || countQc.isEmpty || countDev.isEmpty) {
|
|
|
+ } else if (countPlat == 0) {
|
|
|
ResponseEntity(HttpStatus.NOT_FOUND)
|
|
|
+ } else if (countQc == 0 || countDev == 0) {
|
|
|
+ ResponseEntity(HttpStatus.FORBIDDEN)
|
|
|
} else if (bugInput.description.isNotBlank()) {
|
|
|
val foundPlat = platformRepository.findPlatform(userId.id.toString(), bugInput.platform)
|
|
|
val qc = userRepository.findById(bugInput.qc).get()
|
|
@@ -202,8 +204,8 @@ class BugController(
|
|
|
if (listOf(save).isNotEmpty()) {
|
|
|
val output = BugOutput(
|
|
|
id = save.id,
|
|
|
- created = SimpleDateFormat("dd-MM-yyyy").format(save.created),
|
|
|
- description = save.description.trim(),
|
|
|
+ created = SimpleDateFormat("dd-MM-yyyy HH:mm:ss").format(save.created),
|
|
|
+ description = save.description,
|
|
|
qc = save.qc!!.name,
|
|
|
dev = save.dev!!.name,
|
|
|
platform = save.platform!!.name,
|
|
@@ -229,47 +231,56 @@ class BugController(
|
|
|
|
|
|
private fun validColumn(id: Long, bugInput: BugInput): Boolean {
|
|
|
val userId = userRepository.getUserByUsername(SecurityContextHolder.getContext().authentication.name)
|
|
|
- val role = memberRepository.getRole(userId.id.toString(), bugInput.platform)
|
|
|
- val roleEnum =
|
|
|
- if (Enum.Member.values().any { it.ordinal == role }) Enum.Member.values()[role] else Enum.Member.UNDEFINED
|
|
|
- val valid = bugRepository.validOwnerAdmin(userId.id.toString())
|
|
|
+ val validQc = memberRepository.validRoleByPlatform(userId.id.toString(), bugInput.platform, 0.toString())
|
|
|
+ val validPro = memberRepository.validRoleByPlatform(userId.id.toString(), bugInput.platform, 1.toString())
|
|
|
+ val validAdmin = memberRepository.validRoleByPlatform(userId.id.toString(), bugInput.platform, 2.toString())
|
|
|
+ val validOwner = bugRepository.validOwnerAdmin(userId.id.toString(), id)
|
|
|
val bugData: Bug = bugRepository.findById(id).get()
|
|
|
var col = arrayOf<Number>()
|
|
|
- if (bugInput.description.trim() !== bugData.description.trim()) { //col += "description,"
|
|
|
+ if (!Objects.equals(bugInput.description.trim(), bugData.description.trim())) { //col += "description,"
|
|
|
col += 1
|
|
|
}
|
|
|
- if (userRepository.findById(bugInput.qc).get().name !== bugData.qc!!.name) {//col += "qc,"
|
|
|
+ if (userRepository.findById(bugInput.qc).get().name.trim() !== bugData.qc!!.name.trim()) {//col += "qc,"
|
|
|
col += 2
|
|
|
}
|
|
|
- if (userRepository.findById(bugInput.dev).get().name !== bugData.dev!!.name) {//col += "dev,"
|
|
|
+ if (userRepository.findById(bugInput.dev).get().name.trim() !== bugData.dev!!.name.trim()) {//col += "dev,"
|
|
|
col += 3
|
|
|
}
|
|
|
- if (bugInput.platform.trim() !== bugData.platform!!.name) {//col += "platform,"
|
|
|
+ if (!Objects.equals(bugInput.platform.trim(), bugData.platform!!.name.trim())) {//col += "platform,"
|
|
|
col += 4
|
|
|
}
|
|
|
- if (bugInput.goodday_url.trim() !== bugData.goodday_url.trim()) {//col += "goodday_url,"
|
|
|
+ if (!Objects.equals(bugInput.goodday_url.trim(), bugData.goodday_url.trim())) {//col += "goodday_url,"
|
|
|
col += 5
|
|
|
}
|
|
|
- if (bugInput.image_url.trim() !== bugData.image_url.trim()) {//col += "image_url,"
|
|
|
- col += 6
|
|
|
- }
|
|
|
- if (Enum.Level.values()[bugData.level] !== Enum.Level.valueOf(bugInput.level.uppercase())) {//col += "level,"
|
|
|
+ if (!Objects.equals(bugInput.image_url.trim(), bugData.image_url.trim())) {//col += "image_url,"
|
|
|
col += 6
|
|
|
}
|
|
|
- if (Enum.Status.values()[bugData.status] !== Enum.Status.valueOf(bugInput.status.uppercase())) {//col += "level,"
|
|
|
+ if (!Objects.equals(
|
|
|
+ Enum.Level.values()[bugData.level], Enum.Level.valueOf(bugInput.level.uppercase())
|
|
|
+ )
|
|
|
+ ) {//col += "level,"
|
|
|
col += 7
|
|
|
}
|
|
|
- if (Enum.Dev_Status.values()[bugData.dev_status] !== Enum.Dev_Status.valueOf(bugInput.dev_status.uppercase())) {//col += "level,"
|
|
|
+ if (!Objects.equals(
|
|
|
+ Enum.Status.values()[bugData.status], Enum.Status.valueOf(bugInput.status.uppercase())
|
|
|
+ )
|
|
|
+ ) {//col += "level,"
|
|
|
col += 8
|
|
|
}
|
|
|
+ if (!Objects.equals(
|
|
|
+ Enum.Dev_Status.values()[bugData.dev_status], Enum.Dev_Status.valueOf(bugInput.dev_status.uppercase())
|
|
|
+ )
|
|
|
+ ) {//col += "level,"
|
|
|
+ col += 9
|
|
|
+ }
|
|
|
var ret = false
|
|
|
- if (roleEnum == Enum.Member.PROGRAMMER && col.contains(9)) {
|
|
|
+ if (col.isEmpty()) {
|
|
|
ret = true
|
|
|
- }
|
|
|
- if (roleEnum == Enum.Member.QC && (col.contains(6) || col.contains(7) || col.contains(8))) {
|
|
|
+ } else if (validAdmin > 0 || validOwner > 0) {
|
|
|
ret = true
|
|
|
- }
|
|
|
- if (roleEnum == Enum.Member.ADMIN || valid > 0) {
|
|
|
+ } else if (validQc > 0 && (col.contains(6) || col.contains(7) || col.contains(8))) {
|
|
|
+ ret = true
|
|
|
+ } else if (validPro > 0 && col.contains(9)) {
|
|
|
ret = true
|
|
|
}
|
|
|
return ret
|
|
@@ -312,7 +323,7 @@ class BugController(
|
|
|
if (listOf(save).isNotEmpty()) {
|
|
|
val output = BugOutput(
|
|
|
id = save.id,
|
|
|
- description = save.description.trim(),
|
|
|
+ description = save.description,
|
|
|
qc = save.qc!!.name,
|
|
|
dev = save.dev!!.name,
|
|
|
platform = save.platform!!.name,
|
|
@@ -346,7 +357,7 @@ class BugController(
|
|
|
val find = bugRepository.findById(id)
|
|
|
val used = commentRepository.findByBug(id.toString())
|
|
|
val userId = userRepository.getUserByUsername(SecurityContextHolder.getContext().authentication.name)
|
|
|
- val validOwnerAdmin = bugRepository.validOwnerAdmin(userId.id.toString())
|
|
|
+ val validOwnerAdmin = bugRepository.validOwnerAdmin(userId.id.toString(), id)
|
|
|
return try {
|
|
|
if (validOwnerAdmin > 0) {
|
|
|
if (used > 0) {//child used in transaction
|