Skip to content
sunjvhuiPublic

About

gin项目练习

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

7 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

此项目为gin框架接口练习

安装golang

配置环境


创建数据库

数据库名blog 编码为utf8_general_ci

在数据库下

创建表

1,标签表

CREATE TABLE blog_tag(idint(10) unsigned NOT NULL AUTO_INCREMENT,namevarchar(100) DEFAULT '' COMMENT '标签名称',created_onint(10) unsigned DEFAULT '0' COMMENT '创建时间',created_byvarchar(100) DEFAULT '' COMMENT '创建人',modified_onint(10) unsigned DEFAULT '0' COMMENT '修改时间',modified_byvarchar(100) DEFAULT '' COMMENT '修改人',state tinyint(3) unsigned DEFAULT '1' COMMENT '状态 0为禁用、1为启用', PRIMARY KEY (id) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='文章标签管理';

2,文章表

CREATE TABLE blog_article(idint(10) unsigned NOT NULL AUTO_INCREMENT,tag_idint(10) unsigned DEFAULT '0' COMMENT '标签ID',titlevarchar(100) DEFAULT '' COMMENT '文章标题',descvarchar(255) DEFAULT '' COMMENT '简述',contenttext,created_onint(11) DEFAULT NULL,created_byvarchar(100) DEFAULT '' COMMENT '创建人',modified_onint(10) unsigned DEFAULT '0' COMMENT '修改时间',modified_byvarchar(255) DEFAULT '' COMMENT '修改人',state tinyint(3) unsigned DEFAULT '1' COMMENT '状态 0为禁用1为启用', PRIMARY KEY (id) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='文章管理';

3,认证表

CREATE TABLE blog_auth(idint(10) unsigned NOT NULL AUTO_INCREMENT,usernamevarchar(50) DEFAULT '' COMMENT '账号',password varchar(50) DEFAULT '' COMMENT '密码', PRIMARY KEY (id) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; INSERT INTO blog.blog_auth (id, username, password) VALUES (null, 'test', 'test123456');

拉取代码

go build

验证功能

用Postman

PUT:http://127.0.0.1:8000/api/v1/tags/1?name=edit1&state=0&modified_by=edit1,查看code是否返回200

DELETE:http://127.0.0.1:8000/api/v1/tags/1,查看code是否返回200

POST:http://127.0.0.1:8000/api/v1/articles?tag_id=1&title=test1&desc=test-desc&content=test-content&created_by=test-created&state=1

GET:http://127.0.0.1:8000/api/v1/articles

GET:http://127.0.0.1:8000/api/v1/articles/1

PUT:http://127.0.0.1:8000/api/v1/articles/1?tag_id=1&title=test-edit1&desc=test-desc-edit&content=test-content-edit&modified_by=test-created-edit&state=0

DELETE:http://127.0.0.1:8000/api/v1/articles/1

About

gin项目练习

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages

⌂ 换网址