@@ -22,4 +22,7 @@ interface StaffSearchInfo { | |||||
@get:Value("#{target.currentPosition?.name}") | @get:Value("#{target.currentPosition?.name}") | ||||
val currentPosition: String? | val currentPosition: String? | ||||
@get:Value("#{target.user?.id}") | |||||
val userId: Long? | |||||
} | } |
@@ -1,5 +1,6 @@ | |||||
package com.ffii.tsms.modules.data.service | package com.ffii.tsms.modules.data.service | ||||
import com.ffii.core.exception.UnprocessableEntityException | |||||
import com.ffii.core.support.AbstractBaseEntityService | import com.ffii.core.support.AbstractBaseEntityService | ||||
import com.ffii.core.support.JdbcDao | import com.ffii.core.support.JdbcDao | ||||
import com.ffii.tsms.modules.common.SecurityUtils | import com.ffii.tsms.modules.common.SecurityUtils | ||||
@@ -8,12 +9,10 @@ import com.ffii.tsms.modules.data.entity.projections.StaffSearchInfo | |||||
import com.ffii.tsms.modules.data.web.models.NewStaffRequest | import com.ffii.tsms.modules.data.web.models.NewStaffRequest | ||||
import com.ffii.tsms.modules.user.entity.User | import com.ffii.tsms.modules.user.entity.User | ||||
import com.ffii.tsms.modules.user.entity.UserRepository | import com.ffii.tsms.modules.user.entity.UserRepository | ||||
import org.springframework.data.jpa.domain.AbstractPersistable_.id | |||||
import org.springframework.security.crypto.password.PasswordEncoder | import org.springframework.security.crypto.password.PasswordEncoder | ||||
import org.springframework.stereotype.Service | import org.springframework.stereotype.Service | ||||
import org.springframework.transaction.annotation.Transactional | import org.springframework.transaction.annotation.Transactional | ||||
import java.util.* | import java.util.* | ||||
import java.util.stream.Collectors | |||||
import kotlin.jvm.optionals.getOrNull | import kotlin.jvm.optionals.getOrNull | ||||
@@ -96,6 +95,13 @@ open class StaffsService( | |||||
@Transactional(rollbackFor = [Exception::class]) | @Transactional(rollbackFor = [Exception::class]) | ||||
open fun saveStaff(req: NewStaffRequest): Staff { | open fun saveStaff(req: NewStaffRequest): Staff { | ||||
// if (req.staffId) | |||||
val checkStaffIdList: List<StaffSearchInfo> = staffRepository.findStaffSearchInfoByAndDeletedFalse() | |||||
checkStaffIdList.forEach{ s -> | |||||
if (s.staffId == req.staffId) { | |||||
throw UnprocessableEntityException("Duplicated StaffId Found") | |||||
} | |||||
} | |||||
val currentPosition = positionRepository.findById(req.currentPositionId).orElseThrow() | val currentPosition = positionRepository.findById(req.currentPositionId).orElseThrow() | ||||
val joinPosition = positionRepository.findById(req.joinPositionId).orElseThrow() | val joinPosition = positionRepository.findById(req.joinPositionId).orElseThrow() | ||||
val company = companyRepository.findById(req.companyId).orElseThrow() | val company = companyRepository.findById(req.companyId).orElseThrow() | ||||
@@ -39,7 +39,7 @@ open class TeamService( | |||||
@Transactional(rollbackFor = [Exception::class]) | @Transactional(rollbackFor = [Exception::class]) | ||||
open fun saveTeam(req: NewTeamRequest): Team { | open fun saveTeam(req: NewTeamRequest): Team { | ||||
val ids = req.addStaffIds!! | val ids = req.addStaffIds!! | ||||
println(ids) | |||||
// println(ids) | |||||
val teamLead = staffRepository.findById(ids[0]).orElseThrow() | val teamLead = staffRepository.findById(ids[0]).orElseThrow() | ||||
val teamName = "Team " + teamLead.name | val teamName = "Team " + teamLead.name | ||||
@@ -7,6 +7,7 @@ import com.ffii.tsms.modules.data.service.SkillService | |||||
import com.ffii.tsms.modules.data.web.models.NewSkillRequest | import com.ffii.tsms.modules.data.web.models.NewSkillRequest | ||||
import jakarta.servlet.http.HttpServletRequest | import jakarta.servlet.http.HttpServletRequest | ||||
import jakarta.validation.Valid | import jakarta.validation.Valid | ||||
import org.springframework.http.HttpStatus | |||||
import org.springframework.web.bind.ServletRequestBindingException | import org.springframework.web.bind.ServletRequestBindingException | ||||
import org.springframework.web.bind.annotation.* | import org.springframework.web.bind.annotation.* | ||||
@@ -25,6 +26,11 @@ class SkillController(private val skillService: SkillService) { | |||||
args["id"] = id | args["id"] = id | ||||
return skillService.list(args); | return skillService.list(args); | ||||
} | } | ||||
@DeleteMapping("/delete/{id}") | |||||
@ResponseStatus(HttpStatus.NO_CONTENT) | |||||
fun delete(@PathVariable id: Long?) { | |||||
skillService.markDelete(id) | |||||
} | |||||
@GetMapping | @GetMapping | ||||
fun list(): List<Map<String, Any>> { | fun list(): List<Map<String, Any>> { | ||||
@@ -5,10 +5,6 @@ import jakarta.validation.constraints.NotNull | |||||
import java.time.LocalDate | import java.time.LocalDate | ||||
data class NewStaffRequest( | data class NewStaffRequest( | ||||
val id: Long?, | |||||
// @field:NotNull(message = "Staff userId cannot be empty") | |||||
// val userId: Long, | |||||
@field:NotBlank(message = "Staff name cannot be empty") | @field:NotBlank(message = "Staff name cannot be empty") | ||||
val name: String, | val name: String, | ||||
@field:NotBlank(message = "Staff staffId cannot be empty") | @field:NotBlank(message = "Staff staffId cannot be empty") | ||||
@@ -17,21 +13,30 @@ data class NewStaffRequest( | |||||
val companyId: Long, | val companyId: Long, | ||||
@field:NotNull(message = "Staff salaryId cannot be empty") | @field:NotNull(message = "Staff salaryId cannot be empty") | ||||
val salaryId: Long, | val salaryId: Long, | ||||
// @field:NotNull(message = "Staff skillSetId cannot be empty") | |||||
val skillSetId: List<Long>?, | |||||
@field:NotNull(message = "joinDate cannot be empty") | |||||
val joinDate: LocalDate, | val joinDate: LocalDate, | ||||
@field:NotNull(message = "Staff currentPositionId cannot be empty") | |||||
val currentPositionId: Long, | val currentPositionId: Long, | ||||
// val salaryEffId: Long, | |||||
@field:NotNull(message = "Staff joinPositionId cannot be empty") | |||||
val joinPositionId: Long, | val joinPositionId: Long, | ||||
val gradeId: Long?, | |||||
val teamId: Long?, | |||||
@field:NotNull(message = "Staff departmentId cannot be empty") | |||||
val departmentId: Long, | val departmentId: Long, | ||||
@field:NotBlank(message = "Staff phone1 cannot be empty") | |||||
val phone1: String, | val phone1: String, | ||||
val phone2: String?, | |||||
@field:NotBlank(message = "Staff email cannot be empty") | |||||
val email: String, | val email: String, | ||||
@field:NotBlank(message = "Staff emergContactName cannot be empty") | |||||
val emergContactName: String, | val emergContactName: String, | ||||
@field:NotBlank(message = "Staff emergContactPhone cannot be empty") | |||||
val emergContactPhone: String, | val emergContactPhone: String, | ||||
@field:NotBlank(message = "Staff employType cannot be empty") | |||||
val employType: String, | val employType: String, | ||||
val id: Long?, | |||||
val skillSetId: List<Long>?, | |||||
val gradeId: Long?, | |||||
val phone2: String?, | |||||
val teamId: Long?, | |||||
val departDate: LocalDate?, | val departDate: LocalDate?, | ||||
val departReason: String?, | val departReason: String?, | ||||
val remark: String?, | val remark: String?, |