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

import com.brilliance.isc.bo.model.Wbdp;
import com.brilliance.isc.common.transaction.newcheck.AbstractModuleValidator;
import com.brilliance.isc.common.transaction.newcheck.ValidResult;
import com.brilliance.isc.common.transaction.newcheck.Validate;
import com.brilliance.isc.common.util.StringUtils;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

@Component
public class WbpcreValidator extends AbstractModuleValidator<Wbdp> {

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

    @Validate(path = "trtp.wbdp.act")
    public ValidResult checkAct(Wbdp wbdpVo) {
        if ("X".equalsIgnoreCase(wbdpVo.getVisiableFlag())) {
            if (StringUtils.isEmpty(wbdpVo.getAct())) {
                return ValidResult.build(false, "该字段是必填项");
            }
        }
        return null;
    }

    @Validate(path = "trtp.wbdp.actpro")
    public ValidResult checkActpro(Wbdp wbdpVo) {
        if ("X".equalsIgnoreCase(wbdpVo.getVisiableFlag())) {
            if (StringUtils.isEmpty(wbdpVo.getActpro())) {
                return ValidResult.build(false, "该字段是必填项");
            }
        }
        return null;
    }
}
