

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

import com.lideeyunji.core.framework.config.aspect.enhance.model.EnhanceContext;
import com.lideeyunji.core.framework.config.aspect.enhance.plugin.AroundAdvicePlugin;
import com.lideeyunji.core.framework.mapper.example.ExampleDbFormMapper;
import com.lideeyunji.core.framework.utils.FuncWeb;
import com.lideeyunji.tool.framework.yunji.utils.lideeYunJiUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * 学生-详情-环绕增强
 */
@Slf4j
@Component("studentAroundEnhanceDetail")
public class ExampleStudentAroundEnhanceDetail implements AroundAdvicePlugin {

    @Autowired
    private ExampleDbFormMapper exampleDbFormMapper;

    @Override
    public void beforeExecute(EnhanceContext enhanceContext) {
        log.info("进入=======>studentAroundEnhanceDetail=======>beforeExecute");
        Map<String, Object> params = enhanceContext.getParam().getParams();
        Long id = lideeYunJiUtils.getMap2Long(params, "id");
        // 手动编写sql语句
        Map<String, Object> map = exampleDbFormMapper.getStudentById(id);
        FuncWeb.setDetailResult(enhanceContext, map);
    }

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