package com.yihu.hos.resource.dao;

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

import java.util.Map;

/**
 * Created by chenweida on 2016/1/21.
 */
@Repository("resourceDatasetDao")
public class RsResourceDatasetDaoImpl extends SQLGeneralDAO{

    public static final String BEAN_ID = "resourceDatasetDao";

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