#[derive(Debug, Copy, Clone)]
pub enum BusinessStatus {
SUCCESS,
FAIL,
}
impl BusinessStatus {
pub fn ordinal(&self) -> i32 {
match self {
BusinessStatus::SUCCESS => 0,
BusinessStatus::FAIL => 1,
}
}
}
#[derive(Debug, Copy, Clone)]
pub enum BusinessType {
OTHER(i32),
INSERT,
UPDATE,
DELETE,
GRANT,
EXPORT,
IMPORT,
FORCE,
GENCODE,
CLEAN,
}
impl BusinessType {
pub fn ordinal(&self) -> i32 {
match self {
BusinessType::OTHER(v) => *v,
BusinessType::INSERT => 1,
BusinessType::UPDATE => 2,
BusinessType::DELETE => 3,
BusinessType::GRANT => 4,
BusinessType::EXPORT => 5,
BusinessType::IMPORT => 6,
BusinessType::FORCE => 7,
BusinessType::GENCODE => 8,
BusinessType::CLEAN => 9,
}
}
}
#[derive(Debug, Copy, Clone)]
pub enum OperatorType {
OTHER(i32),
MANAGE,
MOBILE,
}
impl OperatorType {
pub fn ordinal(&self) -> i32 {
match self {
OperatorType::OTHER(v) => *v,
OperatorType::MANAGE => 1,
OperatorType::MOBILE => 2,
}
}
}
#[derive(Debug, Clone)]
pub struct OperationLog {
pub title: String,
pub business_type: BusinessType,
pub operator_type: OperatorType,
pub save_request_data: bool,
pub save_response_data: bool,
}
impl Default for OperationLog {
fn default() -> Self {
Self::new()
}
}
impl OperationLog {
pub fn new() -> Self {
Self {
title: "".to_string(),
business_type: BusinessType::OTHER(0),
operator_type: OperatorType::MANAGE,
save_request_data: true,
save_response_data: true,
}
}
pub fn title(mut self, title: &str) -> Self {
self.title = title.to_string();
self
}
pub fn business_type(mut self, business_type: BusinessType) -> Self {
self.business_type = business_type;
self
}
pub fn operator_type(mut self, operator_type: OperatorType) -> Self {
self.operator_type = operator_type;
self
}
pub fn save_request_data(mut self, save_request_data: bool) -> Self {
self.save_request_data = save_request_data;
self
}
pub fn save_response_data(mut self, save_response_data: bool) -> Self {
self.save_response_data = save_response_data;
self
}
}