package integration.anyframe.services.corebasis;

import org.springframework.stereotype.Repository;
import org.springframework.util.ClassUtils;

import anyframe.common.Page;
import anyframe.common.util.SearchVO;
import anyframe.common.util.StringUtil;
import anyframe.core.basis.dao.query.GenericDaoQuery;


@Repository("usersDao")
public class UsersDaoQueryImpl extends GenericDaoQuery<Users, String> implements UsersDao {

    public UsersDaoQueryImpl() {
        super(Users.class);
    }
    
        public Page getList(SearchVO searchVO) throws Exception {
        int pageIndex = searchVO.getPageIndex();
        int pageSize = this.getPropertiesService().getInt("PAGE_SIZE");
        int pageUnit = this.getPropertiesService().getInt("PAGE_UNIT");

        String searchCondition = StringUtil.null2str(searchVO.getSearchCondition());
        String searchKeyword = StringUtil.null2str(searchVO.getSearchKeyword());
        String isNumeric = StringUtil.isNumeric(searchKeyword) ? "true" : "false";
        
        Object[] args = new Object[4];                      
        args[0] = "condition=" + searchCondition;
        args[1] = "keywordStr=%" + searchKeyword + "%";
        args[2] = "keywordNum=" + searchKeyword + "";
        args[3] = "isNumeric=" + isNumeric;

        return this.findListWithPaging(ClassUtils.getShortName(getPersistentClass()), args, pageIndex, pageSize, pageUnit);
        }   
}

