| @@ -1,6 +1,10 @@ | |||||
| package com.ffii.tsms.modules.data.entity; | package com.ffii.tsms.modules.data.entity; | ||||
| import com.ffii.core.support.AbstractRepository; | import com.ffii.core.support.AbstractRepository; | ||||
| import com.ffii.tsms.modules.data.entity.projections.GradeInfo; | |||||
| import java.util.List; | |||||
| public interface GradeRepository extends AbstractRepository<Grade, Long> { | public interface GradeRepository extends AbstractRepository<Grade, Long> { | ||||
| List<GradeInfo> findGradeInfoByDeletedFalse(); | |||||
| } | } | ||||
| @@ -0,0 +1,10 @@ | |||||
| package com.ffii.tsms.modules.data.entity.projections | |||||
| /** | |||||
| * Projection for {@link com.ffii.tsms.modules.data.entity.Grade} | |||||
| */ | |||||
| interface GradeInfo { | |||||
| val id: Long? | |||||
| val name: String? | |||||
| val code: String? | |||||
| } | |||||
| @@ -5,6 +5,7 @@ import com.ffii.core.support.AbstractBaseEntityService | |||||
| import com.ffii.core.support.JdbcDao | import com.ffii.core.support.JdbcDao | ||||
| import com.ffii.tsms.modules.data.entity.Grade | import com.ffii.tsms.modules.data.entity.Grade | ||||
| import com.ffii.tsms.modules.data.entity.GradeRepository | import com.ffii.tsms.modules.data.entity.GradeRepository | ||||
| import com.ffii.tsms.modules.data.entity.projections.GradeInfo | |||||
| import org.springframework.stereotype.Service | import org.springframework.stereotype.Service | ||||
| @Service | @Service | ||||
| @@ -22,4 +23,8 @@ open class GradeService( | |||||
| ) | ) | ||||
| return jdbcDao.queryForList(sql.toString(), args) | return jdbcDao.queryForList(sql.toString(), args) | ||||
| } | } | ||||
| open fun allGrades(): List<GradeInfo> { | |||||
| return gradeRepository.findGradeInfoByDeletedFalse() | |||||
| } | |||||
| } | } | ||||
| @@ -2,6 +2,7 @@ package com.ffii.tsms.modules.data.web | |||||
| import com.ffii.core.response.RecordsRes | import com.ffii.core.response.RecordsRes | ||||
| import com.ffii.core.utils.CriteriaArgsBuilder | import com.ffii.core.utils.CriteriaArgsBuilder | ||||
| import com.ffii.tsms.modules.data.entity.projections.GradeInfo | |||||
| import com.ffii.tsms.modules.data.service.GradeService | import com.ffii.tsms.modules.data.service.GradeService | ||||
| import jakarta.servlet.http.HttpServletRequest | import jakarta.servlet.http.HttpServletRequest | ||||
| import org.springframework.web.bind.ServletRequestBindingException | import org.springframework.web.bind.ServletRequestBindingException | ||||
| @@ -13,6 +14,10 @@ import org.springframework.web.bind.annotation.RestController | |||||
| @RestController | @RestController | ||||
| @RequestMapping("/grades") | @RequestMapping("/grades") | ||||
| class GradeController(private val gradeService: GradeService) { | class GradeController(private val gradeService: GradeService) { | ||||
| @GetMapping | |||||
| fun allGrades(): List<GradeInfo> { | |||||
| return gradeService.allGrades(); | |||||
| } | |||||
| @GetMapping("/combo") | @GetMapping("/combo") | ||||
| @Throws(ServletRequestBindingException::class) | @Throws(ServletRequestBindingException::class) | ||||
| @@ -0,0 +1,19 @@ | |||||
| -- liquibase formatted sql | |||||
| -- changeset wayne:position_data | |||||
| INSERT | |||||
| INTO | |||||
| position | |||||
| (name, code) | |||||
| VALUES | |||||
| ('Quantity Surveying Trainee', 'QS Trainee'), | |||||
| ('Assistant Quantity Surveyor', 'A. QS'), | |||||
| ('Quantity Surveyor', 'QS'), | |||||
| ('Senior Quantity Surveyor', 'S. QS'), | |||||
| ('Assistant Manager', 'A. Manager'), | |||||
| ('Deputy Manager', 'D. Manager'), | |||||
| ('Manager', 'Manager'), | |||||
| ('Senior Manager', 'S. Manager'), | |||||
| ('Assistant Director', 'A. Director'), | |||||
| ('Deputy Director', 'D. Director'), | |||||
| ('Director', 'Director'); | |||||
| @@ -0,0 +1,13 @@ | |||||
| -- liquibase formatted sql | |||||
| -- changeset wayne:grade_data | |||||
| INSERT | |||||
| INTO | |||||
| grade | |||||
| (name, code) | |||||
| VALUES | |||||
| ('Grade 1', '1'), | |||||
| ('Grade 2', '2'), | |||||
| ('Grade 3', '3'), | |||||
| ('Grade 4', '4'), | |||||
| ('Grade 5', '5'); | |||||
| @@ -0,0 +1,9 @@ | |||||
| -- liquibase formatted sql | |||||
| -- changeset wayne:mock_staff_positions | |||||
| UPDATE staff SET currentPosition = 7 WHERE id in (1,2); | |||||
| UPDATE staff SET currentPosition = 1 WHERE id in (3,5,7); | |||||
| UPDATE staff SET currentPosition = 2 WHERE id in (4,6,8); | |||||
| UPDATE staff SET currentPosition = 3 WHERE id in (9,10); | |||||
| UPDATE staff SET currentPosition = 4 WHERE id in (11,12); | |||||
| UPDATE staff SET currentPosition = 5 WHERE id in (13,14); | |||||
| @@ -0,0 +1,8 @@ | |||||
| -- liquibase formatted sql | |||||
| -- changeset wayne:mock_staff_grades | |||||
| UPDATE staff SET gradeId = 4 WHERE id in (1,2); | |||||
| UPDATE staff SET gradeId = 1 WHERE id in (3,4,5,6,7,8); | |||||
| UPDATE staff SET gradeId = 2 WHERE id in (9,10); | |||||
| UPDATE staff SET gradeId = 3 WHERE id in (11,12); | |||||
| UPDATE staff SET gradeId = 4 WHERE id in (13,14); | |||||