242 lines
8.5 KiB
Python
242 lines
8.5 KiB
Python
import pandas as pd
|
|
from typing import List, Dict
|
|
|
|
from pydantic import ValidationError, BaseModel
|
|
from pydantic import Field, StrictStr, StrictInt
|
|
|
|
from enum import Enum
|
|
|
|
__all__ = ('TUserModel', 'UserModel', 'TPaylistModel', 'PaylistModel', 'TEventModel', 'EventModel')
|
|
|
|
|
|
class Platform(str, Enum):
|
|
ios = 'ios'
|
|
android = 'android'
|
|
|
|
|
|
class Sex(int, Enum):
|
|
unknown = 0
|
|
woman = 1
|
|
man = 2
|
|
|
|
|
|
class TBaseModel(BaseModel):
|
|
channel_name: StrictStr = Field(..., title="channel", alias='_channel_name')
|
|
channel_uid: StrictStr = Field(..., title="channel_uid", alias='_channel_uid')
|
|
device_id: StrictStr = Field(..., title='device_id', alias='_device_id')
|
|
district_server_id: StrictInt = Field(..., title="区服id", alias='_district_server_id')
|
|
first_device_id: StrictStr = Field(..., title='device_id', alias='_first_device_id')
|
|
game_role_id: StrictStr = Field(..., title="角色id", alias='_game_role_id')
|
|
owner_name: StrictStr = Field(..., title="owner", alias='_owner_name')
|
|
platform: Platform = Field(..., title="平台", alias='_platform')
|
|
event_time: StrictInt = Field(..., title="事件时间", alias='_event_time')
|
|
role_level: StrictInt = Field(..., title="角色等级")
|
|
role_stage: StrictStr = Field(..., title="关卡")
|
|
role_vip: StrictInt = Field(..., title="角色vip等级")
|
|
role_create_time: StrictInt = Field(..., title="角色创建时间")
|
|
user_name: StrictStr = Field(..., title="角色名")
|
|
|
|
class Config:
|
|
error_msg_templates = {
|
|
'type_error.integer': '需要整数类型',
|
|
'type_error.str': '需要字符串类型',
|
|
'type_error.dict': '需要字典类型',
|
|
'type_error.list': '需要列表类型',
|
|
'value_error.list.min_items': '最少需要{limit_value}项',
|
|
'value_error.any_str.min_length': '最小需要{limit_value}个字符',
|
|
'value_error.missing': '缺少该字段',
|
|
'type_error.enum': '需要{enum_values}'
|
|
}
|
|
|
|
|
|
class GBaseModel(BaseModel):
|
|
channel_name: str = Field(..., min_length=1, title="channel", alias='_channel_name')
|
|
channel_uid: str = Field(..., min_length=1, title="channel_uid", alias='_channel_uid')
|
|
device_id: str = Field(..., min_length=1, title='device_id', alias='_device_id')
|
|
district_server_id: int = Field(..., title="区服id", alias='_district_server_id')
|
|
first_device_id: str = Field(..., min_length=1, title='device_id', alias='_first_device_id')
|
|
game_role_id: str = Field(..., min_length=1, title="角色id", alias='_game_role_id')
|
|
owner_name: str = Field(..., min_length=1, title="owner", alias='_owner_name')
|
|
platform: Platform = Field(..., title="平台", alias='_platform')
|
|
event_time: int = Field(..., title="事件时间", alias='_event_time')
|
|
role_level: int = Field(..., title="角色等级")
|
|
role_stage: str = Field(..., min_length=1, title="关卡")
|
|
role_vip: int = Field(..., title="角色vip等级")
|
|
role_create_time: int = Field(..., title="角色创建时间")
|
|
user_name: str = Field(..., min_length=1, title="角色名")
|
|
|
|
class Config:
|
|
error_msg_templates = {
|
|
'type_error.integer': '需要整数类型',
|
|
'type_error.str': '需要字符串类型',
|
|
'type_error.dict': '需要字典类型',
|
|
'type_error.list': '需要列表类型',
|
|
'value_error.list.min_items': '最少需要{limit_value}项',
|
|
'value_error.any_str.min_length': '最小需要{limit_value}个字符',
|
|
'value_error.missing': '缺少该字段',
|
|
'type_error.enum': '需要{enum_values}'
|
|
}
|
|
|
|
|
|
class TUserModel(TBaseModel):
|
|
role_diamonds: StrictInt = Field(...)
|
|
union_name: StrictStr = Field(...)
|
|
union_id: StrictStr = Field(...)
|
|
app_version: StrictStr = Field(..., alias='_app_version')
|
|
app_name: StrictStr = Field(..., alias='_app_name')
|
|
game_version: StrictStr = Field(..., alias='_game_version')
|
|
role_race: StrictStr = Field(...)
|
|
role_sex: Sex = Field(...)
|
|
role_type: StrictStr = Field(...)
|
|
combat_effectiveness: StrictInt = Field(...)
|
|
last_login_time: StrictInt = Field(...)
|
|
role_camp: StrictStr = Field(...)
|
|
role_number: StrictInt = Field(...)
|
|
role_yxb: StrictInt = Field(...)
|
|
|
|
|
|
|
|
|
|
class UserModel(GBaseModel):
|
|
role_diamonds: int = Field(..., title="")
|
|
union_name: str = Field(..., min_length=1, title="")
|
|
union_id: str = Field(..., min_length=1, title="")
|
|
app_version: str = Field(..., min_length=1, alias='_app_version')
|
|
app_name: str = Field(..., min_length=1, alias='_app_name')
|
|
game_version: str = Field(..., min_length=1, alias='_game_version')
|
|
role_race: str = Field(..., min_length=1, title="")
|
|
role_sex: Sex = Field(..., title="")
|
|
role_type: str = Field(..., min_length=1, title="")
|
|
combat_effectiveness: int = Field(..., title="")
|
|
last_login_time: int = Field(..., title="")
|
|
role_camp: str = Field(..., min_length=1, title="")
|
|
role_number: int = Field(..., title="")
|
|
role_yxb: int = Field(..., title="")
|
|
|
|
|
|
|
|
|
|
class TPaylistModel(TBaseModel):
|
|
orderid: StrictStr = Field(...)
|
|
money: StrictInt = Field(...)
|
|
proid: StrictStr = Field(...)
|
|
|
|
|
|
|
|
|
|
class PaylistModel(GBaseModel):
|
|
orderid: str = Field(..., min_length=1)
|
|
money: int = Field(..., gt=0)
|
|
proid: str = Field(..., min_length=1)
|
|
|
|
|
|
|
|
|
|
class TEventModel(TBaseModel):
|
|
role_diamonds: StrictInt = Field(...)
|
|
app_version: StrictStr = Field(..., alias='_app_version')
|
|
app_name: StrictStr = Field(..., alias='_app_name')
|
|
game_version: StrictStr = Field(..., alias='_game_version')
|
|
role_yxb: StrictInt = Field(...)
|
|
need: List[Dict] = Field(None, alias='_game_version')
|
|
prize: List[Dict] = Field(None, alias='_game_version')
|
|
|
|
|
|
|
|
|
|
class EventModel(GBaseModel):
|
|
role_diamonds: int = Field(...)
|
|
app_version: str = Field(..., min_length=1, alias='_app_version')
|
|
app_name: str = Field(..., min_length=1, alias='_app_name')
|
|
game_version: str = Field(..., min_length=1, alias='_game_version')
|
|
role_yxb: int = Field(...)
|
|
need: List[Dict] = Field(None, min_items=1)
|
|
prize: List[Dict] = Field(None, min_items=1)
|
|
|
|
|
|
|
|
|
|
# a = """_game_role_id 角色id str >0
|
|
# _device_id 设备id str >0
|
|
# _first_device_id 注册设备id str >0
|
|
# _channel_name 渠道名 str >0
|
|
# _channel_uid 账号 str >0
|
|
# _district_server_id 区服id int >0
|
|
# _owner_name 发行名 str >0
|
|
# role_create_time 角色创建时间 int >0
|
|
# role_level 角色等级 int >=0
|
|
# role_stage 主线关卡 str >0
|
|
# role_vip 角色vip int >=0
|
|
# _platform 平台 str enum('ios','android')
|
|
# _app_version app版本 str >0
|
|
# _game_version 游戏版本 str >0
|
|
# _app_name app名 str >0
|
|
# user_name 用户名 str >0
|
|
# role_diamonds 钻石数量 int >=0
|
|
# role_yxb 游戏币 int >=0
|
|
# role_number 角色序号 int >=0
|
|
# role_type 角色职业 str
|
|
# role_sex 角色性别 int enum(0,1,2)
|
|
# role_race 角色种族 str
|
|
# role_camp 角色阵营 str
|
|
# last_login_time 最近上线时间 int >0
|
|
# union_id 公会id str
|
|
# union_name 公会名称 str
|
|
# combat_effectiveness 玩家战力 int >=0"""
|
|
#
|
|
# b = """_game_role_id 角色id str >0
|
|
# _platform 平台 str enum('ios','android')
|
|
# orderid 订单id str >0
|
|
# _event_time 事件时间 int >0
|
|
# _owner_name 发行 str >0
|
|
# money 金额 元 int >0
|
|
# _district_server_id 区服id int >0
|
|
# _first_device_id 注册设备id str >0
|
|
# role_level 角色等级 int >=0
|
|
# role_vip 角色vip int >=0
|
|
# _device_id 设备id str >0
|
|
# proid 计费点 str >0
|
|
# _channel_name 渠道名 str >0
|
|
# user_name 用户名 str >0
|
|
# role_stage 主线关卡 str >0
|
|
# _channel_uid 账号 str >0"""
|
|
#
|
|
# c = """_game_role_id 角色id str >0
|
|
# _device_id 设备id str >0
|
|
# _first_device_id 注册设备id str >0
|
|
# _channel_name 渠道名 str >0
|
|
# _channel_uid 账号 str >0
|
|
# _district_server_id 区服id int >0
|
|
# _owner_name 发行名 str >0
|
|
# role_create_time 角色创建时间 int >0
|
|
# role_level 角色等级 int >=0
|
|
# role_stage 主线关卡 str >0
|
|
# role_vip 角色vip int >=0
|
|
# _platform 平台 str enum('ios','android')
|
|
# _app_version app版本 str >0
|
|
# _game_version 游戏版本 str >0
|
|
# _app_name app名 str >0
|
|
# user_name 用户名 str >0
|
|
# role_diamonds 钻石数量 int >=0
|
|
# role_yxb 游戏币 int >=0
|
|
# _event_name 时间名 str >0
|
|
# _event_time 事件时间 int >0
|
|
# need 消耗 (如果有) list[dict,...] >0
|
|
# prize 奖励(如果有) list[dict,...] >0"""
|
|
#
|
|
# aa = set()
|
|
# bb = set()
|
|
# cc = set()
|
|
# for i in a.split('\n'):
|
|
# aa.add(i.split('\t')[0])
|
|
# for i in b.split('\n'):
|
|
# bb.add(i.split('\t')[0])
|
|
#
|
|
# for i in c.split('\n'):
|
|
# cc.add(i.split('\t')[0])
|
|
#
|
|
# dd = (aa & bb & cc)
|
|
# # print(aa - dd)
|
|
# # print(bb - dd)
|
|
# # print(cc - dd)
|