267 lines
9.0 KiB
Java
267 lines
9.0 KiB
Java
package seed.dao;
|
|
|
|
import java.util.List;
|
|
|
|
import org.apache.log4j.Logger;
|
|
import org.hibernate.Criteria;
|
|
import org.hibernate.HibernateException;
|
|
import org.hibernate.SessionFactory;
|
|
import org.hibernate.criterion.MatchMode;
|
|
import org.hibernate.criterion.Order;
|
|
import org.hibernate.criterion.ProjectionList;
|
|
import org.hibernate.criterion.Projections;
|
|
import org.hibernate.criterion.Restrictions;
|
|
import org.springframework.stereotype.Repository;
|
|
|
|
import seed.map.T_POPUP_SET;
|
|
|
|
/**
|
|
* T_POPUP_SET 테이블 정보를 select, insert, update, delete 하는 class
|
|
* */
|
|
@Repository
|
|
public class PopupSetDAOImpl implements PopupSetDAO{
|
|
|
|
private Logger log = Logger.getLogger(this.getClass());
|
|
|
|
private SessionFactory sessionFactory;
|
|
|
|
public void setSessionFactory(SessionFactory sessionFactory) {
|
|
this.sessionFactory = sessionFactory;
|
|
}
|
|
|
|
/**
|
|
* memberIdx 에 해당하는 팝업 설정 리스트를 가지고 오는 메소드
|
|
* @param Integer memberIdx 회원 idx
|
|
* @return List<T_POPUP_SET> 팝업 설정
|
|
* */
|
|
//AdminMemberService, ManagerMemberService
|
|
@SuppressWarnings("unchecked")
|
|
public List<T_POPUP_SET> getPopupSetList(Integer memberIdx){
|
|
|
|
Criteria criteria = sessionFactory.getCurrentSession().createCriteria(T_POPUP_SET.class);
|
|
|
|
criteria.add(Restrictions.eq("tMember.memberIdx", memberIdx));
|
|
|
|
return criteria.list();
|
|
}
|
|
|
|
/**
|
|
* memberIdx 에 해당하는 팝업 설정 리스트를 가지고 오는 메소드
|
|
* @param String siteIdx 사이트 idx
|
|
* @param String[] qryColumns select 컬럼 정의
|
|
* @return List<T_POPUP_SET> 팝업 설정
|
|
* */
|
|
//AdminSiteService
|
|
@SuppressWarnings("unchecked")
|
|
public List<T_POPUP_SET> getPopupSetList(String siteIdx, String[] qryColumns){
|
|
|
|
Criteria criteria = sessionFactory.getCurrentSession().createCriteria(T_POPUP_SET.class);
|
|
|
|
criteria.add(Restrictions.eq("tSite.siteIdx", siteIdx));
|
|
|
|
if(qryColumns != null && qryColumns.length > 0){
|
|
ProjectionList projectionList = Projections.projectionList();
|
|
boolean groupCheck = false;
|
|
for(int q=0; q<qryColumns.length; q++){
|
|
if(!groupCheck && qryColumns[q].indexOf("groupBy") >= 0){
|
|
groupCheck = true;
|
|
continue;
|
|
}
|
|
if(groupCheck){
|
|
if(qryColumns[q].indexOf("Cnt") >= 0){
|
|
String qryColumn = qryColumns[q].substring(0, qryColumns[q].indexOf("Cnt"));
|
|
projectionList.add(Projections.count(qryColumn).as("_"+qryColumns[q].substring(qryColumns[q].lastIndexOf(".")+1)));
|
|
}else{
|
|
projectionList.add(Projections.groupProperty(qryColumns[q]).as("_"+qryColumns[q].substring(qryColumns[q].lastIndexOf(".")+1)));
|
|
}
|
|
}else{
|
|
projectionList.add(Projections.property(qryColumns[q]).as("_"+qryColumns[q].substring(qryColumns[q].lastIndexOf(".")+1)));
|
|
}
|
|
}
|
|
|
|
criteria.setProjection(projectionList);
|
|
criteria.setResultTransformer(Criteria.ALIAS_TO_ENTITY_MAP);
|
|
}
|
|
|
|
criteria.addOrder(Order.asc("popupSetIdx"));
|
|
|
|
return criteria.list();
|
|
}
|
|
|
|
/**
|
|
* siteIdx, column, search 에 해당하는 팝업 설정 개수를 가지고 오는 메소드
|
|
* @param String siteIdx 사이트 idx
|
|
* @param String column 검색 항목
|
|
* @param String search 검색 어
|
|
* @return Long 팝업 개수
|
|
* */
|
|
//ManagerPopupManagerService
|
|
@SuppressWarnings("deprecation")
|
|
public Long getPopupSetListCnt(String siteIdx, String column, String search){
|
|
|
|
Criteria criteria = sessionFactory.getCurrentSession().createCriteria(T_POPUP_SET.class);
|
|
|
|
criteria.createCriteria("tMember", "tMember", Criteria.LEFT_JOIN);
|
|
|
|
criteria.add(Restrictions.eq("tSite.siteIdx", siteIdx));
|
|
|
|
if(!column.equals("")){
|
|
if(column.equals("A")){
|
|
if(!search.equals("")){
|
|
criteria.add(
|
|
Restrictions.or(
|
|
Restrictions.like("popupSetName", search, MatchMode.ANYWHERE),
|
|
Restrictions.like("tMember.memberName", search, MatchMode.ANYWHERE)));
|
|
}
|
|
}else{
|
|
criteria.add(Restrictions.like(column, search, MatchMode.ANYWHERE));
|
|
}
|
|
}
|
|
|
|
criteria.setProjection(Projections.rowCount());
|
|
|
|
return (Long)criteria.uniqueResult();
|
|
}
|
|
|
|
/**
|
|
* siteIdx, column, search 에 해당하는 팝업 설정 개수를 가지고 오는 메소드
|
|
* @param String siteIdx 사이트 idx
|
|
* @param String column 검색 항목
|
|
* @param String search 검색 어
|
|
* @return Long 팝업 개수
|
|
* */
|
|
//ManagerPopupManagerService
|
|
@SuppressWarnings({ "unchecked", "deprecation" })
|
|
public List<T_POPUP_SET> getPopupSetList(String siteIdx, int page, int row, String orderColumn, String order, String column, String search, String[] qryColumns){
|
|
|
|
Criteria criteria = sessionFactory.getCurrentSession().createCriteria(T_POPUP_SET.class);
|
|
|
|
criteria.createCriteria("tMember", "tMember", Criteria.LEFT_JOIN);
|
|
criteria.createCriteria("tPopupDatas", "tPopupDatas", Criteria.LEFT_JOIN);
|
|
|
|
criteria.setFirstResult(page);
|
|
criteria.setMaxResults(row);
|
|
|
|
if(qryColumns != null && qryColumns.length > 0){
|
|
ProjectionList projectionList = Projections.projectionList();
|
|
boolean groupCheck = false;
|
|
for(int q=0; q<qryColumns.length; q++){
|
|
if(!groupCheck && qryColumns[q].indexOf("groupBy") >= 0){
|
|
groupCheck = true;
|
|
continue;
|
|
}
|
|
if(groupCheck){
|
|
if(qryColumns[q].indexOf("Cnt") >= 0){
|
|
String qryColumn = qryColumns[q].substring(0, qryColumns[q].indexOf("Cnt"));
|
|
projectionList.add(Projections.count(qryColumn).as("_"+qryColumns[q].substring(qryColumns[q].lastIndexOf(".")+1)));
|
|
}else{
|
|
projectionList.add(Projections.groupProperty(qryColumns[q]).as("_"+qryColumns[q].substring(qryColumns[q].lastIndexOf(".")+1)));
|
|
}
|
|
}else{
|
|
projectionList.add(Projections.property(qryColumns[q]).as("_"+qryColumns[q].substring(qryColumns[q].lastIndexOf(".")+1)));
|
|
}
|
|
}
|
|
|
|
criteria.setProjection(projectionList);
|
|
criteria.setResultTransformer(Criteria.ALIAS_TO_ENTITY_MAP);
|
|
}
|
|
|
|
criteria.add(Restrictions.eq("tSite.siteIdx", siteIdx));
|
|
|
|
if(!column.equals("")){
|
|
if(column.equals("A")){
|
|
if(!search.equals("")){
|
|
criteria.add(
|
|
Restrictions.or(
|
|
Restrictions.like("popupSetName", search, MatchMode.ANYWHERE),
|
|
Restrictions.like("tMember.memberName", search, MatchMode.ANYWHERE)));
|
|
}
|
|
}else{
|
|
criteria.add(Restrictions.like(column, search, MatchMode.ANYWHERE));
|
|
}
|
|
}
|
|
|
|
if(order.equals("DESC")){
|
|
criteria.addOrder(Order.desc(orderColumn));
|
|
}else{
|
|
criteria.addOrder(Order.asc(orderColumn));
|
|
}
|
|
|
|
return criteria.list();
|
|
}
|
|
|
|
/**
|
|
* popupSetIdx 에 해당하는 팝업 설정 정보를 가지고 오는 메소드
|
|
* @param Integer popupSetIdx 팝업 설정 idx
|
|
* @return T_POPUP_SET 팝업 설정 정보
|
|
* */
|
|
//ManagerPopupManagerService
|
|
public T_POPUP_SET getPopupSetForm(Integer popupSetIdx){
|
|
|
|
return (T_POPUP_SET) this.sessionFactory.getCurrentSession().load(T_POPUP_SET.class, popupSetIdx);
|
|
}
|
|
|
|
/**
|
|
* 팝업 설정 정보를 저장하는 메소드
|
|
* @param T_POPUP_SET tPopupSet 저장할 팝업 정보
|
|
* @return T_POPUP_SET 저장된 팝업 정보
|
|
* */
|
|
//ManagerPopupManagerService
|
|
public T_POPUP_SET setPopupSetRegProc(T_POPUP_SET tPopupSet){
|
|
|
|
try{
|
|
this.sessionFactory.getCurrentSession().save(tPopupSet);
|
|
this.sessionFactory.getCurrentSession().flush();
|
|
this.sessionFactory.getCurrentSession().clear();
|
|
}catch(HibernateException e){
|
|
log.error("CHECK ERROR:",e);
|
|
}
|
|
|
|
return getPopupSetForm(tPopupSet.getPopupSetIdx());
|
|
}
|
|
|
|
/**
|
|
* 팝업 설정 정보를 수정하는 메소드
|
|
* @param T_POPUP_SET tPopupSet 수정할 팝업 정보
|
|
* @return boolean 작업의 성공 여부
|
|
* */
|
|
//ManagerPopupManagerService
|
|
public boolean setPopupSetModProc(T_POPUP_SET tPopupSet){
|
|
|
|
boolean success = false;
|
|
|
|
try{
|
|
this.sessionFactory.getCurrentSession().update(tPopupSet);
|
|
this.sessionFactory.getCurrentSession().flush();
|
|
this.sessionFactory.getCurrentSession().clear();
|
|
success = true;
|
|
}catch(HibernateException e){
|
|
log.error("CHECK ERROR:",e);
|
|
}
|
|
|
|
return success;
|
|
}
|
|
|
|
/**
|
|
* 팝업 설정 정보를 삭제하는 메소드
|
|
* @param T_POPUP_SET tPopupSet 삭제할 팝업 정보
|
|
* @return boolean 작업의 성공 여부
|
|
* */
|
|
//ManagerPopupManagerService
|
|
public boolean setPopupSetDelProc(T_POPUP_SET tPopupSet){
|
|
|
|
boolean success = false;
|
|
|
|
try{
|
|
this.sessionFactory.getCurrentSession().delete(tPopupSet);
|
|
this.sessionFactory.getCurrentSession().flush();
|
|
this.sessionFactory.getCurrentSession().clear();
|
|
success = true;
|
|
}catch(HibernateException e){
|
|
log.error("CHECK ERROR:",e);
|
|
}
|
|
|
|
return success;
|
|
}
|
|
}
|