|
|
@@ -10,11 +10,13 @@ import com.ffii.tsms.modules.data.entity.projections.StaffSearchInfo |
|
|
|
import com.ffii.tsms.modules.data.web.models.NewTeamRequest |
|
|
|
import org.springframework.stereotype.Service |
|
|
|
import org.springframework.transaction.annotation.Transactional |
|
|
|
import java.util.Optional |
|
|
|
|
|
|
|
@Service |
|
|
|
open class TeamService( |
|
|
|
private val teamRepository: TeamRepository, |
|
|
|
private val staffRepository: StaffRepository, |
|
|
|
private val staffsService: StaffsService, |
|
|
|
private val jdbcDao: JdbcDao, |
|
|
|
) : AbstractBaseEntityService<Team, Long, TeamRepository>(jdbcDao, teamRepository) { |
|
|
|
|
|
|
@@ -82,6 +84,17 @@ open class TeamService( |
|
|
|
return team |
|
|
|
} |
|
|
|
|
|
|
|
@Transactional(rollbackFor = [Exception::class]) |
|
|
|
open fun setStaffTeamIdToNull(id: Long) { |
|
|
|
val staffList: List<Staff>? = staffsService.findAllByTeamId(id).orElseThrow() |
|
|
|
if (!staffList.isNullOrEmpty()) { |
|
|
|
for (staff in staffList) { |
|
|
|
staff.apply { |
|
|
|
team = null; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
open fun saveOrUpdate(req: NewTeamRequest): Team { |
|
|
|
val team = if(req.id != null) find(req.id).get() else Team() |
|
|
|
if (req.id != null) { |
|
|
|