

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

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 com.jeelowcode.framework.utils.utils.JeeLowCodeUtils;
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 = JeeLowCodeUtils.getMap2Long(params, "id");
        // 手动编写sql语句
        Map<String, Object> map = exampleDbFormMapper.getStudentById(id);
        FuncWeb.setDetailResult(enhanceContext, map);
    }

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