251118_01_ENH : 인트라넷 확장 초기 세팅 및 프로젝트, 사용자 조회 구현

This commit is contained in:
2025-11-18 10:18:26 +09:00
commit b2e978c776
31 changed files with 951 additions and 0 deletions

View File

@@ -0,0 +1,13 @@
package com.kri.intranet.extension;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class IntranetExtensionApplication {
public static void main(String[] args) {
SpringApplication.run(IntranetExtensionApplication.class, args);
}
}

View File

@@ -0,0 +1,37 @@
package com.kri.intranet.extension.controller;
import com.kri.common.auth.jwt.JwtService;
import com.kri.common.auth.jwt.JwtUserClaimsDto;
import com.kri.intranet.extension.dto.jwt.InternalJwtDto;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
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;
@Tag(name = "InternalJWT", description = "시간 제한 없는 내부 사용용 JWT 생성")
@RestController
@RequestMapping("/api/v1/internal/jwt")
@RequiredArgsConstructor
public class InternalJwtController {
private final JwtService jwtService;
@Operation(
summary = "내부 서비스용 JWT",
description = "시간 제한 없는 내부 사용용 JWT 생성"
)
@PostMapping("generate")
public String generateInternalJwt(@RequestBody InternalJwtDto internalJwtDto) {
JwtUserClaimsDto internalClaims = JwtUserClaimsDto.builder()
.userId(internalJwtDto.getServiceId())
.userTeam("SYSTEM")
.userName(internalJwtDto.getServiceName())
.role(999) // 예: 내부 시스템용 권한코드
.build();
return jwtService.generateAccessToken(internalClaims);
}
}

View File

@@ -0,0 +1,31 @@
package com.kri.intranet.extension.controller;
import com.kri.intranet.extension.dto.project.request.GetProjectTop10RequestDto;
import com.kri.intranet.extension.dto.project.response.GetProjectTop10ResponseDto;
import com.kri.intranet.extension.service.ProjectService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@RestController
@RequestMapping("/api/v1/project")
@RequiredArgsConstructor
@Tag(name = "Project", description = "프로젝트 조회 API")
public class ProjectController {
private final ProjectService projectService;
@Operation(
summary = "상위 10개 프로젝트 조회",
description = "p_child_sn, p_subject, p_intention 조건으로 최신 10건 프로젝트를 조회합니다."
)
@PostMapping("search/top10")
public List<GetProjectTop10ResponseDto> getProjectTop10(
@RequestBody GetProjectTop10RequestDto getProjectTop10RequestDto
) {
return projectService.getProjectTop10(getProjectTop10RequestDto);
}
}

View File

@@ -0,0 +1,33 @@
package com.kri.intranet.extension.controller;
import com.kri.intranet.extension.dto.user.request.GetUserWithIdPwRequestDto;
import com.kri.intranet.extension.dto.user.response.GetUserWithIdPwResponseDto;
import com.kri.intranet.extension.service.UserService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
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/user")
@RequiredArgsConstructor
@Tag(name = "User", description = "사용자 조회 API")
public class UserController {
private final UserService userService;
@Operation(
summary = "사용자 정보 조회",
description = "ID/PW로 사용자 정보 조회"
)
@PostMapping("search/login-info")
public GetUserWithIdPwResponseDto getUserWithIdPw(
@RequestBody GetUserWithIdPwRequestDto getUserWithIdPwRequestDto
) {
return userService.getUserWithIdPw(getUserWithIdPwRequestDto);
}
}

View File

@@ -0,0 +1,16 @@
package com.kri.intranet.extension.dto.jwt;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
@Builder
@Getter
@Setter
@AllArgsConstructor
public class InternalJwtDto {
@Schema(description = "서비스 ID ex) INTRANET_EXTENSION")
private String serviceId;
@Schema(description = "서비스명 ex) Intranet Extension Service")
private String serviceName;
}

View File

@@ -0,0 +1,17 @@
package com.kri.intranet.extension.dto.project.request;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
@Schema(description = "프로젝트 검색 조건 DTO")
public class GetProjectTop10RequestDto {
@Schema(description = "프로젝트 자식 일련번호 (p_child_sn LIKE 검색)")
private String childSn; // p_child_sn용 파라미터
@Schema(description = "제목/의도 통합 키워드 (p_subject / p_intention 공용)")
private String keyword; // p_subject + p_intention 공용 파라미터
}

View File

@@ -0,0 +1,33 @@
package com.kri.intranet.extension.dto.project.response;
import com.kri.intranet.extension.entity.project.ProjectBasicInfoEntity;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Builder;
import lombok.Getter;
@Getter
@Builder
@Schema(description = "프로젝트 조회 결과 DTO")
public class GetProjectTop10ResponseDto {
@Schema(description = "프로젝트 자코드 (p_child_sn)")
private final String childSn;
@Schema(description = "프로젝트 제목 (p_subject 또는 p_subject <p_intention>)")
private final String title;
@Schema(description = "연구팀 코드 (p_rsch_team)")
private final String researchTeam;
@Schema(description = "연구팀 명 (p_rsch_team_name)")
private final String researchTeamName;
public static GetProjectTop10ResponseDto from(ProjectBasicInfoEntity e){
return GetProjectTop10ResponseDto.builder()
.childSn(e.getPChildSn())
.title(e.getPTitle())
.researchTeam(e.getPRschTeam())
.researchTeamName(e.getPRschTeamName())
.build();
}
}

View File

@@ -0,0 +1,17 @@
package com.kri.intranet.extension.dto.user.request;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
@Schema(description = "사용자 ID/PW 검색 요청 DTO")
public class GetUserWithIdPwRequestDto {
@Schema(description = "사용자 ID")
private String userId;
@Schema(description = "사용자 PW")
private String userPw;
}

View File

@@ -0,0 +1,33 @@
package com.kri.intranet.extension.dto.user.response;
import com.kri.intranet.extension.entity.user.UserBasicInfoEntity;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Builder;
import lombok.Getter;
@Getter
@Builder
@Schema(description = "사용자 ID/PW 검색 응답 DTO")
public class GetUserWithIdPwResponseDto {
@Schema(description = "사용자 ID (p_user_mail)")
private final String userId;
@Schema(description = "사용자 이름 (p_name)")
private final String userNm;
@Schema(description = "사용자 팀 (p_depart_now + p_team_now)")
private final String userTeam;
@Schema(description = "사용자 역할")
private final int userRole;
public static GetUserWithIdPwResponseDto from(UserBasicInfoEntity e) {
return GetUserWithIdPwResponseDto.builder()
.userId(e.getUserId())
.userNm(e.getUserName())
.userTeam(e.getUserTeam())
.userRole(e.getUserRole())
.build();
}
}

View File

@@ -0,0 +1,14 @@
package com.kri.intranet.extension.entity.project;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
public class ProjectBasicInfoEntity {
private String pChildSn; // p_child_sn
private String pTitle; // p_title (subject + <intention>)
private String pRschTeam; // p_rsch_team
private String pRschTeamName; // p_rsch_team_name
}

View File

@@ -0,0 +1,14 @@
package com.kri.intranet.extension.entity.user;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
public class UserBasicInfoEntity {
private String userId;
private String userName;
private String userTeam;
private int userRole;
}

View File

@@ -0,0 +1,16 @@
package com.kri.intranet.extension.mapper;
import com.kri.intranet.extension.entity.project.ProjectBasicInfoEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@Mapper
public interface ProjectMapper {
List<ProjectBasicInfoEntity> selectProjectTop10(
@Param("childSn") String childSn,
@Param("keyword") String keyword
);
}

View File

@@ -0,0 +1,16 @@
package com.kri.intranet.extension.mapper;
import com.kri.intranet.extension.entity.user.UserBasicInfoEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@Mapper
public interface UserMapper {
List<UserBasicInfoEntity> selectUserWithIdPw(
@Param("userId") String userId,
@Param("userPw") String userPw
);
}

View File

@@ -0,0 +1,28 @@
package com.kri.intranet.extension.service;
import com.kri.intranet.extension.dto.project.request.GetProjectTop10RequestDto;
import com.kri.intranet.extension.dto.project.response.GetProjectTop10ResponseDto;
import com.kri.intranet.extension.entity.project.ProjectBasicInfoEntity;
import com.kri.intranet.extension.mapper.ProjectMapper;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
@RequiredArgsConstructor
public class ProjectService {
private final ProjectMapper projectMapper;
public List<GetProjectTop10ResponseDto> getProjectTop10(GetProjectTop10RequestDto getProjectTop10RequestDto){
String childSn = getProjectTop10RequestDto.getChildSn();
String keyword = getProjectTop10RequestDto.getKeyword();
List<ProjectBasicInfoEntity> entityList = projectMapper.selectProjectTop10(childSn,keyword);
return entityList.stream()
.map(GetProjectTop10ResponseDto::from)
.toList();
}
}

View File

@@ -0,0 +1,34 @@
package com.kri.intranet.extension.service;
import com.kri.common.web.BusinessException;
import com.kri.intranet.extension.dto.user.request.GetUserWithIdPwRequestDto;
import com.kri.intranet.extension.dto.user.response.GetUserWithIdPwResponseDto;
import com.kri.intranet.extension.entity.user.UserBasicInfoEntity;
import com.kri.intranet.extension.mapper.UserMapper;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
@RequiredArgsConstructor
public class UserService {
private final UserMapper userMapper;
public GetUserWithIdPwResponseDto getUserWithIdPw(GetUserWithIdPwRequestDto getUserWithIdPwRequestDto) {
String userId = getUserWithIdPwRequestDto.getUserId();
String userPw = getUserWithIdPwRequestDto.getUserPw();
List<UserBasicInfoEntity> userBasicInfoEntityList = userMapper.selectUserWithIdPw(userId,userPw);
if(userBasicInfoEntityList.isEmpty()){
throw BusinessException.notFound("USER_NOT_FOUND", "사용자가 없습니다.")
.with("userId", userId)
.with("userPw", userPw);
}
UserBasicInfoEntity entity = userBasicInfoEntityList.get(0);
return GetUserWithIdPwResponseDto.from(entity);
}
}

View File

@@ -0,0 +1 @@
spring.application.name=IntranetExtension

View File

@@ -0,0 +1,33 @@
<?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.intranet.extension.mapper.ProjectMapper">
<select id="selectProjectTop10" resultType="com.kri.intranet.extension.entity.project.ProjectBasicInfoEntity">
SELECT TOP(10)
p_child_sn AS pChildSn
, CASE WHEN p_intention IS NOT NULL
THEN p_subject + ' <![CDATA[<' + p_intention + '>]]>'
ELSE p_subject
END AS pTitle
, d.Code AS pRschTeam
, d.T_Name AS pRschTeamName
FROM project2.dbo.V_PROJECT_METHOD pm WITH (NOLOCK)
LEFT JOIN project2.dbo.v_Department d
ON pm.p_rsch_dept = d.before_t_cd1
OR pm.p_rsch_dept = d.T_CODE
WHERE 1 = 1
<!-- p_child_sn LIKE 검색 (파라미터1) -->
<if test="childSn != null and childSn != ''">
AND p_child_sn LIKE '%' + #{childSn} + '%'
</if>
<!-- p_subject / p_intention 공용 키워드 (파라미터2) -->
<if test="keyword != null and keyword != ''">
AND (
p_subject LIKE '%' + #{keyword} + '%'
OR p_intention LIKE '%' + #{keyword} + '%'
)
</if>
ORDER BY p_input_dt DESC
</select>
</mapper>

View File

@@ -0,0 +1,22 @@
<?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.intranet.extension.mapper.UserMapper">
<select id="selectUserWithIdPw" resultType="com.kri.intranet.extension.entity.user.UserBasicInfoEntity">
SELECT
p_user_mail AS [user_id]
, p_name as [user_name]
, p_depart_now+p_team_now AS user_team
, CASE p_depart_now
WHEN 'R' THEN 2001
WHEN 'S' THEN
CASE WHEN p_team_now <![CDATA[<]]> 300 THEN 3001 ELSE 1001 END
ELSE 1001 END AS [user_role]
FROM project2.dbo.person
WHERE krc_in_date IS NOT NULL and krc_out_date = ''
AND (p_user_mail = #{userId} or p_user_mail = #{userId} + '@kric.com')
AND p_pass_new = #{userPw}
ORDER BY p_no
</select>
</mapper>

View File

@@ -0,0 +1,13 @@
package com.kri.intranet.extension;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest
class IntranetExtensionApplicationTests {
@Test
void contextLoads() {
}
}