package com.persagy.dmp.auth.client;

import cn.hutool.http.HttpStatus;
import com.persagy.dmp.common.constant.ResponseCode;
import com.persagy.dmp.common.model.response.CommonResult;
/**
 *  boss-auth的抽象门面类
 * @author : lijie
 * Update By 2022/1/11 15:26
 */
public abstract class AuthFacade {
    /**
     * 处理一下boss-auth的返回code
     * @param commonResult : 查询结果
     * return : void
     * @author : lijie
     * Update By 2022/1/11 15:06
     */
    public static <T> CommonResult<T> handleResultCode(CommonResult<T> commonResult,Boolean resetErrorFlag) {
        if (String.valueOf(HttpStatus.HTTP_OK).equals(commonResult.getResult())
            || ResponseCode.A00000.getCode().equals(commonResult.getResult())){
            commonResult.setResult(ResponseCode.A00000.getDesc());
            return commonResult;
        }
        if (ResponseCode.A10000.getCode().equals(commonResult.getResult()) || resetErrorFlag){
            commonResult.setResult(ResponseCode.A10000.getDesc());
            return commonResult;
        }
        return commonResult;
    }
}
