change project structure

pull/14/head
ROC 3 years ago
parent bb04f38c8d
commit 8fde76d8ec

3
.gitattributes vendored

@ -1,3 +1,4 @@
*.js linguist-language=go
*.css linguist-language=go
*.vue linguist-language=go
*.json linguist-language=go
*.html linguist-language=go

@ -1,58 +1,128 @@
# PaoPao CE
<div id="top"></div>
官网 https://www.paopao.info
## 1. 代码说明
<!-- PROJECT SHIELDS -->
[![Forks][forks-shield]][forks-url]
[![Stargazers][stars-shield]][stars-url]
[![MIT License][license-shield]][license-url]
[![Contributors][contributors-shield]][contributors-url]
[![Issues][issues-shield]][issues-url]
- paopao-api 泡泡后端
- paopao-web 泡泡前端
<!-- PROJECT LOGO -->
<div align="center">
<a href="https://github.com/rocboss/paopao-ce">
<img src="https://assets.paopao.info/public/image/21/b6/e5/b8/5ca3-48cd-96cd-27e76cb70823.png" alt="Logo" width="80" height="80">
</a>
## 2. 安装说明
<h3 align="center">PaoPao</h3>
- 需要提前安装Go(>=1.17)、Node.js(>=14)、MySQL(>=5.7)、Redis环境
<p align="center">
🔥一个清新文艺的微社区
<br />
<a href="https://www.paopao.info/">View Demo</a>
·
<a href="https://github.com/rocboss/paopao-ce/issues">Report Bug</a>
·
<a href="https://www.rocs.me/archives/paopao.html">Features</a>
</p>
</div>
- 需要安装 Zinc (轻量级全文搜索引擎),可以查阅 https://zincsearch.com/ 安装
### 2.1 paopao-api 后端服务
- 导入 `paopao-api` 目录下的`paopao.sql`文件至数据库
## 1. 截图预览
- 拷贝 config.yaml.sample 文件至 config.yaml然后按照注释完成配置修改
[![明色主题][product-light-screenshot]](https://www.paopao.info)
```
cd 项目根目录/paopao-api
go mod download
go build .
```
编译成功后,将产出 `paopao-api` 二进制文件,运行:
[![暗色主题][product-dark-screenshot]](https://www.paopao.info)
```
chmod +x paopao-api
./paopao-api
```
更多演示请前往[官网](https://www.paopao.info)体验(谢绝灌水)
即可正常启动
<p align="right">(<a href="#top">back to top</a>)</p>
<!-- GETTING STARTED -->
## 2. 快速开始
### 2.2 paopao-web 前端服务
### 2.1 技术栈
编译前需要修改 .env里面的后端地址
PaoPao主要由以下优秀的开源项目/工具构建
```
cd 项目根目录/paopao-web
vim .env
yarn
yarn build
```
build完成后可以在dist目录获取编译产出配置nginx指向至该目录即可
* [Go](https://go.dev/)
* [Gin](https://gin-gonic.com/)
* [Zinc](https://zinclabs.io/)
* [Naive UI](https://www.naiveui.com/)
* [Vue.js](https://vuejs.org/)
* [Vite.js](https://vitejs.dev/)
## 3. 其他
### 2.2 环境要求
后端服务建议使用 supervisor 守护进程然后通过nginx反向代理
- Go (1.17+)
- Node.js (14+)
- MySQL (5.7+)
- Redis
- Zinc
短信通道使用的juhe数据如果申请不下来可以考虑替换其他服务商的
\* Zinc是一款轻量级全文搜索引擎可以查阅 https://zincsearch.com/ 安装
以上环境版本为PaoPao官方的开发版本仅供参考其他版本的环境未进行测试
<br />
### 3. 安装说明
克隆代码库
```sh
git clone https://github.com/rocboss/paopao-ce.git
```
#### 3.1 后端
1. 导入项目根目录下的 `paopao.sql` 文件至MySQL数据库
2. 拷贝项目根目录下 `config.yaml.sample` 文件至 `config.yaml`,按照注释完成配置编辑
3. 编译后端
```sh
go mod download
go build .
```
4. 启动后端
```sh
chmod +x paopao-api
./paopao-api
```
代码结构比较简单喜欢的朋友欢迎贡献PR。
#### 3.2 前端
1. 进入前端目录 `paopao-web`,编辑 `.env` 文件中后端服务地址,下载依赖包
```sh
cd 项目根目录/paopao-web
vim .env
yarn
```
2. 编译前端
```sh
yarn build
```
build完成后可以在dist目录获取编译产出配置nginx指向至该目录即可
#### 3.3 其他
建议后端服务使用 `supervisor` 守护进程并通过nginx反向代理后提供API给前端服务调用。
短信通道使用的juhe数据如果申请不下来可以考虑替换其他服务商的
代码结构比较简单喜欢的朋友欢迎给个Star、贡献PR。
<!-- MARKDOWN LINKS & IMAGES -->
[contributors-shield]: https://img.shields.io/github/contributors/rocboss/paopao-ce?style=flat
[contributors-url]: https://github.com/rocboss/paopao-ce/graphs/contributors
[forks-shield]: https://img.shields.io/github/forks/rocboss/paopao-ce?style=flat
[forks-url]: https://github.com/rocboss/paopao-ce/network/members
[stars-shield]: https://img.shields.io/github/stars/rocboss/paopao-ce.svg?style=flat
[stars-url]: https://github.com/rocboss/paopao-ce/stargazers
[issues-shield]: https://img.shields.io/github/issues/rocboss/paopao-ce.svg?style=flat
[issues-url]: https://github.com/rocboss/paopao-ce/issues
[license-shield]: https://img.shields.io/github/license/rocboss/paopao-ce.svg?style=flat
[license-url]: https://github.com/rocboss/paopao-ce/blob/master/LICENSE.txt
[linkedin-shield]: https://img.shields.io/badge/-LinkedIn-black.svg?style=flat&logo=linkedin&colorB=555
[product-light-screenshot]: https://assets.rocboss.com/imgs/2c/ab/06/82/mpySb2pha5dxmpOXcw==-0682.jpg
[product-dark-screenshot]: https://assets.rocboss.com/imgs/33/11/17/48/mpySb2phapVqmpWVcw==-1748.jpg

@ -3,7 +3,7 @@ package global
import (
"sync"
"github.com/rocboss/paopao-api/pkg/setting"
"github.com/rocboss/paopao-ce/pkg/setting"
"github.com/sirupsen/logrus"
)

@ -1,4 +1,4 @@
module github.com/rocboss/paopao-api
module github.com/rocboss/paopao-ce
go 1.16

@ -6,10 +6,10 @@ import (
"time"
"github.com/go-redis/redis/v8"
"github.com/rocboss/paopao-api/global"
"github.com/rocboss/paopao-api/internal/model"
"github.com/rocboss/paopao-api/pkg/logger"
"github.com/rocboss/paopao-api/pkg/setting"
"github.com/rocboss/paopao-ce/global"
"github.com/rocboss/paopao-ce/internal/model"
"github.com/rocboss/paopao-ce/pkg/logger"
"github.com/rocboss/paopao-ce/pkg/setting"
)
func init() {

@ -1,6 +1,6 @@
package dao
import "github.com/rocboss/paopao-api/internal/model"
import "github.com/rocboss/paopao-ce/internal/model"
func (d *Dao) CreateAttachment(attachment *model.Attachment) (*model.Attachment, error) {
return attachment.Create(d.engine)

@ -1,6 +1,6 @@
package dao
import "github.com/rocboss/paopao-api/internal/model"
import "github.com/rocboss/paopao-ce/internal/model"
func (d *Dao) GetComments(conditions *model.ConditionsT, offset, limit int) ([]*model.Comment, error) {
return (&model.Comment{}).List(d.engine, conditions, offset, limit)

@ -1,6 +1,6 @@
package dao
import "github.com/rocboss/paopao-api/internal/model"
import "github.com/rocboss/paopao-ce/internal/model"
func (d *Dao) GetCommentContentsByIDs(ids []int64) ([]*model.CommentContent, error) {
commentContent := &model.CommentContent{}

@ -1,7 +1,7 @@
package dao
import (
"github.com/rocboss/paopao-api/pkg/zinc"
"github.com/rocboss/paopao-ce/pkg/zinc"
"gorm.io/gorm"
)

@ -1,6 +1,6 @@
package dao
import "github.com/rocboss/paopao-api/internal/model"
import "github.com/rocboss/paopao-ce/internal/model"
func (d *Dao) CreateMessage(msg *model.Message) (*model.Message, error) {
return msg.Create(d.engine)

@ -3,7 +3,7 @@ package dao
import (
"time"
"github.com/rocboss/paopao-api/internal/model"
"github.com/rocboss/paopao-ce/internal/model"
)
func (d *Dao) CreatePost(post *model.Post) (*model.Post, error) {

@ -1,6 +1,6 @@
package dao
import "github.com/rocboss/paopao-api/internal/model"
import "github.com/rocboss/paopao-ce/internal/model"
func (d *Dao) CreatePostContent(content *model.PostContent) (*model.PostContent, error) {
return content.Create(d.engine)

@ -1,7 +1,7 @@
package dao
import (
"github.com/rocboss/paopao-api/pkg/zinc"
"github.com/rocboss/paopao-ce/pkg/zinc"
)
type SearchType string

@ -1,6 +1,6 @@
package dao
import "github.com/rocboss/paopao-api/internal/model"
import "github.com/rocboss/paopao-ce/internal/model"
func (d *Dao) CreateTag(tag *model.Tag) (*model.Tag, error) {
t, err := tag.Get(d.engine)

@ -10,8 +10,8 @@ import (
"strings"
"time"
"github.com/rocboss/paopao-api/global"
"github.com/rocboss/paopao-api/internal/model"
"github.com/rocboss/paopao-ce/global"
"github.com/rocboss/paopao-ce/internal/model"
"gopkg.in/resty.v1"
)

@ -1,8 +1,8 @@
package dao
import (
"github.com/rocboss/paopao-api/global"
"github.com/rocboss/paopao-api/internal/model"
"github.com/rocboss/paopao-ce/global"
"github.com/rocboss/paopao-ce/internal/model"
"gorm.io/gorm"
)

@ -5,10 +5,10 @@ import (
"github.com/dgrijalva/jwt-go"
"github.com/gin-gonic/gin"
"github.com/rocboss/paopao-api/global"
"github.com/rocboss/paopao-api/internal/model"
"github.com/rocboss/paopao-api/pkg/app"
"github.com/rocboss/paopao-api/pkg/errcode"
"github.com/rocboss/paopao-ce/global"
"github.com/rocboss/paopao-ce/internal/model"
"github.com/rocboss/paopao-ce/pkg/app"
"github.com/rocboss/paopao-ce/pkg/errcode"
)
func JWT() gin.HandlerFunc {

@ -2,9 +2,9 @@ package middleware
import (
"github.com/gin-gonic/gin"
"github.com/rocboss/paopao-api/internal/model"
"github.com/rocboss/paopao-api/pkg/app"
"github.com/rocboss/paopao-api/pkg/errcode"
"github.com/rocboss/paopao-ce/internal/model"
"github.com/rocboss/paopao-ce/pkg/app"
"github.com/rocboss/paopao-ce/pkg/errcode"
)
func Priv() gin.HandlerFunc {

@ -4,8 +4,8 @@ import (
"fmt"
"time"
"github.com/rocboss/paopao-api/global"
"github.com/rocboss/paopao-api/pkg/setting"
"github.com/rocboss/paopao-ce/global"
"github.com/rocboss/paopao-ce/pkg/setting"
"gorm.io/driver/mysql"
"gorm.io/gorm"
"gorm.io/gorm/logger"

@ -9,12 +9,12 @@ import (
"github.com/disintegration/imaging"
"github.com/gin-gonic/gin"
"github.com/gofrs/uuid"
"github.com/rocboss/paopao-api/global"
"github.com/rocboss/paopao-api/internal/model"
"github.com/rocboss/paopao-api/internal/service"
"github.com/rocboss/paopao-api/pkg/app"
"github.com/rocboss/paopao-api/pkg/convert"
"github.com/rocboss/paopao-api/pkg/errcode"
"github.com/rocboss/paopao-ce/global"
"github.com/rocboss/paopao-ce/internal/model"
"github.com/rocboss/paopao-ce/internal/service"
"github.com/rocboss/paopao-ce/pkg/app"
"github.com/rocboss/paopao-ce/pkg/convert"
"github.com/rocboss/paopao-ce/pkg/errcode"
)
func GeneratePath(s string) string {

@ -2,12 +2,12 @@ package api
import (
"github.com/gin-gonic/gin"
"github.com/rocboss/paopao-api/global"
"github.com/rocboss/paopao-api/internal/model"
"github.com/rocboss/paopao-api/internal/service"
"github.com/rocboss/paopao-api/pkg/app"
"github.com/rocboss/paopao-api/pkg/convert"
"github.com/rocboss/paopao-api/pkg/errcode"
"github.com/rocboss/paopao-ce/global"
"github.com/rocboss/paopao-ce/internal/model"
"github.com/rocboss/paopao-ce/internal/service"
"github.com/rocboss/paopao-ce/pkg/app"
"github.com/rocboss/paopao-ce/pkg/convert"
"github.com/rocboss/paopao-ce/pkg/errcode"
)
func GetPostComments(c *gin.Context) {

@ -10,13 +10,13 @@ import (
"github.com/afocus/captcha"
"github.com/gin-gonic/gin"
"github.com/gofrs/uuid"
"github.com/rocboss/paopao-api/global"
"github.com/rocboss/paopao-api/internal/model"
"github.com/rocboss/paopao-api/internal/service"
"github.com/rocboss/paopao-api/pkg/app"
"github.com/rocboss/paopao-api/pkg/convert"
"github.com/rocboss/paopao-api/pkg/errcode"
"github.com/rocboss/paopao-api/pkg/util"
"github.com/rocboss/paopao-ce/global"
"github.com/rocboss/paopao-ce/internal/model"
"github.com/rocboss/paopao-ce/internal/service"
"github.com/rocboss/paopao-ce/pkg/app"
"github.com/rocboss/paopao-ce/pkg/convert"
"github.com/rocboss/paopao-ce/pkg/errcode"
"github.com/rocboss/paopao-ce/pkg/util"
)
const MAX_PHONE_CAPTCHA = 10

@ -2,11 +2,11 @@ package api
import (
"github.com/gin-gonic/gin"
"github.com/rocboss/paopao-api/global"
"github.com/rocboss/paopao-api/internal/model"
"github.com/rocboss/paopao-api/internal/service"
"github.com/rocboss/paopao-api/pkg/app"
"github.com/rocboss/paopao-api/pkg/errcode"
"github.com/rocboss/paopao-ce/global"
"github.com/rocboss/paopao-ce/internal/model"
"github.com/rocboss/paopao-ce/internal/service"
"github.com/rocboss/paopao-ce/pkg/app"
"github.com/rocboss/paopao-ce/pkg/errcode"
)
func GetUnreadMsgCount(c *gin.Context) {

@ -2,13 +2,13 @@ package api
import (
"github.com/gin-gonic/gin"
"github.com/rocboss/paopao-api/global"
"github.com/rocboss/paopao-api/internal/dao"
"github.com/rocboss/paopao-api/internal/model"
"github.com/rocboss/paopao-api/internal/service"
"github.com/rocboss/paopao-api/pkg/app"
"github.com/rocboss/paopao-api/pkg/convert"
"github.com/rocboss/paopao-api/pkg/errcode"
"github.com/rocboss/paopao-ce/global"
"github.com/rocboss/paopao-ce/internal/dao"
"github.com/rocboss/paopao-ce/internal/model"
"github.com/rocboss/paopao-ce/internal/service"
"github.com/rocboss/paopao-ce/pkg/app"
"github.com/rocboss/paopao-ce/pkg/convert"
"github.com/rocboss/paopao-ce/pkg/errcode"
)
func GetPostList(c *gin.Context) {

@ -7,12 +7,12 @@ import (
"unicode/utf8"
"github.com/gin-gonic/gin"
"github.com/rocboss/paopao-api/global"
"github.com/rocboss/paopao-api/internal/model"
"github.com/rocboss/paopao-api/internal/service"
"github.com/rocboss/paopao-api/pkg/app"
"github.com/rocboss/paopao-api/pkg/convert"
"github.com/rocboss/paopao-api/pkg/errcode"
"github.com/rocboss/paopao-ce/global"
"github.com/rocboss/paopao-ce/internal/model"
"github.com/rocboss/paopao-ce/internal/service"
"github.com/rocboss/paopao-ce/pkg/app"
"github.com/rocboss/paopao-ce/pkg/convert"
"github.com/rocboss/paopao-ce/pkg/errcode"
"github.com/smartwalle/alipay/v3"
)

@ -5,8 +5,8 @@ import (
"github.com/gin-contrib/cors"
"github.com/gin-gonic/gin"
"github.com/rocboss/paopao-api/internal/middleware"
"github.com/rocboss/paopao-api/internal/routers/api"
"github.com/rocboss/paopao-ce/internal/middleware"
"github.com/rocboss/paopao-ce/internal/routers/api"
)
func NewRouter() *gin.Engine {

@ -1,6 +1,6 @@
package service
import "github.com/rocboss/paopao-api/internal/model"
import "github.com/rocboss/paopao-ce/internal/model"
func (svc *Service) CreateAttachment(attachment *model.Attachment) (*model.Attachment, error) {
return svc.dao.CreateAttachment(attachment)

@ -4,10 +4,10 @@ import (
"strings"
"time"
"github.com/rocboss/paopao-api/global"
"github.com/rocboss/paopao-api/internal/model"
"github.com/rocboss/paopao-api/pkg/errcode"
"github.com/rocboss/paopao-api/pkg/util"
"github.com/rocboss/paopao-ce/global"
"github.com/rocboss/paopao-ce/internal/model"
"github.com/rocboss/paopao-ce/pkg/errcode"
"github.com/rocboss/paopao-ce/pkg/util"
)
type CommentCreationReq struct {

@ -1,8 +1,8 @@
package service
import (
"github.com/rocboss/paopao-api/internal/model"
"github.com/rocboss/paopao-api/pkg/errcode"
"github.com/rocboss/paopao-ce/internal/model"
"github.com/rocboss/paopao-ce/pkg/errcode"
)
type ReadMessageReq struct {

@ -7,11 +7,11 @@ import (
"strings"
"time"
"github.com/rocboss/paopao-api/global"
"github.com/rocboss/paopao-api/internal/dao"
"github.com/rocboss/paopao-api/internal/model"
"github.com/rocboss/paopao-api/pkg/util"
"github.com/rocboss/paopao-api/pkg/zinc"
"github.com/rocboss/paopao-ce/global"
"github.com/rocboss/paopao-ce/internal/dao"
"github.com/rocboss/paopao-ce/internal/model"
"github.com/rocboss/paopao-ce/pkg/util"
"github.com/rocboss/paopao-ce/pkg/zinc"
)
type TagType string

@ -2,9 +2,9 @@ package service
import (
"github.com/gin-gonic/gin"
"github.com/rocboss/paopao-api/global"
"github.com/rocboss/paopao-api/internal/dao"
"github.com/rocboss/paopao-api/pkg/zinc"
"github.com/rocboss/paopao-ce/global"
"github.com/rocboss/paopao-ce/internal/dao"
"github.com/rocboss/paopao-ce/pkg/zinc"
)
type Service struct {

@ -4,8 +4,8 @@ import (
"fmt"
"sort"
"github.com/rocboss/paopao-api/global"
"github.com/rocboss/paopao-api/pkg/util"
"github.com/rocboss/paopao-ce/global"
"github.com/rocboss/paopao-ce/pkg/util"
)
func (svc *Service) GetParamSign(param map[string]interface{}, secretKey string) string {

@ -8,11 +8,11 @@ import (
"unicode/utf8"
"github.com/gofrs/uuid"
"github.com/rocboss/paopao-api/global"
"github.com/rocboss/paopao-api/internal/model"
"github.com/rocboss/paopao-api/pkg/convert"
"github.com/rocboss/paopao-api/pkg/errcode"
"github.com/rocboss/paopao-api/pkg/util"
"github.com/rocboss/paopao-ce/global"
"github.com/rocboss/paopao-ce/internal/model"
"github.com/rocboss/paopao-ce/pkg/convert"
"github.com/rocboss/paopao-ce/pkg/errcode"
"github.com/rocboss/paopao-ce/pkg/util"
)
const MAX_CAPTCHA_TIMES = 2

@ -3,9 +3,9 @@ package service
import (
"time"
"github.com/rocboss/paopao-api/global"
"github.com/rocboss/paopao-api/internal/model"
"github.com/rocboss/paopao-api/pkg/errcode"
"github.com/rocboss/paopao-ce/global"
"github.com/rocboss/paopao-ce/internal/model"
"github.com/rocboss/paopao-ce/pkg/errcode"
)
type RechargeReq struct {

@ -5,8 +5,8 @@ import (
"net/http"
"github.com/gin-gonic/gin"
"github.com/rocboss/paopao-api/global"
"github.com/rocboss/paopao-api/internal/routers"
"github.com/rocboss/paopao-ce/global"
"github.com/rocboss/paopao-ce/internal/routers"
)
func main() {

@ -1,7 +0,0 @@
# Vue 3 + Vite
This template should help get you started developing with Vue 3 in Vite. The template uses Vue 3 `<script setup>` SFCs, check out the [script setup docs](https://v3.vuejs.org/api/sfc-script-setup.html#sfc-script-setup) to learn more.
## Recommended IDE Setup
- [VS Code](https://code.visualstudio.com/) + [Volar](https://marketplace.visualstudio.com/items?itemName=johnsoncodehk.volar)

@ -5,7 +5,7 @@ import (
"os"
"github.com/gin-gonic/gin"
"github.com/rocboss/paopao-api/pkg/errcode"
"github.com/rocboss/paopao-ce/pkg/errcode"
)
type Response struct {

@ -4,8 +4,8 @@ import (
"time"
"github.com/dgrijalva/jwt-go"
"github.com/rocboss/paopao-api/global"
"github.com/rocboss/paopao-api/internal/model"
"github.com/rocboss/paopao-ce/global"
"github.com/rocboss/paopao-ce/internal/model"
)
type Claims struct {

@ -2,8 +2,8 @@ package app
import (
"github.com/gin-gonic/gin"
"github.com/rocboss/paopao-api/global"
"github.com/rocboss/paopao-api/pkg/convert"
"github.com/rocboss/paopao-ce/global"
"github.com/rocboss/paopao-ce/pkg/convert"
)
func GetPage(c *gin.Context) int {

@ -6,8 +6,8 @@ import (
"io"
"time"
"github.com/rocboss/paopao-api/global"
"github.com/rocboss/paopao-api/pkg/setting"
"github.com/rocboss/paopao-ce/global"
"github.com/rocboss/paopao-ce/pkg/setting"
"github.com/sirupsen/logrus"
"gopkg.in/natefinch/lumberjack.v2"
"gopkg.in/resty.v1"

@ -7,7 +7,7 @@ import (
"github.com/fbsobreira/gotron-sdk/pkg/proto/core"
"github.com/golang/protobuf/proto"
"github.com/rocboss/paopao-api/pkg/crypto"
"github.com/rocboss/paopao-ce/pkg/crypto"
)
// SignTransaction 签名交易
Loading…
Cancel
Save