Skip to content

xince-fun/douyin-zhgg

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

75 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GitHub go.mod Go version of a Go module Kitex Gorm MySQL Hertz

douyin-zhgg

参考课上所讲的 easy-note 做的结构。

项目文档

https://tlkl01qmcs.feishu.cn/docx/Ap3EdPNM9ofV0axcMyccuNpLnLd

项目结构图

等待补充....

目前文件结构树

├── LICENSE
├── README.md
├── cmd
│   ├── api
│   ├── comment
│   ├── favorite
│   ├── feed
│   ├── public
│   ├── relation
│   └── user
├── docker-compose.yml
├── go.mod
├── idl
│   ├── comment.thrift
│   ├── favorite.thrift
│   ├── feed.thrift
│   ├── public.thrift
│   ├── relation.thrift
│   └── user.thrift
├── kitex_gen
│   ├── comment
│   ├── favorite
│   ├── feed
│   ├── public
│   ├── relation
│   └── user
└── pkg
    ├── configs
    ├── consts
    └── errno

注意事项

  • 把数据访问全放在dal目录下

  • 错误生成在pkg/errno下,之后内容多的话可以把ErrcodeErr单独拎出来放在一个文件

  • 一些参数条件判断可以写在thrift文件中,在根目录中重新生成

kitex --thrift-plugin validator -module ByteTech-7815/douyin-zhgg idl/xx.thrift

这个在cmd/xx执行

kitex --thrift-plugin validator -module ByteTech-7815/douyin-zhgg -service xx -use ByteTech-7815/douyin-zhgg/kitex_gen ../../idl/xx.thrift

如果需要更新api.thrift

cmd/api下执行

hz update -mod ByteTech-7815/douyin-zhgg/cmd/api -idl ../../idl/api.thrift

包括内容

对内容有疑问可以直接看idl文件,里面写的比较清晰了。

base方向

  • user 用户注册、登录、信息等
  • feed流
  • publish 视频上传

互动接口

  • favorite 内容
  • comment 内容

社交接口

  • follow 内容
  • follower 内容
  • 暂未包括内容: friendUser 之后可以加入

开发注意

git clone [email protected]:XinceChan/douyin-zhgg.git

项目启动

1、更新依赖

go mod tidy

2、启动项目所依赖的环境

docker network create zhgg-dy_zhggdy_net
docker-compose up

补充 可以使用以下命令检查网络

docker network ls

3、启动服务 暂时还未补充

cd cmd/user
sh build.sh
sh output/bootstrap.sh
cd cmd/api
go run .

4、API Requests

推荐postman

小队邀请: https://app.getpostman.com/join-team?invite_code=50b3f99fbf2f8f2ce2c6ffe942688ff3&target_code=43549d582ad5959e2d665f4dfbbbcb1b

Register

{
    "username":"test1",
    "password":"testtest"
}
response
// successful
{
    "status_code": 0,
    "status_msg": "Success",
    "user_id": 6,
    "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6InRlc3QxIiwidXNlcl9pZCI6NiwiZXhwIjoxNjc1NTkyODg2fQ.yuAu2Ov-Eg0OgR-LTXtu8FAD9ybIRQdQ7EDhTT9Z7x8"
}
// failed
{
    "status_code": 10010,
    "status_msg": "User already exists",
    "data": null
}

Login

{
  "username":"test3",
  "password":"testtest"
}
response
// successfully
{
    "status_code": 0,
    "status_msg": "Success",
    "user_id": 8,
    "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE2NzU2MDcxOTIsImlkIjo4LCJvcmlnX2lhdCI6MTY3NTYwMzU5Mn0.-OnqilfucCUSwoQ-MuYfhesK1BtUzGEhTwhM1EzQagw"
}
// failed
{
    "status_code": 10012,
    "status_msg": "Authorization failed",
    "data": null
}

User Info

127.0.0.1:8080/douyin/user/?user_id=8
{
    "status_code": 0,
    "status_msg": "Success",
    "user": {
        "id": 8,
        "name": "test3",
        "follow_count": 0,
        "follower_count": 0,
        "is_follow": true
    }
}

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •