package com.lideeyunji.core.framework.config.aspect.enhance.strategy.sql;

import com.lideeyunji.core.framework.config.aspect.enhance.model.EnhanceContext;
import com.lideeyunji.core.framework.entity.EnhanceSqlEntity;
import com.lideeyunji.core.framework.utils.Func;
import com.lideeyunji.tool.framework.yunji.constant.lideeYunjiCodeConstant;
import com.lideeyunji.tool.framework.yunji.utils.lideeYunJiUtils;

import java.util.Map;

/**
 * 列表策略
 */
public class ListEnhanceSqlStrategy extends BaseEnhanceSqlStrategy  implements EnhanceSqlStrategy {

    @Override
    public void execute(EnhanceContext context, EnhanceSqlEntity enhanceSqlEntity) {
        //列表 前端只保留了一个
        Map<String, Object> params = context.getParam().getParams();
        Integer pageSize = lideeYunJiUtils.getMap2Integer(params, "pageSize");
        if (Func.isEmpty(pageSize) || pageSize == -1 || Func.equals(pageSize, lideeYunjiCodeConstant.NOT_PAGE)) {
            super.executeEnhanceAfterList(context, enhanceSqlEntity);
        } else {
            super.executeEnhanceAfterPage(context, enhanceSqlEntity);
        }
    }

}
