

package com.lideeyunji.module.biz.enhance;

import com.lideeyunji.core.framework.config.aspect.enhance.model.EnhanceContext;
import com.lideeyunji.core.framework.config.aspect.enhance.model.EnhanceResult;
import com.lideeyunji.core.framework.config.aspect.enhance.plugin.AfterAdvicePlugin;
import com.lideeyunji.core.framework.utils.Func;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

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

/**
 * 后置增强
 */
@Component
@Slf4j
public class MyAfterEnhance implements AfterAdvicePlugin {
    @Override
    public void execute(EnhanceContext enhanceContext) {
        EnhanceResult result = enhanceContext.getResult();
        List<Map<String, Object>> dataMapList = result.getRecords();
        if(Func.isEmpty(dataMapList)){
            return;
        }
        for(Map<String,Object> dataMap:dataMapList){
            String name = Func.getMap2Str(dataMap,"name");
            dataMap.put("name",name+"-after");
        }
    }
}
