package org.dromara.settlement.api.domain;

import com.fasterxml.jackson.annotation.JsonCreator;

/**
 * 微服务接口返回结果状态 SUCCESS：成功 200 ERROR:失败 500 CONFIRM:需要确认 201 TIP:业务提示 202
 * NoPermission:无权限访问 203
 *
 * @author 丁红博
 *
 */
public enum ResultCodeEnum {
	SUCCESS(200), ERROR(500), CONFIRM(201), TIP(202), NoPermission(203);
	int resultCode = 200;

	private ResultCodeEnum(int resultCode) {
		this.resultCode = resultCode;
	}

	public int Code() {
		return resultCode;
	}

	@JsonCreator // This is the factory method and must be static
    public static ResultCodeEnum fromString(int string) {
		if (string == 200) {
			return ResultCodeEnum.SUCCESS;
		} else if (string == 500) {
			return ResultCodeEnum.ERROR;
		} else if (string == 201) {
			return ResultCodeEnum.CONFIRM;
		} else if (string == 202) {
			return ResultCodeEnum.TIP;
		} else if (string == 203) {
			return ResultCodeEnum.NoPermission;
		}
		return null;
	}
}
