package com.madeu.crm.appointment.service.impl;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.madeu.common.dao.CommonDao;
import com.madeu.common.service.MenuAuthService;
import com.madeu.constants.Constants;
import com.madeu.crm.appointment.service.AppointmentService;

import lombok.extern.slf4j.Slf4j;

@Slf4j
@Service("AppointmentService")
public class AppointmentServiceImpl implements AppointmentService {

	@Autowired
    private CommonDao cmmnDAO;
    
    @Autowired
    private MenuAuthService menuAuthService;


    /**
     * 칭찬불만접수 게시판으로 이동
     *
     *
     * @param paramMap
     * @return
     * @throws Exception
     */
    @Override
    public HashMap<String, Object> moveAppointmentList(HashMap<String, Object> paramMap) throws Exception {
        log.debug("moveFeedbackReceptionList START");

        HashMap<String, Object> map = menuAuthService.getMenuAuthority(paramMap);

        log.debug("loginMemberId       :"+paramMap.get("loginMemberId"));
        log.debug("menuClass           :"+paramMap.get("menuClass"));
        log.debug("moveFeedbackReceptionList END");
        return map;
    }
    
    /**
     * 홈페이지 칭찬불만접수 리스트 조회
     *
     *
     * @param paramMap
     * @return
     * @throws Exception
     */
    @Override
    public HashMap<String, Object> getAppointmentList(HashMap<String, Object> paramMap) throws Exception {

        HashMap<String, Object> map = menuAuthService.getMenuAuthority(paramMap);

        List<Map<String, Object>> listMap = new ArrayList<Map<String,Object>>();
        
        int totalCount = cmmnDAO.selectCount("FeedbackReceptionSql.getFeedbackReceptionCnt", paramMap);

        if(0 < totalCount) {
            listMap = cmmnDAO.selectList("FeedbackReceptionSql.getFeedbackReceptionList", paramMap);
        }

        map.put("msgCode", Constants.OK);
        map.put("success","true");
        map.put("totalCount", totalCount);
        map.put("rows",listMap);

        return map;
    }

    
}
