package com.jfinal.club._admin.ws;

import com.jfinal.club.common.model.Wsinfo;
import com.jfinal.plugin.activerecord.Page;
import org.apache.commons.lang3.StringUtils;

/**
 * @ProjectName: jfinal-club
 * @Package: com.jfinal.club._admin.ws
 * @ClassName: WsAdminService
 * @Author: Jzdsh
 * @Description:
 * @Date: 2020/4/2 13:38
 * @Version: 1.0
 */
public class WsAdminService {


    public Page< Wsinfo > page(int pageNum, int pageSize, String searchName) {
        try {
            if (StringUtils.isNotBlank(searchName)) {
                searchName = "%" + searchName.trim( ) + "%";
                return Wsinfo.dao.paginate(pageNum, pageSize, "select b.nickName,a.* ", "from wsinfo a left join users b  on a.userId = b.id where status = 1 and nickName like ? order by a.createAt desc", searchName);
            } else {
                return Wsinfo.dao.paginate(pageNum, pageSize, "select b.nickName,a.* ", "from wsinfo a left join users b  on a.userId = b.id where status = 1 order by a.createAt desc");
            }
        } catch (Exception e) {
            e.printStackTrace( );
        }
        return null;
    }
}
