修改用户注册接口请求参数
This commit is contained in:
parent
ad6ede61d7
commit
3c09789a2c
@ -3,14 +3,14 @@ use validator::Validate;
|
|||||||
|
|
||||||
#[derive(Debug, Validate, Deserialize, Serialize)]
|
#[derive(Debug, Validate, Deserialize, Serialize)]
|
||||||
pub struct GameAccountCreate {
|
pub struct GameAccountCreate {
|
||||||
#[validate(length(min = 1, message = "用户名称不能为空"))]
|
#[validate(required(message = "用户名称不能为空"), length(min = 1, message = "用户名称不能为空"))]
|
||||||
pub username: String,
|
pub username: Option<String>,
|
||||||
#[validate(length(min = 1, message = "电子邮箱不能为空"))]
|
#[validate(required, length(min = 1, message = "电子邮箱不能为空"))]
|
||||||
pub email: String,
|
pub email: Option<String>,
|
||||||
#[validate(length(min = 1, message = "平台ID不能为空"))]
|
#[validate(required, length(min = 1, message = "平台ID不能为空"))]
|
||||||
pub platform_id: String,
|
pub platform_id: Option<String>,
|
||||||
#[validate(length(min = 1, message = "用户类型不能为空"))]
|
#[validate(required, length(min = 1, message = "用户类型不能为空"))]
|
||||||
pub user_type: String,
|
pub user_type: Option<String>,
|
||||||
#[validate(length(min = 1, message = "用户所属区域不能为空"))]
|
#[validate(required, length(min = 1, message = "用户所属区域不能为空"))]
|
||||||
pub country_code: String,
|
pub country_code: Option<String>,
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@ use sea_orm::{ColumnTrait, EntityTrait, PaginatorTrait, QueryFilter, Set};
|
|||||||
|
|
||||||
pub async fn create(req: GameAccountCreate) -> ResResult<ResOK<()>> {
|
pub async fn create(req: GameAccountCreate) -> ResResult<ResOK<()>> {
|
||||||
match GameAccount::find()
|
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!())
|
.count(db!())
|
||||||
.await
|
.await
|
||||||
{
|
{
|
||||||
@ -26,11 +26,11 @@ pub async fn create(req: GameAccountCreate) -> ResResult<ResOK<()>> {
|
|||||||
let now = chrono::Local::now().naive_local();
|
let now = chrono::Local::now().naive_local();
|
||||||
|
|
||||||
let model = game_account::ActiveModel {
|
let model = game_account::ActiveModel {
|
||||||
username: Set(req.username),
|
username: Set(req.username.unwrap()),
|
||||||
email: Set(Option::from(req.email)),
|
email: Set(Option::from(req.email)),
|
||||||
platform_id: Set(req.platform_id),
|
platform_id: Set(req.platform_id.unwrap()),
|
||||||
user_type: Set(req.user_type),
|
user_type: Set(req.user_type.unwrap()),
|
||||||
country_code: Set(req.country_code),
|
country_code: Set(req.country_code.unwrap()),
|
||||||
created_at: Set(now),
|
created_at: Set(now),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user