package com.zhongshu.card.client.model.base;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Builder;
import lombok.Data;

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

/**
 * 批量操作结果 返回 （成功多少，失败多少）
 *
 * @author TRX
 * @date 2025/3/3
 */
@Data
public class OutNumberModel {

    @Schema(description = "成功数量")
    private Long success = 0L;

    @Schema(description = "成功的数据")
    private List<OutMessage> successList = new ArrayList<>();

    public void addSuccess() {
        this.success++;
    }

    public void addSuccess(String key, String msg) {
        this.successList.add(new OutMessage(key, msg));
        this.success++;
    }

    public void addSuccess(String key) {
        this.successList.add(new OutMessage(key, "成功"));
        this.success++;
    }

    @Schema(description = "失败数量")
    private Long fail = 0L;

    @Schema(description = "失败的数据")
    private List<OutMessage> failList = new ArrayList<>();

    public void addFail() {
        this.fail++;
    }

    public void addFail(String key, String msg) {
        this.fail++;
        this.failList.add(new OutMessage(key, msg));
    }

    @Data
    @Builder
    public static class OutMessage {

        @Schema(description = "相关数据")
        private String key;

        @Schema(description = "结果")
        private String msg;
    }
}
