260115_01_ENH : 대표 템플릿 저장 구현 및 Front 연동 테스트 완료
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
package com.kri.contact.server.common.enums;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonValue;
|
||||
import com.kri.common.enums.CodeEnum;
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
@Getter(onMethod_ = @JsonValue)
|
||||
@RequiredArgsConstructor
|
||||
public enum ChannelType implements CodeEnum<Short> {
|
||||
|
||||
EMAIL((short) 1),
|
||||
SMS((short) 2);
|
||||
|
||||
private final Short code;
|
||||
|
||||
ChannelType(CodeEnum<Short> source) {
|
||||
this.code = source.getCode();
|
||||
}
|
||||
|
||||
@JsonCreator(mode = JsonCreator.Mode.DELEGATING)
|
||||
public static ChannelType fromCode(Short code) {
|
||||
if (code == null) return null;
|
||||
for (ChannelType s : values()) {
|
||||
if (s.code == code) return s;
|
||||
}
|
||||
throw new IllegalArgumentException("Unknown ChannelType code: " + code);
|
||||
}
|
||||
}
|
||||
@@ -8,22 +8,28 @@ import lombok.RequiredArgsConstructor;
|
||||
@Getter
|
||||
@RequiredArgsConstructor
|
||||
public enum SystemEventType implements CodeEnum<Short> {
|
||||
LOGIN((short) 11), // 로그인
|
||||
LOGOUT((short) 12), // 로그 아웃
|
||||
//1의 자리 1 insert, 2 update, 3 delete, 4 upload
|
||||
//100의 자리 대분류, 10의 자리 소분류
|
||||
|
||||
CREATE_PROJECT((short) 21), // 프로젝트 생성
|
||||
UPDATE_PROJECT((short) 22), // 프로젝트 수정
|
||||
DELETE_PROJECT((short) 23), // 프로젝트 삭제
|
||||
ASSIGN_PROJECT_USER((short) 24), // 프로젝트 배정
|
||||
LOGIN((short) 111), // 로그인
|
||||
LOGOUT((short) 121), // 로그 아웃
|
||||
|
||||
CREATE_USER((short) 31), // 사용자 생성
|
||||
UPDATE_USER((short) 32), // 사용자 수정
|
||||
DELETE_USER((short) 33), // 사용자 삭제
|
||||
UPLOAD_USER((short) 34), // 사용자 삭제
|
||||
CREATE_PROJECT((short) 211), // 프로젝트 생성
|
||||
UPDATE_PROJECT((short) 212), // 프로젝트 수정
|
||||
DELETE_PROJECT((short) 213), // 프로젝트 삭제
|
||||
ASSIGN_PROJECT_USER((short) 222), // 프로젝트 배정
|
||||
UPDATE_PROJECT_DEFAULT_TEMPLATE((short) 232), // 기본 템플릿 수정
|
||||
|
||||
CREATE_ROLE((short) 41), // 권한 생성
|
||||
UPDATE_ROLE((short) 42), // 권한 수정
|
||||
DELETE_ROLE((short) 43); // 권한 삭제
|
||||
CREATE_USER((short) 311), // 사용자 생성
|
||||
UPDATE_USER((short) 312), // 사용자 수정
|
||||
DELETE_USER((short) 313), // 사용자 삭제
|
||||
UPLOAD_USER((short) 314), // 사용자 삭제
|
||||
|
||||
CREATE_ROLE((short) 411), // 권한 생성
|
||||
UPDATE_ROLE((short) 412), // 권한 수정
|
||||
DELETE_ROLE((short) 413), // 권한 삭제
|
||||
|
||||
DUMMY((short) 9999);
|
||||
|
||||
private final Short code;
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.kri.contact.server.controller;
|
||||
import com.kri.common.datetime.DateTimeUtil;
|
||||
import com.kri.common.webmvc.RequestUserContext;
|
||||
import com.kri.common.webmvc.page.PageResponseDto;
|
||||
import com.kri.contact.server.common.enums.ChannelType;
|
||||
import com.kri.contact.server.dto.*;
|
||||
import com.kri.contact.server.service.FileService;
|
||||
import com.kri.contact.server.service.ProjectService;
|
||||
@@ -57,6 +58,16 @@ public class ProjectController {
|
||||
public ProjectOwnerResponseDto getOwnerList(RequestUserContext ctx) {
|
||||
return projectService.getOwnerList(ctx.getUserRole());
|
||||
}
|
||||
|
||||
//프로젝트 메인 발송 템플릿 조회 시 살아있는 템플릿인지 한번 검사하기
|
||||
@Operation(summary = "프로젝트 대표 발송 템플릿 조회")
|
||||
@GetMapping("/main-template/{prjctIdx}/{chnnlTy}")
|
||||
public Long getMainTemplateIdx(
|
||||
@PathVariable Long prjctIdx,
|
||||
@PathVariable ChannelType chnnlTy
|
||||
){
|
||||
return projectService.getMainTemplateIdx(prjctIdx, chnnlTy.getCode());
|
||||
}
|
||||
|
||||
@Operation(summary = "프로젝트 생성")
|
||||
@PutMapping()
|
||||
@@ -98,6 +109,18 @@ public class ProjectController {
|
||||
systemEventLogService.writeUpdateProject(ctx.getUserId(), now, ctx.getClientIp(), prjctIdx, req);
|
||||
}
|
||||
|
||||
@Operation(summary = "프로젝트 대표 발송 템플릿 지정")
|
||||
@PatchMapping("/main-template")
|
||||
public void updateProjectMainTemplate(
|
||||
@Valid @RequestBody ProjectMainTemplateUpdateRequestDto req,
|
||||
RequestUserContext ctx
|
||||
) {
|
||||
final LocalDateTime now = DateTimeUtil.nowKstLocalDateTime();
|
||||
|
||||
projectService.updateProjectMainTemplate(req, ctx.getUserId(), now);
|
||||
systemEventLogService.writeUpdateDefaultMessageTemplate(ctx.getUserId(), now, ctx.getClientIp(), req);
|
||||
}
|
||||
|
||||
@Operation(summary = "프로젝트 삭제(소프트 삭제)")
|
||||
@DeleteMapping("/{prjctIdx}")
|
||||
public void deleteProject(@PathVariable Long prjctIdx, RequestUserContext ctx) {
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.kri.contact.server.dto;
|
||||
|
||||
import com.kri.contact.server.common.enums.ChannelType;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Schema(description = "프로젝트 생성 요청")
|
||||
public class ProjectMainTemplateUpdateRequestDto {
|
||||
|
||||
@NotNull
|
||||
@Schema(description = "프로젝트 명")
|
||||
private Long prjctIdx;
|
||||
|
||||
@NotNull
|
||||
@Schema(description = "템플릿 채널 타입")
|
||||
private ChannelType chnnlTy;
|
||||
|
||||
@NotNull
|
||||
@Schema(description = "프로젝트 명")
|
||||
private Long tmplatIdx;
|
||||
|
||||
}
|
||||
@@ -34,7 +34,7 @@ public class TPrjctEntity {
|
||||
@NotNull
|
||||
@ColumnDefault("0")
|
||||
@Column(name = "prjct_status", nullable = false)
|
||||
private Short prjctStatus = ProjectStatus.STANDBY.getCode();
|
||||
private Short prjctStatus;
|
||||
|
||||
@Size(max = 128)
|
||||
@NotNull
|
||||
@@ -59,7 +59,7 @@ public class TPrjctEntity {
|
||||
@NotNull
|
||||
@ColumnDefault("0")
|
||||
@Column(name = "survey_ty", nullable = false)
|
||||
private Short surveyTy = SurveyType.NONE.getCode();
|
||||
private Short surveyTy;
|
||||
|
||||
@Size(max = 32)
|
||||
@Column(name = "survey_prjct_cd", length = 32)
|
||||
@@ -72,12 +72,12 @@ public class TPrjctEntity {
|
||||
@NotNull
|
||||
@ColumnDefault("0")
|
||||
@Column(name = "is_ff", nullable = false)
|
||||
private Boolean ff = false;
|
||||
private Boolean ff;
|
||||
|
||||
@NotNull
|
||||
@ColumnDefault("0")
|
||||
@Column(name = "is_use_contact_senario", nullable = false)
|
||||
private Boolean useContactSenario = false;
|
||||
private Boolean useContactSenario;
|
||||
|
||||
@Lob
|
||||
@Column(name = "contact_senario")
|
||||
@@ -103,7 +103,7 @@ public class TPrjctEntity {
|
||||
@NotNull
|
||||
@ColumnDefault("0")
|
||||
@Column(name = "is_del", nullable = false)
|
||||
private Boolean del = false;
|
||||
private Boolean del;
|
||||
|
||||
@Size(max = 32)
|
||||
@Column(name = "del_user", length = 32)
|
||||
@@ -134,12 +134,17 @@ public class TPrjctEntity {
|
||||
public static TPrjctEntity create(ProjectCreateRequestDto req, String prjctCd, String regUser, LocalDateTime regDt) {
|
||||
return TPrjctEntity.builder()
|
||||
.prjctCd(prjctCd)
|
||||
.prjctStatus(ProjectStatus.STANDBY.getCode())
|
||||
.prjctNm(req.getPrjctName())
|
||||
.itrntPrjctCd(req.getItrntPrjctCd())
|
||||
.ownerDept(req.getOwnerDept())
|
||||
.ownerFw(req.getOwnerFw())
|
||||
.surveyTy(SurveyType.NONE.getCode())
|
||||
.ff(false)
|
||||
.useContactSenario(false)
|
||||
.regUser(regUser)
|
||||
.regDt(regDt)
|
||||
.del(false)
|
||||
.build();
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
package com.kri.contact.server.persistence.entity;
|
||||
|
||||
import com.kri.contact.server.dto.ProjectMainTemplateUpdateRequestDto;
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.EmbeddedId;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.Table;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import jakarta.validation.constraints.Size;
|
||||
import lombok.*;
|
||||
import org.hibernate.annotations.ColumnDefault;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Entity
|
||||
@Table(name = "t_prjct_main_tmplat")
|
||||
public class TPrjctMainTmplatEntity {
|
||||
@EmbeddedId
|
||||
private TPrjctMainTmplatEntityId id;
|
||||
|
||||
@NotNull
|
||||
@Column(name = "tmplat_idx", nullable = false)
|
||||
private Long tmplatIdx;
|
||||
|
||||
@NotNull
|
||||
@Size(max = 32)
|
||||
@Column(name = "reg_user", nullable = false, length = 32)
|
||||
private String regUser;
|
||||
|
||||
@NotNull
|
||||
@ColumnDefault("CURRENT_TIMESTAMP")
|
||||
@Column(name = "reg_dt", nullable = false)
|
||||
private LocalDateTime regDt;
|
||||
|
||||
// convenience
|
||||
public Long getPrjctIdx() {
|
||||
return id != null ? id.getPrjctIdx() : null;
|
||||
}
|
||||
|
||||
public Short getChnnlTy() {
|
||||
return id != null ? id.getChnnlTy() : null;
|
||||
}
|
||||
|
||||
public static TPrjctMainTmplatEntity create(ProjectMainTemplateUpdateRequestDto req, String regUser, LocalDateTime regDt) {
|
||||
return TPrjctMainTmplatEntity.builder()
|
||||
.id(TPrjctMainTmplatEntityId.create(req.getPrjctIdx(), req.getChnnlTy().getCode()))
|
||||
.tmplatIdx(req.getTmplatIdx())
|
||||
.regUser(regUser)
|
||||
.regDt(regDt)
|
||||
.build();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package com.kri.contact.server.persistence.entity;
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Embeddable;
|
||||
import lombok.*;
|
||||
import org.hibernate.Hibernate;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Objects;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Embeddable
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class TPrjctMainTmplatEntityId implements Serializable {
|
||||
private static final long serialVersionUID = -263674621497298216L;
|
||||
|
||||
@Column(name = "prjct_idx", nullable = false, columnDefinition = "INT UNSIGNED")
|
||||
private Long prjctIdx;
|
||||
|
||||
@Column(name = "chnnl_ty", nullable = false)
|
||||
private Short chnnlTy;
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || Hibernate.getClass(this) != Hibernate.getClass(o)) return false;
|
||||
TPrjctMainTmplatEntityId entity = (TPrjctMainTmplatEntityId) o;
|
||||
return Objects.equals(this.prjctIdx, entity.prjctIdx) &&
|
||||
Objects.equals(this.chnnlTy, entity.chnnlTy);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(prjctIdx, chnnlTy);
|
||||
}
|
||||
|
||||
public static TPrjctMainTmplatEntityId create(Long prjctIdx, Short chnnlTy) {
|
||||
return TPrjctMainTmplatEntityId.builder()
|
||||
.prjctIdx(prjctIdx)
|
||||
.chnnlTy(chnnlTy)
|
||||
.build();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.kri.contact.server.persistence.repository;
|
||||
|
||||
import com.kri.contact.server.persistence.entity.TPrjctMainTmplatEntity;
|
||||
import com.kri.contact.server.persistence.entity.TPrjctMainTmplatEntityId;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
public interface ProjectMainTemplateRepository extends JpaRepository<TPrjctMainTmplatEntity, TPrjctMainTmplatEntityId>, JpaSpecificationExecutor<TPrjctMainTmplatEntity> {
|
||||
|
||||
Optional<TPrjctMainTmplatEntity> findByIdPrjctIdxAndIdChnnlTy(Long prjctIdx, Short chnnlTy);
|
||||
|
||||
long deleteByIdPrjctIdxAndIdChnnlTy(Long prjctIdx, Short chnnlTy);
|
||||
}
|
||||
@@ -4,9 +4,10 @@ import com.kri.common.web.BusinessException;
|
||||
import com.kri.common.webmvc.page.*;
|
||||
import com.kri.contact.server.common.consts.ContactConstant;
|
||||
import com.kri.contact.server.dto.*;;
|
||||
import com.kri.contact.server.persistence.entity.TPrjctMainTmplatEntity;
|
||||
import com.kri.contact.server.persistence.entity.TPrjctEntity;
|
||||
import com.kri.contact.server.persistence.query.ProjectSorts;
|
||||
import com.kri.contact.server.persistence.query.ProjectSpecs;
|
||||
import com.kri.contact.server.persistence.repository.ProjectMainTemplateRepository;
|
||||
import com.kri.contact.server.persistence.repository.ProjectRepository;
|
||||
import org.springframework.dao.DataIntegrityViolationException;
|
||||
import org.springframework.data.domain.*;
|
||||
@@ -25,6 +26,7 @@ public class ProjectService {
|
||||
private final AssignService assignService;
|
||||
private final ResultCodeService resultCodeService;
|
||||
private final ProjectRepository projectRepository;
|
||||
private final ProjectMainTemplateRepository projectMainTemplateRepository;
|
||||
private static final List<Short> STATUS_0_1 = List.of((short) 0, (short) 1);
|
||||
private static final List<Short> STATUS_1 = List.of((short) 1);
|
||||
|
||||
@@ -128,6 +130,12 @@ public class ProjectService {
|
||||
return projectRepository.findDistinctOwnerFw(statusList);
|
||||
}
|
||||
|
||||
public Long getMainTemplateIdx(Long prjctIdx, Short chnnlTy) {
|
||||
return projectMainTemplateRepository.findByIdPrjctIdxAndIdChnnlTy(prjctIdx, chnnlTy)
|
||||
.map(TPrjctMainTmplatEntity::getTmplatIdx)
|
||||
.orElse(null);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void updateProject(long prjctIdx, ProjectUpdateRequestDto req, String modUser, LocalDateTime modDt) {
|
||||
// dirty checking 업데이트
|
||||
@@ -143,6 +151,17 @@ public class ProjectService {
|
||||
resultCodeService.updateResultCode(prjctIdx, req.getResultCodeList(), modUser, modDt);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void updateProjectMainTemplate(ProjectMainTemplateUpdateRequestDto req, String modUser, LocalDateTime modDt) {
|
||||
Short chnnlTy = req.getChnnlTy().getCode();
|
||||
projectMainTemplateRepository.deleteByIdPrjctIdxAndIdChnnlTy(req.getPrjctIdx(), chnnlTy);
|
||||
|
||||
if(req.getTmplatIdx() == null) return;
|
||||
|
||||
TPrjctMainTmplatEntity entity = TPrjctMainTmplatEntity.create(req, modUser, modDt);
|
||||
projectMainTemplateRepository.save(entity);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void deleteProject(Long prjctIdx, String delUser, LocalDateTime delDt) {
|
||||
int deleteCount = projectRepository.softDeleteByPrjctIdx(prjctIdx, delUser, delDt);
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.kri.contact.server.service;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.kri.common.datetime.DateTimeUtil;
|
||||
import com.kri.contact.server.dto.*;
|
||||
import com.kri.contact.server.dto.systemlog.UploadUserContentDto;
|
||||
import com.kri.contact.server.common.enums.SystemEventType;
|
||||
@@ -81,6 +80,10 @@ public class SystemEventLogService {
|
||||
writeSystemLog(SystemEventType.UPDATE_PROJECT, "Update Project", prjctIdx, regId, regDt, clientIp, req);
|
||||
}
|
||||
|
||||
public void writeUpdateDefaultMessageTemplate(String regId, LocalDateTime regDt, String clientIp, ProjectMainTemplateUpdateRequestDto req) {
|
||||
writeSystemLog(SystemEventType.UPDATE_PROJECT_DEFAULT_TEMPLATE, "Update Project Default Message Template", req.getPrjctIdx(), regId, regDt, clientIp, req);
|
||||
}
|
||||
|
||||
public void writeDeleteProject(String regId, LocalDateTime regDt, String clientIp, Long prjctIdx) {
|
||||
writeSystemLog(
|
||||
SystemEventType.DELETE_PROJECT,
|
||||
|
||||
Reference in New Issue
Block a user