package com.pictc.enums;

import org.slf4j.helpers.MessageFormatter;

import com.xjrsoft.common.exception.ExceptionCode;

import lombok.Setter;

/**
 * @author 张福财
 * @date 2025年10月14日 上午10:38:49
 * @Description: 
 * <div>业务错误编码  </div>
 * <p> 通用-默认  10000-10500 {@link com.xjrsoft.common.enums.ResponseCode}</p> 
 * <p>通用-参数     10501-10999 {@link com.pictc.enums.ExceptionCommonCode} </p> 
 * <p>合同  	  11000-11999 {@link com.pictc.enums.BContractCode} </p> 
 * <p>采购  	  12000-12999 {@link com.pictc.enums.BProcurementCode} </p> 
 * <p>销售  	  13000-13999 {@link com.pictc.enums.BSalesCode} </p> 
 * <p>运输               14000-14999 {@link com.pictc.enums.BTransportCode} </p> 
 * <p>储备               15000-15999 {@link com.pictc.enums.BReserveCode} </p> 
 * <p>财务               16000-16999 {@link com.pictc.enums.BFinanceCode} </p> 
 */
@Setter
public class BusinessCode implements ExceptionCode{
	
	private int code;
	
	private String message;
	
	private BusinessCode(int code, String message) {
		super();
		this.code = code;
		this.message = message;
	}
	
	@Override
	public int getCode() {
		return code;
	}

	@Override
	public String getMessage() {
		return message;
	}
	
	public static BusinessCode ofArgs(BusinessCode bcode,Object... args) {
		String msg = bcode.getMessage();
		if(args!=null && args.length > 0) {
			msg = MessageFormatter.arrayFormat(bcode.getMessage(),args).getMessage();
		}
		return new BusinessCode(bcode.getCode(),msg);
	}
	
	public static BusinessCode of(int code,String msg) {
		return new BusinessCode(code,msg);
	}



}
