/***********************************************************************************
 * @@ Program Name : RepoAdmUser.java Description : 보고관리자 정보에 대한 클레스 Author : Create Date : History :
 * @@
 ***********************************************************************************/
package kr.co.kihyun.beans.user;

import java.sql.ResultSet;
import java.sql.SQLException;
import kr.co.kihyun.beans.entity.MUser;
import kr.co.kihyun.beans.entity.MoumiEntity;

import kr.co.kihyun.db.DBManager;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class RepoAdmUser extends DBManager {
	private static final Logger LOG = LoggerFactory.getLogger(RepoAdmUser.class);

	private ResultSet rs = null;

	/******** 보고관리자 ID ********/
	public String getID(Long deptID, int sysAuth) {
		StringBuilder sql = new StringBuilder(120);
		String id = "";

		try {
			sql.append("select id from ").append(MoumiEntity.getTableName(MUser.class))
					.append(" where dept_id=? and sys_auth=? and (del_type='0' or del_type='N')");

			rs = execQuery(sql, deptID, sysAuth);
			if (rs.next()) {
				id = rs.getString("id");
			}
			return id;
		} catch (SQLException sqlEx) {
			LOG.error("\nSQLState - {}\nMySQL Error Code - {}\nmessage - {}\nsql - {}",
					new Object[] { sqlEx.getSQLState(), sqlEx.getErrorCode(), sqlEx.getMessage(), sql });
			throw new RuntimeException(sqlEx);
		} catch (Exception ex) {
			throw new RuntimeException(ex);
		} finally {
			close(rs);
			execClose();
		}
	}
}
