/*
 * Decompiled with CFR 0.152.
 * 
 * Could not load the following classes:
 *  lombok.Generated
 *  org.slf4j.Logger
 *  org.slf4j.LoggerFactory
 *  org.springframework.beans.factory.annotation.Autowired
 *  org.springframework.beans.factory.annotation.Value
 *  org.springframework.stereotype.Service
 *  org.springframework.transaction.annotation.Propagation
 *  org.springframework.transaction.annotation.Transactional
 *  org.springframework.web.multipart.MultipartFile
 */
package com.madeu.crm.procedureReview.svc;

import com.madeu.common.service.AttachFileService;
import com.madeu.crm.procedureReview.mapper.ProcedureReviewMapper;
import com.madeu.dao.web.webauthmenurelation.WebAuthMenuRelationSqlMapDAO;
import com.madeu.dao.web.webmember.WebMemberSqlMapDAO;
import com.madeu.util.ValidationCheckUtil;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import lombok.Generated;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;

@Service(value="ProcedureReviewService")
public class ProcedureReviewService {
    @Generated
    private static final Logger log = LoggerFactory.getLogger(ProcedureReviewService.class);
    @Autowired
    private ProcedureReviewMapper procedureReviewMapper;
    @Autowired
    private WebMemberSqlMapDAO webMemberSqlMapDAO;
    @Autowired
    private WebAuthMenuRelationSqlMapDAO webAuthMenuRelationSqlMapDAO;
    @Autowired
    private AttachFileService afs;
    @Value(value="${url.cdn}")
    String CDN_URL;

    public HashMap<String, Object> selectProcedureReviewListIntro(HashMap<String, Object> paramMap) throws Exception {
        log.debug("ProcedureReviewService selectProcedureReviewListIntro START");
        HashMap<String, Object> map = new HashMap<String, Object>();
        try {
            boolean check = true;
            String menuClass = String.valueOf(paramMap.get("menuClass"));
            if (!ValidationCheckUtil.emptyCheck(menuClass).booleanValue()) {
                check = false;
                map.put("msgCode", "-1");
                map.put("msgDesc", "\uba54\ub274 \uc815\ubcf4\uac00 \uc5c6\uc2b5\ub2c8\ub2e4.");
            }
            if (check) {
                List<Map<String, Object>> userListMap = this.webMemberSqlMapDAO.checkMember(paramMap);
                int userListMapSize = userListMap.size();
                if (1 == userListMapSize) {
                    paramMap.put("menuClassAuthId", userListMap.get(0).get("muAuthId"));
                } else {
                    check = false;
                    map.put("msgCode", "-1");
                    map.put("msgDesc", "\uc0ac\uc6a9\uc790 \uc815\ubcf4\uac00 \uc62c\ubc14\ub974\uc9c0 \uc54a\uc2b5\ub2c8\ub2e4.");
                }
            }
            if (check) {
                HashMap<String, Object> authCheckParamMap = new HashMap<String, Object>();
                authCheckParamMap.put("menuClass", paramMap.get("menuClass"));
                authCheckParamMap.put("muAuthId", paramMap.get("menuClassAuthId"));
                List<Map<String, Object>> authMenuRelationlistMap = this.webAuthMenuRelationSqlMapDAO.selectAuthMenuRelation(authCheckParamMap);
                int authMenuRelationlistMapSize = authMenuRelationlistMap.size();
                if (1 == authMenuRelationlistMapSize) {
                    map.put("msgCode", "0");
                    map.put("success", "true");
                    map.put("selectUseYn", authMenuRelationlistMap.get(0).get("selectUseYn"));
                    map.put("insertUseYn", authMenuRelationlistMap.get(0).get("insertUseYn"));
                    map.put("updateUseYn", authMenuRelationlistMap.get(0).get("updateUseYn"));
                    map.put("deleteUseYn", authMenuRelationlistMap.get(0).get("deleteUseYn"));
                    map.put("downloadUseYn", authMenuRelationlistMap.get(0).get("downloadUseYn"));
                } else {
                    map.put("msgCode", "-1");
                    map.put("msgDesc", "\uad8c\ud55c \uc815\ubcf4\uac00 \uc5c6\uc2b5\ub2c8\ub2e4.");
                }
            }
        }
        catch (Exception e) {
            e.printStackTrace();
            throw e;
        }
        log.debug("ProcedureReviewService selectProcedureReviewListIntro END");
        return map;
    }

    public HashMap<String, Object> selectListProcedureReview(HashMap<String, Object> hashMap) throws Exception {
        throw new Error("Unresolved compilation problems: \n\tThe method selectTotalProcedureReviewCount(ProcedureReviewDTO) in the type ProcedureReviewMapper is not applicable for the arguments (HashMap<String,Object>)\n\tThe method selectListProcedureReview(ProcedureReviewDTO) in the type ProcedureReviewMapper is not applicable for the arguments (HashMap<String,Object>)\n");
    }

    public HashMap<String, Object> selectProcedureReview(HashMap<String, Object> hashMap) throws Exception {
        throw new Error("Unresolved compilation problem: \n\tThe method selectProcedureReview(ProcedureReviewDTO) in the type ProcedureReviewMapper is not applicable for the arguments (HashMap<String,Object>)\n");
    }

    @Transactional(rollbackFor={Exception.class}, propagation=Propagation.REQUIRES_NEW)
    public HashMap<String, Object> insertProcedureReviewFile(HashMap<String, Object> paramMap, MultipartFile file) throws Exception {
        log.debug("ProcedureReviewService insertProcedureReviewFile START");
        HashMap<String, Object> map = new HashMap<String, Object>();
        try {
            boolean check = true;
            String tId = String.valueOf(System.currentTimeMillis());
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            Calendar c1 = Calendar.getInstance();
            String tDate = sdf.format(c1.getTime());
            if (file == null || file.isEmpty()) {
                check = false;
                map.put("msgCode", "-1");
                map.put("msgDesc", "\uc774\ubbf8\uc9c0 \uc815\ubcf4\uac00 \uc5c6\uc2b5\ub2c8\ub2e4.");
            }
            if (check) {
                List<Map<String, Object>> userListMap = this.webMemberSqlMapDAO.checkMember(paramMap);
                int userListMapSize = userListMap.size();
                if (1 == userListMapSize) {
                    paramMap.put("menuClassAuthId", userListMap.get(0).get("muAuthId"));
                } else {
                    check = false;
                    map.put("msgCode", "-1");
                    map.put("msgDesc", "\uc0ac\uc6a9\uc790 \uc815\ubcf4\uac00 \uc62c\ubc14\ub974\uc9c0 \uc54a\uc2b5\ub2c8\ub2e4.");
                }
            }
            if (check) {
                HashMap<String, Object> authCheckParamMap = new HashMap<String, Object>();
                authCheckParamMap.put("menuClass", paramMap.get("menuClass"));
                authCheckParamMap.put("muAuthId", paramMap.get("menuClassAuthId"));
                List<Map<String, Object>> authMenuRelationlistMap = this.webAuthMenuRelationSqlMapDAO.selectAuthMenuRelation(authCheckParamMap);
                int authMenuRelationlistMapSize = authMenuRelationlistMap.size();
                if (1 == authMenuRelationlistMapSize) {
                    if (!"Y".equals(authMenuRelationlistMap.get(0).get("insertUseYn"))) {
                        check = false;
                        map.put("msgCode", "-1");
                        map.put("msgDesc", "\ub4f1\ub85d \uad8c\ud55c \uc815\ubcf4\uac00 \uc5c6\uc2b5\ub2c8\ub2e4.");
                    }
                } else {
                    check = false;
                    map.put("msgCode", "-1");
                    map.put("msgDesc", "\uad8c\ud55c \uc815\ubcf4\uac00 \uc5c6\uc2b5\ub2c8\ub2e4.");
                }
            }
            if (check) {
                if (file != null && !file.isEmpty()) {
                    Map<String, Object> fileMap = this.afs.saveAttachFile("img", file);
                    String filePath = String.valueOf(fileMap.get("filePath"));
                    String fileName = String.valueOf(fileMap.get("attachfileNm"));
                    String chgFileName = String.valueOf(fileMap.get("orgAttachfileNm"));
                    Object formattedCdnUrl = this.CDN_URL.endsWith("/") ? this.CDN_URL : this.CDN_URL + "/";
                    paramMap.put("filePath", (String)formattedCdnUrl + filePath);
                    paramMap.put("fileName", fileName);
                    paramMap.put("originalFileName", chgFileName);
                    paramMap.put("attachfileId", fileMap.get("attachfileId"));
                }
                paramMap.put("tDate", tDate);
                paramMap.put("tId", tId);
                map.put("rows", paramMap);
                map.put("msgCode", "0");
                map.put("msgDesc", "\ub4f1\ub85d\ub418\uc5c8\uc2b5\ub2c8\ub2e4.");
            }
        }
        catch (Exception e) {
            e.printStackTrace();
            throw e;
        }
        log.debug("ProcedureReviewService insertProcedureReviewFile END");
        return map;
    }

    public HashMap<String, Object> selectListCategory(HashMap<String, Object> hashMap) throws Exception {
        throw new Error("Unresolved compilation problem: \n\tThe method selectListPhotoCategory(ProcedureReviewDTO) in the type ProcedureReviewMapper is not applicable for the arguments (HashMap<String,Object>)\n");
    }

    public HashMap<String, Object> selectProcedureReviewInsertIntro(HashMap<String, Object> hashMap) throws Exception {
        throw new Error("Unresolved compilation problem: \n\tThe method selectListPhotoCategory(ProcedureReviewDTO) in the type ProcedureReviewMapper is not applicable for the arguments (HashMap<String,Object>)\n");
    }

    @Transactional(rollbackFor={Exception.class}, propagation=Propagation.REQUIRES_NEW)
    public HashMap<String, Object> insertProcedureReview(HashMap<String, Object> hashMap) throws Exception {
        throw new Error("Unresolved compilation problem: \n\tThe method insertProcedureReview(ProcedureReviewDTO) in the type ProcedureReviewMapper is not applicable for the arguments (HashMap<String,Object>)\n");
    }

    public HashMap<String, Object> selectProcedureReviewUpdateIntro(HashMap<String, Object> hashMap) throws Exception {
        throw new Error("Unresolved compilation problem: \n\tThe method selectListPhotoCategory(ProcedureReviewDTO) in the type ProcedureReviewMapper is not applicable for the arguments (HashMap<String,Object>)\n");
    }

    @Transactional(rollbackFor={Exception.class}, propagation=Propagation.REQUIRES_NEW)
    public HashMap<String, Object> updateProcedureReview(HashMap<String, Object> hashMap) throws Exception {
        throw new Error("Unresolved compilation problem: \n\tThe method updateProcedureReview(ProcedureReviewDTO) in the type ProcedureReviewMapper is not applicable for the arguments (HashMap<String,Object>)\n");
    }

    public HashMap<String, Object> deleteProcedureReview(HashMap<String, Object> hashMap) throws Exception {
        throw new Error("Unresolved compilation problem: \n\tThe method deleteProcedureReview(ProcedureReviewDTO) in the type ProcedureReviewMapper is not applicable for the arguments (HashMap<String,Object>)\n");
    }
}
