Commit 076f73c7 authored by xuwencheng's avatar xuwencheng

token

parent 36b7ba27
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, Serialize, Deserialize)]
......@@ -28,12 +27,27 @@ impl TokenInfo {
crate::id::short_link_hash(&combined_string)
}
pub fn generate_simple_token(&self) -> String {
let combined_string = format!("{}:{}", self.client_type, self.device_id);
crate::id::short_link_hash(&combined_string)
}
pub fn get_standard_device_id(&self, token: String) -> String {
let padded_device_id = format!("{:0>17}", self.device_id);
let sub_device_id = &padded_device_id[padded_device_id.len() - 17..];
format!("qm_cli_{}_{}", token, sub_device_id)
}
pub fn simple_std_device_id(&self) -> String {
// 标准设备号
if self.device_id.starts_with("qm_cli_") {
self.device_id.clone()
} else {
let token = self.generate_simple_token();
self.get_standard_device_id(token)
}
}
pub fn standard_device_id(&self) -> String {
// 标准设备号
if self.device_id.starts_with("qm_cli_") {
......@@ -55,4 +69,4 @@ impl TokenInfo {
extend: None,
}
}
}
\ No newline at end of file
}
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