휴가관리 사원 연차사용정보 추가
This commit is contained in:
parent
87215dba93
commit
ea3ce3b517
@ -179,7 +179,7 @@ public class BoardController {
|
|||||||
/**
|
/**
|
||||||
* 댓글/대댓글 작성
|
* 댓글/대댓글 작성
|
||||||
* @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,6 @@
|
|||||||
package io.company.localhost.controller.api;
|
package io.company.localhost.controller.api;
|
||||||
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 +9,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;
|
||||||
|
|
||||||
@ -23,31 +27,32 @@ import lombok.extern.slf4j.Slf4j;
|
|||||||
public class VacationController {
|
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<String> 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");
|
||||||
|
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
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 +61,21 @@ 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));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -13,6 +13,10 @@ 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -3,6 +3,7 @@ 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.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
@ -140,4 +141,18 @@ 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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -14,5 +14,23 @@
|
|||||||
FROM localvaca
|
FROM localvaca
|
||||||
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
|
||||||
|
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>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
Loading…
Reference in New Issue
Block a user