From 91fff4fddd3e53f20d7c7d51050eae16a30cbfb5 Mon Sep 17 00:00:00 2001 From: "cyril.tsui" Date: Mon, 25 Aug 2025 12:49:36 +0800 Subject: [PATCH] rename --- .../modules/stock/entity/EscalationLog.kt | 4 ++-- .../modules/stock/entity/EscalationLogInfo.kt | 20 +++++++++---------- .../stock/entity/EscalationLogRepository.kt | 4 ++-- .../stock/service/EscalationLogService.kt | 16 +++++++-------- .../web/model/SaveEscalationLogRequest.kt | 2 +- .../web/model/SaveEscalationLogResponse.kt | 8 ++++---- .../01_update_escalation_log.sql | 11 ++++++++++ 7 files changed, 38 insertions(+), 27 deletions(-) create mode 100644 src/main/resources/db/changelog/changes/20250825_01_cyril/01_update_escalation_log.sql diff --git a/src/main/java/com/ffii/fpsms/modules/stock/entity/EscalationLog.kt b/src/main/java/com/ffii/fpsms/modules/stock/entity/EscalationLog.kt index 3d5f173..4180652 100644 --- a/src/main/java/com/ffii/fpsms/modules/stock/entity/EscalationLog.kt +++ b/src/main/java/com/ffii/fpsms/modules/stock/entity/EscalationLog.kt @@ -14,8 +14,8 @@ import java.time.LocalDateTime open class EscalationLog : BaseEntity() { @NotNull @ManyToOne - @JoinColumn(name = "personInCharge", nullable = false, referencedColumnName = "id") - open var personInCharge: User? = null + @JoinColumn(name = "handlerId", nullable = false, referencedColumnName = "id") + open var handler: User? = null @Size(max = 100) @Column(name = "type", nullable = false, length = 100) diff --git a/src/main/java/com/ffii/fpsms/modules/stock/entity/EscalationLogInfo.kt b/src/main/java/com/ffii/fpsms/modules/stock/entity/EscalationLogInfo.kt index 88c928d..c11da8d 100644 --- a/src/main/java/com/ffii/fpsms/modules/stock/entity/EscalationLogInfo.kt +++ b/src/main/java/com/ffii/fpsms/modules/stock/entity/EscalationLogInfo.kt @@ -52,16 +52,16 @@ interface EscalationLogInfo { @get:Value("#{target.stockInLine?.item?.itemUoms.^[stockUnit == true && deleted == false]?.uom.udfudesc}") val stockUomDesc: String? - @get:Value("#{target.personInCharge?.id}") - val personInChargeId: Long? - @get:Value("#{target.personInCharge?.department} - #{target.personInCharge?.title} - #{target.personInCharge?.name}") - val personInCharge: String? - @get:Value("#{target.personInCharge?.name}") - val personInChargeName: String? - @get:Value("#{target.personInCharge?.title}") - val personInChargeTitle: String? - @get:Value("#{target.personInCharge?.department}") - val personInChargeDepartment: String? + @get:Value("#{target.handler?.id}") + val handlerId: Long? + @get:Value("#{target.handler?.department} - #{target.handler?.title} - #{target.handler?.name}") + val handler: String? + @get:Value("#{target.handler?.name}") + val handlerName: String? + @get:Value("#{target.handler?.title}") + val handlerTitle: String? + @get:Value("#{target.handler?.department}") + val handlerDepartment: String? // @get:Value("#{target.type}") // val escalationLevel: String diff --git a/src/main/java/com/ffii/fpsms/modules/stock/entity/EscalationLogRepository.kt b/src/main/java/com/ffii/fpsms/modules/stock/entity/EscalationLogRepository.kt index 4fe53bf..e3d2b00 100644 --- a/src/main/java/com/ffii/fpsms/modules/stock/entity/EscalationLogRepository.kt +++ b/src/main/java/com/ffii/fpsms/modules/stock/entity/EscalationLogRepository.kt @@ -6,10 +6,10 @@ import java.io.Serializable @Repository interface EscalationLogRepository: AbstractRepository { -// fun findAllByPersonInCharge(personInCharge: Long): List +// fun findAllByHandler(handler: Long): List fun findAllInfoByDeletedFalse(): List fun findAllInfoByDeletedFalseAndStockInLineIdIn(stockInLineIds: List): List - fun findAllInfoByDeletedFalseAndPersonInChargeIdIs(personInChargeId: Serializable): List + fun findAllInfoByDeletedFalseAndHandlerIdIs(handlerId: Serializable): List } \ No newline at end of file diff --git a/src/main/java/com/ffii/fpsms/modules/stock/service/EscalationLogService.kt b/src/main/java/com/ffii/fpsms/modules/stock/service/EscalationLogService.kt index 51ff04a..de86a1a 100644 --- a/src/main/java/com/ffii/fpsms/modules/stock/service/EscalationLogService.kt +++ b/src/main/java/com/ffii/fpsms/modules/stock/service/EscalationLogService.kt @@ -37,14 +37,14 @@ open class EscalationLogService( open fun getLogsByUser(): List { val user = SecurityUtils.getUser().orElseThrow() - val logs = user.id?.let { escalationLogRepository.findAllInfoByDeletedFalseAndPersonInChargeIdIs(it) } ?: listOf() + val logs = user.id?.let { escalationLogRepository.findAllInfoByDeletedFalseAndHandlerIdIs(it) } ?: listOf() return logs } open fun saveEscalationLog(request: SaveEscalationLogRequest): SaveEscalationLogResponse{ val escalationLog = request.id?.let { escalationLogRepository.findById(it).getOrNull() } ?: EscalationLog() - val personInCharge = request.personInChargeId.let { userService.getUserById(it) } - if (personInCharge == null && escalationLog.personInCharge == null) { + val handler = request.handlerId.let { userService.getUserById(it) } + if (handler == null && escalationLog.handler == null) { throw NoSuchElementException("Person In Charge is null."); } @@ -57,7 +57,7 @@ open class EscalationLogService( val status = request.status.let { status -> EscalationLogStatus.entries.find{ it.value == status} } escalationLog.apply { - this.personInCharge = personInCharge + this.handler = handler type = request.type this.stockInLine = stockInLine this.stockOutLine = stockOutLine @@ -73,10 +73,10 @@ open class EscalationLogService( id = it.id, stockInLineId = it.stockInLine?.id, stockOutLineId = it.stockOutLine?.id, - personInChargeId = it.personInCharge?.id, - personInChargeName = it.personInCharge?.name, - personInChargeTitle = it.personInCharge?.title, - personInChargeDepartment = it.personInCharge?.department, + handlerId = it.handler?.id, + handlerName = it.handler?.name, + handlerTitle = it.handler?.title, + handlerDepartment = it.handler?.department, recordDate = it.recordDate, status = it.status?.value, reason = it.reason, diff --git a/src/main/java/com/ffii/fpsms/modules/stock/web/model/SaveEscalationLogRequest.kt b/src/main/java/com/ffii/fpsms/modules/stock/web/model/SaveEscalationLogRequest.kt index c3bf6ef..9b00c57 100644 --- a/src/main/java/com/ffii/fpsms/modules/stock/web/model/SaveEscalationLogRequest.kt +++ b/src/main/java/com/ffii/fpsms/modules/stock/web/model/SaveEscalationLogRequest.kt @@ -7,7 +7,7 @@ import java.time.LocalDateTime data class SaveEscalationLogRequest( val id: Long?, @field:NotNull(message = "Person In Charge cannot be empty") - val personInChargeId: Long, + val handlerId: Long, val type: String?, val stockInLineId: Long?, val stockOutLineId: Long?, diff --git a/src/main/java/com/ffii/fpsms/modules/stock/web/model/SaveEscalationLogResponse.kt b/src/main/java/com/ffii/fpsms/modules/stock/web/model/SaveEscalationLogResponse.kt index 557df4c..b1d924c 100644 --- a/src/main/java/com/ffii/fpsms/modules/stock/web/model/SaveEscalationLogResponse.kt +++ b/src/main/java/com/ffii/fpsms/modules/stock/web/model/SaveEscalationLogResponse.kt @@ -6,10 +6,10 @@ data class SaveEscalationLogResponse( val id: Long?, val stockInLineId: Long?, val stockOutLineId: Long?, - val personInChargeId: Long?, - val personInChargeName: String?, - val personInChargeTitle: String?, - val personInChargeDepartment: String?, + val handlerId: Long?, + val handlerName: String?, + val handlerTitle: String?, + val handlerDepartment: String?, val recordDate: LocalDateTime?, val status: String?, val reason: String?, diff --git a/src/main/resources/db/changelog/changes/20250825_01_cyril/01_update_escalation_log.sql b/src/main/resources/db/changelog/changes/20250825_01_cyril/01_update_escalation_log.sql new file mode 100644 index 0000000..74acd9f --- /dev/null +++ b/src/main/resources/db/changelog/changes/20250825_01_cyril/01_update_escalation_log.sql @@ -0,0 +1,11 @@ +-- liquibase formatted sql +-- changeset cyril:rename_escalation_log + +ALTER TABLE `escalation_log` + DROP FOREIGN KEY `FK_SUPERVISION_APPROVAL_LOG_ON_PERSONINCHARGE`; +ALTER TABLE `escalation_log` + CHANGE COLUMN `personInCharge` `handlerId` INT NOT NULL ; +ALTER TABLE `escalation_log` + ADD CONSTRAINT `FK_SUPERVISION_APPROVAL_LOG_ON_PERSONINCHARGE` + FOREIGN KEY (`handlerId`) + REFERENCES `user` (`id`);