package com.brilliance.isc.common.api.gle.vo;

import com.brilliance.isc.bo.Cbb;
import com.brilliance.isc.common.glemod.vo.GlemodVo;
import com.brilliance.isc.common.liaallg.vo.LiaallgVo;
import com.brilliance.isc.common.setfeg.vo.SetfegVo;
import com.brilliance.isc.common.setfog.vo.SetfogVo;
import com.brilliance.isc.common.setglg.vo.SetglgVo;
import com.brilliance.isc.common.vo.AbstractCommonVo;
import com.brilliance.isc.common.vo.BizInfoVo;
import com.brilliance.isc.common.vo.PtsptaVo;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import static com.brilliance.mda.runtime.mda.Constants.NULLSTR;

/**
 * 会计分录请求
 * @param <T>
 */
@Data
@JsonIgnoreProperties(ignoreUnknown = true)
@ApiModel(value = "会计分录请求", description = "会计分录请求")
public class GlentryRequest<T extends BizInfoVo> extends AbstractCommonVo {
    /**
     * 当前交易码
     */
    @ApiModelProperty(value = "当前交易码", name = "transName", required = true)
    private String transName = NULLSTR;
    /**
     * 当前经办人员ID
     */
    @ApiModelProperty(value = "当前经办人员ID", name = "userId", required = true)
    private String userId = NULLSTR;
    /**
     * 业务摘要信息
     */
    @ApiModelProperty(value = "业务摘要信息", name = "rec", required = true)
    private T rec;
    /**
     * CBB列表
     */
    @ApiModelProperty(value = "CBB列表", name = "cbsMap", required = true)
    private Map<String, Cbb> cbsMap;
    /**
     * 交易角色参与方列表
     */
    @ApiModelProperty(value = "交易角色参与方列表", name = "ptsList", required = true)
    private List<PtsptaVo> ptsList;
    /**
     * 他行收费
     */
    @ApiModelProperty(value = "他行收费", name = "setfog", required = true)
    private SetfogVo setfog;
    /**
     * 我行收费
     */
    @ApiModelProperty(value = "我行收费", name = "setfeg", required = true)
    private SetfegVo setfeg;
    /**
     * 账务信息
     */
    @ApiModelProperty(value = "账务信息", name = "setglg", required = true)
    private SetglgVo setglg;
    /**
     * 表外记账信息
     */
    @ApiModelProperty(value = "表外记账信息", name = "liaallg", required = true)
    private List<LiaallgVo> liaallg;

    @ApiModelProperty(hidden = true)
    private GlemodVo glemodVo;

    @Override
    public void reset() {
        if (rec == null) {
            rec = (T) new BizInfoVo();
        }
        rec.reset();
        if (cbsMap == null) {
            cbsMap = new HashMap<>();
        }
        if (ptsList == null) {
            ptsList = new ArrayList<>();
        }
        ptsList.forEach(ptsptaVo -> ptsptaVo.reset());
        if (setfog == null) {
            setfog = new SetfogVo();
        }
        setfog.reset();
        if (setfeg == null) {
            setfeg = new SetfegVo();
        }
        setfeg.reset();
        if (setglg == null) {
            setglg = new SetglgVo();
        }
        setglg.reset();
        if (liaallg == null) {
            liaallg = new ArrayList<>();
        }
        liaallg.forEach(liaallgVo -> liaallgVo.reset());
        if (glemodVo == null) {
            glemodVo = new GlemodVo(this);
        }
        glemodVo.reset();
    }
}
