package com.brilliance.isc.swift.objmtconvert.model.mt9xx;

import com.brilliance.isc.swift.objmtconvert.annotation.FieldDescription;
import com.brilliance.isc.swift.objmtconvert.annotation.Status;
import com.brilliance.isc.swift.objmtconvert.annotation.TagName;
import com.brilliance.isc.swift.objmtconvert.annotation.TagRegex;
import com.brilliance.isc.swift.objmtconvert.model.AbsMTCreator;
import com.brilliance.isc.swift.objmtconvert.model.AbsTagCreate;
import com.brilliance.isc.swift.objmtconvert.model.mt9xx.tag.tag986.Tag20Creator;
import com.brilliance.isc.swift.objmtconvert.model.mt9xx.tag.tag986.Tag21Creator;
import com.brilliance.isc.swift.objmtconvert.model.mt9xx.tag.tag986.Tag59Creator;
import com.brilliance.isc.swift.objmtconvert.model.mt9xx.tag.tag986.Tag79Creator;
import com.brilliance.isc.swift.objmtconvert.result.MtResult;

import java.util.ArrayList;
import java.util.List;

/**
 * @author hedonghao
 * @date 2023/2/25
 */
public class MT986Creator extends AbsMTCreator {

    @Status("M")
    @TagName("20")
    @FieldDescription("transactionReferenceNumber")
    @TagRegex("16x")
    //20
    private String transactionReferenceNumber;

    @Status("M")
    @TagName("21")
    @FieldDescription("relatedReference")
    @TagRegex("16x")
    //21
    private String relatedReference;

    @Status("O")
    @TagName("59")
    @FieldDescription("enquiredParty")
    @TagRegex("[/34x]<crlf>4*35x")
    //59
    private String enquiredParty;

    @Status("M")
    @TagName("79")
    @FieldDescription("narrative")
    @TagRegex("35*50x")
    //79
    private String narrative;

    public String getTransactionReferenceNumber() {
        return transactionReferenceNumber;
    }

    public void setTransactionReferenceNumber(String transactionReferenceNumber) {
        this.transactionReferenceNumber = transactionReferenceNumber;
    }

    public String getRelatedReference() {
        return relatedReference;
    }

    public void setRelatedReference(String relatedReference) {
        this.relatedReference = relatedReference;
    }

    public String getEnquiredParty() {
        return enquiredParty;
    }

    public void setEnquiredParty(String enquiredParty) {
        this.enquiredParty = enquiredParty;
    }

    public String getNarrative() {
        return narrative;
    }

    public void setNarrative(String narrative) {
        this.narrative = narrative;
    }

    public MT986Creator(String msgType)  {
        super(msgType);
    }

    public MT986Creator() {
        super();
    }

    /**
     * 需要编写组装报文逻辑，调用set方法即可
     *
     * @return
     */
    public void pack() {
        // MtResult mtResult = new MtResult();
        List<AbsTagCreate> tagCreateList=new ArrayList<>();
        try {
            tagCreateList.add(new Tag20Creator(this));
            tagCreateList.add(new Tag21Creator(this));
            tagCreateList.add(new Tag59Creator(this));
            tagCreateList.add(new Tag79Creator(this));

            dealTags(tagCreateList);

            mtResult.setMessage(abstractMT.message());
        } catch (Exception e) {
            e.printStackTrace();
            mtResult.setSuccess(false);
            mtResult.addDescription(e.getLocalizedMessage());
        }

        //return mtResult;

    }

    public MtResult unpack() {
        return null;
    }


}
