获取反馈列表接口的权限
This commit is contained in:
parent
9a7271cf83
commit
dd5533ab31
@ -20,7 +20,8 @@ pub async fn add_feedback(
|
|||||||
|
|
||||||
/// 获取反馈信息列表
|
/// 获取反馈信息列表
|
||||||
pub async fn get_feedback_list_by_page(
|
pub async fn get_feedback_list_by_page(
|
||||||
|
Extension(context): Extension<Context>,
|
||||||
Query(page_params): Query<PageParams>
|
Query(page_params): Query<PageParams>
|
||||||
) -> ResResult<ResData<Pageable<Feedback>>> {
|
) -> ResResult<ResData<Pageable<Feedback>>> {
|
||||||
service::feedback::get_feedback_list_by_page(page_params.page.unwrap(), page_params.page_size.unwrap()).await
|
service::feedback::get_feedback_list_by_page(context, page_params.page.unwrap(), page_params.page_size.unwrap()).await
|
||||||
}
|
}
|
@ -26,9 +26,9 @@ pub(crate) fn init() -> Router {
|
|||||||
post(controller::feedback::add_feedback)
|
post(controller::feedback::add_feedback)
|
||||||
.get(controller::feedback::get_feedback_list_by_page),
|
.get(controller::feedback::get_feedback_list_by_page),
|
||||||
)
|
)
|
||||||
/* .layer(axum::middleware::from_fn(
|
.layer(axum::middleware::from_fn(
|
||||||
library::middleware::req_ctx::authenticate_ctx,
|
library::middleware::req_ctx::authenticate_ctx,
|
||||||
)) */;
|
));
|
||||||
|
|
||||||
Router::new()
|
Router::new()
|
||||||
.nest("/", open)
|
.nest("/", open)
|
||||||
|
@ -5,9 +5,6 @@ use jsonwebtoken::{decode, DecodingKey, Validation};
|
|||||||
use crate::{cache::account_cache::LOGIN_CACHE, config, context::Context, token::Claims};
|
use crate::{cache::account_cache::LOGIN_CACHE, config, context::Context, token::Claims};
|
||||||
|
|
||||||
const WHITE_LIST: &[(&str, &str)] = &[
|
const WHITE_LIST: &[(&str, &str)] = &[
|
||||||
("GET", "/api/v1/users/:id"),
|
|
||||||
("POST", "/api/v1/orders"),
|
|
||||||
("GET", "/feedback"),
|
|
||||||
("POST", "/account/sys"),
|
("POST", "/account/sys"),
|
||||||
];
|
];
|
||||||
|
|
||||||
@ -15,6 +12,7 @@ pub async fn authenticate_ctx(mut req: Request, next: Next) -> Response {
|
|||||||
// 获取请求的url和method,然后判断是否在白名单中,如果在白名单中,则直接返回next(req),否则继续执行下面的代码
|
// 获取请求的url和method,然后判断是否在白名单中,如果在白名单中,则直接返回next(req),否则继续执行下面的代码
|
||||||
let method = req.method().clone().to_string();
|
let method = req.method().clone().to_string();
|
||||||
let uri = req.uri().path_and_query().unwrap().to_string();
|
let uri = req.uri().path_and_query().unwrap().to_string();
|
||||||
|
tracing::info!("method: {}, uri: {}", method, uri);
|
||||||
if WHITE_LIST.into_iter().find(|item| {
|
if WHITE_LIST.into_iter().find(|item| {
|
||||||
return item.0 == method && item.1 == uri;
|
return item.0 == method && item.1 == uri;
|
||||||
}).is_some() {
|
}).is_some() {
|
||||||
|
@ -6,7 +6,15 @@ use library::res::pageable::Pageable;
|
|||||||
use library::res::response::{ResData, ResResult};
|
use library::res::response::{ResData, ResResult};
|
||||||
|
|
||||||
/// 获取反馈信息列表
|
/// 获取反馈信息列表
|
||||||
pub async fn get_feedback_list_by_page(page: i64, page_size: i64) -> ResResult<ResData<Pageable<Feedback>>> {
|
pub async fn get_feedback_list_by_page(
|
||||||
|
context: Context,
|
||||||
|
page: i64,
|
||||||
|
page_size: i64
|
||||||
|
) -> ResResult<ResData<Pageable<Feedback>>> {
|
||||||
|
if !context.account.role.is_admin() {
|
||||||
|
tracing::error!("非管理员用户,无法获取反馈信息列表");
|
||||||
|
return Ok(ResData::some(Pageable::<Feedback>::empty()));
|
||||||
|
}
|
||||||
let feedback_list = Feedback::search_feedback(page, page_size, db!()).await.ok();
|
let feedback_list = Feedback::search_feedback(page, page_size, db!()).await.ok();
|
||||||
if feedback_list.is_none() {
|
if feedback_list.is_none() {
|
||||||
tracing::error!("反馈信息为空");
|
tracing::error!("反馈信息为空");
|
||||||
|
Loading…
Reference in New Issue
Block a user