package com.royalrangers.utils;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.royalrangers.bean.ResponseResult;
import lombok.Getter;

public class ResponseBuilder {

    public static ResponseResult success() {
        return new ResponseResult(true, new EmptyJsonResponse());
    }

    public static ResponseResult success(Object data) {
        return new ResponseResult(true, data);
    }

    public static ResponseResult success(String message) {
        return new ResponseResult(true, new ResponseMessage(message));
    }

    public static ResponseResult fail() {
        return new ResponseResult(false, new EmptyJsonResponse());
    }

    public static ResponseResult fail(String message) {
        return new ResponseResult(false, new ResponseMessage(message));
    }

    @JsonSerialize
    private static class EmptyJsonResponse { }

    @Getter
    @JsonSerialize
    private static class ResponseMessage{
        private String message;

        ResponseMessage (String message) {
            this.message = message;
        }
    }
}

@@ -158,16 +158,65 @@
 etter;%0A%0A
+import java.util.HashMap;%0Aimport java.util.Map;%0A%0A
 public c
@@ -594,32 +594,236 @@
 message));%0A    %7D
+%0A    public static ResponseResult success(String key, String value) %7B%0A        Map%3CString, String%3E data = new HashMap%3C%3E();%0A        data.put(key, value);%0A        return new ResponseResult(true, data);%0A    %7D
 %0A%0A    public sta

Add success method for custom message in data.