修改用户注册接口请求参数

This commit is contained in:
李运家 2024-04-11 11:14:26 +08:00
parent ad6ede61d7
commit 3c09789a2c
2 changed files with 15 additions and 15 deletions

View File

@ -3,14 +3,14 @@ use validator::Validate;
#[derive(Debug, Validate, Deserialize, Serialize)]
pub struct GameAccountCreate {
#[validate(length(min = 1, message = "用户名称不能为空"))]
pub username: String,
#[validate(length(min = 1, message = "电子邮箱不能为空"))]
pub email: String,
#[validate(length(min = 1, message = "平台ID不能为空"))]
pub platform_id: String,
#[validate(length(min = 1, message = "用户类型不能为空"))]
pub user_type: String,
#[validate(length(min = 1, message = "用户所属区域不能为空"))]
pub country_code: String,
#[validate(required(message = "用户名称不能为空"), length(min = 1, message = "用户名称不能为空"))]
pub username: Option<String>,
#[validate(required, length(min = 1, message = "电子邮箱不能为空"))]
pub email: Option<String>,
#[validate(required, length(min = 1, message = "平台ID不能为空"))]
pub platform_id: Option<String>,
#[validate(required, length(min = 1, message = "用户类型不能为空"))]
pub user_type: Option<String>,
#[validate(required, length(min = 1, message = "用户所属区域不能为空"))]
pub country_code: Option<String>,
}

View File

@ -8,7 +8,7 @@ use sea_orm::{ColumnTrait, EntityTrait, PaginatorTrait, QueryFilter, Set};
pub async fn create(req: GameAccountCreate) -> ResResult<ResOK<()>> {
match GameAccount::find()
.filter(game_account::Column::PlatformId.eq(req.platform_id.clone()))
.filter(game_account::Column::PlatformId.eq(req.platform_id.clone().unwrap()))
.count(db!())
.await
{
@ -26,11 +26,11 @@ pub async fn create(req: GameAccountCreate) -> ResResult<ResOK<()>> {
let now = chrono::Local::now().naive_local();
let model = game_account::ActiveModel {
username: Set(req.username),
username: Set(req.username.unwrap()),
email: Set(Option::from(req.email)),
platform_id: Set(req.platform_id),
user_type: Set(req.user_type),
country_code: Set(req.country_code),
platform_id: Set(req.platform_id.unwrap()),
user_type: Set(req.user_type.unwrap()),
country_code: Set(req.country_code.unwrap()),
created_at: Set(now),
..Default::default()
};