package com.palmnest.dao.estateserve.impl;

import java.util.List;

import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Repository;

import com.palmnest.dao.estateserve.VirArchModelDao;
import com.palmnest.dao.hibernate.GenericDaoHibernate;
import com.palmnest.model.RoomInfo;
import com.palmnest.model.VirArchModel;
import com.palmnest.model.property.VirtualArchitecture;

/**
 * 企业模板配置(入驻、迁出)
 *
 * @author longmeizhen
 */
@Repository("virArchModeDao")
public class VirArchModelDaoImpl extends GenericDaoHibernate<VirArchModel, Integer> implements VirArchModelDao {

	public VirArchModelDaoImpl() {
		super(VirArchModel.class);
	}

	@Override
	public List<VirArchModel> getVirArchModelByType(int type, String orgId) throws Exception {
		String sql = "";
		if (type == 0) {
			sql = "from VirArchModel where isEnabled='1' ";
		} else {
			sql = "from VirArchModel where type='" + type + "' and isEnabled='1' ";
		}
		if (StringUtils.isNotBlank(orgId)) {
			sql += " and orgId in (" + orgId + ")";
		}
		List<VirArchModel> list = getSession().createQuery(sql).list();
		return list;
	}
}
