正在显示
7 个修改的文件
包含
184 行增加
和
5 行删除
cmd/discuss/api/dsl/core/article.api
0 → 100644
| 1 | +syntax = "v1" | ||
| 2 | + | ||
| 3 | +info( | ||
| 4 | + title: "文章内容处理" | ||
| 5 | + desc: "编辑处理文章内容" | ||
| 6 | + author: "author" | ||
| 7 | + email: "email" | ||
| 8 | + version: "v1" | ||
| 9 | +) | ||
| 10 | + | ||
| 11 | +// 坐标地点描述 | ||
| 12 | +type Location { | ||
| 13 | + Longitude float64 `json:"longitude"` //经度 | ||
| 14 | + Latitude float64 `json:"latitude"` //纬度 | ||
| 15 | + Descript string `json:"descript"` //地点描述 | ||
| 16 | +} | ||
| 17 | + | ||
| 18 | +// 人员的简单展示信息 | ||
| 19 | +type Author { | ||
| 20 | + Id int64 `json:"id"` // 人员id | ||
| 21 | + Name string `json:"name"` // 人员的名字 | ||
| 22 | + Avatar string `json:"avatar"` // 人员头像URL | ||
| 23 | + Group string `json:"group"` // 人员的分组 | ||
| 24 | + Position string `json:"position"` // 职位 | ||
| 25 | +} | ||
| 26 | + | ||
| 27 | +// 创建发布文章 | ||
| 28 | +type ( | ||
| 29 | + ArticleCreateRequest { | ||
| 30 | + Title string `json:"title"` //标题 | ||
| 31 | + Section []string `json:"section"` //文章的文本内容 | ||
| 32 | + AuthorId int `json:"authorId"` //发布人id | ||
| 33 | + Images []string `json:"images"` //图片 | ||
| 34 | + WhoRead []int `json:"whoRead"` //谁可查看 | ||
| 35 | + WhoReview []int `json:"whoReview"` //谁可评论 | ||
| 36 | + Location Location `json:"location"` //定位坐标 | ||
| 37 | + } | ||
| 38 | + ArticleCreateResponse { | ||
| 39 | + Id int64 `json:"id"` | ||
| 40 | + } | ||
| 41 | +) | ||
| 42 | + | ||
| 43 | +// 查看文章的详情 | ||
| 44 | +type ( | ||
| 45 | + ArticleGetRequest { | ||
| 46 | + Id int64 `json:"id"` //id | ||
| 47 | + } | ||
| 48 | + ArticleGetResponse { | ||
| 49 | + Title string `json:"title"` //标题 | ||
| 50 | + AuthorId int `json:"authorId"` //发布人id | ||
| 51 | + Author Author `json:"author"` //发布人 | ||
| 52 | + CreatedAt int64 `json:"createdAt"` //文章的发布时间 | ||
| 53 | + Section []string `json:"section"` //文章的文本内容 | ||
| 54 | + Images []string `json:"images"` //图片 | ||
| 55 | + WhoRead []int `json:"whoRead"` //谁可查看 | ||
| 56 | + WhoReview []int `json:"whoReview"` //谁可评论 | ||
| 57 | + Location Location `json:"location"` //定位坐标 | ||
| 58 | + CountLove int `json:"countLove"` // 点赞数量 | ||
| 59 | + CountComment int `json:"countComment"` // 评论数量 | ||
| 60 | + Show int `json:"showState"` // 评论的展示状态(0显示、1不显示) | ||
| 61 | + } | ||
| 62 | +) | ||
| 63 | + | ||
| 64 | +// 小程序接口 | ||
| 65 | +@server( | ||
| 66 | + prefix: v1/mini | ||
| 67 | + group: article | ||
| 68 | + jwt: MiniAuth | ||
| 69 | +) | ||
| 70 | +service Core { | ||
| 71 | + @doc "小程序创建发布内容" | ||
| 72 | + @handler CreateArticle | ||
| 73 | + post /article (ArticleCreateRequest) returns (ArticleCreateResponse) | ||
| 74 | + @doc "小程序获取文章内容详情" | ||
| 75 | + @handler GetArticle | ||
| 76 | + get /article/:id (ArticleGetRequest) returns (ArticleGetResponse) | ||
| 77 | +} |
cmd/discuss/api/dsl/core/article_tag.api
0 → 100644
| 1 | +syntax = "v1" | ||
| 2 | + | ||
| 3 | +info( | ||
| 4 | + title: "后台编辑标签" | ||
| 5 | + desc: "编辑处理标签信息" | ||
| 6 | + author: "author" | ||
| 7 | + email: "email" | ||
| 8 | + version: "v1" | ||
| 9 | +) | ||
| 10 | + | ||
| 11 | +// 创建标签 | ||
| 12 | +type ( | ||
| 13 | + TagCreateRequest { | ||
| 14 | + CompanyId int64 `json:"companyId"` | ||
| 15 | + Image string `json:"image"` | ||
| 16 | + Name string `json:"name"` // 标签名称 | ||
| 17 | + Group string `json:"group"` // 标签分类 | ||
| 18 | + Remark string `json:"remark"` // 备注 | ||
| 19 | + } | ||
| 20 | + | ||
| 21 | + TagCreateResponse { | ||
| 22 | + Id int64 `json:"id"` | ||
| 23 | + } | ||
| 24 | +) | ||
| 25 | + | ||
| 26 | +// 编辑标签 | ||
| 27 | +type ( | ||
| 28 | + TagEditRequest { | ||
| 29 | + Id int64 `json:"id"` | ||
| 30 | + CompanyId int64 `json:"companyId"` | ||
| 31 | + Image string `json:"image"` | ||
| 32 | + Name string `json:"name"` // 标签名称 | ||
| 33 | + Group string `json:"group"` // 标签分类 | ||
| 34 | + Remark string `json:"remark"` // 备注 | ||
| 35 | + } | ||
| 36 | + | ||
| 37 | + TagEditResponse { | ||
| 38 | + Id int64 `json:"id"` | ||
| 39 | + } | ||
| 40 | +) | ||
| 41 | + | ||
| 42 | +// 获取标签详情 | ||
| 43 | +type ( | ||
| 44 | + TagGetRequest { | ||
| 45 | + Id int64 `json:"id"` | ||
| 46 | + } | ||
| 47 | + TagGetResponse { | ||
| 48 | + Id int64 `json:"id"` | ||
| 49 | + Image string `json:"image"` | ||
| 50 | + Name string `json:"name"` // 标签名称 | ||
| 51 | + Group string `json:"group"` // 标签分类 | ||
| 52 | + Remark string `json:"remark"` // 备注 | ||
| 53 | + } | ||
| 54 | +) | ||
| 55 | + | ||
| 56 | +//标签列表 | ||
| 57 | +type ( | ||
| 58 | + TagListRequest { | ||
| 59 | + Page int `json:"page"` | ||
| 60 | + Size int `json:"size"` | ||
| 61 | + } | ||
| 62 | + TagListResponse { | ||
| 63 | + Total int `json:"total"` | ||
| 64 | + List []TagItem `json:"list"` | ||
| 65 | + } | ||
| 66 | + TagItem { | ||
| 67 | + Id int64 `json:"id"` | ||
| 68 | + Image string `json:"image"` | ||
| 69 | + Name string `json:"name"` // 标签名称 | ||
| 70 | + Group string `json:"group"` // 标签分类 | ||
| 71 | + Remark string `json:"remark"` // 备注 | ||
| 72 | + CreatedAt int64 `json:"createdAt"` | ||
| 73 | + } | ||
| 74 | +) | ||
| 75 | + | ||
| 76 | +//删除标签 | ||
| 77 | +type ( | ||
| 78 | + TagDeleteRequest { | ||
| 79 | + Id int64 `json:"id"` | ||
| 80 | + } | ||
| 81 | + TagDeleteResponse { | ||
| 82 | + Id int64 `json:"id"` | ||
| 83 | + } | ||
| 84 | +) | ||
| 85 | + | ||
| 86 | +@server( | ||
| 87 | + prefix: v1/mini | ||
| 88 | + group: tags | ||
| 89 | + jwt: MiniAuth | ||
| 90 | +) | ||
| 91 | +service Core { | ||
| 92 | + @doc "后台创建文章标签" | ||
| 93 | + @handler CreateTag | ||
| 94 | + post /article_tag (TagCreateRequest) returns (TagCreateResponse) | ||
| 95 | + @doc "后台编辑文章标签" | ||
| 96 | + @handler EditTag | ||
| 97 | + put /article_tag (TagEditRequest) returns (TagEditResponse) | ||
| 98 | + @doc "后台获取文章标签" | ||
| 99 | + @handler GetTag | ||
| 100 | + get /article_tag/:id (TagGetRequest) returns (TagGetResponse) | ||
| 101 | + @doc "后台删除文章标签" | ||
| 102 | + @handler DeleteTag | ||
| 103 | + delete /article_tag (TagDeleteRequest) returns (TagDeleteResponse) | ||
| 104 | +} |
| @@ -36,6 +36,7 @@ type ServiceContext struct { | @@ -36,6 +36,7 @@ type ServiceContext struct { | ||
| 36 | func NewServiceContext(c config.Config) *ServiceContext { | 36 | func NewServiceContext(c config.Config) *ServiceContext { |
| 37 | 37 | ||
| 38 | db := database.OpenGormPGDB(c.DB.DataSource, c.Log.Mode) | 38 | db := database.OpenGormPGDB(c.DB.DataSource, c.Log.Mode) |
| 39 | + | ||
| 39 | mlCache := cache.NewMultiLevelCache([]string{c.Redis.Host}, c.Redis.Pass) | 40 | mlCache := cache.NewMultiLevelCache([]string{c.Redis.Host}, c.Redis.Pass) |
| 40 | redis, _ := redis.NewRedis(redis.RedisConf{Host: c.Redis.Host, Pass: c.Redis.Pass, Type: "node"}) | 41 | redis, _ := redis.NewRedis(redis.RedisConf{Host: c.Redis.Host, Pass: c.Redis.Pass, Type: "node"}) |
| 41 | 42 |
| @@ -27,7 +27,6 @@ type Article struct { | @@ -27,7 +27,6 @@ type Article struct { | ||
| 27 | TargetUser int // 分发方式 0 分发给所有人 1 分发给指定的人 | 27 | TargetUser int // 分发方式 0 分发给所有人 1 分发给指定的人 |
| 28 | CountLove int // 点赞数量 | 28 | CountLove int // 点赞数量 |
| 29 | CountComment int // 评论数量 | 29 | CountComment int // 评论数量 |
| 30 | - Tags []int `gorm:"type:jsonb;serializer:json"` // 标签 | ||
| 31 | Show int // 评论的展示状态(0显示、1不显示) | 30 | Show int // 评论的展示状态(0显示、1不显示) |
| 32 | } | 31 | } |
| 33 | 32 |
| @@ -158,7 +158,6 @@ func (repository *ArticleRepository) ModelToDomainModel(from *models.Article) (* | @@ -158,7 +158,6 @@ func (repository *ArticleRepository) ModelToDomainModel(from *models.Article) (* | ||
| 158 | TargetUser: domain.ArticleTarget(from.TargetUser), | 158 | TargetUser: domain.ArticleTarget(from.TargetUser), |
| 159 | CountLove: from.CountLove, | 159 | CountLove: from.CountLove, |
| 160 | CountComment: from.CountComment, | 160 | CountComment: from.CountComment, |
| 161 | - Tags: from.Tags, | ||
| 162 | Show: domain.ArticleShow(from.Show), | 161 | Show: domain.ArticleShow(from.Show), |
| 163 | } | 162 | } |
| 164 | return to, nil | 163 | return to, nil |
| @@ -182,7 +181,6 @@ func (repository *ArticleRepository) DomainModelToModel(from *domain.Article) (* | @@ -182,7 +181,6 @@ func (repository *ArticleRepository) DomainModelToModel(from *domain.Article) (* | ||
| 182 | TargetUser: int(from.TargetUser), | 181 | TargetUser: int(from.TargetUser), |
| 183 | CountLove: from.CountLove, | 182 | CountLove: from.CountLove, |
| 184 | CountComment: from.CountComment, | 183 | CountComment: from.CountComment, |
| 185 | - Tags: from.Tags, | ||
| 186 | Show: int(from.Show), | 184 | Show: int(from.Show), |
| 187 | } | 185 | } |
| 188 | // err := copier.Copy(to, from) | 186 | // err := copier.Copy(to, from) |
| @@ -24,7 +24,6 @@ type Article struct { | @@ -24,7 +24,6 @@ type Article struct { | ||
| 24 | TargetUser ArticleTarget `json:"targetUser"` // 分发方式 0 分发给所有人 1 分发给指定的人 | 24 | TargetUser ArticleTarget `json:"targetUser"` // 分发方式 0 分发给所有人 1 分发给指定的人 |
| 25 | CountLove int `json:"countLove"` // 点赞数量 | 25 | CountLove int `json:"countLove"` // 点赞数量 |
| 26 | CountComment int `json:"countComment"` // 评论数量 | 26 | CountComment int `json:"countComment"` // 评论数量 |
| 27 | - Tags []int `json:"tags"` // 标签 | ||
| 28 | Show ArticleShow `json:"showState"` // 评论的展示状态(0显示、1不显示) | 27 | Show ArticleShow `json:"showState"` // 评论的展示状态(0显示、1不显示) |
| 29 | // ...more | 28 | // ...more |
| 30 | } | 29 | } |
-
请 注册 或 登录 后发表评论