260506_01_fst: First Commit
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
package com.kri.kfpa.dash;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
public class KfpaCxDashBackApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(KfpaCxDashBackApplication.class, args);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.kri.kfpa.dash.common.consts;
|
||||
|
||||
import com.kri.kfpa.dash.dto.CsiDataDto;
|
||||
import java.util.Map;
|
||||
|
||||
public final class KfpaDashConstant {
|
||||
|
||||
public static final String KFPA_DASH_PKEY = "2601009_A";
|
||||
public static final String KFPA_COMMENT_PKEY = "2604005_F";
|
||||
public static final String TOTAL = "-1";
|
||||
public static final String SEOUL = "1";
|
||||
public static final String GYEONGGI = "2";
|
||||
public static final String BUSAN = "3";
|
||||
public static final String DAEGU = "4";
|
||||
public static final String DAEJEON = "5";
|
||||
public static final String GWANGJU = "6";
|
||||
|
||||
private static final String IDKEY_PREFIX = "Q1003_";
|
||||
|
||||
public static final Map<String, String> IDKEY_MAP = Map.of(
|
||||
SEOUL, IDKEY_PREFIX + SEOUL,
|
||||
GYEONGGI, IDKEY_PREFIX + GYEONGGI,
|
||||
BUSAN, IDKEY_PREFIX + BUSAN,
|
||||
DAEGU, IDKEY_PREFIX + DAEGU,
|
||||
DAEJEON, IDKEY_PREFIX + DAEJEON,
|
||||
GWANGJU, IDKEY_PREFIX + GWANGJU
|
||||
);
|
||||
|
||||
public static final Map<String, CsiDataDto> DATA_2025 = Map.of(
|
||||
TOTAL, CsiDataDto.of(2025,4.47, 4.46, null, 4.43, 4.63),
|
||||
SEOUL, CsiDataDto.of(2025,4.39, 4.36, null, 4.37, 4.63),
|
||||
GYEONGGI, CsiDataDto.of(2025,4.48, 4.46, null, 4.44, 4.65),
|
||||
BUSAN, CsiDataDto.of(2025,4.43, 4.41, null, 4.39, 4.62),
|
||||
DAEGU, CsiDataDto.of(2025,4.56, 4.55, null, 4.54, 4.66),
|
||||
DAEJEON, CsiDataDto.of(2025,4.47, 4.47, null, 4.40, 4.57),
|
||||
GWANGJU, CsiDataDto.of(2025,4.52, 4.51, null, 4.46, 4.67)
|
||||
);
|
||||
|
||||
private KfpaDashConstant() {}
|
||||
}
|
||||
28
src/main/java/com/kri/kfpa/dash/config/DataSourceConfig.java
Normal file
28
src/main/java/com/kri/kfpa/dash/config/DataSourceConfig.java
Normal file
@@ -0,0 +1,28 @@
|
||||
package com.kri.kfpa.dash.config;
|
||||
|
||||
import com.zaxxer.hikari.HikariDataSource;
|
||||
import javax.sql.DataSource;
|
||||
import org.springframework.boot.autoconfigure.jdbc.DataSourceProperties;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Primary;
|
||||
|
||||
@Configuration
|
||||
public class DataSourceConfig {
|
||||
|
||||
@Bean
|
||||
@Primary
|
||||
@ConfigurationProperties(prefix = "spring.datasource")
|
||||
public DataSourceProperties mainDataSourceProperties() {
|
||||
return new DataSourceProperties();
|
||||
}
|
||||
|
||||
@Bean(name = "mainDataSource")
|
||||
@Primary
|
||||
public DataSource mainDataSource(DataSourceProperties mainDataSourceProperties) {
|
||||
return mainDataSourceProperties.initializeDataSourceBuilder()
|
||||
.type(HikariDataSource.class)
|
||||
.build();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.kri.kfpa.dash.controller;
|
||||
|
||||
import com.kri.kfpa.dash.dto.RequestWriteDivCommentDto;
|
||||
import com.kri.kfpa.dash.service.AdminService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.Valid;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.PatchMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/v1/admin")
|
||||
@RequiredArgsConstructor
|
||||
@Tag(name = "admin", description = "관리자 API")
|
||||
public class AdminController {
|
||||
|
||||
private final AdminService adminService;
|
||||
|
||||
@Operation(summary = "지역 본부 코멘트 작성")
|
||||
@PatchMapping("/div-comment")
|
||||
public boolean updateDivComment(
|
||||
@Valid @RequestBody RequestWriteDivCommentDto request
|
||||
){
|
||||
return adminService.updateDivComment(request);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.kri.kfpa.dash.controller;
|
||||
|
||||
import com.kri.common.feature.datetime.DateTimeUtil;
|
||||
import com.kri.common.feature.web.RequestUserContext;
|
||||
import com.kri.kfpa.dash.dto.LoginRequestDto;
|
||||
import com.kri.kfpa.dash.dto.LoginResponseDto;
|
||||
import com.kri.kfpa.dash.service.AuthService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.Valid;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/v1/auth")
|
||||
@RequiredArgsConstructor
|
||||
@Tag(name = "Auth", description = "인증 API")
|
||||
public class AuthController {
|
||||
|
||||
private final AuthService authService;
|
||||
|
||||
@Operation(summary = "로그인 요청")
|
||||
@PostMapping("/login")
|
||||
public LoginResponseDto tryLogin(
|
||||
@Valid @RequestBody LoginRequestDto request
|
||||
) {
|
||||
return authService.tryLogin(request);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.kri.kfpa.dash.controller;
|
||||
|
||||
import com.kri.kfpa.dash.dto.CsiDataDto;
|
||||
import com.kri.kfpa.dash.dto.DivDetailDataDto;
|
||||
import com.kri.kfpa.dash.service.StatisticsService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
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("/api/v1/statistics")
|
||||
@RequiredArgsConstructor
|
||||
@Tag(name = "Statistics", description = "통계치 조회 API")
|
||||
public class StatisticsController {
|
||||
|
||||
private final StatisticsService statisticsService;
|
||||
|
||||
@Operation(summary = "csi 데이터 조회")
|
||||
@GetMapping("/csi")
|
||||
public Map<String, List<CsiDataDto>> getCsiData() {
|
||||
return statisticsService.getCsiData();
|
||||
}
|
||||
|
||||
@Operation(summary = "지역 본부 상세 조회")
|
||||
@GetMapping("/div-detail/{div}")
|
||||
public Map<String, DivDetailDataDto> getDivDetailData(
|
||||
@PathVariable String div
|
||||
) {
|
||||
return statisticsService.getDivDetailData(div);
|
||||
}
|
||||
|
||||
}
|
||||
29
src/main/java/com/kri/kfpa/dash/dto/CommentValueDto.java
Normal file
29
src/main/java/com/kri/kfpa/dash/dto/CommentValueDto.java
Normal file
@@ -0,0 +1,29 @@
|
||||
package com.kri.kfpa.dash.dto;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@Schema(description = "세부 항목 별 코멘트")
|
||||
public class CommentValueDto {
|
||||
|
||||
@NotNull
|
||||
@Schema(description = "고객 직접 체감")
|
||||
private String directExperience;
|
||||
|
||||
@NotNull
|
||||
@Schema(description = "고객 간접 체감")
|
||||
private String indirectExperience;
|
||||
|
||||
@NotNull
|
||||
@Schema(description = "내부역량 강화 등")
|
||||
private String capability;
|
||||
|
||||
}
|
||||
57
src/main/java/com/kri/kfpa/dash/dto/CsiDataDto.java
Normal file
57
src/main/java/com/kri/kfpa/dash/dto/CsiDataDto.java
Normal file
@@ -0,0 +1,57 @@
|
||||
package com.kri.kfpa.dash.dto;
|
||||
|
||||
import com.kri.kfpa.dash.entity.CsiDataEntity;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import java.math.BigDecimal;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@Schema(description = "CSI 계산결과 Dto")
|
||||
public class CsiDataDto {
|
||||
|
||||
@Schema(description = "연도")
|
||||
private Integer wave;
|
||||
|
||||
@Schema(description = "CSI 점수")
|
||||
private Double csi;
|
||||
|
||||
@Schema(description = "현장 안전점검 도움 정도")
|
||||
private Double safeHelp;
|
||||
|
||||
@Schema(description = "위험개선권고사항 도움 정도")
|
||||
private Double recHelp;
|
||||
|
||||
@Schema(description = "점검직원 전문성")
|
||||
private Double staffProf;
|
||||
|
||||
@Schema(description = "점검직원 태도")
|
||||
private Double staffAtt;
|
||||
|
||||
public static CsiDataDto of(Integer wave, Double csi, Double safeHelp, Double recHelp, Double staffProf, Double staffAtt) {
|
||||
return CsiDataDto.builder()
|
||||
.wave(wave)
|
||||
.csi(csi)
|
||||
.safeHelp(safeHelp)
|
||||
.recHelp(recHelp)
|
||||
.staffProf(staffProf)
|
||||
.staffAtt(staffAtt)
|
||||
.build();
|
||||
}
|
||||
|
||||
public static CsiDataDto from(Integer wave,CsiDataEntity entity) {
|
||||
return CsiDataDto.builder()
|
||||
.wave(wave)
|
||||
.csi(entity.getCsi())
|
||||
.safeHelp(entity.getSafeHelp())
|
||||
.recHelp(entity.getRecHelp())
|
||||
.staffProf(entity.getStaffProf())
|
||||
.staffAtt(entity.getStaffAtt())
|
||||
.build();
|
||||
}
|
||||
}
|
||||
27
src/main/java/com/kri/kfpa/dash/dto/CsiRankDto.java
Normal file
27
src/main/java/com/kri/kfpa/dash/dto/CsiRankDto.java
Normal file
@@ -0,0 +1,27 @@
|
||||
package com.kri.kfpa.dash.dto;
|
||||
|
||||
import com.kri.kfpa.dash.entity.ObjectTypeCsiRankEntity;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@Schema(description = "물건 별 순위 Dto")
|
||||
public class CsiRankDto {
|
||||
|
||||
private Double csi;
|
||||
|
||||
private Integer divRank;
|
||||
|
||||
public static CsiRankDto from(ObjectTypeCsiRankEntity entity) {
|
||||
return CsiRankDto.builder()
|
||||
.csi(entity.getCsi())
|
||||
.divRank(entity.getDivRank())
|
||||
.build();
|
||||
}
|
||||
}
|
||||
32
src/main/java/com/kri/kfpa/dash/dto/DivDetailDataDto.java
Normal file
32
src/main/java/com/kri/kfpa/dash/dto/DivDetailDataDto.java
Normal file
@@ -0,0 +1,32 @@
|
||||
package com.kri.kfpa.dash.dto;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import java.util.Map;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@Schema(description = "지역 본부 별 상세")
|
||||
public class DivDetailDataDto {
|
||||
|
||||
@NotNull
|
||||
@Schema(description = "물건별 csi 점수 및 순위")
|
||||
private Map<String, CsiRankDto> csiRanks;
|
||||
|
||||
@NotNull
|
||||
@Schema(description = "항목별 코멘트")
|
||||
Map<String, CommentValueDto> commentValues;
|
||||
|
||||
public static DivDetailDataDto of(Map<String, CsiRankDto> csiRanks, Map<String, CommentValueDto> commentValues) {
|
||||
return DivDetailDataDto.builder()
|
||||
.csiRanks(csiRanks)
|
||||
.commentValues(commentValues)
|
||||
.build();
|
||||
}
|
||||
}
|
||||
17
src/main/java/com/kri/kfpa/dash/dto/LoginRequestDto.java
Normal file
17
src/main/java/com/kri/kfpa/dash/dto/LoginRequestDto.java
Normal file
@@ -0,0 +1,17 @@
|
||||
package com.kri.kfpa.dash.dto;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Schema(description = "사용자 로그인 요청")
|
||||
public class LoginRequestDto {
|
||||
|
||||
@Schema(description = "사용자 ID")
|
||||
private String userId;
|
||||
|
||||
@Schema(description = "사용자 PW")
|
||||
private String userPw;
|
||||
}
|
||||
26
src/main/java/com/kri/kfpa/dash/dto/LoginResponseDto.java
Normal file
26
src/main/java/com/kri/kfpa/dash/dto/LoginResponseDto.java
Normal file
@@ -0,0 +1,26 @@
|
||||
package com.kri.kfpa.dash.dto;
|
||||
|
||||
|
||||
import com.kri.common.feature.auth.dto.JwtUserClaimsDto;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
@Builder
|
||||
@Schema(description = "로그인 응답")
|
||||
public class LoginResponseDto {
|
||||
|
||||
@Schema(description = "jwt access 토큰")
|
||||
private String accessToken;
|
||||
|
||||
@Schema(description = "사용자 정보")
|
||||
private JwtUserClaimsDto user;
|
||||
|
||||
public static LoginResponseDto from(String accessToken, JwtUserClaimsDto jwtUserClaims) {
|
||||
return LoginResponseDto.builder()
|
||||
.accessToken(accessToken)
|
||||
.user(jwtUserClaims)
|
||||
.build();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.kri.kfpa.dash.dto;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import java.util.Map;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@Schema(description = "관리자 코멘트 입력")
|
||||
public class RequestWriteDivCommentDto {
|
||||
|
||||
@NotNull
|
||||
@Schema(description = "본부 ID")
|
||||
Integer divId;
|
||||
|
||||
@NotNull
|
||||
@Schema(description = "항목별 코멘트")
|
||||
Map<String, CommentValueDto> commentValues;
|
||||
|
||||
}
|
||||
21
src/main/java/com/kri/kfpa/dash/entity/CsiDataEntity.java
Normal file
21
src/main/java/com/kri/kfpa/dash/entity/CsiDataEntity.java
Normal file
@@ -0,0 +1,21 @@
|
||||
package com.kri.kfpa.dash.entity;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class CsiDataEntity {
|
||||
|
||||
private String div;
|
||||
|
||||
private Double csi;
|
||||
|
||||
private Double safeHelp;
|
||||
|
||||
private Double recHelp;
|
||||
|
||||
private Double staffProf;
|
||||
|
||||
private Double staffAtt;
|
||||
}
|
||||
54
src/main/java/com/kri/kfpa/dash/entity/DivCommentEntity.java
Normal file
54
src/main/java/com/kri/kfpa/dash/entity/DivCommentEntity.java
Normal file
@@ -0,0 +1,54 @@
|
||||
package com.kri.kfpa.dash.entity;
|
||||
|
||||
import com.kri.kfpa.dash.dto.CommentValueDto;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class DivCommentEntity {
|
||||
|
||||
private String performance25DirectExperience;
|
||||
|
||||
private String performance25IndirectExperience;
|
||||
|
||||
private String performance25Capability;
|
||||
|
||||
private String plan26DirectExperience;
|
||||
|
||||
private String plan26IndirectExperience;
|
||||
|
||||
private String plan26Capability;
|
||||
|
||||
private String performance26DirectExperience;
|
||||
|
||||
private String performance26IndirectExperience;
|
||||
|
||||
private String performance26Capability;
|
||||
|
||||
public static DivCommentEntity empty() {
|
||||
return new DivCommentEntity();
|
||||
}
|
||||
|
||||
public Map<String, CommentValueDto> getCommentValues() {
|
||||
Map<String, CommentValueDto> commentValues = new LinkedHashMap<>();
|
||||
commentValues.put("performance25", CommentValueDto.builder()
|
||||
.directExperience(performance25DirectExperience)
|
||||
.indirectExperience(performance25IndirectExperience)
|
||||
.capability(performance25Capability)
|
||||
.build());
|
||||
commentValues.put("plan26", CommentValueDto.builder()
|
||||
.directExperience(plan26DirectExperience)
|
||||
.indirectExperience(plan26IndirectExperience)
|
||||
.capability(plan26Capability)
|
||||
.build());
|
||||
commentValues.put("performance26", CommentValueDto.builder()
|
||||
.directExperience(performance26DirectExperience)
|
||||
.indirectExperience(performance26IndirectExperience)
|
||||
.capability(performance26Capability)
|
||||
.build());
|
||||
return commentValues;
|
||||
}
|
||||
}
|
||||
19
src/main/java/com/kri/kfpa/dash/entity/KonUserEntity.java
Normal file
19
src/main/java/com/kri/kfpa/dash/entity/KonUserEntity.java
Normal file
@@ -0,0 +1,19 @@
|
||||
package com.kri.kfpa.dash.entity;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class KonUserEntity {
|
||||
|
||||
private String pUserMail;
|
||||
|
||||
private String pName;
|
||||
|
||||
private String pCompany;
|
||||
|
||||
private String pTeam;
|
||||
|
||||
private Integer pRole;
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.kri.kfpa.dash.entity;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class ObjectTypeCsiRankEntity {
|
||||
|
||||
private String div;
|
||||
|
||||
private String objectType;
|
||||
|
||||
private Double csi;
|
||||
|
||||
private Integer divRank;
|
||||
}
|
||||
32
src/main/java/com/kri/kfpa/dash/mapper/DataMapper.java
Normal file
32
src/main/java/com/kri/kfpa/dash/mapper/DataMapper.java
Normal file
@@ -0,0 +1,32 @@
|
||||
package com.kri.kfpa.dash.mapper;
|
||||
|
||||
import com.kri.kfpa.dash.dto.CommentValueDto;
|
||||
import com.kri.kfpa.dash.entity.CsiDataEntity;
|
||||
import com.kri.kfpa.dash.entity.DivCommentEntity;
|
||||
import com.kri.kfpa.dash.entity.ObjectTypeCsiRankEntity;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
@Mapper
|
||||
public interface DataMapper {
|
||||
|
||||
List<CsiDataEntity> selectDivCsiData(@Param("pkey") String pkey);
|
||||
|
||||
List<ObjectTypeCsiRankEntity> selectDivObjectTypeCsiRank(
|
||||
@Param("pkey") String pkey,
|
||||
@Param("div") String div
|
||||
);
|
||||
|
||||
DivCommentEntity selectDivComment(
|
||||
@Param("pkey") String pkey,
|
||||
@Param("idkey") String idkey
|
||||
);
|
||||
|
||||
boolean updateDivComment(
|
||||
@Param("pkey") String pkey,
|
||||
@Param("idkey") String idkey,
|
||||
@Param("commentValues") Map<String, CommentValueDto> commentValues
|
||||
);
|
||||
}
|
||||
15
src/main/java/com/kri/kfpa/dash/mapper/KonUserMapper.java
Normal file
15
src/main/java/com/kri/kfpa/dash/mapper/KonUserMapper.java
Normal file
@@ -0,0 +1,15 @@
|
||||
package com.kri.kfpa.dash.mapper;
|
||||
|
||||
import com.kri.kfpa.dash.entity.KonUserEntity;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
@Mapper
|
||||
public interface KonUserMapper {
|
||||
|
||||
KonUserEntity selectKonUser(
|
||||
@Param("pAccessPkey") String pAccessPkey,
|
||||
@Param("pUserMail") String pUserMail,
|
||||
@Param("pPassNew") String pPassNew
|
||||
);
|
||||
}
|
||||
53
src/main/java/com/kri/kfpa/dash/service/AdminService.java
Normal file
53
src/main/java/com/kri/kfpa/dash/service/AdminService.java
Normal file
@@ -0,0 +1,53 @@
|
||||
package com.kri.kfpa.dash.service;
|
||||
|
||||
import static com.kri.kfpa.dash.common.consts.KfpaDashConstant.IDKEY_MAP;
|
||||
import static com.kri.kfpa.dash.common.consts.KfpaDashConstant.KFPA_COMMENT_PKEY;
|
||||
|
||||
import com.kri.common.feature.web.BusinessException;
|
||||
import com.kri.kfpa.dash.dto.CommentValueDto;
|
||||
import com.kri.kfpa.dash.dto.RequestWriteDivCommentDto;
|
||||
import com.kri.kfpa.dash.mapper.DataMapper;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class AdminService {
|
||||
|
||||
private static final List<String> REQUIRED_COMMENT_KEYS = List.of(
|
||||
"performance25",
|
||||
"plan26",
|
||||
"performance26"
|
||||
);
|
||||
|
||||
private final DataMapper dataMapper;
|
||||
|
||||
public boolean updateDivComment(RequestWriteDivCommentDto request) {
|
||||
String idkey = IDKEY_MAP.get(request.getDivId().toString());
|
||||
if (idkey == null) {
|
||||
throw BusinessException.badRequest("INVALID_DIV_ID", "지역본부 ID가 잘못됐습니다.");
|
||||
}
|
||||
|
||||
validateCommentValues(request.getCommentValues());
|
||||
|
||||
return dataMapper.updateDivComment(KFPA_COMMENT_PKEY, idkey, request.getCommentValues());
|
||||
}
|
||||
|
||||
private void validateCommentValues(Map<String, CommentValueDto> commentValues) {
|
||||
if (commentValues == null) {
|
||||
throw BusinessException.badRequest("INVALID_COMMENT_VALUES", "commentValues는 필수입니다.");
|
||||
}
|
||||
|
||||
for (String requiredKey : REQUIRED_COMMENT_KEYS) {
|
||||
if (commentValues.get(requiredKey) == null) {
|
||||
throw BusinessException.badRequest(
|
||||
"MISSING_COMMENT_VALUE",
|
||||
"필수 코멘트 항목이 누락됐습니다."
|
||||
)
|
||||
.with("requiredKey", requiredKey);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
41
src/main/java/com/kri/kfpa/dash/service/AuthService.java
Normal file
41
src/main/java/com/kri/kfpa/dash/service/AuthService.java
Normal file
@@ -0,0 +1,41 @@
|
||||
package com.kri.kfpa.dash.service;
|
||||
|
||||
import static com.kri.kfpa.dash.common.consts.KfpaDashConstant.KFPA_DASH_PKEY;
|
||||
|
||||
import com.kri.common.feature.auth.dto.JwtUserClaimsDto;
|
||||
import com.kri.common.feature.auth.jwt.JwtService;
|
||||
import com.kri.common.feature.web.BusinessException;
|
||||
import com.kri.kfpa.dash.dto.LoginRequestDto;
|
||||
import com.kri.kfpa.dash.dto.LoginResponseDto;
|
||||
import com.kri.kfpa.dash.entity.KonUserEntity;
|
||||
import com.kri.kfpa.dash.mapper.KonUserMapper;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class AuthService {
|
||||
private final JwtService jwtService;
|
||||
private final KonUserMapper konUserMapper;
|
||||
|
||||
public LoginResponseDto tryLogin(LoginRequestDto request) {
|
||||
KonUserEntity konUserEntity = konUserMapper.selectKonUser(KFPA_DASH_PKEY, request.getUserId(), request.getUserPw());
|
||||
|
||||
if(konUserEntity == null){
|
||||
throw BusinessException
|
||||
.notFound("NOT_FOUND_USER","사용자가 없습니다.")
|
||||
.with("userId", request.getUserId());
|
||||
}
|
||||
|
||||
JwtUserClaimsDto claims = JwtUserClaimsDto.builder()
|
||||
.userId(konUserEntity.getPUserMail())
|
||||
.userCmpn(konUserEntity.getPCompany())
|
||||
.userName(konUserEntity.getPName())
|
||||
.userTeam(konUserEntity.getPTeam())
|
||||
.userRole(konUserEntity.getPRole())
|
||||
.build();
|
||||
|
||||
String accessToken = jwtService.generateAccessToken(claims);
|
||||
return LoginResponseDto.from(accessToken, claims);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
package com.kri.kfpa.dash.service;
|
||||
|
||||
import static com.kri.kfpa.dash.common.consts.KfpaDashConstant.DATA_2025;
|
||||
import static com.kri.kfpa.dash.common.consts.KfpaDashConstant.IDKEY_MAP;
|
||||
import static com.kri.kfpa.dash.common.consts.KfpaDashConstant.KFPA_COMMENT_PKEY;
|
||||
import static com.kri.kfpa.dash.common.consts.KfpaDashConstant.KFPA_DASH_PKEY;
|
||||
|
||||
import com.kri.common.feature.web.BusinessException;
|
||||
import com.kri.kfpa.dash.dto.CsiDataDto;
|
||||
import com.kri.kfpa.dash.dto.CsiRankDto;
|
||||
import com.kri.kfpa.dash.dto.DivDetailDataDto;
|
||||
import com.kri.kfpa.dash.entity.CsiDataEntity;
|
||||
import com.kri.kfpa.dash.entity.DivCommentEntity;
|
||||
import com.kri.kfpa.dash.entity.ObjectTypeCsiRankEntity;
|
||||
import com.kri.kfpa.dash.mapper.DataMapper;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class StatisticsService {
|
||||
|
||||
private final DataMapper dataMapper;
|
||||
|
||||
public Map<String, List<CsiDataDto>> getCsiData() {
|
||||
List<CsiDataEntity> csiDataList = dataMapper.selectDivCsiData(KFPA_DASH_PKEY);
|
||||
|
||||
Map<String, CsiDataDto> csiData = csiDataList.stream()
|
||||
.collect(Collectors.toMap(
|
||||
CsiDataEntity::getDiv,
|
||||
entity -> CsiDataDto.from(2026, entity)
|
||||
));
|
||||
|
||||
Map<String, List<CsiDataDto>> mergedCsiData = new LinkedHashMap<>();
|
||||
DATA_2025.forEach((div, data) -> mergedCsiData.put(div, new ArrayList<>(List.of(data))));
|
||||
csiData.forEach((div, data) -> mergedCsiData
|
||||
.computeIfAbsent(div, key -> new ArrayList<>())
|
||||
.add(data));
|
||||
|
||||
return mergedCsiData;
|
||||
}
|
||||
|
||||
public Map<String, DivDetailDataDto> getDivDetailData(String div) {
|
||||
String idkey = IDKEY_MAP.get(div);
|
||||
if (idkey == null) {
|
||||
throw BusinessException.badRequest(
|
||||
"INVALID_DIVISION",
|
||||
"유효하지 않은 지역 본부입니다."
|
||||
).with("div", div);
|
||||
}
|
||||
|
||||
List<ObjectTypeCsiRankEntity> objectTypeCsiRankList =
|
||||
dataMapper.selectDivObjectTypeCsiRank(KFPA_DASH_PKEY, div);
|
||||
|
||||
Map<String, DivDetailDataDto> divDetailData = new LinkedHashMap<>();
|
||||
Map<String, DivCommentEntity> divCommentCache = new LinkedHashMap<>();
|
||||
|
||||
for (ObjectTypeCsiRankEntity entity : objectTypeCsiRankList) {
|
||||
DivCommentEntity divCommentEntity = divCommentCache.computeIfAbsent(
|
||||
div,
|
||||
key -> {
|
||||
DivCommentEntity selectedComment = dataMapper.selectDivComment(KFPA_COMMENT_PKEY, idkey);
|
||||
return selectedComment == null ? DivCommentEntity.empty() : selectedComment;
|
||||
}
|
||||
);
|
||||
|
||||
DivDetailDataDto detailData = divDetailData.computeIfAbsent(
|
||||
div,
|
||||
key -> DivDetailDataDto.of(new LinkedHashMap<>(), divCommentEntity.getCommentValues())
|
||||
);
|
||||
detailData.getCsiRanks().put(entity.getObjectType(), CsiRankDto.from(entity));
|
||||
}
|
||||
|
||||
return divDetailData;
|
||||
}
|
||||
}
|
||||
53
src/main/resources/application.yaml
Normal file
53
src/main/resources/application.yaml
Normal file
@@ -0,0 +1,53 @@
|
||||
server:
|
||||
port: 6103
|
||||
forward-headers-strategy: framework
|
||||
|
||||
spring:
|
||||
application:
|
||||
name: kfpa-cx-dash-back
|
||||
datasource:
|
||||
driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver
|
||||
url: jdbc:sqlserver://1.235.195.8:20022;databaseName=KON;encrypt=false
|
||||
username: kon
|
||||
password: kon#51304
|
||||
|
||||
logging:
|
||||
file:
|
||||
path: ./logs
|
||||
|
||||
mybatis:
|
||||
mapper-locations: classpath:/mybatis/mapper/*.xml
|
||||
type-aliases-package: com.kri.kfpa.dash.entity
|
||||
configuration:
|
||||
map-underscore-to-camel-case: true
|
||||
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
|
||||
|
||||
kri:
|
||||
auth:
|
||||
header-name: "X-API-Key" # API Key 헤더
|
||||
|
||||
security:
|
||||
enabled: true
|
||||
public-paths: # 인증 없이 열어둘 URL
|
||||
- /v3/api-docs/**
|
||||
- /swagger-ui.html
|
||||
- /swagger-ui/**
|
||||
- /ping
|
||||
- /api/v1/statistics/**
|
||||
- /api/v1/auth/login
|
||||
|
||||
swagger:
|
||||
enabled: true
|
||||
title: "KFPA CSI Dashboard API"
|
||||
description: "화재보험협회 고객 관점 성과 측정·평가 체계 API"
|
||||
version: "v1.0.0"
|
||||
base-package: "com.kri.kfpa.dash"
|
||||
allowed-ips:
|
||||
- 211.254.145.130
|
||||
|
||||
web:
|
||||
enabled: true # 공통 Web 구성 사용 여부 (기본 true)
|
||||
redis:
|
||||
enabled: false # RedisQueueHelper 사용 시 true
|
||||
scheduling:
|
||||
enabled: false # @Scheduled 사용 시 true
|
||||
155
src/main/resources/mybatis/mapper/DataMapper.xml
Normal file
155
src/main/resources/mybatis/mapper/DataMapper.xml
Normal file
@@ -0,0 +1,155 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "https://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
|
||||
<mapper namespace="com.kri.kfpa.dash.mapper.DataMapper">
|
||||
<resultMap id="DivCsiDataResultMap" type="com.kri.kfpa.dash.entity.CsiDataEntity">
|
||||
<result property="div" column="div"/>
|
||||
<result property="csi" column="csi"/>
|
||||
<result property="safeHelp" column="safe_help"/>
|
||||
<result property="recHelp" column="rec_help"/>
|
||||
<result property="staffProf" column="staff_prof"/>
|
||||
<result property="staffAtt" column="staff_att"/>
|
||||
</resultMap>
|
||||
|
||||
<resultMap id="DivObjectTypeCsiRankResultMap" type="com.kri.kfpa.dash.entity.ObjectTypeCsiRankEntity">
|
||||
<result property="div" column="div"/>
|
||||
<result property="objectType" column="object_type"/>
|
||||
<result property="csi" column="csi"/>
|
||||
<result property="divRank" column="div_rank"/>
|
||||
</resultMap>
|
||||
|
||||
<resultMap id="DivCommentResultMap" type="com.kri.kfpa.dash.entity.DivCommentEntity">
|
||||
<result property="performance25DirectExperience" column="performance25_direct_experience"/>
|
||||
<result property="performance25IndirectExperience" column="performance25_indirect_experience"/>
|
||||
<result property="performance25Capability" column="performance25_capability"/>
|
||||
<result property="plan26DirectExperience" column="plan26_direct_experience"/>
|
||||
<result property="plan26IndirectExperience" column="plan26_indirect_experience"/>
|
||||
<result property="plan26Capability" column="plan26_capability"/>
|
||||
<result property="performance26DirectExperience" column="performance26_direct_experience"/>
|
||||
<result property="performance26IndirectExperience" column="performance26_indirect_experience"/>
|
||||
<result property="performance26Capability" column="performance26_capability"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="BaseDataSelect">
|
||||
SELECT
|
||||
IDKEY
|
||||
, TRY_CAST(JSON_VALUE(DATJSON, '$.Q1.Q1') AS DECIMAL(18, 4)) AS q1
|
||||
, TRY_CAST(JSON_VALUE(DATJSON, '$.Q2.Q2') AS DECIMAL(18, 4)) AS q2
|
||||
, TRY_CAST(JSON_VALUE(DATJSON, '$.Q7.Q7') AS DECIMAL(18, 4)) AS q4
|
||||
, TRY_CAST(JSON_VALUE(DATJSON, '$.Q10.Q10') AS DECIMAL(18, 4)) AS q5
|
||||
, CASE
|
||||
WHEN JSON_VALUE(DATJSON, '$.Q16.Q14') IS NOT NULL
|
||||
THEN JSON_VALUE(DATJSON, '$.Q16.Q14')
|
||||
ELSE JSON_VALUE(DATJSON, '$.Q14.Q14')
|
||||
END AS object_type_raw
|
||||
, CASE
|
||||
WHEN JSON_VALUE(DATJSON, '$.Q16.Q15') IS NOT NULL
|
||||
THEN JSON_VALUE(DATJSON, '$.Q16.Q15')
|
||||
ELSE JSON_VALUE(DATJSON, '$.Q15.Q15')
|
||||
END AS div
|
||||
FROM Kon.dbo.DATA
|
||||
WHERE SURVEY_TYPE != 'TEST'
|
||||
AND Status = 10
|
||||
AND PKEY = #{pkey}
|
||||
</sql>
|
||||
|
||||
<select id="selectDivCsiData" resultMap="DivCsiDataResultMap">
|
||||
WITH Base AS (
|
||||
<include refid="BaseDataSelect"/>
|
||||
)
|
||||
SELECT
|
||||
div
|
||||
, AVG(q1 * 0.4 + q2 * 0.4 + q4 * 0.1 + q5 * 0.1) AS csi
|
||||
, AVG(q1) AS safe_help
|
||||
, AVG(q2) AS rec_help
|
||||
, AVG(q4) AS staff_prof
|
||||
, AVG(q5) AS staff_att
|
||||
FROM Base
|
||||
WHERE object_type_raw IS NOT NULL
|
||||
AND div IS NOT NULL
|
||||
AND object_type_raw != '99'
|
||||
AND div != '99'
|
||||
GROUP BY div
|
||||
ORDER BY div
|
||||
</select>
|
||||
|
||||
<select id="selectDivObjectTypeCsiRank" resultMap="DivObjectTypeCsiRankResultMap">
|
||||
WITH Base AS (
|
||||
<include refid="BaseDataSelect"/>
|
||||
),
|
||||
Recode AS (
|
||||
SELECT
|
||||
IDKEY
|
||||
, q1
|
||||
, q2
|
||||
, q4
|
||||
, q5
|
||||
, div
|
||||
, CASE
|
||||
WHEN object_type_raw IN ('4', '12') THEN object_type_raw
|
||||
ELSE '90'
|
||||
END AS object_type
|
||||
FROM Base
|
||||
),
|
||||
CsiAgg AS (
|
||||
SELECT
|
||||
div
|
||||
, object_type
|
||||
, AVG(q1 * 0.4 + q2 * 0.4 + q4 * 0.1 + q5 * 0.1) AS csi
|
||||
FROM Recode
|
||||
WHERE div IS NOT NULL
|
||||
AND div = #{div}
|
||||
GROUP BY div, object_type
|
||||
)
|
||||
SELECT
|
||||
div
|
||||
, object_type
|
||||
, CSI
|
||||
, DENSE_RANK() OVER (
|
||||
PARTITION BY object_type
|
||||
ORDER BY CSI DESC
|
||||
) AS div_rank
|
||||
FROM CsiAgg
|
||||
ORDER BY div, object_type, div_rank
|
||||
</select>
|
||||
|
||||
<select id="selectDivComment" resultMap="DivCommentResultMap">
|
||||
SELECT
|
||||
ISNULL(JSON_VALUE(DATJSON, '$.Q1.Q1_1_1'), '') AS performance25_direct_experience
|
||||
, ISNULL(JSON_VALUE(DATJSON, '$.Q1.Q1_2_1'), '') AS performance25_indirect_experience
|
||||
, ISNULL(JSON_VALUE(DATJSON, '$.Q1.Q1_3_1'), '') AS performance25_capability
|
||||
, ISNULL(JSON_VALUE(DATJSON, '$.Q1.Q1_1_2'), '') AS plan26_direct_experience
|
||||
, ISNULL(JSON_VALUE(DATJSON, '$.Q1.Q1_2_2'), '') AS plan26_indirect_experience
|
||||
, ISNULL(JSON_VALUE(DATJSON, '$.Q1.Q1_3_2'), '') AS plan26_capability
|
||||
, ISNULL(JSON_VALUE(DATJSON, '$.Q1.Q1_1_3'), '') AS performance26_direct_experience
|
||||
, ISNULL(JSON_VALUE(DATJSON, '$.Q1.Q1_2_3'), '') AS performance26_indirect_experience
|
||||
, ISNULL(JSON_VALUE(DATJSON, '$.Q1.Q1_3_3'), '') AS performance26_capability
|
||||
FROM Kon.dbo.DATA
|
||||
WHERE PKEY = #{pkey}
|
||||
AND IDKEY = #{idkey}
|
||||
</select>
|
||||
|
||||
<update id="updateDivComment">
|
||||
UPDATE A
|
||||
SET DATJSON = JSON_MODIFY(
|
||||
DATJSON,
|
||||
'$.Q1',
|
||||
JSON_QUERY((
|
||||
SELECT
|
||||
#{commentValues.performance25.directExperience} AS [Q1_1_1]
|
||||
, #{commentValues.performance25.indirectExperience} AS [Q1_2_1]
|
||||
, #{commentValues.performance25.capability} AS [Q1_3_1]
|
||||
, #{commentValues.plan26.directExperience} AS [Q1_1_2]
|
||||
, #{commentValues.plan26.indirectExperience} AS [Q1_2_2]
|
||||
, #{commentValues.plan26.capability} AS [Q1_3_2]
|
||||
, #{commentValues.performance26.directExperience} AS [Q1_1_3]
|
||||
, #{commentValues.performance26.indirectExperience} AS [Q1_2_3]
|
||||
, #{commentValues.performance26.capability} AS [Q1_3_3]
|
||||
FOR JSON PATH, WITHOUT_ARRAY_WRAPPER
|
||||
))
|
||||
)
|
||||
FROM Kon.dbo.DATA A
|
||||
WHERE PKEY = #{pkey}
|
||||
AND IDKEY = #{idkey}
|
||||
</update>
|
||||
</mapper>
|
||||
26
src/main/resources/mybatis/mapper/KonUserMapper.xml
Normal file
26
src/main/resources/mybatis/mapper/KonUserMapper.xml
Normal file
@@ -0,0 +1,26 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "https://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
|
||||
<mapper namespace="com.kri.kfpa.dash.mapper.KonUserMapper">
|
||||
<resultMap id="KonUserResultMap" type="com.kri.kfpa.dash.entity.KonUserEntity">
|
||||
<result property="pUserMail" column="p_user_mail"/>
|
||||
<result property="pName" column="p_name"/>
|
||||
<result property="pCompany" column="p_company"/>
|
||||
<result property="pTeam" column="p_team"/>
|
||||
<result property="pRole" column="p_role"/>
|
||||
</resultMap>
|
||||
|
||||
<select id="selectKonUser" resultMap="KonUserResultMap">
|
||||
SELECT
|
||||
p_user_mail,
|
||||
p_name,
|
||||
p_company,
|
||||
p_team,
|
||||
p_role
|
||||
FROM Kon.dbo.KON_USER
|
||||
WHERE is_delete = '0'
|
||||
AND p_access_pkey LIKE CONCAT('%', #{pAccessPkey}, '%')
|
||||
AND p_user_mail = #{pUserMail}
|
||||
AND p_pass_new = #{pPassNew}
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.kri.kfpa.dash;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
@SpringBootTest
|
||||
class KfpaCxDashBackApplicationTests {
|
||||
|
||||
@Test
|
||||
void contextLoads() {
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user