Git Product home page Git Product logo

blog-admin's Introduction

typescript + koa2 + koa-swagger-decorator + mysql

个人博客的后台api系统

  • 前后台分离式开发(当前为后台仓库)。

LICENSE  996.icu

实现功能

  • RESTful api 实现
  • swagger接口文档实现
  • websocket实现

技术栈

  • typescript + koa2 + mysql + koa-swagger-decorator
  • joi dayjs koa2-cors koa-helmet jsonwebtoken

博客预览

pc 端管理系统页面

swagger接口文档页面

项目结构

目录结构

.

├─public                // 公共资源
├─src                   // 代码入口文件
├─static                // 后台静态文件目录
└─src
   ├─conf               // 配置目录
   ├─controller         // controller目录
   ├─middleware         // 中间件目录
   ├─types              // 数据类型
   ├─router             // 路由目录
   ├─lib                // 工具方法目录
   ├─server.ts          // 启动文件
   └─lib
       ├─schemas        // 校验目录
       ├─utils          // 工具目录
       └─statement      // 数据库语句目录

表结构

文章表

CREATE TABLE  IF NOT EXISTS `article_info` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `title` varchar(255) DEFAULT NULL,
  `categories` varchar(255) DEFAULT NULL,
  `tagIds` varchar(255) DEFAULT NULL,
  `userId` int(11) DEFAULT 1,
  `createTime` varchar(50) DEFAULT NULL,
  `updateTime` varchar(50) DEFAULT NULL,
  `content` longtext DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

文章评论表

CREATE TABLE  IF NOT EXISTS `article_comment` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `articleId` int(11) DEFAULT NULL COMMENT '文章Id',
  `userId` int(11) DEFAULT NULL COMMENT '评论人',
  `content` longtext DEFAULT NULL COMMENT '评论内容',
  `createTime` varchar(50) DEFAULT NULL COMMENT '创建时间',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

文章评论回复表

CREATE TABLE  IF NOT EXISTS `article_reply` (
 `id` int(11) NOT NULL AUTO_INCREMENT,
  `commentId` int(11) NULL DEFAULT NULL COMMENT '文章评论id',
  `replyWay` int(11) NULL DEFAULT NULL COMMENT '回复方式(10: 回复他人评论, 20:回复别人的回复)',
  `replyId` int(11) NULL DEFAULT NULL COMMENT '回复目标id(replyWay为10时为commentId,replyWay为20时为replyId)',
  `userId` int(11) NULL DEFAULT NULL COMMENT '评论用户id',
  `toUserId` int(11) NULL DEFAULT NULL COMMENT '回复用户id',
  `content` longtext CHARACTER SET utf8 COLLATE utf8_general_ci NULL COMMENT '回复内容',
  `type` int(11) NULL DEFAULT NULL COMMENT '回复类型(10:点赞,20:踩,  30: 文字回复)',
  `createTime` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '创建时间',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

目录表

CREATE TABLE  IF NOT EXISTS `category_info` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(255) DEFAULT NULL,
  `userId` int(11) DEFAULT 1,
  `updateTime` varchar(50) DEFAULT NULL,
  `createTime` varchar(50) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

标签

CREATE TABLE  IF NOT EXISTS `tag_info` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(255) DEFAULT NULL,
  `userId` int(11) DEFAULT 1,
  `color` varchar(20) DEFAULT NULL,
  `updateTime` varchar(50) DEFAULT NULL,
  `createTime` varchar(50) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

收发关系表

CREATE TABLE  IF NOT EXISTS `message` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `sendId` int(11) DEFAULT NULL COMMENT '发送人id',
  `recId` int(11) DEFAULT NULL COMMENT '接收人id(recId为0时为全部用户)',
  `messageId` int(11) DEFAULT NULL COMMENT 'message内容id',
  `createDate` varchar(50) DEFAULT NULL COMMENT '发送日期',
   PRIMARY KEY (`id`)
)  ENGINE=InnoDB DEFAULT CHARSET=utf8;

发送消息表

CREATE TABLE  IF NOT EXISTS `message_content` (
   `id` int(11) NOT NULL AUTO_INCREMENT,
  `type` int(11) NULL DEFAULT NULL COMMENT '10: 文章评论 20:文章评论回复(业务可扩展)',
  `title` varchar(255) DEFAULT NULL COMMENT '评论主题',
  `sourceId` int(11) NULL DEFAULT NULL COMMENT '评论源id',
  `content` longtext DEFAULT NULL COMMENT '内容',
  `createDate` varchar(50) DEFAULT NULL COMMENT '发送日期',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

用户消息关系表

CREATE TABLE  IF NOT EXISTS `message_user` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `userId` int(11) DEFAULT NULL COMMENT '用户id',
  `messageId` int(11) DEFAULT NULL COMMENT '信息id',
  `status` int(11) NULL DEFAULT 10 COMMENT '(10:已阅读)',
  `createDate` varchar(50) DEFAULT NULL COMMENT '阅读日期',
   PRIMARY KEY (`id`)
)  ENGINE=InnoDB DEFAULT CHARSET=utf8;

使用这个项目

git https://github.com/paul-wj/blog-amdin.git

## 安装依赖以及开启开发模式
cd blog-amdin
npm install
npm run watch-server

PS : 觉得不错的伙伴可以给个 star ~~~ 或者 fork 下来看看哦。如果有什么建议,也可以提 issue 哦

blog-admin's People

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.