package com.crm.rely.backend.core.dto.base;

import com.crm.rely.backend.core.constant.Constants;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;

@Data
@NoArgsConstructor
public class ResultWithPagerDto<T> extends BaseResultWithPagerDto<List<T>> {

    public ResultWithPagerDto(PageDto page) {
        super(page);
    }

    public static <T> ResultWithPagerDto success(List<T> data, PageDto page) {
        return ResultWithPagerDto.success(Constants.SUCCESS, data, page);
    }

    public static <T> ResultWithPagerDto success( PageDto page,List<T> data) {
        return ResultWithPagerDto.success(Constants.SUCCESS, data, page);
    }

    public static ResultWithPagerDto success(PageDto page) {
        return ResultWithPagerDto.success(Constants.SUCCESS, null, page);
    }

    public static <T> ResultWithPagerDto success(String msg, List<T> data, PageDto page) {
        return result(Constants.SUCCESS_CODE, msg, data, page);
    }

    private static <T> ResultWithPagerDto result(int code, String msg, List<T> data, PageDto page) {
        return new ResultWithPagerDto(code, msg, data, page);

    }

    public ResultWithPagerDto(PageDto page, List<T> data) {
        super(page, data);
    }

    public ResultWithPagerDto(List<T> data, PageDto page) {
        super(page, data);
    }

    public ResultWithPagerDto(int code, String msg) {
        super(code, msg);
    }

    public ResultWithPagerDto(int code, String msg, PageDto page) {
        super(code, msg, page);
    }

    public ResultWithPagerDto(int code, String msg, PageDto page, List<T> data) {
        super(code, msg, page, data);
    }

    public ResultWithPagerDto(int code, String msg, List<T> data, PageDto page) {
        super(code, msg, page, data);
    }
}
