package com.diagbot.facade.data;

import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.diagbot.entity.MedAbnormalInfo;
import com.diagbot.service.impl.MedAbnormalInfoServiceImpl;
import com.diagbot.vo.data.AHomePageIngVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Date;
import java.util.List;

@Component
public class AMedAbnormalInfoFacade extends MedAbnormalInfoServiceImpl {
    @Autowired
    private AHomePageFacade aHomePageFacade;
    /**
     * 接口日志记录
     *
     * @param paramIn
     * @param paramOut
     * @param remark
     */
    public void saveAbnormalInfo(String moduleName, String recId, String paramIn, String paramOut, String remark) {
        MedAbnormalInfo medAbnormalInfo = new MedAbnormalInfo();
        medAbnormalInfo.setModuleName(moduleName);
        medAbnormalInfo.setRecId(recId);
        medAbnormalInfo.setParamIn(paramIn);
        medAbnormalInfo.setParamOut(paramOut);
        medAbnormalInfo.setRamark(remark);
        medAbnormalInfo.setGmtCreate(new Date());
        this.save(medAbnormalInfo);
    }

    public void a(String name){
        QueryWrapper<MedAbnormalInfo> wrapper =new QueryWrapper<>();
        wrapper.eq("module_name",name);
        List<MedAbnormalInfo> medAbnormalInfo =this.list(wrapper);
        medAbnormalInfo.forEach(s->{
            AHomePageIngVO aHomePageIngVO = JSON.parseObject(s.getParamIn(),AHomePageIngVO.class);
            aHomePageFacade.updateHomePageIng(aHomePageIngVO);
        });

    }
}
