package com.brilliance.isc.common.transaction.newcheck.trndia;

import com.brilliance.isc.common.transaction.newcheck.AbstractModuleValidator;
import com.brilliance.isc.common.trndia.vo.DiaVo;
import com.brilliance.isc.common.trndia.vo.TrndiaVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Component
public class TrndiaValidator extends AbstractModuleValidator<TrndiaVo> {

    @Autowired
    private DiaryValidator diaryValidator;

    @Override
    @PostConstruct
    public void register() {
        super.register();
        diaryValidator.register();
    }

    @Override
    public Map<String, String> validate(TrndiaVo vo) {
        Map<String, String> maps = new HashMap<>();
        maps.putAll(super.validate(vo));
        //验证备忘录条目
        List<DiaVo> dias = vo.getDias();
        for (int i = 0; i < dias.size(); i++) {
            maps.putAll(diaryValidator.validate(dias.get(i), i));
        }
        return maps;
    }




}
