Sfoglia il codice sorgente

update team edit

tags/Baseline_30082024_BACKEND_UAT
MSI\derek 1 anno fa
parent
commit
768ec2f91f
1 ha cambiato i file con 14 aggiunte e 4 eliminazioni
  1. +14
    -4
      src/main/java/com/ffii/tsms/modules/data/service/TeamService.kt

+ 14
- 4
src/main/java/com/ffii/tsms/modules/data/service/TeamService.kt Vedi File

@@ -49,8 +49,8 @@ open class TeamService(

@Transactional(rollbackFor = [Exception::class])
open fun updateTeam(req: NewTeamRequest, team: Team): Team {
val ids = req.addStaffIds
val teamLead = staffRepository.findById(ids[0]).orElseThrow()
val addIds = req.addStaffIds
val teamLead = staffRepository.findById(addIds[0]).orElseThrow()
val teamName = "Team " + teamLead.name

val initials = teamLead.name.split(" ").map { it.first() }
@@ -61,8 +61,18 @@ open class TeamService(
code = teamCode
description = req.description
}
println(!req.deleteStaffIds.isNullOrEmpty())
if (!req.deleteStaffIds.isNullOrEmpty()) {
for (id in req.deleteStaffIds) {
val staff = staffRepository.findById(id).orElseThrow()
staff.apply {
this.team = null
}
staffRepository.save(staff)
}
}

for (id in ids) {
for (id in addIds) {
val staff = staffRepository.findById(id).orElseThrow()
staff.apply {
this.team = team
@@ -73,7 +83,7 @@ open class TeamService(
}

open fun saveOrUpdate(req: NewTeamRequest): Team {
val team = if(req.id != null) find(req.id).get() else Team()
val team = if(req.id != null) find(req.id).get() else Team()
if (req.id != null) {
updateTeam(req, team)
} else {


Caricamento…
Annulla
Salva