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.commontag.ActnoBicAdrTagXXX;
import com.brilliance.isc.swift.objmtconvert.model.mt9xx.tag.tag985.Tag20Creator;
import com.brilliance.isc.swift.objmtconvert.model.mt9xx.tag.tag985.Tag57aCreator;
import com.brilliance.isc.swift.objmtconvert.model.mt9xx.tag.tag985.Tag59Creator;
import com.brilliance.isc.swift.objmtconvert.model.mt9xx.tag.tag985.Tag75Creator;
import com.brilliance.isc.swift.objmtconvert.result.MtResult;

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

/**
 * @author hedonghao
 * @date 2023/2/25
 */
public class MT985Creator extends AbsMTCreator {
    @Status("M")
    @TagName("20")
    @FieldDescription("Transaction Reference Number")
    @TagRegex("16x")
    //20
    private String tranReferenceNum;
    @Status("O")
    @TagName({"57A","57B","57D"})
    @FieldDescription("Account With Institution")
    @TagRegex({"[/1!a][/34x]<crlf>4!a2!a2!c[3!c]","[/1!a][/34x]<crlf>[35x],[/1!a][/34x]<crlf>4*35x"})
    //57a
    private ActnoBicAdrTagXXX accountWithInstitution57a;
    @Status("M")
    @TagName({"59"})
    @FieldDescription("Enquired Party")
    @TagRegex({"[/34x]<crlf>4*35x"})
    //59
    private ActnoBicAdrTagXXX enquiredParty59;
    @Status("O")
    @TagName({"75"})
    @FieldDescription("Queries")
    @TagRegex({"6*35x"})
    //75
    private String queries;


    public ActnoBicAdrTagXXX getAccountWithInstitution57a() {
        return accountWithInstitution57a;
    }

    public void setAccountWithInstitution57a(ActnoBicAdrTagXXX accountWithInstitution57a) {
        this.accountWithInstitution57a = accountWithInstitution57a;
    }

    public ActnoBicAdrTagXXX getEnquiredParty59() {
        return enquiredParty59;
    }

    public void setEnquiredParty59(ActnoBicAdrTagXXX enquiredParty59) {
        this.enquiredParty59 = enquiredParty59;
    }

    public String getQueries() {
        return queries;
    }

    public void setQueries(String queries) {
        this.queries = queries;
    }

//    public MT985Creator(String jsonData) throws Exception {
//        super(jsonData);
//    }

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

    public MT985Creator() {
        super();
    }

    public String getTranReferenceNum() {
        return tranReferenceNum;
    }

    public void setTranReferenceNum(String tranReferenceNum) {
        this.tranReferenceNum = tranReferenceNum;
    }


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


            tagCreateList.add(new Tag20Creator(this));
            tagCreateList.add(new Tag57aCreator(this));
            tagCreateList.add(new Tag59Creator(this));
            tagCreateList.add(new Tag75Creator(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;
    }


}
