| @@ -0,0 +1,55 @@ | |||||
| package com.ffii.tsms.modules.data.entity; | |||||
| import com.ffii.core.entity.BaseEntity; | |||||
| import jakarta.persistence.*; | |||||
| import jakarta.validation.constraints.NotNull; | |||||
| import java.time.LocalDate; | |||||
| @Entity | |||||
| @Table(name = "grade_log") | |||||
| public class GradeLog extends BaseEntity<Long> { | |||||
| @NotNull | |||||
| @OneToOne | |||||
| @JoinColumn(name = "staffId") | |||||
| private Staff staff; | |||||
| @NotNull | |||||
| @OneToOne | |||||
| @JoinColumn(name = "gradeId") | |||||
| private Grade grade; | |||||
| @NotNull | |||||
| @OneToOne | |||||
| @JoinColumn(name = "positionId") | |||||
| private Position position; | |||||
| @NotNull | |||||
| @Column(name = "from", length = 30) | |||||
| private LocalDate from; | |||||
| @NotNull | |||||
| @Column(name = "to", length = 30) | |||||
| private LocalDate to; | |||||
| public Staff getStaff() { | |||||
| return staff; | |||||
| } | |||||
| public void setStaff(Staff staff) { | |||||
| this.staff = staff; | |||||
| } | |||||
| public Grade getGrade() { return grade; } | |||||
| public void setGrade(Grade grade) { this.grade = grade; } | |||||
| public Position getPosition() { return position; } | |||||
| public void setPosition(Position position) { this.position = position; } | |||||
| public LocalDate getFrom() { return from; } | |||||
| public void setFrom(LocalDate from) { this.from = from; } | |||||
| } | |||||
| @@ -0,0 +1,10 @@ | |||||
| package com.ffii.tsms.modules.data.entity; | |||||
| import com.ffii.core.support.AbstractRepository; | |||||
| import com.ffii.tsms.modules.data.entity.projections.GradeLogInfo; | |||||
| import java.util.List; | |||||
| public interface GradeLogRepository extends AbstractRepository<GradeLog, Long> { | |||||
| List<GradeLogInfo> findGradeLogInfoByStaffIdAndDeletedFalse(Long staffId); | |||||
| } | |||||
| @@ -0,0 +1,25 @@ | |||||
| package com.ffii.tsms.modules.data.entity.projections | |||||
| import com.ffii.tsms.modules.data.entity.Grade | |||||
| import com.ffii.tsms.modules.data.entity.Position | |||||
| import org.springframework.beans.factory.annotation.Value | |||||
| import java.time.LocalDate | |||||
| interface GradeLogInfo { | |||||
| val id: Long | |||||
| @get:Value("#{target.staff.id}") | |||||
| val staffId: Long | |||||
| @get:Value("#{target.staff.name}") | |||||
| val staffName: String | |||||
| @get:Value("#{target.staff.staffId}") | |||||
| val staffCode: String | |||||
| val grade: Grade | |||||
| val position: Position | |||||
| val from: LocalDate | |||||
| val to: LocalDate? | |||||
| } | |||||
| @@ -0,0 +1,21 @@ | |||||
| 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.GradeLog | |||||
| import com.ffii.tsms.modules.data.entity.GradeLogRepository | |||||
| import com.ffii.tsms.modules.data.entity.projections.GradeLogInfo | |||||
| import org.springframework.stereotype.Service | |||||
| @Service | |||||
| open class GradeLogService( | |||||
| private val gradeLogRepository: GradeLogRepository, | |||||
| private val jdbcDao: JdbcDao, | |||||
| ) : AbstractBaseEntityService<GradeLog, Long, GradeLogRepository>(jdbcDao, gradeLogRepository) { | |||||
| open fun allGradeLog(staffId: Long): List<GradeLogInfo> { | |||||
| return gradeLogRepository.findGradeLogInfoByStaffIdAndDeletedFalse(staffId) | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,24 @@ | |||||
| package com.ffii.tsms.modules.data.web | |||||
| import com.ffii.tsms.modules.data.entity.GradeLog | |||||
| import com.ffii.tsms.modules.data.entity.GradeLogRepository | |||||
| import com.ffii.tsms.modules.data.entity.projections.GradeLogInfo | |||||
| import com.ffii.tsms.modules.data.service.GradeLogService | |||||
| import com.ffii.tsms.modules.project.entity.projections.ProjectSearchInfo | |||||
| import org.springframework.web.bind.annotation.GetMapping | |||||
| import org.springframework.web.bind.annotation.PathVariable | |||||
| import org.springframework.web.bind.annotation.RequestMapping | |||||
| import org.springframework.web.bind.annotation.RestController | |||||
| @RestController | |||||
| @RequestMapping("/gradeLog") | |||||
| class GradeLogController( | |||||
| private val gradeLogService: GradeLogService, | |||||
| private val gradeLogRepository: GradeLogRepository, | |||||
| ) { | |||||
| @GetMapping("/{staffId}") | |||||
| fun allGradeLog(@PathVariable staffId: Long): List<GradeLogInfo> { | |||||
| return gradeLogService.allGradeLog(staffId) | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,22 @@ | |||||
| -- liquibase formatted sql | |||||
| -- changeset derek:create grade log table | |||||
| CREATE TABLE grade_log ( | |||||
| id INT NOT NULL AUTO_INCREMENT, | |||||
| version INT NOT NULL DEFAULT '0', | |||||
| created DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, | |||||
| createdBy VARCHAR(30) NULL, | |||||
| modified DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, | |||||
| modifiedBy VARCHAR(30) NULL, | |||||
| deleted TINYINT(1) NOT NULL DEFAULT '0', | |||||
| staffId INT NOT NULL, | |||||
| gradeId INT NOT NULL, | |||||
| positionId INT NOT NULL, | |||||
| `from` DATE NOT NULL, | |||||
| `to` DATE NULL, | |||||
| CONSTRAINT pk_grade_log PRIMARY KEY (id) | |||||
| ); | |||||
| ALTER TABLE grade_log ADD CONSTRAINT FK_GRADE_LOG_ON_STAFFID FOREIGN KEY (staffId) REFERENCES staff (id); | |||||
| ALTER TABLE grade_log ADD CONSTRAINT FK_GRADE_LOG_ON_GRADEID FOREIGN KEY (gradeId) REFERENCES grade (id); | |||||
| ALTER TABLE grade_log ADD CONSTRAINT FK_GRADE_LOG_ON_POSITIONID FOREIGN KEY (positionId) REFERENCES `position` (id); | |||||