Skip to content

Commit 11f36ee

Browse files
committed
🚧 编制了一部分业务路由,并为此提前建立了暂行的请求数据结构。
位于 `_utils::models` 下的数据结构,在确认所有路由建立完毕后,需要删掉用不上的部分。
1 parent 08aba4d commit 11f36ee

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+1236
-138
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
use anyhow::Result;
2+
3+
use _utils::models::AreaAddRequest;
4+
use axum::{extract::Json, http::StatusCode, response::IntoResponse};
5+
6+
use crate::middlewares::ExtractAuthInfo;
7+
8+
/// 新增地区
9+
/// PUT /area/add
10+
/// 返回新增地区ID
11+
#[tracing::instrument(skip_all)]
12+
pub async fn add(
13+
ExtractAuthInfo(auth): ExtractAuthInfo,
14+
Json(payload): Json<AreaAddRequest>,
15+
) -> Result<impl IntoResponse, (StatusCode, String)> {
16+
Ok(())
17+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
use anyhow::Result;
2+
3+
use axum::{extract::Path, http::StatusCode, response::IntoResponse};
4+
5+
use crate::middlewares::ExtractAuthInfo;
6+
7+
/// 删除地区
8+
/// DELETE /area/{areaId}
9+
/// 此操作会递归删除,请在前端做二次确认
10+
/// 此操作会把该地区和所属的所有子地区的物品和点位删除
11+
/// 如果点位还属于其他地区的物品,那么这个点位将被保留
12+
#[tracing::instrument(skip_all)]
13+
pub async fn delete(
14+
ExtractAuthInfo(auth): ExtractAuthInfo,
15+
Path(area_id): Path<i64>,
16+
) -> Result<impl IntoResponse, (StatusCode, String)> {
17+
Ok(())
18+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
use anyhow::Result;
2+
3+
use axum::{extract::Path, http::StatusCode, response::IntoResponse};
4+
5+
use crate::middlewares::ExtractAuthInfo;
6+
7+
/// 获取单个地区信息
8+
/// POST /area/get/{areaId}
9+
#[tracing::instrument(skip_all)]
10+
pub async fn get(
11+
ExtractAuthInfo(auth): ExtractAuthInfo,
12+
Path(area_id): Path<i64>,
13+
) -> Result<impl IntoResponse, (StatusCode, String)> {
14+
Ok(())
15+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
use anyhow::Result;
2+
3+
use axum::{extract::Json, http::StatusCode, response::IntoResponse};
4+
use _utils::models::AreaListRequest;
5+
6+
use crate::middlewares::ExtractAuthInfo;
7+
8+
/// 列出地区
9+
/// POST /area/get/list
10+
/// 可根据父级地区id列出子地区列表
11+
#[tracing::instrument(skip_all)]
12+
pub async fn list(
13+
ExtractAuthInfo(auth): ExtractAuthInfo,
14+
Json(payload): Json<AreaListRequest>,
15+
) -> Result<impl IntoResponse, (StatusCode, String)> {
16+
Ok(())
17+
}
Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,23 @@
1+
mod add;
2+
mod delete;
3+
mod get;
4+
mod list;
5+
mod update;
6+
17
use anyhow::Result;
28

3-
use axum::Router;
9+
use axum::{
10+
routing::{delete, post, put},
11+
Router,
12+
};
413

514
pub async fn router() -> Result<Router> {
6-
let ret = Router::new();
15+
let ret = Router::new()
16+
.route("/get/list", post(list::list))
17+
.route("/get/:area_id", post(get::get))
18+
.route("/add", put(add::add))
19+
.route("/update", post(update::update))
20+
.route("/:area_id", delete(delete::delete));
721

822
Ok(ret)
923
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
use anyhow::Result;
2+
3+
use _utils::models::AreaUpdateRequest;
4+
use axum::{extract::Json, http::StatusCode, response::IntoResponse};
5+
6+
use crate::middlewares::ExtractAuthInfo;
7+
8+
/// 修改地区
9+
/// POST /area/update
10+
#[tracing::instrument(skip_all)]
11+
pub async fn update(
12+
ExtractAuthInfo(auth): ExtractAuthInfo,
13+
Json(payload): Json<AreaUpdateRequest>,
14+
) -> Result<impl IntoResponse, (StatusCode, String)> {
15+
Ok(())
16+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
use anyhow::Result;
2+
3+
use axum::{extract::Json, http::StatusCode, response::IntoResponse};
4+
5+
use crate::middlewares::ExtractAuthInfo;
6+
use _utils::models::icon::IconAddRequest;
7+
8+
/// 新增图标
9+
/// 无需指定icon的id,id由系统自动生成并在响应中返回
10+
/// 一组name和creator需要唯一(允许单一重复)
11+
/// PUT /icon/add
12+
#[tracing::instrument(skip_all)]
13+
pub async fn add(
14+
ExtractAuthInfo(auth): ExtractAuthInfo,
15+
Json(payload): Json<IconAddRequest>,
16+
) -> Result<impl IntoResponse, (StatusCode, String)> {
17+
Ok(())
18+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
use anyhow::Result;
2+
3+
use axum::{
4+
extract::Path,
5+
http::StatusCode,
6+
response::IntoResponse,
7+
};
8+
9+
use crate::middlewares::ExtractAuthInfo;
10+
11+
/// 删除图标
12+
/// DELETE /icon/delete/{iconId}
13+
#[tracing::instrument(skip_all)]
14+
pub async fn delete(
15+
ExtractAuthInfo(auth): ExtractAuthInfo,
16+
Path(icon_id): Path<i64>,
17+
) -> Result<impl IntoResponse, (StatusCode, String)> {
18+
Ok(())
19+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
use anyhow::Result;
2+
3+
use axum::{extract::Path, http::StatusCode, response::IntoResponse};
4+
5+
use crate::middlewares::ExtractAuthInfo;
6+
7+
/// 获取单个图标信息
8+
/// POST /icon/get/single/{iconId}
9+
#[tracing::instrument(skip_all)]
10+
pub async fn get_single(
11+
ExtractAuthInfo(auth): ExtractAuthInfo,
12+
Path(icon_id): Path<i64>,
13+
) -> Result<impl IntoResponse, (StatusCode, String)> {
14+
Ok(())
15+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
use anyhow::Result;
2+
3+
use axum::{extract::Json, http::StatusCode, response::IntoResponse};
4+
5+
use crate::middlewares::ExtractAuthInfo;
6+
use _utils::models::icon::IconListRequest;
7+
8+
/// 列出图标
9+
/// 可按照分类(分类需保证为末端分类)和上传者进行查询,也可根据ID批量查询,可分页
10+
/// POST /icon/get/list
11+
#[tracing::instrument(skip_all)]
12+
pub async fn list(
13+
ExtractAuthInfo(auth): ExtractAuthInfo,
14+
Json(payload): Json<IconListRequest>,
15+
) -> Result<impl IntoResponse, (StatusCode, String)> {
16+
Ok(())
17+
}

0 commit comments

Comments
 (0)