feat add tag
This commit is contained in:
@@ -11,7 +11,7 @@ use crate::model::db::tag::ActiveModel as TagActiveModel;
|
||||
use crate::model::db::tag::Column as TagColumn;
|
||||
use crate::model::db::tag::Model as TagModel;
|
||||
use crate::model::db::prelude::Tag;
|
||||
use crate::model::http_body::tag::{TagInfo, TagItem};
|
||||
use crate::model::http_body::tag::{TagInfo, TagResp};
|
||||
use crate::model::http_body::common::SimpleResponse;
|
||||
use crate::AppState;
|
||||
use sea_orm::sqlx::types::chrono::Local;
|
||||
@@ -31,7 +31,7 @@ pub fn get_nest_handlers() -> Router<crate::AppState> {
|
||||
async fn get_all_tags(
|
||||
state: State<AppState>,
|
||||
claims: Claims,
|
||||
) -> Result<Json<Vec<TagItem>>, (StatusCode, String)> {
|
||||
) -> Result<Json<Vec<TagResp>>, (StatusCode, String)> {
|
||||
let uid: i64 = claims.uid.clone();
|
||||
let all_tags = Tag::find()
|
||||
.filter(TagColumn::Uid.eq(uid))
|
||||
@@ -39,9 +39,9 @@ async fn get_all_tags(
|
||||
.await
|
||||
.map_err(|e| (StatusCode::INTERNAL_SERVER_ERROR, e.to_string()))?;
|
||||
|
||||
let mut tags: Vec<TagItem> = Vec::new();
|
||||
let mut tags: Vec<TagResp> = Vec::new();
|
||||
for b in all_tags {
|
||||
let tag_resp = TagItem {
|
||||
let tag_resp = TagResp {
|
||||
id: b.id.into(),
|
||||
name: b.name,
|
||||
};
|
||||
@@ -55,7 +55,7 @@ async fn get_tag_by_id(
|
||||
Path(id): Path<i64>,
|
||||
state: State<AppState>,
|
||||
claims: Claims,
|
||||
) -> Result<Json<TagItem>, (StatusCode, String)> {
|
||||
) -> Result<Json<TagResp>, (StatusCode, String)> {
|
||||
let uid: i64 = claims.uid.clone();
|
||||
let tag_query = Tag::find()
|
||||
.filter(TagColumn::Uid.eq(uid))
|
||||
@@ -64,10 +64,10 @@ async fn get_tag_by_id(
|
||||
.await
|
||||
.map_err(|e| (StatusCode::INTERNAL_SERVER_ERROR, e.to_string()))?;
|
||||
|
||||
let tag_resp: TagItem;
|
||||
let tag_resp: TagResp;
|
||||
match tag_query {
|
||||
Some(b) => {
|
||||
tag_resp = TagItem {
|
||||
tag_resp = TagResp {
|
||||
id: b.id.into(),
|
||||
name: b.name,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user