package com.chinaweal.aiccs.aiccs.security.entity.vo;

import com.alibaba.fastjson.annotation.JSONField;
import com.chinaweal.aiccs.aiccs.security.enums.ErrorCode;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import java.io.Serializable;
import java.util.ArrayList;

/**
 * 批量报销板块的ResultVO
 *
 * @author lroyia
 * @since 2026/1/12 15:48
 **/
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
public class SecurityResultAcceptVO extends SecurityResultVO implements Serializable {

    private static final long serialVersionUID = 1L;

    @JSONField(name = "accpetid")
    private String accpetid;

    /**
     * 创建请求成功信息
     *
     * @param accpetid 受理号
     * @return 成功
     */
    public static SecurityResultAcceptVO success(String accpetid) {
        SecurityResultAcceptVO resultVO = new SecurityResultAcceptVO();
        resultVO.setAckCode(SUCCESS);
        resultVO.setErrors(new ArrayList<>(0));
        resultVO.accpetid = accpetid;
        return resultVO;
    }

    /**
     * 创建失败返回信息
     *
     * @return 成功
     */
    public static SecurityResultAcceptVO error(ErrorCode... codes) {
        SecurityResultAcceptVO resultVO = new SecurityResultAcceptVO();
        resultVO.setAckCode(FAILURE);
        resultVO.setErrors(new ArrayList<>(codes == null ? 0 : codes.length));
        if (codes != null) {
            for (ErrorCode code : codes) {
                resultVO.getErrors().add(new ErrorInfoVO().setErrorCode(code.getCode()).setName(code.getName()).setMessage(code.getMessage()));
            }
        }
        return resultVO;
    }
}
