Merge branch 'main' into yoon
This commit is contained in:
commit
56edd2bc41
@ -172,14 +172,14 @@ public class BoardController {
|
|||||||
@Member
|
@Member
|
||||||
@ParameterCheck
|
@ParameterCheck
|
||||||
@GetMapping("/{boardId}/comments")
|
@GetMapping("/{boardId}/comments")
|
||||||
public ApiResponse<List<MapDto>> getComments(@ReqMap MapDto map) {
|
public ApiResponse<PageInfo<MapDto>> getComments(@ReqMap MapDto map) {
|
||||||
return ApiResponse.ok(boardService.getComments(map));
|
return ApiResponse.ok(boardService.getComments(map));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 댓글/대댓글 작성
|
* 댓글/대댓글 작성
|
||||||
* @param boardId 게시물 ID
|
* @param boardId 게시물 ID
|
||||||
* @ReqMap map 댓글 데이터 (LOCBRDSEQ, LOCCMTRPY, LOCCMTPNT, LOCCMTPWD, MEMBERSEQ 등)
|
* @ReqMap map 댓글 데이터 (LOCBRDSEQ, LOCCMTRPY, LOCCMTPNT, LOCCMTPWD, MEMBERSEQ )
|
||||||
* @return 작성 결과 메시지
|
* @return 작성 결과 메시지
|
||||||
*/
|
*/
|
||||||
@Member
|
@Member
|
||||||
|
|||||||
@ -1,5 +1,8 @@
|
|||||||
package io.company.localhost.controller.api;
|
package io.company.localhost.controller.api;
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.time.temporal.ChronoUnit;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
@ -8,11 +11,14 @@ import org.springframework.web.bind.annotation.RequestBody;
|
|||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import io.company.localhost.common.annotation.Member;
|
||||||
|
import io.company.localhost.common.annotation.ParameterCheck;
|
||||||
import io.company.localhost.common.annotation.ReqMap;
|
import io.company.localhost.common.annotation.ReqMap;
|
||||||
import io.company.localhost.common.dto.ApiResponse;
|
import io.company.localhost.common.dto.ApiResponse;
|
||||||
import io.company.localhost.common.dto.MapDto;
|
import io.company.localhost.common.dto.MapDto;
|
||||||
import io.company.localhost.service.commoncodService;
|
import io.company.localhost.service.commoncodService;
|
||||||
import io.company.localhost.service.localvacaService; // 서비스 클래스 경로 수정
|
import io.company.localhost.service.localvacaService; // 서비스 클래스 경로 수정
|
||||||
|
import io.company.localhost.utils.AuthUtil;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
@ -24,19 +30,20 @@ public class VacationController {
|
|||||||
|
|
||||||
private final localvacaService localVacaService;
|
private final localvacaService localVacaService;
|
||||||
|
|
||||||
|
@Member
|
||||||
|
@ParameterCheck
|
||||||
@PostMapping
|
@PostMapping
|
||||||
public ApiResponse<String> saveVacations(@RequestBody List<MapDto> map) {
|
public ApiResponse<?> saveVacations(@RequestBody List<MapDto> map) {
|
||||||
|
Long user = AuthUtil.getUser().getId();
|
||||||
for (MapDto request : map) {
|
for (MapDto request : map) {
|
||||||
// 각 요청 데이터의 필수 값 검증
|
|
||||||
Integer employeeId = (Integer) request.get("employeeId");
|
|
||||||
String date = request.getString("date");
|
String date = request.getString("date");
|
||||||
String type = request.getString("type");
|
String type = request.getString("type");
|
||||||
|
Object receiverId = request.get("receiverId");
|
||||||
|
|
||||||
if (employeeId == null || date == null || type == null) {
|
if ( date == null || type == null) {
|
||||||
throw new IllegalArgumentException("요청 데이터에 누락된 값이 있습니다: " + request);
|
throw new IllegalArgumentException("요청 데이터에 누락된 값이 있습니다: " + request);
|
||||||
}
|
}
|
||||||
|
request.put("employeeId", user);
|
||||||
// 데이터 저장
|
// 데이터 저장
|
||||||
localVacaService.insertVacation(request);
|
localVacaService.insertVacation(request);
|
||||||
}
|
}
|
||||||
@ -44,10 +51,11 @@ public class VacationController {
|
|||||||
return ApiResponse.ok("모든 휴가가 성공적으로 저장되었습니다.");
|
return ApiResponse.ok("모든 휴가가 성공적으로 저장되었습니다.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 특정 연월에 대한 휴가 데이터 조회
|
* 특정 연월에 대한 휴가 데이터 조회
|
||||||
*/
|
*/
|
||||||
|
@Member
|
||||||
|
@ParameterCheck
|
||||||
@GetMapping("/list/{year}/{month}")
|
@GetMapping("/list/{year}/{month}")
|
||||||
public List<MapDto> getVacations(@PathVariable("year") int year, @PathVariable("month") int month) {
|
public List<MapDto> getVacations(@PathVariable("year") int year, @PathVariable("month") int month) {
|
||||||
return localVacaService.getVacationList(year, month);
|
return localVacaService.getVacationList(year, month);
|
||||||
@ -56,9 +64,44 @@ public class VacationController {
|
|||||||
/**
|
/**
|
||||||
* 특정 연월에 대한 공휴일 데이터 조회
|
* 특정 연월에 대한 공휴일 데이터 조회
|
||||||
*/
|
*/
|
||||||
|
@Member
|
||||||
|
@ParameterCheck
|
||||||
@GetMapping("/{year}/{month}")
|
@GetMapping("/{year}/{month}")
|
||||||
public List<MapDto> getHolidays(@PathVariable("year") int year, @PathVariable("month") int month) {
|
public List<MapDto> getHolidays(@PathVariable("year") int year, @PathVariable("month") int month) {
|
||||||
return localVacaService.getHolidays(year, month);
|
return localVacaService.getHolidays(year, month);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 내 연차 사용 내역 조회
|
||||||
|
*/
|
||||||
|
@Member
|
||||||
|
@ParameterCheck
|
||||||
|
@GetMapping("/history")
|
||||||
|
public ApiResponse<Map<String, List<MapDto>>> getUserVacationHistory() {
|
||||||
|
Long userId = AuthUtil.getUser().getId();
|
||||||
|
return ApiResponse.ok(localVacaService.getUserVacationHistory(userId));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@GetMapping("/remaining")
|
||||||
|
public ApiResponse<List<MapDto>> getRemainingVacation() {
|
||||||
|
List<MapDto> employeeVacations = localVacaService.getEmployeeRemainingVacation();
|
||||||
|
return ApiResponse.ok(employeeVacations);
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/codes")
|
||||||
|
public ApiResponse<List<MapDto>> getVacationCodeNames() {
|
||||||
|
return ApiResponse.ok(localVacaService.getCommonCodeList());
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/sent")
|
||||||
|
public ApiResponse<List<MapDto>> getSentVacations(@ReqMap MapDto map) {
|
||||||
|
Long userId = AuthUtil.getUser().getId(); // 현재 로그인한 사용자 ID
|
||||||
|
map.put("userId", userId);
|
||||||
|
List<MapDto> sentCount = localVacaService.getSentVacationCount(map);
|
||||||
|
|
||||||
|
|
||||||
|
return ApiResponse.ok(sentCount);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -13,6 +13,16 @@ public interface localvacaMapper {
|
|||||||
void insertVacation(MapDto map);
|
void insertVacation(MapDto map);
|
||||||
|
|
||||||
List<MapDto> findVacations(@Param("year") int year, @Param("month") int month);
|
List<MapDto> findVacations(@Param("year") int year, @Param("month") int month);
|
||||||
|
|
||||||
|
List<MapDto> getUsedVacations(@Param("userId") Long userId);
|
||||||
|
|
||||||
|
List<MapDto> getReceivedVacations(@Param("userId") Long userId);
|
||||||
|
|
||||||
|
List<MapDto> getEmployeeRemainingVacation();
|
||||||
|
|
||||||
|
List<MapDto> getCommonCodeNames();
|
||||||
|
|
||||||
|
List<MapDto> countSentVacations(MapDto map);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -110,8 +110,14 @@ public class localbordService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<MapDto> getComments(MapDto map) {
|
public PageInfo<MapDto> getComments(MapDto map) {
|
||||||
return boardMapper.getComments(map);
|
int page = map.getString("page") != null ? Integer.parseInt(map.getString("page")) : 1;
|
||||||
|
int size = map.getString("size") != null ? Integer.parseInt(map.getString("size")) : 10;
|
||||||
|
PageHelper.startPage(page, size);
|
||||||
|
|
||||||
|
List<MapDto> result = boardMapper.getComments(map);
|
||||||
|
|
||||||
|
return PageUtil.redefineNavigation(new PageInfo<>(result, size));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addCommentOrReply(MapDto map) {
|
public void addCommentOrReply(MapDto map) {
|
||||||
|
|||||||
@ -2,14 +2,23 @@ package io.company.localhost.service;
|
|||||||
|
|
||||||
import java.net.URLDecoder;
|
import java.net.URLDecoder;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
|
import java.time.temporal.ChronoUnit;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.http.HttpEntity;
|
import org.springframework.http.HttpEntity;
|
||||||
import org.springframework.http.HttpHeaders;
|
import org.springframework.http.HttpHeaders;
|
||||||
import org.springframework.http.HttpMethod;
|
import org.springframework.http.HttpMethod;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.scheduling.annotation.Scheduled;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.web.client.RestTemplate;
|
import org.springframework.web.client.RestTemplate;
|
||||||
import io.company.localhost.common.dto.MapDto;
|
import io.company.localhost.common.dto.MapDto;
|
||||||
@ -140,4 +149,97 @@ public class localvacaService {
|
|||||||
dto.put("name", item.get("dateName"));
|
dto.put("name", item.get("dateName"));
|
||||||
return dto;
|
return dto;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 내 연차 사용 내역 조회 (사용한 연차 & 받은 연차)
|
||||||
|
*/
|
||||||
|
public Map<String, List<MapDto>> getUserVacationHistory(Long userId) {
|
||||||
|
List<MapDto> usedVacations = localvacaMapper.getUsedVacations(userId);
|
||||||
|
List<MapDto> receivedVacations = localvacaMapper.getReceivedVacations(userId);
|
||||||
|
|
||||||
|
Map<String, List<MapDto>> history = new HashMap<>();
|
||||||
|
history.put("usedVacations", usedVacations);
|
||||||
|
history.put("receivedVacations", receivedVacations);
|
||||||
|
|
||||||
|
return history;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 사원별 남은 연차 개수 조회
|
||||||
|
*/
|
||||||
|
public List<MapDto> getEmployeeRemainingVacation() {
|
||||||
|
List<MapDto> employeeVacations = localvacaMapper.getEmployeeRemainingVacation();
|
||||||
|
|
||||||
|
return employeeVacations.stream().map(emp -> {
|
||||||
|
// 🔹 hireDate 변환 (포맷 정규화)
|
||||||
|
String hireDateString = emp.get("hireDate").toString().split("\\.")[0]; // .0 제거
|
||||||
|
LocalDate hireDate;
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (hireDateString.contains("T")) {
|
||||||
|
hireDate = LocalDateTime.parse(hireDateString, DateTimeFormatter.ISO_LOCAL_DATE_TIME).toLocalDate();
|
||||||
|
} else {
|
||||||
|
hireDate = LocalDate.parse(hireDateString, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException("🚨 입사일 변환 오류: " + hireDateString, e);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 🔹 총 연차 개수 계산
|
||||||
|
int totalVacation = calculateTotalVacation(hireDate);
|
||||||
|
|
||||||
|
// 🔹 사용한 연차 개수 처리 (null 방지)
|
||||||
|
double usedVacation = emp.get("used_quota") != null ? ((Number) emp.get("used_quota")).doubleValue() : 0.0;
|
||||||
|
|
||||||
|
// 🔹 받은 연차 개수 처리 (null 방지)
|
||||||
|
double receivedVacation = emp.get("received_quota") != null ? ((Number) emp.get("received_quota")).doubleValue() : 0.0;
|
||||||
|
|
||||||
|
// 🔹 남은 연차 개수 계산 (반차 포함)
|
||||||
|
double remainingVacation = totalVacation - usedVacation + receivedVacation;
|
||||||
|
|
||||||
|
// 🔹 값 업데이트
|
||||||
|
emp.put("totalQuota", totalVacation);
|
||||||
|
emp.put("remainingQuota", remainingVacation);
|
||||||
|
emp.put("usedQuota", usedVacation);
|
||||||
|
emp.put("receivedQuota", receivedVacation);
|
||||||
|
|
||||||
|
return emp;
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 총 연차 계산 로직
|
||||||
|
*/
|
||||||
|
private int calculateTotalVacation(LocalDate hireDate) {
|
||||||
|
LocalDate today = LocalDate.now();
|
||||||
|
int yearsWorked = hireDate.until(today).getYears();
|
||||||
|
|
||||||
|
// 🔹 1년 미만: 연간 12개 지급
|
||||||
|
if (yearsWorked < 1) {
|
||||||
|
return 12;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 🔹 1년 이상 기본 15개
|
||||||
|
int totalVacation = 15;
|
||||||
|
LocalDate nextIncreaseDate = hireDate.plusYears(2).withMonth(1).withDayOfMonth(1);
|
||||||
|
|
||||||
|
// 🔹 2년마다 1개 추가
|
||||||
|
while (nextIncreaseDate.isBefore(today) || nextIncreaseDate.isEqual(today)) {
|
||||||
|
totalVacation += 1;
|
||||||
|
nextIncreaseDate = nextIncreaseDate.plusYears(2);
|
||||||
|
}
|
||||||
|
|
||||||
|
return totalVacation;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<MapDto> getCommonCodeList() {
|
||||||
|
List<MapDto> codeList = localvacaMapper.getCommonCodeNames();
|
||||||
|
|
||||||
|
// 데이터가 비어있으면 빈 리스트 반환 (null 방지)
|
||||||
|
return (codeList != null) ? codeList : new ArrayList<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<MapDto> getSentVacationCount(MapDto map) {
|
||||||
|
return localvacaMapper.countSentVacations(map);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -135,9 +135,11 @@
|
|||||||
<!-- 댓글/대댓글 조회 -->
|
<!-- 댓글/대댓글 조회 -->
|
||||||
<select id="getComments" resultType="io.company.localhost.common.dto.MapDto">
|
<select id="getComments" resultType="io.company.localhost.common.dto.MapDto">
|
||||||
SELECT
|
SELECT
|
||||||
LOCCMTSEQ,LOCBRDSEQ,LOCCMTPNT,LOCCMTRPY,
|
c.LOCCMTSEQ,c.LOCBRDSEQ,c.LOCCMTPNT,c.LOCCMTRPY,
|
||||||
LOCCMTUDT,LOCCMTPWD,LOCCMTRDT,LOCCMTPNT
|
c.LOCCMTUDT,c.LOCCMTPWD,c.LOCCMTRDT,c.LOCCMTPNT,
|
||||||
FROM localcomt
|
m.MEMBERNAM AS author
|
||||||
|
FROM localcomt c
|
||||||
|
LEFT JOIN netmember m ON c.MEMBERSEQ = m.MEMBERSEQ
|
||||||
WHERE LOCBRDSEQ = #{LOCBRDSEQ}
|
WHERE LOCBRDSEQ = #{LOCBRDSEQ}
|
||||||
ORDER BY LOCCMTPNT ASC, LOCCMTUDT ASC
|
ORDER BY LOCCMTPNT ASC, LOCCMTUDT ASC
|
||||||
</select>
|
</select>
|
||||||
|
|||||||
@ -4,8 +4,8 @@
|
|||||||
|
|
||||||
<!-- 휴가 저장 -->
|
<!-- 휴가 저장 -->
|
||||||
<insert id="insertVacation" parameterType="io.company.localhost.common.dto.MapDto">
|
<insert id="insertVacation" parameterType="io.company.localhost.common.dto.MapDto">
|
||||||
INSERT INTO localvaca (MEMBERSEQ, LOCVACUDT, LOCVACTYP, LOCVACRDT)
|
INSERT INTO localvaca (MEMBERSEQ, LOCVACUDT, LOCVACTYP, LOCVACRDT, LOCVACRMM)
|
||||||
VALUES (#{employeeId}, #{date}, #{type}, NOW())
|
VALUES (#{employeeId}, #{date}, #{type}, NOW(), #{receiverId})
|
||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
<!-- 휴가 정보 조회 -->
|
<!-- 휴가 정보 조회 -->
|
||||||
@ -15,4 +15,103 @@
|
|||||||
WHERE DATE_FORMAT(LOCVACUDT, '%Y-%m') = CONCAT(#{year}, '-', LPAD(#{month}, 2, '0'))
|
WHERE DATE_FORMAT(LOCVACUDT, '%Y-%m') = CONCAT(#{year}, '-', LPAD(#{month}, 2, '0'))
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<!-- 사용자가 사용한 연차 목록 조회 -->
|
||||||
|
<select id="getUsedVacations" resultType="io.company.localhost.common.dto.MapDto">
|
||||||
|
SELECT LOCVACUDT AS date, LOCVACTYP AS type, COUNT(*) AS count, LOCVACRMM AS receiverId,
|
||||||
|
-- 반차(700101, 700102)는 0.5, 연차(700103)는 1로 계산
|
||||||
|
SUM(CASE
|
||||||
|
WHEN LOCVACTYP IN ('700101', '700102') THEN 0.5
|
||||||
|
WHEN LOCVACTYP = '700103' THEN 1
|
||||||
|
ELSE 0
|
||||||
|
END) AS used_quota
|
||||||
|
FROM localvaca
|
||||||
|
WHERE MEMBERSEQ = #{userId}
|
||||||
|
GROUP BY LOCVACUDT, LOCVACTYP, LOCVACRMM
|
||||||
|
ORDER BY LOCVACUDT DESC
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<!-- 사용자가 받은 연차 목록 조회 -->
|
||||||
|
<select id="getReceivedVacations" resultType="io.company.localhost.common.dto.MapDto">
|
||||||
|
SELECT LOCVACUDT AS date, LOCVACTYP AS type, COUNT(*) AS count, MEMBERSEQ AS senderId
|
||||||
|
FROM localvaca
|
||||||
|
WHERE LOCVACRMM = #{userId}
|
||||||
|
GROUP BY LOCVACUDT, LOCVACTYP, MEMBERSEQ
|
||||||
|
ORDER BY LOCVACUDT DESC
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<!-- 전체 직원 남은 연차 조회 -->
|
||||||
|
<select id="getEmployeeRemainingVacation" resultType="io.company.localhost.common.dto.MapDto">
|
||||||
|
<![CDATA[
|
||||||
|
SELECT
|
||||||
|
nm.MEMBERSEQ AS employeeId,
|
||||||
|
nm.MEMBERNAM AS employeeName,
|
||||||
|
nm.MEMBERCDT AS hireDate,
|
||||||
|
|
||||||
|
-- 📌 총 연차 계산 (1년 미만: 12개, 이후 기본 15개 + 2년마다 1개 추가)
|
||||||
|
CASE
|
||||||
|
WHEN TIMESTAMPDIFF(MONTH, nm.MEMBERCDT, CURDATE()) < 12
|
||||||
|
THEN 12
|
||||||
|
ELSE
|
||||||
|
15 + FLOOR(TIMESTAMPDIFF(YEAR, nm.MEMBERCDT, CURDATE()) / 2)
|
||||||
|
END AS total_quota,
|
||||||
|
|
||||||
|
-- 📌 사용한 연차 개수 (반차 0.5, 연차 1)
|
||||||
|
COALESCE(lv.used_quota, 0) AS used_quota,
|
||||||
|
|
||||||
|
-- 📌 받은 연차 개수 (반차 0.5, 연차 1)
|
||||||
|
COALESCE(rv.received_quota, 0) AS received_quota,
|
||||||
|
|
||||||
|
-- 📌 남은 연차 계산 (총 연차 - 사용 연차 + 받은 연차)
|
||||||
|
(
|
||||||
|
CASE
|
||||||
|
WHEN TIMESTAMPDIFF(MONTH, nm.MEMBERCDT, CURDATE()) < 12
|
||||||
|
THEN 12
|
||||||
|
ELSE
|
||||||
|
15 + FLOOR(TIMESTAMPDIFF(YEAR, nm.MEMBERCDT, CURDATE()) / 2)
|
||||||
|
END
|
||||||
|
) - COALESCE(lv.used_quota, 0) + COALESCE(rv.received_quota, 0) AS remaining_quota
|
||||||
|
|
||||||
|
FROM netmember nm
|
||||||
|
|
||||||
|
-- 📌 사용한 연차 개수 가져오기 (반차는 0.5, 연차는 1로 변환)
|
||||||
|
LEFT JOIN (
|
||||||
|
SELECT MEMBERSEQ,
|
||||||
|
SUM(CASE
|
||||||
|
WHEN LOCVACTYP IN ('700101', '700102') THEN 0.5
|
||||||
|
WHEN LOCVACTYP = '700103' THEN 1
|
||||||
|
ELSE 0
|
||||||
|
END) AS used_quota
|
||||||
|
FROM localvaca
|
||||||
|
GROUP BY MEMBERSEQ
|
||||||
|
) lv ON nm.MEMBERSEQ = lv.MEMBERSEQ
|
||||||
|
|
||||||
|
-- 📌 받은 연차 개수 가져오기 (반차는 0.5, 연차는 1로 변환)
|
||||||
|
LEFT JOIN (
|
||||||
|
SELECT LOCVACRMM AS MEMBERSEQ,
|
||||||
|
SUM(CASE
|
||||||
|
WHEN LOCVACTYP IN ('700101', '700102') THEN 0.5
|
||||||
|
WHEN LOCVACTYP = '700103' THEN 1
|
||||||
|
ELSE 0
|
||||||
|
END) AS received_quota
|
||||||
|
FROM localvaca
|
||||||
|
WHERE LOCVACRMM IS NOT NULL
|
||||||
|
GROUP BY LOCVACRMM
|
||||||
|
) rv ON nm.MEMBERSEQ = rv.MEMBERSEQ
|
||||||
|
|
||||||
|
WHERE nm.MEMBERDEL = 'N' -- 퇴사자 제외
|
||||||
|
]]>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<!-- 공통 코드 목록 조회 -->
|
||||||
|
<select id="getCommonCodeNames" resultType="io.company.localhost.common.dto.MapDto">
|
||||||
|
SELECT CMNCODVAL AS code, CMNCODNAM AS name
|
||||||
|
FROM commoncod
|
||||||
|
WHERE CMNCODVAL IN ('700101', '700102', '700103')
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="countSentVacations" resultType="io.company.localhost.common.dto.MapDto">
|
||||||
|
SELECT COUNT(*) as count FROM localvaca WHERE MEMBERSEQ = #{userId} AND LOCVACRMM = #{receiverId} AND YEAR(LOCVACRDT) = YEAR(NOW())
|
||||||
|
</select>
|
||||||
|
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
Loading…
Reference in New Issue
Block a user