|
|
@@ -1,8 +1,11 @@ |
|
|
|
package com.ffii.tsms.modules.data.web |
|
|
|
|
|
|
|
import com.ffii.core.exception.NotFoundException |
|
|
|
import com.ffii.core.response.RecordsRes |
|
|
|
import com.ffii.core.utils.CriteriaArgsBuilder |
|
|
|
import com.ffii.core.utils.Params |
|
|
|
import com.ffii.tsms.modules.data.entity.Team |
|
|
|
import com.ffii.tsms.modules.data.service.StaffsService |
|
|
|
import com.ffii.tsms.modules.data.service.TeamService |
|
|
|
import com.ffii.tsms.modules.data.web.models.NewTeamRequest |
|
|
|
import jakarta.servlet.http.HttpServletRequest |
|
|
@@ -15,7 +18,10 @@ import org.springframework.web.bind.annotation.* |
|
|
|
|
|
|
|
@RestController |
|
|
|
@RequestMapping("/team") |
|
|
|
class TeamController(private val teamService: TeamService) { |
|
|
|
class TeamController( |
|
|
|
private val teamService: TeamService, |
|
|
|
private val staffsService: StaffsService, |
|
|
|
) { |
|
|
|
|
|
|
|
@GetMapping |
|
|
|
fun allStaff(args: Map<String, Any>): List<Map<String, Any>> { |
|
|
@@ -34,6 +40,18 @@ class TeamController(private val teamService: TeamService) { |
|
|
|
return teamService.getTeamDetail(args); |
|
|
|
} |
|
|
|
|
|
|
|
@GetMapping("/{id}") |
|
|
|
fun getStaff(@PathVariable id: Long): MutableMap<String, Any> { |
|
|
|
val map: MutableMap<String, Any> = mutableMapOf("team" to teamService.find(id).orElseThrow { NotFoundException() }) |
|
|
|
val staffList = staffsService.findAllByTeamId(id).orElseThrow { NotFoundException() } |
|
|
|
val staffIdList: MutableList<Long> = mutableListOf() |
|
|
|
for (staff in staffList) { |
|
|
|
staffIdList.add(staff.id as Long) |
|
|
|
} |
|
|
|
map["staffIds"] = staffIdList |
|
|
|
return map |
|
|
|
} |
|
|
|
|
|
|
|
// @Transactional(rollbackFor = [Exception::class]) |
|
|
|
@DeleteMapping("/delete/{id}") |
|
|
|
@ResponseStatus(HttpStatus.NO_CONTENT) |
|
|
|