

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.AfterAdvicePlugin;
import com.lideeyunji.core.framework.mapper.example.ExampleDbFormMapper;
import com.lideeyunji.core.framework.utils.Func;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Map;

/**
 * 学生-删除-后置增强
 */
@Slf4j
@Component("studentAfterEnhanceDelete")
public class ExampleStudentAfterEnhanceDelete implements AfterAdvicePlugin {

    @Autowired
    private ExampleDbFormMapper exampleDbFormMapper;

    @Override
    public void execute(EnhanceContext enhanceContext) {
        log.info("进入=======>studentAfterEnhanceDelete=======>execute");
        // 删除其他表数据
        Map<String, Object> params = enhanceContext.getParam().getParams();
        // 单条删除和批量删除的数据的id都是在dateIdList中
        Object dateIdList = params.get("dataIdList");
        if (Func.isEmpty(dateIdList)) {
            return;
        }
        List<Long> studentIdList = (List<Long>) dateIdList;
        exampleDbFormMapper.delScoreByStudentId(studentIdList);
    }
}
