package com.yihu.hos.resource.dao;

import com.yihu.hos.resource.model.RsDemensionCategory;
import com.yihu.hos.web.framework.dao.SQLGeneralDAO;
import com.yihu.hos.web.framework.model.Result;
import org.springframework.stereotype.Repository;
import org.springframework.util.StringUtils;

import java.util.List;
import java.util.Map;

/**
 * Created by chenweida on 2016/1/26.
 */
@Repository("demensionCategoryDao")
public class RsDemensionCategoryDaoImpl extends SQLGeneralDAO {

    public static final String BEAN_ID = "demensionCategoryDao";

    public List<RsDemensionCategory> getDimensionCategoryList() throws Exception {
        List<RsDemensionCategory> a = (List<RsDemensionCategory>) super.hibernateTemplate.find(" from RsDemensionCategory ");
        return (List<RsDemensionCategory>) super.hibernateTemplate.find(" from RsDemensionCategory ");
    }

    public Result getDimensionCatecoryList(Map<String, Object> conditionMap) throws Exception {
        StringBuilder sb = new StringBuilder();
        sb.append(" from RsDemensionCategory r ");
        sb.append(" where 1=1 ");
        if (!StringUtils.isEmpty(conditionMap.get("name"))) {
            sb.append(" and r.name = '" + conditionMap.get("name") + "'");
        }
        return super.getDataGridResult(sb.toString(),(Integer) conditionMap.get("page"), (Integer)conditionMap.get("rows"));
    }
}
