Commit a525e8f8 authored by ZWT's avatar ZWT

nocommit

parent e8e478b5
package pps.core.auth;
/**
* 基础认证Auth
*
* @author ZWT
* @date 2023/01/09
*/
public interface Auth {
/**
* 基础认证Auth
*
* @return {@link String}
*/
String getAuth();
}
\ No newline at end of file
package pps.core.auth;
import org.apache.commons.codec.binary.Base64;
import java.nio.charset.StandardCharsets;
/**
* 用户名密码认证
*
* @author ZWT
* @date 2023/01/09
*/
public class BasicAuth implements Auth {
private String username;
private String password;
public BasicAuth(String username, String password) {
this.username = username;
this.password = password;
}
@Override
public String getAuth() {
String auth = String.format("%s:%s", this.username, this.password);
byte[] encodedAuth = Base64.encodeBase64(auth.getBytes(StandardCharsets.ISO_8859_1));
return "Basic " + new String(encodedAuth);
}
}
\ No newline at end of file
package pps.core.auth;
/**
* Bearer Token 认证
*
* @author ZWT
* @date 2023/01/09
*/
public class BearerAuth implements Auth {
private String token;
public BearerAuth(String token) {
this.token = token;
}
@Override
public String getAuth() {
return "Bearer " + this.token;
}
}
\ No newline at end of file
package pps.core.common.cache;
import lombok.Data;
import xstartup.base.XContext;
import xstartup.cache.XCacheLife;
import xstartup.cache.XCacheObject;
import xstartup.cache.XSingleCache;
import java.util.Date;
/**
* 第三方Token查询缓存
*
* @author ZWT
* @date 2023/12/12
*/
@Data
public class ThirdPartyConfigCache implements XCacheObject, XCacheLife {
private String codeKey;
private String code;
private Integer validity;
private Date currentDate;
@Override
public Integer getDuration() {
return validity * 60;
}
@Override
public String getCacheKey() {
return this.codeKey;
}
/**
* 检查缓存是否存在指定的code
*
* @param context 上下文
* @param code 密码
* @return {@link ThirdPartyConfigCache}
*/
public static ThirdPartyConfigCache exist(XContext context, String code) {
return XSingleCache.get(Tool.class).find(context, code, ThirdPartyConfigCache.class);
}
/**
* 删去
*
* @param context 上下文
* @param loginName 登录名
*/
public static void delete(XContext context, String loginName) {
XSingleCache.get(Tool.class).delete(context, loginName, ThirdPartyConfigCache.class);
}
/**
* 设置缓存
*
* @param context 上下文
* @param cache 隐藏物
*/
public static void set(XContext context, ThirdPartyConfigCache cache) {
XSingleCache.get(Tool.class).set(context, cache);
}
static class Tool extends XSingleCache<ThirdPartyConfigCache> {
@Override
protected ThirdPartyConfigCache restore(XContext context, String cacheKey) {
return null;
}
}
}
\ No newline at end of file
package pps.core.prediction.constant;
/**
* 第三方接口地址
*
* @author ZWT
* @date 2024/03/18 09:25
*/
public class ThirdPartyApiConstant {
/*------------------------------ 长庆 ------------------------------*/
/**
* Redis缓存key
*/
public static final String CQ_TOKEN_CACHE_KEY = "pps.third.cq.token";
/**
* 长庆Token
*/
public static final String CQ_TOKEN = "/Smart_Well_Data/api/v1/Auth/GetToken";
/**
* 获取日耗电日产液等信息
*/
public static final String CQ_WELL_TECH_DAILY = "/Smart_Well_Data/api/v1/PvDataManagement/GET_WELL_TECH_DAILY";
/**
* 获取有功功率数据
*/
public static final String CQ_WELL_STATION_PV_DATA = "/Smart_Well_Data/api/v1/PvDataManagement/GET_WELL_STATION_PV_DATA";
/**
* 获取甘特图数据
*/
public static final String CQ_RPT_SYSTEM_START_STOP = "/Smart_Well_Data/api/v1/SdDataManagement/Get_RPT_SYSTEM_START_STOP";
/**
* 本日累计数据
*/
public static final String CQ_WELL_REAL_PV_DATA = "/Smart_Well_Data/api/v1/PvDataManagement/GET_WELL_Real_PV_DATA";
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment