first commit

This commit is contained in:
编码猿
2024-09-27 02:06:13 +08:00
commit 852d94fbb9
36760 changed files with 3274413 additions and 0 deletions

View File

@@ -0,0 +1,107 @@
import { JsonController, Authorized, Body, HeaderParam, Get, Post, UseBefore, QueryParam} from 'routing-controllers';
import { RequestLog } from '@/middleware/requestLog'
import { Inject, Service } from 'typedi';
import { ArticleServiceImpl } from '@/impl/ArticleServiceImpl';
import { JsonResult, msgList, res } from '@/utils/jsonResult';
import { User } from '@/m_res/user'
import {CommentParams } from "@/model/request/Comment";
import config from '@/config'
import { Token } from '@/m_req/Token'
@Service()
@JsonController(config.setPrefix("app/article"))
export class ArticleController {
@Inject()
articleServiceImpl!: ArticleServiceImpl;
@Inject()
json!: JsonResult<any>;
/**
* @api {get} /app/user/info/:id info
* @apiDescription 获取用户的详细信息
* @apiName info
* @apiGroup user
* @apiParam {number} id 用户的id参数
*
* @apiSuccess {Object} data 用户数据存放在data内部
* @apiSuccess {Number} data.user_id 用户id
* @apiSuccess {String} data.user_name 用户名
* @apiSuccess {String} data.user_pwd 用户密码
* @apiSuccess {Number} data.user_phone 用户手机号
* @apiSuccess {String} data.user_img 用户头像
* @apiSuccess {String} data.user_addtime 注册时间
* @apiSuccessExample {json} 请求成功的返回:
* {
* "code" : 200,
* "msg" : "请求成功"
* "data" : {
* user_id: 1,
* user_name: "bmy",
* user_pwd: "714500",
* user_phone: 15056042604,
* user_img: "https://www.baidu.com/img/flexible/logo/pc/result@2.png",
* user_addtime: "2023-06-03T12:25:16.000Z"
* }
* }
* @apiErrorExample {json} 请求失败的返回
* {
* "code": 200,
* "msg" : "请求成功"
* "data": null
* }
* @apiSampleRequest http://127.0.0.1:3000/app/user/info
*/
@Get('/articleList')
@UseBefore(RequestLog)
async GetArticleList(@QueryParam("text") text: string) {
return await this.articleServiceImpl.GetArticleList(text);
}
@Get('/info')
@UseBefore(RequestLog)
async GetArticleInfo(@QueryParam("id") id: number) {
return await this.articleServiceImpl.GetArticleInfo(id);
}
@Get('/categories_list')
@UseBefore(RequestLog)
async GetCategoriesList() {
return await this.articleServiceImpl.GetCategoriesList();
}
//标签接口
@Get('/tagList')
@UseBefore(RequestLog)
async GetTagListDao() {
return await this.articleServiceImpl.GetTagListDao();
}
@Get('/categories_info')
@UseBefore(RequestLog)
async GetCategoriesInfo(@QueryParam("id") id: number) {
return await this.articleServiceImpl.GetCategoriesInfo(id);
}
@Get('/search')
@UseBefore(RequestLog)
async Getsearch(@QueryParam("word") word: string) {
return await this.articleServiceImpl.GetSearch(word);
}
@Post('/push_comment')
@UseBefore(RequestLog)
@Authorized()
async PushComment(@Body() params: CommentParams,
@HeaderParam("token") token: Token) {
return await this.articleServiceImpl.pushComment(params, token);
}
}

View File

@@ -0,0 +1,28 @@
import { JsonController, Authorized, Body, HeaderParam, Get, Post, UseBefore, QueryParam} from 'routing-controllers';
import { RequestLog } from '@/middleware/requestLog'
import { Inject, Service } from 'typedi';
import { LinkServiceImpl } from '@/impl/LinkServiceImpl';
import { JsonResult, msgList, res } from '@/utils/jsonResult';
import { User } from '@/m_res/user'
import {CommentParams } from "@/model/request/Comment";
import config from '@/config'
import { Token } from '@/m_req/Token'
@Service()
@JsonController(config.setPrefix("app/link"))
export class ArticleController {
@Inject()
linkServiceImpl!: LinkServiceImpl;
@Inject()
json!: JsonResult<any>;
@Get('/list')
@UseBefore(RequestLog)
async LinkList() {
return this.linkServiceImpl.GetAllLink();
}
}

View File

@@ -0,0 +1,74 @@
import { JsonController, Authorized, Body, HeaderParam, Get, Post, UseBefore, UseInterceptor} from 'routing-controllers';
import { getOneUser, addUser } from '@/m_req/User'
import { RequestLog } from '@/middleware/requestLog'
import { Inject, Service } from 'typedi';
import { UserServiceImpl } from '@/impl/userServiceImpl';
import { JsonResult, msgList, res } from '@/utils/jsonResult';
import { User } from '@/m_res/user'
import { Token } from '@/m_req/Token'
import config from '@/config'
@Service()
@JsonController(config.setPrefix("app/user"))
export class UserController {
@Inject()
userServiceImpl!: UserServiceImpl;
@Inject()
json!: JsonResult<any>;
/**
* @api {get} /app/user/info/:id info
* @apiDescription 获取用户的详细信息
* @apiName info
* @apiGroup user
* @apiParam {number} id 用户的id参数
*
* @apiSuccess {Object} data 用户数据存放在data内部
* @apiSuccess {Number} data.user_id 用户id
* @apiSuccess {String} data.user_name 用户名
* @apiSuccess {Number} data.user_phone 用户手机号
* @apiSuccess {String} data.user_img 用户头像
* @apiSuccess {String} data.user_addtime 注册时间
* @apiSuccessExample {json} 请求成功的返回:
* {
* "code" : 200,
* "msg" : "请求成功"
* "data" : {
* user_id: 1,
* user_name: "bmy",
* user_phone: 15056042604,
* user_img: "https://www.baidu.com/img/flexible/logo/pc/result@2.png",
* user_addtime: "2023-06-03T12:25:16.000Z"
* }
* }
* @apiErrorExample {json} 请求失败的返回
* {
* "code": 200,
* "msg" : "请求成功"
* "data": null
* }
* @apiSampleRequest http://127.0.0.1:3000/app/user/info
*/
@Post('/info')
@UseBefore(RequestLog)
@Authorized()
async getOneUser(@HeaderParam("token") token: Token): Promise<res<User | null>>{
return await this.userServiceImpl.GetOneUser(token.user_id);
}
@Post('/add')
@UseBefore(RequestLog)
async add(@Body() params: addUser): Promise<res<null>> {
return await this.userServiceImpl.addUser(params);
}
@Post('/login')
@UseBefore(RequestLog)
async Login(@Body() params: addUser): Promise<res<User | null>> {
return await this.userServiceImpl.Login(params);
}
}