

package com.jeelowcode.core.framework.enhance.example.dbform.student;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jeelowcode.core.framework.config.aspect.enhance.model.EnhanceContext;
import com.jeelowcode.core.framework.config.aspect.enhance.plugin.AroundAdvicePlugin;
import com.jeelowcode.core.framework.mapper.example.ExampleDbFormMapper;
import com.jeelowcode.core.framework.utils.FuncWeb;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * 学生-分页-环绕增强
 */
@Slf4j
@Component("studentAroundEnhancePage")
public class ExampleStudentAroundEnhancePage implements AroundAdvicePlugin {

    @Autowired
    private ExampleDbFormMapper exampleDbFormMapper;

    @Override
    public void beforeExecute(EnhanceContext enhanceContext) {
        log.info("进入=======>studentAroundEnhancePage=======>beforeExecute");
        Map<String, Object> params = enhanceContext.getParam().getParams();
        Page page = FuncWeb.getPage(params);
        // 手动编写sql语句
        IPage<Map<String, Object>> pages = exampleDbFormMapper.getStudentPage(page, params);
        FuncWeb.setPageResult(enhanceContext, pages);
    }

    @Override
    public void afterExecute(EnhanceContext enhanceContext) {
    }
}
