| @@ -3,8 +3,10 @@ package com.ffii.tsms.modules.data.entity; | |||
| import com.ffii.core.support.AbstractRepository; | |||
| import com.ffii.tsms.modules.data.entity.projections.StaffSearchInfo; | |||
| import org.springframework.data.repository.query.Param; | |||
| import java.util.List; | |||
| import java.util.Map; | |||
| public interface StaffRepository extends AbstractRepository<Staff, Long> { | |||
| List<StaffSearchInfo> findStaffSearchInfoByAndDeletedFalse(); | |||
| @@ -1,13 +1,28 @@ | |||
| package com.ffii.tsms.modules.data.service | |||
| import com.ffii.core.support.AbstractBaseEntityService | |||
| import com.ffii.core.support.JdbcDao | |||
| import com.ffii.tsms.modules.data.entity.Company | |||
| import com.ffii.tsms.modules.data.entity.CompanyRepository | |||
| import com.ffii.tsms.modules.data.entity.projections.CompanySearchInfo | |||
| import org.springframework.stereotype.Service | |||
| @Service | |||
| class CompanyService( | |||
| private val companyRepository: CompanyRepository | |||
| ) { | |||
| fun allCompanys(): List<CompanySearchInfo>{ | |||
| open class CompanyService( | |||
| private val companyRepository: CompanyRepository, | |||
| private val jdbcDao: JdbcDao, | |||
| ) : AbstractBaseEntityService<Company, Long, CompanyRepository>(jdbcDao, companyRepository) { | |||
| open fun allCompanys(): List<CompanySearchInfo>{ | |||
| return companyRepository.findCompanySearchInfoBy() | |||
| } | |||
| open fun combo(args: Map<String, Any>): List<Map<String, Any>> { | |||
| val sql = StringBuilder("select" | |||
| + " c.id as id," | |||
| + " c.name as label" | |||
| + " from company c" | |||
| + " where c.deleted = false " | |||
| ) | |||
| return jdbcDao.queryForList(sql.toString(), args) | |||
| } | |||
| } | |||
| @@ -1,21 +1,23 @@ | |||
| package com.ffii.tsms.modules.data.service | |||
| import com.ffii.tsms.modules.data.entity.CompanyRepository | |||
| import com.ffii.core.support.AbstractBaseEntityService | |||
| import com.ffii.core.support.JdbcDao | |||
| import com.ffii.tsms.modules.data.entity.Department | |||
| import com.ffii.tsms.modules.data.entity.DepartmentRepository | |||
| import com.ffii.tsms.modules.data.entity.projections.CompanySearchInfo | |||
| import com.ffii.tsms.modules.data.entity.projections.DepartmentSearchInfo | |||
| import com.ffii.tsms.modules.data.web.models.NewDepartmentRequest | |||
| import org.springframework.stereotype.Service | |||
| @Service | |||
| class DepartmentService( | |||
| private val departmentRepository: DepartmentRepository | |||
| ) { | |||
| fun allDepartments(): List<DepartmentSearchInfo>{ | |||
| open class DepartmentService( | |||
| private val departmentRepository: DepartmentRepository, | |||
| private val jdbcDao: JdbcDao, | |||
| ) : AbstractBaseEntityService<Department, Long, DepartmentRepository>(jdbcDao, departmentRepository) { | |||
| open fun allDepartments(): List<DepartmentSearchInfo>{ | |||
| return departmentRepository.findDepartmentSearchInfoBy() | |||
| } | |||
| fun saveDepartment(request: NewDepartmentRequest): Department { | |||
| open fun saveDepartment(request: NewDepartmentRequest): Department { | |||
| val department = | |||
| Department().apply { | |||
| name = request.departmentName | |||
| @@ -25,4 +27,14 @@ class DepartmentService( | |||
| return departmentRepository.save(department) | |||
| } | |||
| open fun combo(args: Map<String, Any>): List<Map<String, Any>> { | |||
| val sql = StringBuilder("select" | |||
| + " d.id as id," | |||
| + " d.name as label" | |||
| + " from department d" | |||
| + " where d.deleted = false" | |||
| ) | |||
| return jdbcDao.queryForList(sql.toString(), args) | |||
| } | |||
| } | |||
| @@ -0,0 +1,25 @@ | |||
| package com.ffii.tsms.modules.data.service | |||
| import com.ffii.core.support.AbstractBaseEntityService | |||
| import com.ffii.core.support.JdbcDao | |||
| import com.ffii.tsms.modules.data.entity.Grade | |||
| import com.ffii.tsms.modules.data.entity.GradeRepository | |||
| import org.springframework.stereotype.Service | |||
| @Service | |||
| open class GradeService( | |||
| private val jdbcDao: JdbcDao, | |||
| private val gradeRepository: GradeRepository, | |||
| ) : AbstractBaseEntityService<Grade, Long, GradeRepository>(jdbcDao, gradeRepository) { | |||
| open fun combo(args: Map<String, Any>): List<Map<String, Any>> { | |||
| val sql = StringBuilder("select" | |||
| + " g.id as id," | |||
| + " g.name as label" | |||
| + " from grade g" | |||
| + " where g.deleted = false" | |||
| ) | |||
| return jdbcDao.queryForList(sql.toString(), args) | |||
| } | |||
| } | |||
| @@ -1,5 +1,7 @@ | |||
| package com.ffii.tsms.modules.data.service | |||
| import com.ffii.core.support.AbstractBaseEntityService | |||
| import com.ffii.core.support.JdbcDao | |||
| import com.ffii.tsms.modules.data.entity.CompanyRepository | |||
| import com.ffii.tsms.modules.data.entity.Department | |||
| import com.ffii.tsms.modules.data.entity.DepartmentRepository | |||
| @@ -12,14 +14,15 @@ import com.ffii.tsms.modules.data.web.models.NewDepartmentRequest | |||
| import com.ffii.tsms.modules.data.web.models.NewPositionRequest | |||
| import org.springframework.stereotype.Service | |||
| @Service | |||
| class PositionService( | |||
| private val positionRepository: PositionRepository | |||
| ) { | |||
| fun allPositions(): List<PositionSearchInfo>{ | |||
| open class PositionService( | |||
| private val positionRepository: PositionRepository, | |||
| private val jdbcDao: JdbcDao, | |||
| ) : AbstractBaseEntityService<Position, Long, PositionRepository>(jdbcDao, positionRepository) { | |||
| open fun allPositions(): List<PositionSearchInfo>{ | |||
| return positionRepository.findPositionSearchInfoBy() | |||
| } | |||
| fun savePosition(request: NewPositionRequest): Position { | |||
| open fun savePosition(request: NewPositionRequest): Position { | |||
| val position = | |||
| Position().apply { | |||
| name = request.positionName | |||
| @@ -29,4 +32,14 @@ class PositionService( | |||
| return positionRepository.save(position) | |||
| } | |||
| open fun combo(args: Map<String, Any>): List<Map<String, Any>> { | |||
| val sql = StringBuilder("select" | |||
| + " p.id as id," | |||
| + " p.name as label" | |||
| + " from position p" | |||
| + " where p.deleted = false" | |||
| ) | |||
| return jdbcDao.queryForList(sql.toString(), args) | |||
| } | |||
| } | |||
| @@ -0,0 +1,25 @@ | |||
| package com.ffii.tsms.modules.data.service | |||
| import com.ffii.core.support.AbstractIdEntityService | |||
| import com.ffii.core.support.JdbcDao | |||
| import com.ffii.tsms.modules.data.entity.SalaryEffective | |||
| import com.ffii.tsms.modules.data.entity.SalaryEffectiveRepository | |||
| import org.springframework.stereotype.Service | |||
| @Service | |||
| open class SalaryEffectiveService( | |||
| private val salaryEffectiveRepository: SalaryEffectiveRepository, | |||
| private val jdbcDao: JdbcDao, | |||
| ) : AbstractIdEntityService<SalaryEffective, Long, SalaryEffectiveRepository>(jdbcDao, salaryEffectiveRepository) { | |||
| // open fun combo(args: Map<String, Any>): List<Map<String, Any>> { | |||
| // val sql = StringBuilder("select" | |||
| // + " id as id," | |||
| // + " name as label" | |||
| // + " from salaryEffective se" | |||
| // + " where deleted = false" | |||
| // ) | |||
| // return jdbcDao.queryForList(sql.toString(), args) | |||
| // } | |||
| } | |||
| @@ -0,0 +1,26 @@ | |||
| package com.ffii.tsms.modules.data.service | |||
| import com.ffii.core.support.AbstractBaseEntityService | |||
| import com.ffii.core.support.AbstractIdEntityService | |||
| import com.ffii.core.support.JdbcDao | |||
| import com.ffii.tsms.modules.data.entity.Department | |||
| import com.ffii.tsms.modules.data.entity.DepartmentRepository | |||
| import com.ffii.tsms.modules.data.entity.Salary | |||
| import com.ffii.tsms.modules.data.entity.SalaryRepository | |||
| import org.springframework.stereotype.Service | |||
| @Service | |||
| open class SalaryService( | |||
| private val jdbcDao: JdbcDao, | |||
| private val salaryRepository: SalaryRepository, | |||
| ) : AbstractIdEntityService<Salary, Long, SalaryRepository>(jdbcDao, salaryRepository) { | |||
| open fun combo(args: Map<String, Any>): List<Map<String, Any>> { | |||
| val sql = StringBuilder("select" | |||
| + " id, " | |||
| + " concat(salaryPoint, ' (', lowerLimit,' - ', upperLimit, ') ') as label " | |||
| + " from salary s " | |||
| ) | |||
| return jdbcDao.queryForList(sql.toString(), args) | |||
| } | |||
| } | |||
| @@ -0,0 +1,27 @@ | |||
| package com.ffii.tsms.modules.data.service | |||
| import com.ffii.core.support.AbstractBaseEntityService | |||
| import com.ffii.core.support.JdbcDao | |||
| import com.ffii.tsms.modules.data.entity.Department | |||
| import com.ffii.tsms.modules.data.entity.DepartmentRepository | |||
| import com.ffii.tsms.modules.data.entity.Skill | |||
| import com.ffii.tsms.modules.data.entity.SkillRepository | |||
| import org.springframework.stereotype.Service | |||
| @Service | |||
| open class SkillService( | |||
| private val skillRepository: SkillRepository, | |||
| private val jdbcDao: JdbcDao, | |||
| ) : AbstractBaseEntityService<Skill, Long, SkillRepository>(jdbcDao, skillRepository) { | |||
| open fun combo(args: Map<String, Any>): List<Map<String, Any>> { | |||
| val sql = StringBuilder("select" | |||
| + " id as id," | |||
| + " name as label" | |||
| + " from skill s" | |||
| + " where deleted = false" | |||
| ) | |||
| return jdbcDao.queryForList(sql.toString(), args) | |||
| } | |||
| } | |||
| @@ -1,24 +1,18 @@ | |||
| package com.ffii.tsms.modules.data.service | |||
| import com.ffii.tsms.modules.data.entity.Staff | |||
| import com.ffii.tsms.modules.data.entity.StaffRepository | |||
| import com.ffii.tsms.modules.user.entity.User | |||
| import com.ffii.tsms.modules.user.entity.UserRepository | |||
| import com.ffii.tsms.modules.data.entity.PositionRepository | |||
| import com.ffii.tsms.modules.data.entity.CompanyRepository | |||
| import com.ffii.tsms.modules.data.entity.GradeRepository | |||
| import com.ffii.tsms.modules.data.entity.TeamRepository | |||
| import com.ffii.tsms.modules.data.entity.SkillRepository | |||
| import com.ffii.tsms.modules.data.entity.SalaryEffectiveRepository | |||
| import com.ffii.tsms.modules.data.entity.DepartmentRepository | |||
| import com.ffii.core.support.AbstractBaseEntityService | |||
| import com.ffii.core.support.JdbcDao | |||
| import com.ffii.tsms.modules.data.entity.* | |||
| import com.ffii.tsms.modules.data.entity.projections.StaffSearchInfo | |||
| import com.ffii.tsms.modules.data.web.models.NewStaffRequest | |||
| import org.springframework.stereotype.Service | |||
| import com.ffii.core.support.JdbcDao; | |||
| import com.ffii.core.support.AbstractBaseEntityService; | |||
| import com.ffii.tsms.modules.user.entity.User | |||
| import com.ffii.tsms.modules.user.entity.UserRepository | |||
| import org.springframework.beans.BeanUtils | |||
| import org.springframework.security.crypto.password.PasswordEncoder | |||
| import org.springframework.stereotype.Service | |||
| import org.springframework.transaction.annotation.Transactional | |||
| @Service | |||
| open class StaffsService( | |||
| private val staffRepository: StaffRepository, | |||
| @@ -32,8 +26,7 @@ open class StaffsService( | |||
| private val departmentRepository: DepartmentRepository, | |||
| private val jdbcDao: JdbcDao, | |||
| private val passwordEncoder: PasswordEncoder | |||
| ) | |||
| : AbstractBaseEntityService<Staff, Long, StaffRepository>(jdbcDao, staffRepository) { | |||
| ) : AbstractBaseEntityService<Staff, Long, StaffRepository>(jdbcDao, staffRepository) { | |||
| open fun getTeamLeads(): List<Staff> { | |||
| // TODO: Replace with actual logic and make a projection instead of returning all fields | |||
| return staffRepository.findAll() | |||
| @@ -43,6 +36,15 @@ open class StaffsService( | |||
| return staffRepository.findStaffSearchInfoByAndDeletedFalse(); | |||
| } | |||
| open fun getStaff(id: Long): Staff { | |||
| return staffRepository.findById(id).orElseThrow(); | |||
| } | |||
| // open fun getStaff(id: Long): Map<String, Staff> { | |||
| // return staffRepository.findStaffByIdAndDeletedFalse(id); | |||
| // } | |||
| // fun allStaff(args: Map<String, Any>): List<Map<String, Any>> { | |||
| // val sql = StringBuilder("select" | |||
| // + " s.*," | |||
| @@ -103,4 +105,52 @@ open class StaffsService( | |||
| } | |||
| return staffRepository.save(staff) | |||
| } | |||
| @Transactional(rollbackFor = [Exception::class]) | |||
| open fun updateStaff(req: NewStaffRequest, staff: Staff): Staff { | |||
| val currentPosition = positionRepository.findById(req.currentPositionId).orElseThrow() | |||
| val joinPosition = positionRepository.findById(req.joinPositionId).orElseThrow() | |||
| val company = companyRepository.findById(req.companyId).orElseThrow() | |||
| val grade = gradeRepository.findById(req.gradeId).orElseThrow() | |||
| val team = teamRepository.findById(req.teamId).orElseThrow() | |||
| val skill = skillRepository.findById(req.skillSetId).orElseThrow() | |||
| val salaryEffective = salaryEffectiveRepository.findById(req.salaryEffId).orElseThrow() | |||
| val department = departmentRepository.findById(req.departmentId).orElseThrow() | |||
| staff.apply { | |||
| joinDate = req.joinDate | |||
| name = req.name | |||
| staffId = req.staffId | |||
| phone1 = req.phone1 | |||
| phone2 = req.phone2 | |||
| email = req.email | |||
| emergContactName = req.emergContactName | |||
| emergContactPhone = req.emergContactPhone | |||
| employType = req.employType | |||
| departDate = req.departDate | |||
| departReason = req.departReason | |||
| remark = req.remark | |||
| this.currentPosition = currentPosition | |||
| this.joinPosition = joinPosition | |||
| this.company = company | |||
| this.grade = grade | |||
| this.team = team | |||
| this.skill = skill | |||
| this.salaryEffective = salaryEffective | |||
| this.department = department | |||
| } | |||
| return staffRepository.save(staff) | |||
| } | |||
| @Transactional(rollbackFor = [Exception::class]) | |||
| open fun saveOrUpdate(req: NewStaffRequest): Staff { | |||
| val staff = find(req.id).get() | |||
| if (req.id != 0L) { | |||
| updateStaff(req, staff) | |||
| } else { | |||
| saveStaff(req) | |||
| } | |||
| return staff; | |||
| } | |||
| } | |||
| @@ -0,0 +1,24 @@ | |||
| package com.ffii.tsms.modules.data.service | |||
| import com.ffii.core.support.AbstractBaseEntityService | |||
| import com.ffii.core.support.JdbcDao | |||
| import com.ffii.tsms.modules.data.entity.Team | |||
| import com.ffii.tsms.modules.data.entity.TeamRepository | |||
| import org.springframework.stereotype.Service | |||
| @Service | |||
| open class TeamService( | |||
| private val teamRepository: TeamRepository, | |||
| private val jdbcDao: JdbcDao, | |||
| ) : AbstractBaseEntityService<Team, Long, TeamRepository>(jdbcDao, teamRepository) { | |||
| open fun combo(args: Map<String, Any>): List<Map<String, Any>> { | |||
| val sql = StringBuilder("select" | |||
| + " t.id as id," | |||
| + " t.name as label" | |||
| + " from Team t" | |||
| + " where t.deleted = false " | |||
| ) | |||
| return jdbcDao.queryForList(sql.toString(), args) | |||
| } | |||
| } | |||
| @@ -1,11 +1,16 @@ | |||
| package com.ffii.tsms.modules.data.web.models | |||
| import com.ffii.core.response.RecordsRes | |||
| import com.ffii.core.utils.CriteriaArgsBuilder | |||
| import com.ffii.tsms.modules.data.entity.projections.CompanySearchInfo | |||
| import com.ffii.tsms.modules.data.service.CompanyService | |||
| import jakarta.servlet.http.HttpServletRequest | |||
| import org.springframework.web.bind.ServletRequestBindingException | |||
| import org.springframework.web.bind.annotation.GetMapping | |||
| import org.springframework.web.bind.annotation.RequestMapping | |||
| import org.springframework.web.bind.annotation.RestController | |||
| @RestController | |||
| @RequestMapping("/companys") | |||
| class CompanyController(private val companyService: CompanyService) { | |||
| @@ -13,4 +18,21 @@ class CompanyController(private val companyService: CompanyService) { | |||
| fun allProjects(): List<CompanySearchInfo>{ | |||
| return companyService.allCompanys() | |||
| } | |||
| // @GetMapping("/combo") | |||
| // fun combo(): List<CompanySearchInfo>{ | |||
| // return companyService.allCompanys() | |||
| // } | |||
| @GetMapping("/combo") | |||
| @Throws(ServletRequestBindingException::class) | |||
| fun combo(request: HttpServletRequest?): RecordsRes<Map<String, Any>> { | |||
| println(request) | |||
| return RecordsRes<Map<String, Any>>( | |||
| companyService.combo( | |||
| CriteriaArgsBuilder.withRequest(request) | |||
| .build() | |||
| ) | |||
| ) | |||
| } | |||
| } | |||
| @@ -1,12 +1,16 @@ | |||
| package com.ffii.tsms.modules.data.web | |||
| import com.ffii.core.response.RecordsRes | |||
| import com.ffii.core.utils.CriteriaArgsBuilder | |||
| import com.ffii.tsms.modules.data.entity.Department | |||
| import com.ffii.tsms.modules.data.entity.projections.DepartmentSearchInfo | |||
| import com.ffii.tsms.modules.data.service.DepartmentService | |||
| import com.ffii.tsms.modules.data.web.models.NewDepartmentRequest | |||
| import com.ffii.tsms.modules.project.entity.Project | |||
| import com.ffii.tsms.modules.project.web.models.NewProjectRequest | |||
| import jakarta.servlet.http.HttpServletRequest | |||
| import jakarta.validation.Valid | |||
| import org.springframework.web.bind.ServletRequestBindingException | |||
| import org.springframework.web.bind.annotation.* | |||
| @RestController | |||
| @@ -22,4 +26,16 @@ class DepartmentController(private val departmentService: DepartmentService | |||
| fun saveProject(@Valid @RequestBody newDepartment: NewDepartmentRequest): Department { | |||
| return departmentService.saveDepartment(newDepartment) | |||
| } | |||
| @GetMapping("/combo") | |||
| @Throws(ServletRequestBindingException::class) | |||
| fun combo(request: HttpServletRequest?): RecordsRes<Map<String, Any>> { | |||
| println(request) | |||
| return RecordsRes<Map<String, Any>>( | |||
| departmentService.combo( | |||
| CriteriaArgsBuilder.withRequest(request) | |||
| .build() | |||
| ) | |||
| ) | |||
| } | |||
| } | |||
| @@ -0,0 +1,28 @@ | |||
| package com.ffii.tsms.modules.data.web | |||
| import com.ffii.core.response.RecordsRes | |||
| import com.ffii.core.utils.CriteriaArgsBuilder | |||
| import com.ffii.tsms.modules.data.service.GradeService | |||
| import jakarta.servlet.http.HttpServletRequest | |||
| import org.springframework.web.bind.ServletRequestBindingException | |||
| import org.springframework.web.bind.annotation.GetMapping | |||
| import org.springframework.web.bind.annotation.RequestMapping | |||
| import org.springframework.web.bind.annotation.RestController | |||
| @RestController | |||
| @RequestMapping("/grades") | |||
| class GradeController(private val gradeService: GradeService) { | |||
| @GetMapping("/combo") | |||
| @Throws(ServletRequestBindingException::class) | |||
| fun combo(request: HttpServletRequest?): RecordsRes<Map<String, Any>> { | |||
| println(request) | |||
| return RecordsRes<Map<String, Any>>( | |||
| gradeService.combo( | |||
| CriteriaArgsBuilder.withRequest(request) | |||
| .build() | |||
| ) | |||
| ) | |||
| } | |||
| } | |||
| @@ -1,5 +1,7 @@ | |||
| package com.ffii.tsms.modules.data.web | |||
| import com.ffii.core.response.RecordsRes | |||
| import com.ffii.core.utils.CriteriaArgsBuilder | |||
| import com.ffii.tsms.modules.data.entity.Department | |||
| import com.ffii.tsms.modules.data.entity.Position | |||
| import com.ffii.tsms.modules.data.entity.projections.DepartmentSearchInfo | |||
| @@ -10,7 +12,9 @@ import com.ffii.tsms.modules.data.web.models.NewDepartmentRequest | |||
| import com.ffii.tsms.modules.data.web.models.NewPositionRequest | |||
| import com.ffii.tsms.modules.project.entity.Project | |||
| import com.ffii.tsms.modules.project.web.models.NewProjectRequest | |||
| import jakarta.servlet.http.HttpServletRequest | |||
| import jakarta.validation.Valid | |||
| import org.springframework.web.bind.ServletRequestBindingException | |||
| import org.springframework.web.bind.annotation.* | |||
| @RestController | |||
| @@ -26,4 +30,16 @@ class PositionController(private val positionService: PositionService | |||
| fun saveProject(@Valid @RequestBody newPosition: NewPositionRequest): Position { | |||
| return positionService.savePosition(newPosition) | |||
| } | |||
| @GetMapping("/combo") | |||
| @Throws(ServletRequestBindingException::class) | |||
| fun combo(request: HttpServletRequest?): RecordsRes<Map<String, Any>> { | |||
| println(request) | |||
| return RecordsRes<Map<String, Any>>( | |||
| positionService.combo( | |||
| CriteriaArgsBuilder.withRequest(request) | |||
| .build() | |||
| ) | |||
| ) | |||
| } | |||
| } | |||
| @@ -0,0 +1,31 @@ | |||
| package com.ffii.tsms.modules.data.web | |||
| import com.ffii.core.response.RecordsRes | |||
| import com.ffii.core.utils.CriteriaArgsBuilder | |||
| import com.ffii.tsms.modules.data.service.DepartmentService | |||
| import com.ffii.tsms.modules.data.service.SalaryService | |||
| import jakarta.servlet.http.HttpServletRequest | |||
| import org.springframework.web.bind.ServletRequestBindingException | |||
| import org.springframework.web.bind.annotation.GetMapping | |||
| import org.springframework.web.bind.annotation.RequestMapping | |||
| import org.springframework.web.bind.annotation.RestController | |||
| @RestController | |||
| @RequestMapping("/salary") | |||
| class SalaryController( | |||
| private val salaryService: SalaryService | |||
| ) { | |||
| @GetMapping("/combo") | |||
| @Throws(ServletRequestBindingException::class) | |||
| fun combo(request: HttpServletRequest?): RecordsRes<Map<String, Any>> { | |||
| println(request) | |||
| return RecordsRes<Map<String, Any>>( | |||
| salaryService.combo( | |||
| CriteriaArgsBuilder.withRequest(request) | |||
| .build() | |||
| ) | |||
| ) | |||
| } | |||
| } | |||
| @@ -0,0 +1,28 @@ | |||
| package com.ffii.tsms.modules.data.web | |||
| import com.ffii.core.response.RecordsRes | |||
| import com.ffii.core.utils.CriteriaArgsBuilder | |||
| import com.ffii.tsms.modules.data.service.SalaryEffectiveService | |||
| import jakarta.servlet.http.HttpServletRequest | |||
| import org.springframework.web.bind.ServletRequestBindingException | |||
| import org.springframework.web.bind.annotation.GetMapping | |||
| import org.springframework.web.bind.annotation.RequestMapping | |||
| import org.springframework.web.bind.annotation.RestController | |||
| @RestController | |||
| @RequestMapping("/salaryEffective") | |||
| class SalaryEffectiveController(private val salaryEffectiveService: SalaryEffectiveService) { | |||
| // @GetMapping("/combo") | |||
| // @Throws(ServletRequestBindingException::class) | |||
| // fun combo(request: HttpServletRequest?): RecordsRes<Map<String, Any>> { | |||
| // println(request) | |||
| // return RecordsRes<Map<String, Any>>( | |||
| // salaryEffectiveService.combo( | |||
| // CriteriaArgsBuilder.withRequest(request) | |||
| // .build() | |||
| // ) | |||
| // ) | |||
| // } | |||
| } | |||
| @@ -0,0 +1,29 @@ | |||
| package com.ffii.tsms.modules.data.web | |||
| import com.ffii.core.response.RecordsRes | |||
| import com.ffii.core.utils.CriteriaArgsBuilder | |||
| import com.ffii.tsms.modules.data.service.DepartmentService | |||
| import com.ffii.tsms.modules.data.service.SkillService | |||
| import jakarta.servlet.http.HttpServletRequest | |||
| import org.springframework.web.bind.ServletRequestBindingException | |||
| import org.springframework.web.bind.annotation.GetMapping | |||
| import org.springframework.web.bind.annotation.RequestMapping | |||
| import org.springframework.web.bind.annotation.RestController | |||
| @RestController | |||
| @RequestMapping("/skill") | |||
| class SkillController(private val skillService: SkillService) { | |||
| @GetMapping("/combo") | |||
| @Throws(ServletRequestBindingException::class) | |||
| fun combo(request: HttpServletRequest?): RecordsRes<Map<String, Any>> { | |||
| println(request) | |||
| return RecordsRes<Map<String, Any>>( | |||
| skillService.combo( | |||
| CriteriaArgsBuilder.withRequest(request) | |||
| .build() | |||
| ) | |||
| ) | |||
| } | |||
| } | |||
| @@ -1,5 +1,7 @@ | |||
| package com.ffii.tsms.modules.data.web | |||
| import com.ffii.core.exception.NotFoundException | |||
| import com.ffii.core.utils.Params | |||
| import com.ffii.tsms.modules.data.entity.Staff | |||
| import com.ffii.tsms.modules.data.entity.projections.StaffSearchInfo | |||
| import com.ffii.tsms.modules.data.service.StaffsService | |||
| @@ -8,6 +10,7 @@ import jakarta.validation.Valid | |||
| import org.springframework.http.HttpStatus | |||
| import org.springframework.web.bind.annotation.* | |||
| @RestController | |||
| @RequestMapping("/staffs") | |||
| class StaffsController(private val staffsService: StaffsService) { | |||
| @@ -24,22 +27,19 @@ class StaffsController(private val staffsService: StaffsService) { | |||
| return staffsService.getTeamLeads() | |||
| } | |||
| @GetMapping("/{id}") | |||
| fun getStaff(@PathVariable id: Long?): Map<String, Any> { | |||
| return java.util.Map.of( | |||
| Params.DATA, staffsService.find(id).orElseThrow { NotFoundException() }) | |||
| } | |||
| @DeleteMapping("/delete/{id}") | |||
| @ResponseStatus(HttpStatus.NO_CONTENT) | |||
| fun delete(@PathVariable id: Long?) { | |||
| staffsService.markDelete(id) | |||
| } | |||
| @PostMapping("/new") | |||
| @PostMapping("/save") | |||
| fun saveStaff(@Valid @RequestBody newStaff: NewStaffRequest): Staff { | |||
| return staffsService.saveStaff(newStaff) | |||
| return staffsService.saveOrUpdate(newStaff) | |||
| } | |||
| // @GetMapping("/newlist") | |||
| // fun list(request: HttpServletRequest): RecordsRes<Map<String, Any>> { | |||
| // return RecordsRes(staffsService.fetchStaffList( | |||
| // CriteriaArgsBuilder.withRequest(request) | |||
| // .addString("staffId") | |||
| // .build() | |||
| // )) | |||
| // } | |||
| } | |||
| @@ -0,0 +1,28 @@ | |||
| package com.ffii.tsms.modules.data.web | |||
| import com.ffii.core.response.RecordsRes | |||
| import com.ffii.core.utils.CriteriaArgsBuilder | |||
| import com.ffii.tsms.modules.data.service.TeamService | |||
| import jakarta.servlet.http.HttpServletRequest | |||
| import org.springframework.web.bind.ServletRequestBindingException | |||
| import org.springframework.web.bind.annotation.GetMapping | |||
| import org.springframework.web.bind.annotation.RequestMapping | |||
| import org.springframework.web.bind.annotation.RestController | |||
| @RestController | |||
| @RequestMapping("/team") | |||
| class TeamController(private val teamService: TeamService) { | |||
| @GetMapping("/combo") | |||
| @Throws(ServletRequestBindingException::class) | |||
| fun combo(request: HttpServletRequest?): RecordsRes<Map<String, Any>> { | |||
| println(request) | |||
| return RecordsRes<Map<String, Any>>( | |||
| teamService.combo( | |||
| CriteriaArgsBuilder.withRequest(request) | |||
| .build() | |||
| ) | |||
| ) | |||
| } | |||
| } | |||
| @@ -5,8 +5,10 @@ import jakarta.validation.constraints.NotNull | |||
| import java.time.LocalDate | |||
| data class NewStaffRequest( | |||
| @field:NotNull(message = "Staff userId cannot be empty") | |||
| val userId: Long, | |||
| val id: Long, | |||
| // @field:NotNull(message = "Staff userId cannot be empty") | |||
| // val userId: Long, | |||
| @field:NotBlank(message = "Staff name cannot be empty") | |||
| val name: String, | |||
| @field:NotBlank(message = "Staff staffId cannot be empty") | |||
| @@ -15,7 +17,7 @@ data class NewStaffRequest( | |||
| val companyId: Long, | |||
| @field:NotNull(message = "Staff salaryEffId cannot be empty") | |||
| val salaryEffId: Long, | |||
| @field:NotNull(message = "Staff salaryEffId cannot be empty") | |||
| @field:NotNull(message = "Staff skillSetId cannot be empty") | |||
| val skillSetId: Long, | |||
| val joinDate: LocalDate, | |||