package com.clx.performance.sqlProvider.vehiclewarn;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.clx.performance.param.pc.vehiclewarn.PageVehicleWarnUserParam;
import org.apache.commons.lang.StringUtils;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.jdbc.SQL;

public class VehicleWarnUserSqlProvider {

    private static final String TABLE = "vehicle_warn_user";

    public String pageByParam(@Param("page") Page page, @Param("param") PageVehicleWarnUserParam param) {

        return new SQL(){{

            SELECT("*");
            FROM(TABLE);
            WHERE("delete_status = 0");
            if (StringUtils.isNotBlank(param.getName())) {WHERE("name = #{param.name}");}
            if (StringUtils.isNotBlank(param.getMobile())) {WHERE("mobile = #{param.mobile}");}

            ORDER_BY("id desc");
        }}.toString();
    }

}
