作者 tangxvhui

更新模型

syntax = "v1"
import "core/comment.api"
import "core/message.api"
import "core/article_tag.api"
... ...
syntax = "v1"
import "article_type.api"
info(
title: "文章内容处理"
desc: "编辑处理文章内容"
... ... @@ -31,128 +33,18 @@ service Core {
@doc "小程序获取我发布的文章"
@handler MiniArticleSearchMe
post /article/search/me (MiniArticleSearchMeRequest) returns (MiniArticleSearchMeResponse)
}
// 坐标地点描述
type Location {
Longitude float64 `json:"longitude,optional"` //经度
Latitude float64 `json:"latitude,optional"` //纬度
Descript string `json:"descript,optional"` //地点描述
}
// 人员的简单展示信息
type Author {
Id int64 `json:"id"` // 人员id
Name string `json:"name"` // 人员的名字
Avatar string `json:"avatar"` // 人员头像URL
Group string `json:"group"` // 人员的分组
Position string `json:"position"` // 职位
Company string `json:"company"` // 公司
}
//小程序端创建发布文章
type (
MiniArticleCreateRequest {
Title string `json:"title"` //标题
Section []string `json:"section"` //文章的文本内容
AuthorId int64 `json:"authorId,optional"` //发布人id
Images []string `json:"images,optional"` //图片
WhoRead []int64 `json:"whoRead,optional"` //谁可查看
WhoReview []int64 `json:"whoReview,optional"` //谁可评论
Location Location `json:"location,optional"` //定位坐标
}
MiniArticleCreateResponse {
Id int64 `json:"id"`
}
)
//小程序端查看文章的详情
type (
MiniArticleGetRequest {
Id int64 `path:"id"` //id
CompanyId int64 `path:",optional"`
}
MiniArticleGetResponse {
Id int64 `json:"id"` //id
Title string `json:"title"` //标题
AuthorId int64 `json:"authorId"` //发布人id
Author Author `json:"author"` //发布人
CreatedAt int64 `json:"createdAt"` //文章的发布时间
Section []ArticleSection `json:"section"` //文章的文本内容
Images []string `json:"images"` //图片
WhoRead []int64 `json:"whoRead"` //谁可查看
WhoReview []int64 `json:"whoReview"` //谁可评论
Location Location `json:"location"` //定位坐标
CountLove int `json:"countLove"` // 点赞数量
CountComment int `json:"countComment"` // 评论数量
CountRead int `json:"countRead"` // 浏览数量
Show int `json:"show"` // 评论的展示状态(0显示、1不显示)
}
ArticleSection {
Id int64 `json:"id"` //段落id
Content string `json:"content"` // 文本内容
SortBy int `json:"sortBy"` // 排序
TotalComment int `json:"totalComment"` // 评论的数量
}
)
// 获取我的发文章记录
type (
MiniArticleSearchMeRequest {
AuthorId int64 `json:",optional"`
CompanyId int64 `json:",optional"`
Page int `json:"page"`
Size int `json:"size"`
}
MiniArticleSearchMeResponse {
Total int `json:"total"`
List []ArticleSearchMe `json:"list"`
}
ArticleSearchMe {
Id int64 `json:"id"` //id
Title string `json:"title"` //标题
Images []string `json:"images"` //图片
CreatedAt int64 `json:"createdAt"` //文章的创建日期
CountLove int `json:"countLove"` //点赞数量
CountComment int `json:"CountComment"` //评论数量
Show int `json:"show"` //是否隐藏 [0显示、1不显示]
}
)
// 管理后台接口
// @server(
// prefix: v1/system
// group: article
// jwt: MiniAuth
// )
// service Core {
// @doc "管理后台获取文章内容详情"
// @handler SystemGetArticle
// get /article/:id (SystemArticleGetRequest) returns (SystemArticleGetResponse)
// }
//获取列表,文章有哪些人进行了点赞
type (
MiniUserLikeArticleRequest {
ArticleId int64 `json:"articleId"` // 文章id
CompanyId int64 `json:",optional"` //公司id
Page int `json:"page"` //分页,第几页
Size int `json:"size"` //分页,每页几条
}
MiniUserLikeArticleResponse {
Total int64 `json:"total"` //总数
List []WhichUserLikeArticle `json:"list"` //列表
}
WhichUserLikeArticle {
ArticleId int64 `json:"articleId"` // 文章id
UserId int64 `json:"userId"` // 人员id
Name string `json:"name"` // 人员名称
Avatar string `json:"avatar"` // 人员头像
CreatedAt int64 `json:"createdAt"` // 点赞记录的时间
}
)
// 人员点赞文章/评论
type (
MiniSetUserLikeRequset {
ArticleId int64 `json:"articleId"` //文章id
CommentId int64 `json:"commentId"` //评论id
UserId int64 `json:",optional"` //操作人
Flag int `json:"flag"` //点赞标志 1、点赞 2 、取消点赞
}
MiniSetUserLikeResponse {
ArticleId int64 `json:"articleId"` //文章id
CommentId int64 `json:"commentId"` //评论id
Count int `json:"count"` //现有的点赞数量
}
)
\ No newline at end of file
... ...
syntax = "v1"
// 坐标地点描述
type Location {
Longitude float64 `json:"longitude,optional"` //经度
Latitude float64 `json:"latitude,optional"` //纬度
Descript string `json:"descript,optional"` //地点描述
}
// 人员的简单展示信息
type Author {
Id int64 `json:"id"` // 人员id
Name string `json:"name"` // 人员的名字
Avatar string `json:"avatar"` // 人员头像URL
Group string `json:"group"` // 人员的分组
Position string `json:"position"` // 职位
Company string `json:"company"` // 公司
}
//小程序端创建发布文章
type (
MiniArticleCreateRequest {
Title string `json:"title"` //标题
Section []string `json:"section"` //文章的文本内容
AuthorId int64 `json:"authorId,optional"` //发布人id
Images []string `json:"images,optional"` //图片
WhoRead []int64 `json:"whoRead,optional"` //谁可查看
WhoReview []int64 `json:"whoReview,optional"` //谁可评论
Location Location `json:"location,optional"` //定位坐标
}
MiniArticleCreateResponse {
Id int64 `json:"id"`
}
)
//小程序端查看文章的详情
type (
MiniArticleGetRequest {
Id int64 `path:"id"` //id
CompanyId int64 `path:",optional"`
}
MiniArticleGetResponse {
Id int64 `json:"id"` //id
Title string `json:"title"` //标题
AuthorId int64 `json:"authorId"` //发布人id
Author Author `json:"author"` //发布人
CreatedAt int64 `json:"createdAt"` //文章的发布时间
Section []ArticleSection `json:"section"` //文章的文本内容
Images []string `json:"images"` //图片
WhoRead []int64 `json:"whoRead"` //谁可查看
WhoReview []int64 `json:"whoReview"` //谁可评论
Location Location `json:"location"` //定位坐标
CountLove int `json:"countLove"` // 点赞数量
CountComment int `json:"countComment"` // 评论数量
CountRead int `json:"countRead"` // 浏览数量
Show int `json:"show"` // 评论的展示状态(0显示、1不显示)
Edit int `json:"edit"` // 文章是否存在变更记录 (0 不存在 1存在)
}
ArticleSection {
Id int64 `json:"id"` //段落id
Content string `json:"content"` // 文本内容
SortBy int `json:"sortBy"` // 排序
TotalComment int `json:"totalComment"` // 评论的数量
}
)
// 小程序获取我的发文章记录
type (
MiniArticleSearchMeRequest {
AuthorId int64 `json:",optional"`
CompanyId int64 `json:",optional"`
Page int `json:"page"`
Size int `json:"size"`
}
MiniArticleSearchMeResponse {
Total int `json:"total"`
List []ArticleSearchMe `json:"list"`
}
ArticleSearchMe {
Id int64 `json:"id"` //id
Title string `json:"title"` //标题
Images []string `json:"images"` //图片
CreatedAt int64 `json:"createdAt"` //文章的创建日期
CountLove int `json:"countLove"` //点赞数量
CountComment int `json:"CountComment"` //评论数量
Show int `json:"show"` //是否隐藏 [0显示、1不显示]
}
)
//小程序端获取文章有哪些人进行了点赞
type (
MiniUserLikeArticleRequest {
ArticleId int64 `json:"articleId"` // 文章id
CompanyId int64 `json:",optional"` //公司id
Page int `json:"page"` //分页,第几页
Size int `json:"size"` //分页,每页几条
}
MiniUserLikeArticleResponse {
Total int64 `json:"total"` //总数
List []WhichUserLikeArticle `json:"list"` //列表
}
WhichUserLikeArticle {
ArticleId int64 `json:"articleId"` // 文章id
UserId int64 `json:"userId"` // 人员id
Name string `json:"name"` // 人员名称
Avatar string `json:"avatar"` // 人员头像
CreatedAt int64 `json:"createdAt"` // 点赞记录的时间
}
)
// 小程序端人员点赞文章/评论
type (
MiniSetUserLikeRequset {
ArticleId int64 `json:"articleId"` //文章id
CommentId int64 `json:"commentId"` //评论id
UserId int64 `json:",optional"` //操作人
Flag int `json:"flag"` //点赞标志 1、点赞 2 、取消点赞
}
MiniSetUserLikeResponse {
ArticleId int64 `json:"articleId"` //文章id
CommentId int64 `json:"commentId"` //评论id
Count int `json:"count"` //现有的点赞数量
}
)
//管理后台获取文章详情
type (
SystemArticleGetRequest {
Id int64 `path:"id"` //id
CompanyId int64 `path:",optional"`
}
UserShowName {
Id int `json:"id"`
Name int `json:"name"`
}
SystemArticleGetResponse {
Id int64 `json:"id"` // id
Title string `json:"title"` // 标题
AuthorId int64 `json:"authorId"` // 发布人id
Author Author `json:"author"` // 发布人
CreatedAt int64 `json:"createdAt"` // 文章的发布时间
Section []ArticleSection `json:"section"` // 文章的文本内容
Images []string `json:"images"` // 图片
WhoRead []int64 `json:"whoRead"` // 谁可查看
WhoReadInfo []UserShowName `json:"whoReadInfo"` // 谁可查看
WhoReview []int64 `json:"whoReview"` // 谁可评论
WhoReviewInfo []UserShowName `json:"whoReviewInfo"` // 谁可评论
Location Location `json:"location"` // 定位坐标
CountLove int `json:"countLove"` // 点赞数量
CountComment int `json:"countComment"` // 评论数量
CountRead int `json:"countRead"` // 浏览数量
Show int `json:"show"` // 评论的展示状态(0显示、1不显示)
}
)
//管理后台获取文章列表
\ No newline at end of file
... ...
... ... @@ -8,7 +8,6 @@ info(
version: "v1"
)
// 小程序接口
@server(
prefix: v1
... ... @@ -21,7 +20,6 @@ service Core {
get /mini/comment (CommentRequest) returns (CommentResposne)
}
// 后台接口
@server(
prefix: v1
... ... @@ -34,15 +32,13 @@ service Core {
get /system/comment (CommentRequest) returns (CommentResposne)
}
type(
CommentRequest struct{
type (
CommentRequest {
}
CommentResposne struct{
CommentResposne {
List []Comment `json:"list"`
}
Comment struct{
Comment {
}
)
\ No newline at end of file
... ...
... ... @@ -24,7 +24,7 @@ service Core {
}
type (
MessageSystemRequest struct {
MessageSystemRequest {
Page int `json:"page"`
Size int `json:"size"`
}
... ... @@ -32,7 +32,7 @@ type (
List []MessageSystemItem `json:"list"`
Total int64 `json:"total"`
}
MessageSystemItem struct {
MessageSystemItem {
Id int64 `json:"id"` // ID
Type int `json:"type"` // 系统分类
Title string `json:"title"` // 标题
... ... @@ -40,7 +40,7 @@ type (
CreatedAt int64 `json:"createdAt"` // 创建时间
}
MessageBusinessRequest struct {
MessageBusinessRequest {
Type int `json:"type"`
Page int `json:"page"`
Size int `json:"size"`
... ... @@ -49,7 +49,7 @@ type (
List []MessageBusinessItem `json:"list"`
Total int64 `json:"total"`
}
MessageBusinessItem struct {
MessageBusinessItem {
Id int64 `json:"id"`
Type int `json:"type"` // 分类 (1回复 2点赞 3被采纳)
OptType int `json:"optType"` // 操作类型(1针对文章、1针对评论、2针对圆桌)
... ... @@ -67,7 +67,7 @@ type (
Comment *Comment `json:"comment"` // 评论(不一定是自己,可能是被人@到)
}
User struct {
User {
Id int64 `json:"id"`
CompanyId int64 `json:"companyId,omitempty"` // 公司ID
CompanyName string `json:"companyName,omitempty"` // 公司名称
... ... @@ -77,10 +77,11 @@ type (
}
SimpleArticle struct {
SimpleArticle {
Id int64 `json:"id"`
Title string `json:"title"` // 文章标题
CountLove int `json:"countLove"` // 点赞数量
CountComment int `json:"countComment"` // 评论数量
}
)
\ No newline at end of file
... ...
... ... @@ -92,8 +92,11 @@ func (l *MiniGetArticleLogic) MiniGetArticle(req *types.MiniArticleGetRequest) (
CountComment: articleInfo.CountComment,
CountRead: articleInfo.CountRead,
Show: int(articleInfo.Show),
Edit: 0,
}
if articleInfo.CreatedAt != articleInfo.UpdatedAt {
resp.Edit = 1
}
for _, val := range articleInfo.Images {
resp.Images = append(resp.Images, val.Url)
}
... ...
... ... @@ -228,7 +228,9 @@ func (l *MiniSetUserLikeLogic) setUserLikeArticle(req *types.MiniSetUserLikeRequ
flagInfo := domain.UserLoveFlag{
Id: 0,
ArticleId: req.ArticleId,
CommentId: req.CommentId,
ArticleAuthor: articleInfo.AuthorId,
CommentId: 0,
CommentAuthor: 0,
UserId: req.UserId,
}
// 去除点赞标识
... ... @@ -307,7 +309,9 @@ func (l *MiniSetUserLikeLogic) setUserLikeComment(req *types.MiniSetUserLikeRequ
flagInfo := domain.UserLoveFlag{
Id: 0,
ArticleId: req.ArticleId,
ArticleAuthor: articleInfo.AuthorId,
CommentId: req.CommentId,
CommentAuthor: commentInfo.FromUserId,
UserId: req.UserId,
}
// 设置赞标识
... ...
... ... @@ -319,6 +319,7 @@ type MiniArticleGetResponse struct {
CountComment int `json:"countComment"` // 评论数量
CountRead int `json:"countRead"` // 浏览数量
Show int `json:"show"` // 评论的展示状态(0显示、1不显示)
Edit int `json:"edit"` // 文章是否存在变更记录 (0 不存在 1存在)
}
type ArticleSection struct {
... ... @@ -382,3 +383,32 @@ type MiniSetUserLikeResponse struct {
CommentId int64 `json:"commentId"` //评论id
Count int `json:"count"` //现有的点赞数量
}
type SystemArticleGetRequest struct {
Id int64 `path:"id"` //id
CompanyId int64 `path:",optional"`
}
type UserShowName struct {
Id int `json:"id"`
Name int `json:"name"`
}
type SystemArticleGetResponse struct {
Id int64 `json:"id"` // id
Title string `json:"title"` // 标题
AuthorId int64 `json:"authorId"` // 发布人id
Author Author `json:"author"` // 发布人
CreatedAt int64 `json:"createdAt"` // 文章的发布时间
Section []ArticleSection `json:"section"` // 文章的文本内容
Images []string `json:"images"` // 图片
WhoRead []int64 `json:"whoRead"` // 谁可查看
WhoReadInfo []UserShowName `json:"whoReadInfo"` // 谁可查看
WhoReview []int64 `json:"whoReview"` // 谁可评论
WhoReviewInfo []UserShowName `json:"whoReviewInfo"` // 谁可评论
Location Location `json:"location"` // 定位坐标
CountLove int `json:"countLove"` // 点赞数量
CountComment int `json:"countComment"` // 评论数量
CountRead int `json:"countRead"` // 浏览数量
Show int `json:"show"` // 评论的展示状态(0显示、1不显示)
}
... ...
... ... @@ -13,6 +13,8 @@ type UserLoveFlag struct {
Id int64 `gorm:"primaryKey"` // 唯一标识
ArticleId int64 // 点赞文章时,文章id
CommentId int64 // 点赞评论时,填评论id
ArticleAuthor int64 // 文章的发布人
CommentAuthor int64 // 评论的填写人
UserId int64
CreatedAt int64
UpdatedAt int64
... ...
... ... @@ -153,6 +153,8 @@ func (repository *UserLoveFlagRepository) ModelToDomainModel(from *models.UserLo
to := &domain.UserLoveFlag{
Id: from.Id,
ArticleId: from.ArticleId,
ArticleAuthor: from.ArticleAuthor,
CommentAuthor: from.CommentAuthor,
CommentId: from.CommentId,
UserId: from.UserId,
CreatedAt: from.CreatedAt,
... ... @@ -169,11 +171,14 @@ func (repository *UserLoveFlagRepository) DomainModelToModel(from *domain.UserLo
Id: from.Id,
ArticleId: from.ArticleId,
CommentId: from.CommentId,
ArticleAuthor: from.ArticleAuthor,
CommentAuthor: from.CommentAuthor,
UserId: from.UserId,
CreatedAt: from.CreatedAt,
UpdatedAt: from.UpdatedAt,
DeletedAt: from.DeletedAt,
Version: from.Version,
IsDel: 0,
}
// err := copier.Copy(to, from)
return to, nil
... ...
... ... @@ -81,7 +81,7 @@ func (a ArticleShow) Named() string {
func (m *Article) MakeBackup(operator UserSimple, section []ArticleSection) *ArticleBackup {
b := ArticleBackup{
Id: 0,
CompanyId: 0,
CompanyId: m.CompanyId,
CreatedAt: 0,
UpdatedAt: 0,
DeletedAt: 0,
... ...
... ... @@ -11,7 +11,9 @@ import (
type UserLoveFlag struct {
Id int64 `json:"id"`
ArticleId int64 `json:"articleId"` // 点赞文章时,文章id
ArticleAuthor int64 `json:"articleAuthor"` // 文章的发布人
CommentId int64 `json:"commentId"` // 点赞评论时,填评论id
CommentAuthor int64 `json:"commentAuthor"` // 评论的填写人
UserId int64 `json:"userId"`
CreatedAt int64 `json:"createdAt,omitempty"`
UpdatedAt int64 `json:"updatedAt,omitempty"`
... ...