728x90
list.jsp 에서 선택한 레슨구분, 레슨시간, 상태값 컨트롤러로 넘겨서 다오에서 DB 검색 후 결과 화면에 출력
<sec:authorize access="hasAnyRole('ROLE_MANAGER', 'ROLE_THEAD')">
<div class="row search-bar">
<div class="inputs" >
<sec:authorize access="hasAnyRole('ROLE_MANAGER', 'ROLE_THEAD')">
<select name="searchLessonMasterId" id="searchLessonMasterIdAdmin" class="searchLessonMasterId" onchange="fn_LessonChange()" title="레슨구분">
<option value="" >레슨구분</option>
<c:forEach var="master" items="${lessonMasterList}" varStatus="status">
<option value="${master.lesson_master_id}" <c:if test="${searchVO.searchLessonMasterId eq master.lesson_master_id }">selected</c:if>>${master.lesson_master_nm }</option>
</c:forEach>
</select>
</sec:authorize>
<select name="searchLessonTime" id="searchLessonTime" title="레슨시간" style="margin-right:5px" onchange="fn_search();">
<option value="" <c:if test="${empty searchVO.searchLessonTime}">selected</c:if>>=== 레슨 시간 ===</option>
<c:forEach var="time" items="${lessonInfo.lesson_time_list}" varStatus="status">
<option value="${time }" <c:if test="${searchVO.searchLessonTime eq time}">selected</c:if>>${time }</option>
</c:forEach>
</select>
<select name="searchLessonStatus" id="searchLessonStatus" title="상태값" style="margin-right:5px" onchange="fn_search();">
<option value="">상태값 전체</option>
<option value="R">예약</option>
<option value="E">완료</option>
<option value="C">취소</option>
</select>
<select name="searchManagerId" id="searchManagerId" title="강사" style="margin-right:5px">
<option value="" >강사 전체</option>
<c:forEach var="manager" items="${managerList}" varStatus="status">
<option value="${manager.uniqId }" <c:if test="${searchVO.searchManagerId eq manager.uniqId }">selected</c:if>>${manager.userName }</option>
</c:forEach>
</select>
<input type="button" onclick="fn_set_pageList(1);" value="검색" class="with-input">
</div>
@RequestMapping("/list.do")
public String list(@ModelAttribute("searchVO") LessonReservationVO vo, Model model, HttpServletRequest request) throws Exception {
logger.info("Call /lesson/reservation/list.do");
try {
// 로그인 정보
LoginVO loginVO = getAuthInfo();
if( loginVO != null ) {
logger.debug( "quniqueId={}", loginVO.getUniqId() );
vo.setLoginId(loginVO.getUniqId());
vo.setLoginNm(loginVO.getName());
vo.setGroupCode(loginVO.getGroupCode());
vo.setGroupId(loginVO.getGroupId());
}else {
return "index";
}
//권한 체크
if( !( userCheckRole("ROLE_MANAGER") || userCheckRole("ROLE_SYSTEM") || userCheckRole("ROLE_TEACHER") || userCheckRole("ROLE_THEAD"))) {
return "index";
}
// 강사는 자기아이티로만
if( userCheckRole("ROLE_TEACHER") ) {
vo.setManagerId(vo.getLoginId());
ManagerVO mVO = new ManagerVO();
mVO.setGroupId(vo.getGroupId());
mVO.setManagerId(vo.getManagerId());
List<String> managerLessonMasterIdList = managerService.selectLessonManagerMasterIdList(mVO);
model.addAttribute("managerLessonMasterIdList", managerLessonMasterIdList);
}else {
if(!vo.getSearchManagerId().equals("")) {
vo.setManagerId(vo.getSearchManagerId());
}
// 매니저 리스튼
ManagerVO mVO = new ManagerVO();
mVO.setGroupId(vo.getGroupId());
List managerList = managerService.selectLessonManagerList(mVO);
model.addAttribute("managerList", managerList);
}
// 선택된 레슨 구분에 따른 시간정보 ------------------------------
LessonVO masterVO = new LessonVO();
masterVO.setGroupId(vo.getGroupId());
masterVO.setLessonMasterId(vo.getSearchLessonMasterId());
Map lessonInfo = lessonService.selectLessonMasterInfo(masterVO);
model.addAttribute("lessonInfo", lessonInfo);
// 선택된 레슨 구분에 따른 시간정보 ------------------------------
logger.info("컨트롤러 vo.getSearchLessonStatus()={}",vo.getSearchLessonStatus());
logger.info("컨트롤러 vo.getSearchLessonMasterId()={}",vo.getSearchLessonMasterId());
logger.info("컨트롤러 vo.getSearchLessonTime()={}"+vo.getSearchLessonTime());
// 레슨 일정 목록
Map<String, Object> resultMap = lessonReservationService.selectList(vo);
model.addAttribute("resultList", resultMap.get("resultList"));
model.addAttribute("resultCnt", SF_Utils.convertInteger(resultMap.get("resultCnt")));
model.addAttribute("pagination", resultMap.get("pagination"));
// 레슨 구분 목록
LessonVO lessonVO = new LessonVO();
lessonVO.setGroupId(vo.getGroupId());
List lessonMasterList = lessonService.selectLessonMasterList(lessonVO);
model.addAttribute("lessonMasterList", lessonMasterList);
} catch (Exception e) {
logger.error(e.getMessage(), e);
}
return "manager/lessonManage/reservation/list";
}
public class LessonReservationDAO extends AbstractMongoDAO {
private static Logger logger = LogManager.getLogger(LessonReservationDAO.class);
@Autowired
private MongoTemplate mongoTemplate;
public Map selectList(LessonReservationVO vo) throws Exception{
logger.info("******************************************************");
logger.info("selectClassList !! ");
Map<String, Object> resultMap = new HashMap<>();
List<Map> resultList = new ArrayList();
long resultCnt = 0;
try {
Query query = new Query();
query.addCriteria(Criteria.where("group_id").is(vo.getGroupId()));
if(!vo.getManagerId().equals("")) {
query.addCriteria(Criteria.where("manager_id").is(vo.getManagerId()));
}
if(!vo.getSearchLessonMasterId().equals("")) {
query.addCriteria(Criteria.where("lesson_master_id").is(vo.getSearchLessonMasterId()));
logger.info("1Dao - vo.getSearchLessonMasterId()={}",vo.getSearchLessonMasterId());
}else if(vo.getSearchLessonMasterId().equals("")) {
logger.info("master_id값 없음");
}
if(!vo.getSearchLessonTime().equals("")) {
query.addCriteria(Criteria.where("lesson_time").is(vo.getSearchLessonTime()));
logger.info("1Dao - vo.getSearchLessonTime()={}",vo.getSearchLessonTime());
}else if(vo.getSearchLessonTime().equals("")) {
logger.info("lesson_time값 없음");
}
if(!vo.getSearchLessonStatus().equals("")) {
query.addCriteria(Criteria.where("lesson_status").is(vo.getSearchLessonStatus()));
logger.info("1Dao - vo.getSearchLessonStatus()={}",vo.getSearchLessonStatus());
}
// 개수
resultCnt = mongoTemplate.count(query, Map.class, LESSON_RESERVATION_COLLECTION);
Criteria matchCrit = new Criteria();
matchCrit.and("group_id").is( vo.getGroupId() );
if(!vo.getManagerId().equals("")) {
matchCrit.and("manager_id").is(vo.getManagerId());
}
if(!vo.getSearchLessonMasterId().equals("")) {
matchCrit.and("lesson_master_id").is(vo.getSearchLessonMasterId());
logger.info("1Dao - vo.getSearchLessonMasterId()={}",vo.getSearchLessonMasterId());
}else if(vo.getSearchLessonMasterId().equals("")) {
logger.info("master_id값 없음");
}
if(!vo.getSearchLessonTime().equals("")) {
matchCrit.and("lesson_time").is(vo.getSearchLessonTime());
logger.info("1Dao - vo.getSearchLessonTime()={}",vo.getSearchLessonTime());
}else if(vo.getSearchLessonTime().equals("")) {
logger.info("lesson_time값 없음");
}
if(!vo.getSearchLessonStatus().equals("")) {
matchCrit.and("lesson_status").is(vo.getSearchLessonStatus());
logger.info("Dao - vo.getSearchLessonStatus()={}",vo.getSearchLessonStatus());
}
resultMap.put("resultList", resultList);
resultMap.put("resultCnt", resultCnt);
return resultMap;
}
728x90
'SpringBoot' 카테고리의 다른 글
[JSTL] 날짜사용 (0) | 2023.11.09 |
---|---|
[Spring Boot] select 검색조건유지 jstl (0) | 2023.11.06 |
[Spring Boot] jstl 로 스크립트 줄이기 (0) | 2023.11.03 |
jsp 스크립트 sec:authorize access (0) | 2023.11.02 |
[Spring Boot] jsp - controller - service - dao (0) | 2023.11.01 |