作者 yangfu

角色权限

正在显示 30 个修改的文件 包含 578 行增加257 行删除
syntax = "v1"
import "core/comment.api"
import "core/message.api"
import "core/article_tag.api"
... ...
syntax = "v1"
import "article_type.api"
info(
title: "文章内容处理"
desc: "编辑处理文章内容"
... ... @@ -18,9 +20,6 @@ service Core {
@doc "小程序创建发布内容"
@handler MiniCreateArticle
post /article (MiniArticleCreateRequest) returns (MiniArticleCreateResponse)
@doc "小程序获取我发布的文章"
@handler MiniArticleSearchMe
post /article/search/me (MiniArticleSearchMeRequest) returns (MiniArticleSearchMeResponse)
@doc "小程序获取文章内容详情"
@handler MiniGetArticle
get /article/:id (MiniArticleGetRequest) returns (MiniArticleGetResponse)
... ... @@ -30,128 +29,25 @@ service Core {
@doc "小程序人员操作点赞文章/评论"
@handler MiniSetUserLike
post /article/user_like/set (MiniSetUserLikeRequset) returns (MiniSetUserLikeResponse)
}
// 坐标地点描述
type Location {
Longitude float64 `json:"longitude,optional"` //经度
Latitude float64 `json:"latitude,optional"` //纬度
Descript string `json:"descript,optional"` //地点描述
}
@doc "小程序获取我发布的文章"
@handler MiniArticleSearchMe
post /article/search/me (MiniArticleSearchMeRequest) returns (MiniArticleSearchMeResponse)
// 人员的简单展示信息
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:"-"`
}
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:"-"`
CompanyId int64 `json:"-"`
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:"-"` //公司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"` // 点赞记录的时间
}
// 管理后台接口
@server(
prefix: v1/system
group: article
jwt: MiniAuth
)
// 人员点赞文章/评论
type (
MiniSetUserLikeRequset {
ArticleId int64 `json:"articleId"` //文章id
CommentId int64 `json:"commentId"` //评论id
UserId int64 `json:"-"` //操作人
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
service Core {
@doc "管理后台获取文章内容详情"
@handler SystemGetArticle
get /article/:id (SystemArticleGetRequest) returns (SystemArticleGetResponse)
@doc "管理后台获取文章列表"
@handler SystemSearchArticle
post /article/search (SystemArticleSearchRequest) returns (SystemArticleSearchResponse)
}
\ 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不显示)
}
)
//管理后台获取文章列表
type (
SystemArticleSearchRequest {
CompanyId int64 `json:",optional"`
Page int `json:"page"`
Size int `json:"size"`
}
SystemArticleSearchResponse {
Total int `json:"total"`
List []SystemArticleSearch `json:"list"`
}
SystemArticleSearch {
Id int64 `json:"id"` //id
Title string `json:"title"` //标题
Author string `json:"author"` //发布人
Images []string `json:"images"` //图片
CreatedAt int64 `json:"createdAt"` //文章的创建日期
CountLove int `json:"countLove"` //点赞数量
CountComment int `json:"CountComment"` //评论数量
Show int `json:"show"` //是否隐藏 [0显示、1不显示]
Tags []string `json:"tags"` //标签
TargetUser int `json:"targetUser"` //分发方式 [0分发给所有人、1分发给指定的人]
}
)
\ No newline at end of file
... ...
syntax = "v1"
info(
title: "天联鹰蜓"
desc: "天联鹰蜓"
author: "email"
email: "email"
version: "v1"
title: "天联鹰蜓"
desc: "天联鹰蜓"
author: "email"
email: "email"
version: "v1"
)
// 小程序接口
@server(
prefix: v1
group: comment
jwt: MiniAuth
prefix: v1
group: comment
jwt: MiniAuth
)
service Core {
@doc "小程序评论"
@handler miniComment
get /mini/comment (CommentRequest) returns (CommentResposne)
@doc "小程序评论"
@handler miniComment
get /mini/comment (CommentRequest) returns (CommentResposne)
}
// 后台接口
@server(
prefix: v1
group: comment
jwt: SystemAuth
prefix: v1
group: comment
jwt: SystemAuth
)
service Core {
@doc "系统评论"
@handler systemComment
get /system/comment (CommentRequest) returns (CommentResposne)
@doc "系统评论"
@handler systemComment
get /system/comment (CommentRequest) returns (CommentResposne)
}
type(
CommentRequest struct{
}
CommentResposne struct{
List []Comment `json:"list"`
}
Comment struct{
type (
CommentRequest {
}
CommentResposne {
List []Comment `json:"list"`
}
}
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
... ...
... ... @@ -3,7 +3,7 @@ Host: 0.0.0.0
Port: 8081
Verbose: true
Migrate: false
Timeout: 30000
Log:
#Mode: file
Encoding: plain
... ... @@ -24,4 +24,4 @@ Redis:
Type: node
Pass:
DB:
DataSource: host=114.55.200.59 user=postgres password=eagle1010 dbname=sumifcc-discuss-dev port=31543 sslmode=disable TimeZone=Asia/Shanghai
\ No newline at end of file
DataSource: host=114.55.200.59 user=postgres password=eagle1010 dbname=sumifcc-discuss-dev port=31543 sslmode=disable TimeZone=Asia/Shanghai
... ...
... ... @@ -8,6 +8,7 @@ import (
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/result"
)
func MiniArticleSearchMeHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
... ... @@ -23,10 +24,6 @@ func MiniArticleSearchMeHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
req.AuthorId = token.UserId
req.CompanyId = token.CompanyId
resp, err := l.MiniArticleSearchMe(&req)
if err != nil {
httpx.ErrorCtx(r.Context(), w, err)
} else {
httpx.OkJsonCtx(r.Context(), w, resp)
}
result.HttpResult(r, w, resp, err)
}
}
... ...
... ... @@ -8,6 +8,7 @@ import (
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/result"
)
func MiniCreateArticleHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
... ... @@ -22,10 +23,7 @@ func MiniCreateArticleHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
l := article.NewMiniCreateArticleLogic(r.Context(), svcCtx)
req.AuthorId = token.UserId
resp, err := l.MiniCreateArticle(&req)
if err != nil {
httpx.ErrorCtx(r.Context(), w, err)
} else {
httpx.OkJsonCtx(r.Context(), w, resp)
}
result.HttpResult(r, w, resp, err)
}
}
... ...
... ... @@ -8,6 +8,7 @@ import (
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/result"
)
func MiniGetArticleHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
... ... @@ -22,10 +23,6 @@ func MiniGetArticleHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
token := contextdata.GetUserTokenFromCtx(r.Context())
req.CompanyId = token.CompanyId
resp, err := l.MiniGetArticle(&req)
if err != nil {
httpx.ErrorCtx(r.Context(), w, err)
} else {
httpx.OkJsonCtx(r.Context(), w, resp)
}
result.HttpResult(r, w, resp, err)
}
}
... ...
... ... @@ -8,6 +8,7 @@ import (
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/result"
)
func MiniSetUserLikeHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
... ... @@ -22,10 +23,6 @@ func MiniSetUserLikeHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
token := contextdata.GetUserTokenFromCtx(r.Context())
req.UserId = token.UserId
resp, err := l.MiniSetUserLike(&req)
if err != nil {
httpx.ErrorCtx(r.Context(), w, err)
} else {
httpx.OkJsonCtx(r.Context(), w, resp)
}
result.HttpResult(r, w, resp, err)
}
}
... ...
... ... @@ -8,6 +8,7 @@ import (
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/result"
)
func MiniUserLikeArticleHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
... ... @@ -22,10 +23,6 @@ func MiniUserLikeArticleHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
token := contextdata.GetUserTokenFromCtx(r.Context())
req.CompanyId = token.CompanyId
resp, err := l.MiniUserLikeArticle(&req)
if err != nil {
httpx.ErrorCtx(r.Context(), w, err)
} else {
httpx.OkJsonCtx(r.Context(), w, resp)
}
result.HttpResult(r, w, resp, err)
}
}
... ...
package article
import (
"net/http"
"github.com/zeromicro/go-zero/rest/httpx"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/article"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
)
func SystemGetArticleHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.SystemArticleGetRequest
if err := httpx.Parse(r, &req); err != nil {
httpx.ErrorCtx(r.Context(), w, err)
return
}
l := article.NewSystemGetArticleLogic(r.Context(), svcCtx)
resp, err := l.SystemGetArticle(&req)
if err != nil {
httpx.ErrorCtx(r.Context(), w, err)
} else {
httpx.OkJsonCtx(r.Context(), w, resp)
}
}
}
... ...
package article
import (
"net/http"
"github.com/zeromicro/go-zero/rest/httpx"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/article"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
)
func SystemSearchArticleHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.SystemArticleSearchRequest
if err := httpx.Parse(r, &req); err != nil {
httpx.ErrorCtx(r.Context(), w, err)
return
}
l := article.NewSystemSearchArticleLogic(r.Context(), svcCtx)
resp, err := l.SystemSearchArticle(&req)
if err != nil {
httpx.ErrorCtx(r.Context(), w, err)
} else {
httpx.OkJsonCtx(r.Context(), w, resp)
}
}
}
... ...
... ... @@ -189,11 +189,6 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
Handler: article.MiniCreateArticleHandler(serverCtx),
},
{
Method: http.MethodPost,
Path: "/article/search/me",
Handler: article.MiniArticleSearchMeHandler(serverCtx),
},
{
Method: http.MethodGet,
Path: "/article/:id",
Handler: article.MiniGetArticleHandler(serverCtx),
... ... @@ -208,6 +203,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
Path: "/article/user_like/set",
Handler: article.MiniSetUserLikeHandler(serverCtx),
},
{
Method: http.MethodPost,
Path: "/article/search/me",
Handler: article.MiniArticleSearchMeHandler(serverCtx),
},
},
rest.WithJwt(serverCtx.Config.MiniAuth.AccessSecret),
rest.WithPrefix("/v1/mini"),
... ... @@ -217,6 +217,23 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
[]rest.Route{
{
Method: http.MethodGet,
Path: "/article/:id",
Handler: article.SystemGetArticleHandler(serverCtx),
},
{
Method: http.MethodPost,
Path: "/article/search",
Handler: article.SystemSearchArticleHandler(serverCtx),
},
},
rest.WithJwt(serverCtx.Config.MiniAuth.AccessSecret),
rest.WithPrefix("/v1/system"),
)
server.AddRoutes(
[]rest.Route{
{
Method: http.MethodGet,
Path: "/system/role/:id",
Handler: role.SystemGetRoleHandler(serverCtx),
},
... ...
... ... @@ -35,7 +35,10 @@ func (l *MiniCreateArticleLogic) MiniCreateArticle(req *types.MiniArticleCreateR
if err != nil {
return nil, xerr.NewErrMsgErr("创建文章内容失败", err)
}
//TODO 获取人员信息
companyInfo, err := l.svcCtx.CompanyRepository.FindOne(l.ctx, conn, author.CompanyId)
if err != nil {
return nil, xerr.NewErrMsgErr("创建文章内容失败", err)
}
articleAuthor := domain.UserSimple{
Id: author.Id,
Name: author.Name,
... ... @@ -43,9 +46,16 @@ func (l *MiniCreateArticleLogic) MiniCreateArticle(req *types.MiniArticleCreateR
GroupId: 0,
Group: "",
Position: author.Position,
Company: "",
Company: companyInfo.Name,
CompanyId: author.CompanyId,
}
if author.DepartmentId > 0 {
department, err := l.svcCtx.DepartmentRepository.FindOne(l.ctx, conn, author.DepartmentId)
if err == nil {
articleAuthor.GroupId = department.Id
articleAuthor.Group = department.Name
}
}
if len(req.Images) > 9 {
return nil, xerr.NewErrMsg("图片数量最多9张")
}
... ... @@ -76,10 +86,12 @@ func (l *MiniCreateArticleLogic) MiniCreateArticle(req *types.MiniArticleCreateR
}
//检查文章可被哪些人评论
whoReview := []int64{}
if len(req.WhoReview) > 0 {
whoReview = lo.Uniq(req.WhoReview)
}
//有指定可查看人的情况
if len(whoRead) > 0 {
if len(whoReview) > 0 {
whoReview = lo.Uniq(req.WhoReview)
// 检查 whoRead 是否 完全包含 whoReview
ok := lo.Every(whoRead, whoReview)
if !ok {
... ... @@ -146,7 +158,12 @@ func (l *MiniCreateArticleLogic) MiniCreateArticle(req *types.MiniArticleCreateR
Latitude: req.Location.Latitude,
Descript: req.Location.Descript,
},
TargetUser: domain.ArticleTargetAll,
TargetUser: domain.ArticleTargetAll,
CountLove: 0,
CountComment: 0,
CountRead: 0,
Show: 0,
Tags: []int64{},
}
if len(whoRead) > 0 {
newArticle.TargetUser = domain.ArticleTargetLimit
... ...
... ... @@ -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)
}
... ...
... ... @@ -226,10 +226,12 @@ func (l *MiniSetUserLikeLogic) setUserLikeArticle(req *types.MiniSetUserLikeRequ
}
err = transaction.UseTrans(l.ctx, conn.DB(), func(ctx context.Context, c transaction.Conn) error {
flagInfo := domain.UserLoveFlag{
Id: 0,
ArticleId: req.ArticleId,
CommentId: req.CommentId,
UserId: req.UserId,
Id: 0,
ArticleId: req.ArticleId,
ArticleAuthor: articleInfo.AuthorId,
CommentId: 0,
CommentAuthor: 0,
UserId: req.UserId,
}
// 去除点赞标识
_, err = l.svcCtx.UserLoveFlagRepository.Insert(ctx, c, &flagInfo)
... ... @@ -247,7 +249,7 @@ func (l *MiniSetUserLikeLogic) setUserLikeArticle(req *types.MiniSetUserLikeRequ
return nil, xerr.NewErrMsgErr("设置点赞标识失败", err)
}
articleInfo, err = l.svcCtx.ArticleRepository.FindOne(l.ctx, conn, req.ArticleId)
if err == nil {
if err != nil {
return nil, xerr.NewErrMsgErr("获取点赞数量失败", err)
}
resp = &types.MiniSetUserLikeResponse{
... ... @@ -305,10 +307,12 @@ func (l *MiniSetUserLikeLogic) setUserLikeComment(req *types.MiniSetUserLikeRequ
err = transaction.UseTrans(l.ctx, conn.DB(), func(ctx context.Context, c transaction.Conn) error {
flagInfo := domain.UserLoveFlag{
Id: 0,
ArticleId: req.ArticleId,
CommentId: req.CommentId,
UserId: req.UserId,
Id: 0,
ArticleId: req.ArticleId,
ArticleAuthor: articleInfo.AuthorId,
CommentId: req.CommentId,
CommentAuthor: commentInfo.FromUserId,
UserId: req.UserId,
}
// 设置赞标识
_, err = l.svcCtx.UserLoveFlagRepository.Insert(ctx, c, &flagInfo)
... ...
... ... @@ -25,7 +25,7 @@ func NewMiniUserLikeArticleLogic(ctx context.Context, svcCtx *svc.ServiceContext
}
}
// 获取点赞的人员列表
// 获取点赞文章的的人员列表
func (l *MiniUserLikeArticleLogic) MiniUserLikeArticle(req *types.MiniUserLikeArticleRequest) (resp *types.MiniUserLikeArticleResponse, err error) {
var conn = l.svcCtx.DefaultDBConn()
queryOption := domain.NewQueryOptions().
... ...
package article
import (
"context"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
"github.com/zeromicro/go-zero/core/logx"
)
type SystemGetArticleLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewSystemGetArticleLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SystemGetArticleLogic {
return &SystemGetArticleLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
func (l *SystemGetArticleLogic) SystemGetArticle(req *types.SystemArticleGetRequest) (resp *types.SystemArticleGetResponse, err error) {
// todo: add your logic here and delete this line
return
}
... ...
package article
import (
"context"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
"github.com/zeromicro/go-zero/core/logx"
)
type SystemSearchArticleLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewSystemSearchArticleLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SystemSearchArticleLogic {
return &SystemSearchArticleLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
func (l *SystemSearchArticleLogic) SystemSearchArticle(req *types.SystemArticleSearchRequest) (resp *types.SystemArticleSearchResponse, err error) {
// todo: add your logic here and delete this line
return
}
... ...
... ... @@ -55,22 +55,32 @@ func (l *MiniSystemLogic) ArticleDefined(conn transaction.Conn, companyId, at in
return l.createMessage(conn, companyId, at, domain.MsgTypeNormal, "帖子已定性", fmt.Sprintf("您的帖子[%s]已被定性,如有疑问,请联系运营管理员了解详情。", item))
}
// AbnormalArticleUnapproved 文章未审核通过
//// ArticleAuth 文章权限变更
//func (l *MiniSystemLogic) ArticleAuth(conn transaction.Conn, companyId, at int64, item string) (err error) {
// return l.createMessage(conn, companyId, at, domain.MsgTypeAbnormal, "权限变更", fmt.Sprintf("您的帖子[%s]可见权限已添加,如有疑问,请联系运营管理员了解详情。", item))
//}
// AbnormalArticleUnapproved 异常通知-文章未审核通过
func (l *MiniSystemLogic) AbnormalArticleUnapproved(conn transaction.Conn, companyId, at int64, item string) (err error) {
return l.createMessage(conn, companyId, at, domain.MsgTypeAbnormal, "发帖未通过审核", fmt.Sprintf("您的帖子[%s]因违反运营规则未通过审核,如有疑问,请联系运营管理员了解详情。", item))
}
// AbnormalArticleHidden 文章被隐藏
// AbnormalArticleHidden 异常通知-文章被隐藏
func (l *MiniSystemLogic) AbnormalArticleHidden(conn transaction.Conn, companyId, at int64, item string) (err error) {
return l.createMessage(conn, companyId, at, domain.MsgTypeAbnormal, "帖子被隐藏", fmt.Sprintf("您的帖子[%s]已被隐藏,如有疑问,请联系运营管理员了解详情。", item))
}
// AbnormalCommentUnapproved 评论未审核通过
//// AbnormalArticleAuth 异常通知-文章权限变更
//func (l *MiniSystemLogic) AbnormalArticleAuth(conn transaction.Conn, companyId, at int64, item string) (err error) {
// return l.createMessage(conn, companyId, at, domain.MsgTypeAbnormal, "权限变更", fmt.Sprintf("您的帖子[%s]可见权限已被移除,如有疑问,请联系运营管理员了解详情。", item))
//}
// AbnormalCommentUnapproved 异常通知-评论未审核通过
func (l *MiniSystemLogic) AbnormalCommentUnapproved(conn transaction.Conn, companyId, at int64, item string) (err error) {
return l.createMessage(conn, companyId, at, domain.MsgTypeAbnormal, "评论未通过审核", fmt.Sprintf("您的评论[%s]因违反运营规则未通过审核,如有疑问,请联系运营管理员了解详情。", item))
}
// AbnormalCommentHidden 评论被隐藏
// AbnormalCommentHidden 异常通知-评论被隐藏
func (l *MiniSystemLogic) AbnormalCommentHidden(conn transaction.Conn, companyId, at int64, item string) (err error) {
return l.createMessage(conn, companyId, at, domain.MsgTypeAbnormal, "评论被隐藏", fmt.Sprintf("您的评论[%s]已被隐藏,如有疑问,请联系运营管理员了解详情。", item))
}
... ...
... ... @@ -174,7 +174,6 @@ type MiniUserInfoResponse struct {
TotalLoved int64 `json:"totalLoved"` // 累计收到的赞
TotalAccepted int64 `json:"totalAccepted"` // 累计被采纳
Accounts []Account `json:"accounts"` // 公司账号
Auths []Auth `json:"auths"` // 权限
}
type MiniUserApplyJoinCompanyRequest struct {
... ... @@ -316,7 +315,7 @@ type MiniArticleCreateResponse struct {
type MiniArticleGetRequest struct {
Id int64 `path:"id"` //id
CompanyId int64 `path:"-"`
CompanyId int64 `path:",optional"`
}
type MiniArticleGetResponse struct {
... ... @@ -334,6 +333,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 {
... ... @@ -344,8 +344,8 @@ type ArticleSection struct {
}
type MiniArticleSearchMeRequest struct {
AuthorId int64 `json:"-"`
CompanyId int64 `json:"-"`
AuthorId int64 `json:",optional"`
CompanyId int64 `json:",optional"`
Page int `json:"page"`
Size int `json:"size"`
}
... ... @@ -367,7 +367,7 @@ type ArticleSearchMe struct {
type MiniUserLikeArticleRequest struct {
ArticleId int64 `json:"articleId"` // 文章id
CompanyId int64 `json:"-"` //公司id
CompanyId int64 `json:",optional"` //公司id
Page int `json:"page"` //分页,第几页
Size int `json:"size"` //分页,每页几条
}
... ... @@ -388,7 +388,7 @@ type WhichUserLikeArticle struct {
type MiniSetUserLikeRequset struct {
ArticleId int64 `json:"articleId"` //文章id
CommentId int64 `json:"commentId"` //评论id
UserId int64 `json:"-"` //操作人
UserId int64 `json:",optional"` //操作人
Flag int `json:"flag"` //点赞标志 1、点赞 2 、取消点赞
}
... ... @@ -398,6 +398,59 @@ type MiniSetUserLikeResponse struct {
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不显示)
}
type SystemArticleSearchRequest struct {
CompanyId int64 `json:",optional"`
Page int `json:"page"`
Size int `json:"size"`
}
type SystemArticleSearchResponse struct {
Total int `json:"total"`
List []SystemArticleSearch `json:"list"`
}
type SystemArticleSearch struct {
Id int64 `json:"id"` //id
Title string `json:"title"` //标题
Author string `json:"author"` //发布人
Images []string `json:"images"` //图片
CreatedAt int64 `json:"createdAt"` //文章的创建日期
CountLove int `json:"countLove"` //点赞数量
CountComment int `json:"CountComment"` //评论数量
Show int `json:"show"` //是否隐藏 [0显示、1不显示]
Tags []string `json:"tags"` //标签
TargetUser int `json:"targetUser"` //分发方式 [0分发给所有人、1分发给指定的人]
}
type RoleGetRequest struct {
Id int64 `path:"id"`
}
... ...
... ... @@ -45,6 +45,7 @@ func (m *Article) BeforeCreate(tx *gorm.DB) (err error) {
func (m *Article) BeforeUpdate(tx *gorm.DB) (err error) {
m.UpdatedAt = time.Now().Unix()
m.Version += 1
return
}
... ...
... ... @@ -45,6 +45,7 @@ func (m *ArticleComment) BeforeCreate(tx *gorm.DB) (err error) {
func (m *ArticleComment) BeforeUpdate(tx *gorm.DB) (err error) {
m.UpdatedAt = time.Now().Unix()
m.Version += 1
return
}
... ...
... ... @@ -10,15 +10,17 @@ import (
)
type UserLoveFlag struct {
Id int64 `gorm:"primaryKey"` // 唯一标识
ArticleId int64 // 点赞文章时,文章id
CommentId int64 // 点赞评论时,填评论id
UserId int64
CreatedAt int64
UpdatedAt int64
DeletedAt int64
Version int
IsDel soft_delete.DeletedAt `gorm:"softDelete:flag,DeletedAtField:DeletedAt"`
Id int64 `gorm:"primaryKey"` // 唯一标识
ArticleId int64 // 点赞文章时,文章id
CommentId int64 // 点赞评论时,填评论id
ArticleAuthor int64 // 文章的发布人
CommentAuthor int64 // 评论的填写人
UserId int64
CreatedAt int64
UpdatedAt int64
DeletedAt int64
Version int
IsDel soft_delete.DeletedAt `gorm:"softDelete:flag,DeletedAtField:DeletedAt"`
}
func (m *UserLoveFlag) TableName() string {
... ...
... ... @@ -194,9 +194,25 @@ func (repository *ArticleCommentRepository) DomainModelToModel(from *domain.Arti
return to, nil
}
// TODO 点赞数量变动
// 点赞数量变动
func (repository *ArticleCommentRepository) IncreaseCountUserLove(ctx context.Context, conn transaction.Conn, incr int, dm *domain.ArticleComment) error {
var (
err error
m *models.ArticleComment
tx = conn.DB()
)
if m, err = repository.DomainModelToModel(dm); err != nil {
return err
}
queryFunc := func() (interface{}, error) {
tx = tx.Model(m).Update("count_user_love", gorm.Expr("count_user_love+?", incr))
return nil, tx.Error
}
if _, err = repository.Query(queryFunc, m.CacheKeyFunc()); err != nil {
return err
}
return nil
}
func NewArticleCommentRepository(cache *cache.CachedRepository) domain.ArticleCommentRepository {
... ...
... ... @@ -168,6 +168,7 @@ func (repository *ArticleRepository) ModelToDomainModel(from *models.Article) (*
CountComment: from.CountComment,
CountRead: from.CountRead,
Show: domain.ArticleShow(from.Show),
Tags: from.Tags,
}
return to, nil
}
... ... @@ -193,22 +194,27 @@ func (repository *ArticleRepository) DomainModelToModel(from *domain.Article) (*
CountRead: from.CountRead,
CountComment: from.CountComment,
Show: int(from.Show),
Tags: from.Tags,
}
// err := copier.Copy(to, from)
return to, nil
}
// 点赞数量变动
func (repository *ArticleRepository) IncreaseCountLove(ctx context.Context, conn transaction.Conn, incr int, article *domain.Article) error {
func (repository *ArticleRepository) IncreaseCountLove(ctx context.Context, conn transaction.Conn, incr int, dm *domain.Article) error {
//
var (
err error
m *models.Article
tx = conn.DB()
)
m = &models.Article{Id: article.Id}
if m, err = repository.DomainModelToModel(dm); err != nil {
return err
}
queryFunc := func() (interface{}, error) {
tx = tx.Model(m).Update("count_love", gorm.Expr("count_love+?", incr))
tx = tx.Model(m).Updates(map[string]interface{}{
"count_love": gorm.Expr("count_love+?", incr),
})
return nil, tx.Error
}
if _, err = repository.Query(queryFunc, m.CacheKeyFunc()); err != nil {
... ... @@ -218,13 +224,15 @@ func (repository *ArticleRepository) IncreaseCountLove(ctx context.Context, conn
}
// 浏览数量变动
func (repository *ArticleRepository) IncreaseCountRead(ctx context.Context, conn transaction.Conn, incr int, article *domain.Article) error {
func (repository *ArticleRepository) IncreaseCountRead(ctx context.Context, conn transaction.Conn, incr int, dm *domain.Article) error {
var (
err error
m *models.Article
tx = conn.DB()
)
m = &models.Article{Id: article.Id}
if m, err = repository.DomainModelToModel(dm); err != nil {
return err
}
queryFunc := func() (interface{}, error) {
tx = tx.Model(m).Update("count_read", gorm.Expr("count_read+?", incr))
return nil, tx.Error
... ... @@ -236,13 +244,15 @@ func (repository *ArticleRepository) IncreaseCountRead(ctx context.Context, conn
}
// 评论数量变动
func (repository *ArticleRepository) IncreaseCountComment(ctx context.Context, conn transaction.Conn, incr int, article *domain.Article) error {
func (repository *ArticleRepository) IncreaseCountComment(ctx context.Context, conn transaction.Conn, incr int, dm *domain.Article) error {
var (
err error
m *models.Article
tx = conn.DB()
)
m = &models.Article{Id: article.Id}
if m, err = repository.DomainModelToModel(dm); err != nil {
return err
}
queryFunc := func() (interface{}, error) {
tx = tx.Model(m).Update("count_comment", gorm.Expr("count_comment+?", incr))
return nil, tx.Error
... ...
... ... @@ -151,14 +151,16 @@ func (repository *UserLoveFlagRepository) Find(ctx context.Context, conn transac
func (repository *UserLoveFlagRepository) ModelToDomainModel(from *models.UserLoveFlag) (*domain.UserLoveFlag, error) {
to := &domain.UserLoveFlag{
Id: from.Id,
ArticleId: from.ArticleId,
CommentId: from.CommentId,
UserId: from.UserId,
CreatedAt: from.CreatedAt,
UpdatedAt: from.UpdatedAt,
DeletedAt: from.DeletedAt,
Version: from.Version,
Id: from.Id,
ArticleId: from.ArticleId,
ArticleAuthor: from.ArticleAuthor,
CommentAuthor: from.CommentAuthor,
CommentId: from.CommentId,
UserId: from.UserId,
CreatedAt: from.CreatedAt,
UpdatedAt: from.UpdatedAt,
DeletedAt: from.DeletedAt,
Version: from.Version,
}
// err := copier.Copy(to, from)
return to, nil
... ... @@ -166,14 +168,17 @@ func (repository *UserLoveFlagRepository) ModelToDomainModel(from *models.UserLo
func (repository *UserLoveFlagRepository) DomainModelToModel(from *domain.UserLoveFlag) (*models.UserLoveFlag, error) {
to := &models.UserLoveFlag{
Id: from.Id,
ArticleId: from.ArticleId,
CommentId: from.CommentId,
UserId: from.UserId,
CreatedAt: from.CreatedAt,
UpdatedAt: from.UpdatedAt,
DeletedAt: from.DeletedAt,
Version: from.Version,
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,
... ...
... ... @@ -9,14 +9,16 @@ import (
// 人员点赞标记
type UserLoveFlag struct {
Id int64 `json:"id"`
ArticleId int64 `json:"articleId"` // 点赞文章时,文章id
CommentId int64 `json:"commentId"` // 点赞评论时,填评论id
UserId int64 `json:"userId"`
CreatedAt int64 `json:"createdAt,omitempty"`
UpdatedAt int64 `json:"updatedAt,omitempty"`
DeletedAt int64 `json:"deletedAt,omitempty"`
Version int `json:"version,omitempty"`
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"`
DeletedAt int64 `json:"deletedAt,omitempty"`
Version int `json:"version,omitempty"`
}
type UserLoveFlagRepository interface {
Insert(ctx context.Context, conn transaction.Conn, dm *UserLoveFlag) (*UserLoveFlag, error)
... ...