/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package kr.co.kihyun.service;

import java.util.List;
import javax.jdo.PersistenceManager;
import javax.jdo.Query;
//import kr.co.kihyun.beans.entity.TotDocProcess;
//import kr.co.kihyun.service.vo.TotDocVO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 *
 * @author KWON,HAN
 */
public class ShareDocService extends BaseService {

    private static final Logger LOG = LoggerFactory.getLogger(ShareDocService.class);

    /**
     * 기본생성자
     */
    public ShareDocService() {
    }

    /**
     * 생성자
     *
     * @param pm PersistenceManager
     */
    public ShareDocService(PersistenceManager pm) {
        super(pm);
    }

    /**
     * 공유문서에서 공유자ID의 정보를 조회하는 메소드
     *
     * @param delYn, docId, docReportType
     * @return
     */
    public List<String> getSearchDocIdType(Object delYn, Object docId, Object docReportType) {
        String sql = "";

        sql += "SELECT A.ID   \n";
        sql += "     , A.USER_ID   \n";
        sql += "     , SP_CM_DEC_FU(US.NAME)  AS USER_NAME   \n";
        sql += "     , US.DEPT_ID   \n";
        sql += "     , ( SELECT NAME FROM MOUMI_DEPT WHERE ID = US.DEPT_ID AND ROWNUM = 1 ) AS DEPT_NAME  \n";
        sql += "  FROM MOUMI_SHARE_DOC  A  \n";
        sql += "     , MOUMI_MUSER      US  \n";
        sql += " WHERE A.DEL_YN = NVL('" + delYn + "', A.DEL_YN)   \n";
        sql += "   AND A.DOC_ID = " + docId + "  \n";
        sql += "   AND A.DOC_REPORT_TYPE = '" + docReportType + "'  \n";
        sql += "   AND A.USER_ID = US.ID(+)   \n";
        sql += " ORDER BY A.ID   \n";

        Query q = pm.newQuery("javax.jdo.query.SQL", sql);
        //v2. 6.SQL 삽입 : JDO형식이므로 해결책에 따른 prepare SQL 문으로 변경할 수 없음
        return (List<String>) q.execute();
        //==================
    }

}
