From bc2df1e0b7e92f004206a6a3bcef6968edd6d1b4 Mon Sep 17 00:00:00 2001 From: heqingpan Date: Fri, 8 Dec 2023 00:29:17 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E6=8E=A7=E5=88=B6=E5=8F=B0?= =?UTF-8?q?=E5=88=86=E9=A1=B5=E6=9F=A5=E8=AF=A2=E7=94=A8=E6=88=B7=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E6=8E=A5=E5=8F=A3=E5=85=A5=E5=8F=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/console/model/user_model.rs | 14 +++++++++++--- src/console/user_api.rs | 9 +++++---- src/user/model.rs | 4 +++- 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/src/console/model/user_model.rs b/src/console/model/user_model.rs index a6b92f13..3865af15 100644 --- a/src/console/model/user_model.rs +++ b/src/console/model/user_model.rs @@ -11,9 +11,17 @@ pub struct UserInfo { #[derive(Debug, Deserialize, Serialize)] #[serde(rename_all = "camelCase")] -pub struct PageParams { +pub struct UserPageParams { pub like_username: Option, - pub offset: Option, - pub limit: Option, pub is_rev: Option, + pub page_no: Option, + pub page_size: Option, +} + +impl UserPageParams { + pub fn get_limit_info(&self) -> (usize, usize) { + let limit = self.page_size.unwrap_or(0xffff_ffff); + let offset = (self.page_no.unwrap_or(1) - 1) * limit; + (limit, offset) + } } diff --git a/src/console/user_api.rs b/src/console/user_api.rs index e2a7205a..7e624a2f 100644 --- a/src/console/user_api.rs +++ b/src/console/user_api.rs @@ -15,7 +15,7 @@ use crate::{ user::{model::UserDto, UserManagerReq, UserManagerResult}, }; -use super::model::user_model::PageParams; +use super::model::user_model::UserPageParams; #[derive(Debug, Deserialize, Serialize)] #[serde(rename_all = "camelCase")] @@ -81,12 +81,13 @@ pub async fn reset_password( pub async fn get_user_page_list( app: Data>, - web::Query(param): web::Query, + web::Query(param): web::Query, ) -> actix_web::Result { + let (limit, offset) = param.get_limit_info(); let msg = UserManagerReq::QueryPageList { like_username: param.like_username, - offset: param.offset, - limit: param.limit, + offset: Some(offset as i64), + limit: Some(limit as i64), is_rev: param.is_rev.unwrap_or_default(), }; match app.user_manager.send(msg).await.unwrap().unwrap() { diff --git a/src/user/model.rs b/src/user/model.rs index 6388ecee..c141025f 100644 --- a/src/user/model.rs +++ b/src/user/model.rs @@ -59,7 +59,9 @@ impl From for UserDto { Self { username: Arc::new(value.username), nickname: Some(value.nickname), - password: Some(value.password), + //password: Some(value.password), + //不直接返回密码 + password: None, gmt_create: Some(value.gmt_create as i64 * 1000), gmt_modified: Some(value.gmt_modified as i64 * 1000), enable: Some(value.enable),