package com.sys.bus.jx.service;

import com.jfinal.plugin.activerecord.Page;
import com.sys.bus.hr.model.Person;
import com.sys.bus.hr.service.HrService;
import com.sys.bus.model.Entry;
import com.sys.bus.model.WxMsg;
import com.sys.bus.model.WxPerson;
import com.sys.bus.sys.model.DtBean;
import com.sys.bus.syscode.service.SysCodeService;
import com.sys.core.model.PageBean;
import com.sys.core.utils.Tool;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class WxPersonService {
    Log log = LogFactory.getLog(this.getClass());

    /**
     * @param pageNumber
     * @param pageSize
     * @param name

     * @return
     */
    public PageBean getWxPersonQueryList(Integer pageNumber, Integer pageSize, String name) {
        /**
         * sql：
         *    1.获取被评过分的人的数据   type = 1
         *    2.获取直接下级的数据   type = 2
         *    3.把以上两种数据合并去重  根据entryid去重，有相同数据时  去除type=1的数据  count(1)
         */

        String sqlCount  =
                "select  count(1)  from CT_JX_WXPERSON    " ;


        String sqlPara  =
                "select  *   from CT_JX_WXPERSON   " ;

        String whereBy = "";
        if(!StringUtils.isBlank(name)){
            whereBy += " where WXPERSON_PNAME like '%"+name+"%' or WXPERSON_NAME  like '%"+name+"%'";
        }


        sqlCount += whereBy;
        sqlPara += whereBy;

        sqlPara += "order by WXPERSON_UPDATETIME desc ,WXPERSON_CREATETIME desc";//
        PageBean pageBean = new PageBean();
        Page<WxPerson> page = new WxPerson().dao().paginateByFullSql(pageNumber, pageSize, sqlCount, sqlPara);
        pageBean.setCount(page.getTotalRow());
        pageBean.setData(page.getList());
        return pageBean;




    }

}