Merge branch 'dev' of http://gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss into dev
正在显示
28 个修改的文件
包含
939 行增加
和
8 行删除
Dockerfile
0 → 100644
1 | +FROM golang:1.19-alpine as builder | ||
2 | + | ||
3 | +# Define the project name | 定义项目名称 | ||
4 | +ARG PROJECT=core | ||
5 | + | ||
6 | +WORKDIR /build | ||
7 | +COPY . . | ||
8 | + | ||
9 | +RUN go env -w GO111MODULE=on \ | ||
10 | + && go env -w GOPROXY=https://goproxy.cn,direct \ | ||
11 | + && go env -w CGO_ENABLED=0 \ | ||
12 | + && go env \ | ||
13 | + && go mod tidy \ | ||
14 | + && cd cmd/discuss/api \ | ||
15 | + && go build -ldflags="-s -w" -o /build/api/${PROJECT} ${PROJECT}.go | ||
16 | + | ||
17 | +FROM alpine:latest | ||
18 | + | ||
19 | +# Define the project name | 定义项目名称 | ||
20 | +ARG PROJECT=core | ||
21 | +# Define the config file name | 定义配置文件名 | ||
22 | +ARG CONFIG_FILE=core.yaml | ||
23 | +# Define the author | 定义作者 | ||
24 | +ARG AUTHOR=785409885@qq.com | ||
25 | + | ||
26 | +LABEL org.opencontainers.image.authors=${AUTHOR} | ||
27 | + | ||
28 | +WORKDIR /app | ||
29 | +ENV PROJECT=${PROJECT} | ||
30 | +ENV CONFIG_FILE=${CONFIG_FILE} | ||
31 | + | ||
32 | +COPY --from=builder /build/api/${PROJECT} ./ | ||
33 | +COPY --from=builder /build/cmd/discuss/api/etc/${CONFIG_FILE} ./etc/ | ||
34 | + | ||
35 | +EXPOSE 8080 | ||
36 | +ENTRYPOINT ./${PROJECT} -f etc/${CONFIG_FILE} |
@@ -56,6 +56,21 @@ service Core { | @@ -56,6 +56,21 @@ service Core { | ||
56 | @handler SystemArticleCommentSearch | 56 | @handler SystemArticleCommentSearch |
57 | post /article_comment/search (SystemArticleCommentSearchRequest) returns (SystemArticleCommentSearchResponse) | 57 | post /article_comment/search (SystemArticleCommentSearchRequest) returns (SystemArticleCommentSearchResponse) |
58 | 58 | ||
59 | + @doc "管理后台查看所有的评论" | ||
60 | + @handler SystemListAticleComment | ||
61 | + post /article_comment/list (SystemListCommentRequest)returns (SystemListCommentResponse) | ||
62 | + | ||
63 | + @doc "管理后台评论的详情" | ||
64 | + @handler SystemGetAticleComment | ||
65 | + get /article_comment/:id (SystemGetCommentRequest)returns (SystemGetCommentResponse) | ||
66 | + | ||
67 | + @doc "管理后台变更评论的显示状态" | ||
68 | + @handler SystemEditAticleCommentShow | ||
69 | + post /article_comment/edit_show (SystemEditCommentShowRequest)returns (SystemEditCommentShowResponse) | ||
70 | + | ||
71 | + @doc "管理后台变更评论" | ||
72 | + @handler SystemEditAticleComment | ||
73 | + post /article_comment/edit (SystemEditCommentRequest)returns (SystemEditCommentResponse) | ||
59 | } | 74 | } |
60 | 75 | ||
61 | //评论的填写人 | 76 | //评论的填写人 |
@@ -239,4 +254,91 @@ type ( | @@ -239,4 +254,91 @@ type ( | ||
239 | Content string `json:"content"` // 评论的内容 | 254 | Content string `json:"content"` // 评论的内容 |
240 | Show int `json:"show"` // 显示状态 | 255 | Show int `json:"show"` // 显示状态 |
241 | } | 256 | } |
257 | +) | ||
258 | + | ||
259 | +// 管理后台 评论管理列表 | ||
260 | +type ( | ||
261 | + SystemListCommentRequest { | ||
262 | + Page int `json:"page"` | ||
263 | + Size int `json:"size"` | ||
264 | + CompanyId int64 `json:",optional"` // | ||
265 | + TopId int64 `json:"topId"` // 评论的顶层ID | ||
266 | + FromUser string `json:"fromUser,optional"` // 用户 | ||
267 | + Show int `json:"show,optional"` // 显示状态 | ||
268 | + BeginTime int64 `json:"beginTime,optional"` // 填写评论的开始时间 | ||
269 | + EndTime int64 `json:"endTime,optional"` // 填写评论的结束时间 | ||
270 | + ArticleTitle string `json:"articleTitle,optional"` // | ||
271 | + Content string `json:"content,optional"` // | ||
272 | + } | ||
273 | + SystemListCommentResponse { | ||
274 | + Total int `json:"total"` | ||
275 | + List []SystemCommentItem `json:"list"` | ||
276 | + } | ||
277 | + SystemCommentItem { | ||
278 | + Id int64 `json:"id"` //评论id | ||
279 | + Pid int64 `json:"pid"` // | ||
280 | + TopId int64 `json:"topId"` // | ||
281 | + ArticleId int64 `json:"articleId"` //对应的文章id | ||
282 | + ArticleTitle string `json:"articleTitle"` //文章标题 | ||
283 | + FromUserId int64 `json:"fromUserId"` //填写评论的人 | ||
284 | + FromUser CommentAuthor `json:"fromUser"` //填写评论的人 | ||
285 | + CreatedAt int64 `json:"createdAt"` //评论的填写时间 | ||
286 | + Content string `json:"content"` //评论的内容 | ||
287 | + Show int `json:"show"` //是否展示 [1显示] [2不显示] | ||
288 | + CountReply int `json:"countReplay"` //回复数量 | ||
289 | + CountUserLove int `json:"countUserLove"` //用户点赞数量 | ||
290 | + CountAdminLove int `json:"countAdminLove"` //运营点赞数量 | ||
291 | + } | ||
292 | +) | ||
293 | + | ||
294 | +// 管理后台获取评论详情 | ||
295 | +type ( | ||
296 | + SystemGetCommentRequest { | ||
297 | + CompanyId int64 `path:",optional"` | ||
298 | + Id int64 `path:"id"` | ||
299 | + } | ||
300 | + | ||
301 | + SystemGetCommentResponse { | ||
302 | + Id int64 `json:"id"` //评论id | ||
303 | + Pid int64 `json:"pid"` // | ||
304 | + TopId int64 `json:"topId"` // | ||
305 | + ArticleId int64 `json:"articleId"` //对应的文章id | ||
306 | + ArticleTitle string `json:"articleTitle"` //文章标题 | ||
307 | + FromUserId int64 `json:"fromUserId"` //填写评论的人 | ||
308 | + FromUser CommentAuthor `json:"fromUser"` //填写评论的人 | ||
309 | + CreatedAt int64 `json:"createdAt"` //评论的填写时间 | ||
310 | + SectionContent string `json:"sectionContent"` //引用的段落内容 | ||
311 | + Content string `json:"content"` // 评论的内容 | ||
312 | + Show int `json:"show"` //是否展示 [1显示] [2不显示] | ||
313 | + CountReply int `json:"countReplay"` //回复数量 | ||
314 | + CountUserLove int `json:"countUserLove"` //用户点赞数量 | ||
315 | + CountAdminLove int `json:"countAdminLove"` //运营点赞数量 | ||
316 | + } | ||
317 | +) | ||
318 | + | ||
319 | +// 管理后台单独设置评论显示隐藏状态 | ||
320 | +type ( | ||
321 | + SystemEditCommentShowRequest { | ||
322 | + CompanyId int64 `json:",optional"` | ||
323 | + Id []int64 `json:"id"` | ||
324 | + Show int `json:"show"` //[1 显示评论] [2: 隐藏评论] | ||
325 | + } | ||
326 | + | ||
327 | + SystemEditCommentShowResponse { | ||
328 | + Id []int64 `json:"id"` | ||
329 | + } | ||
330 | +) | ||
331 | + | ||
332 | +// 管理后台变更评论 | ||
333 | +type ( | ||
334 | + SystemEditCommentRequest { | ||
335 | + CompanyId int64 `json:",optional"` | ||
336 | + Id int64 `json:"id"` | ||
337 | + Show int `json:"show"` //[1 显示评论] [2: 隐藏评论] | ||
338 | + CountAdminLove int `json:"countAdminLove,optional"` | ||
339 | + } | ||
340 | + | ||
341 | + SystemEditCommentResponse { | ||
342 | + Id int64 `json:"id"` | ||
343 | + } | ||
242 | ) | 344 | ) |
@@ -4,6 +4,8 @@ Port: 8081 | @@ -4,6 +4,8 @@ Port: 8081 | ||
4 | Verbose: true | 4 | Verbose: true |
5 | Migrate: false | 5 | Migrate: false |
6 | Timeout: 30000 | 6 | Timeout: 30000 |
7 | +# CertFile: ./key/fjmaimaimai.com_bundle.crt | ||
8 | +# KeyFile: ./key/fjmaimaimai.com.key | ||
7 | Log: | 9 | Log: |
8 | #Mode: file | 10 | #Mode: file |
9 | Encoding: plain | 11 | Encoding: plain |
@@ -16,7 +16,7 @@ func MiniSearchArticlePageHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | @@ -16,7 +16,7 @@ func MiniSearchArticlePageHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
16 | return func(w http.ResponseWriter, r *http.Request) { | 16 | return func(w http.ResponseWriter, r *http.Request) { |
17 | var req types.MiniSearchArticleRequest | 17 | var req types.MiniSearchArticleRequest |
18 | if err := httpx.Parse(r, &req); err != nil { | 18 | if err := httpx.Parse(r, &req); err != nil { |
19 | - httpx.ErrorCtx(r.Context(), w, err) | 19 | + result.HttpResult(r, w, nil, err) |
20 | return | 20 | return |
21 | } | 21 | } |
22 | 22 |
1 | package comment | 1 | package comment |
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | - "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/result" | ||
5 | "net/http" | 4 | "net/http" |
6 | 5 | ||
6 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/result" | ||
7 | + | ||
7 | "github.com/zeromicro/go-zero/rest/httpx" | 8 | "github.com/zeromicro/go-zero/rest/httpx" |
8 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/comment" | 9 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/comment" |
9 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | 10 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" |
@@ -14,7 +15,7 @@ func SystemArticleCommentSearchHandler(svcCtx *svc.ServiceContext) http.HandlerF | @@ -14,7 +15,7 @@ func SystemArticleCommentSearchHandler(svcCtx *svc.ServiceContext) http.HandlerF | ||
14 | return func(w http.ResponseWriter, r *http.Request) { | 15 | return func(w http.ResponseWriter, r *http.Request) { |
15 | var req types.SystemArticleCommentSearchRequest | 16 | var req types.SystemArticleCommentSearchRequest |
16 | if err := httpx.Parse(r, &req); err != nil { | 17 | if err := httpx.Parse(r, &req); err != nil { |
17 | - httpx.ErrorCtx(r.Context(), w, err) | 18 | + result.HttpResult(r, w, nil, err) |
18 | return | 19 | return |
19 | } | 20 | } |
20 | 21 |
1 | package comment | 1 | package comment |
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | - "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/result" | ||
5 | "net/http" | 4 | "net/http" |
6 | 5 | ||
6 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/result" | ||
7 | + | ||
7 | "github.com/zeromicro/go-zero/rest/httpx" | 8 | "github.com/zeromicro/go-zero/rest/httpx" |
8 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/comment" | 9 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/comment" |
9 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | 10 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" |
@@ -14,7 +15,7 @@ func SystemArticleCommentSearchMeHandler(svcCtx *svc.ServiceContext) http.Handle | @@ -14,7 +15,7 @@ func SystemArticleCommentSearchMeHandler(svcCtx *svc.ServiceContext) http.Handle | ||
14 | return func(w http.ResponseWriter, r *http.Request) { | 15 | return func(w http.ResponseWriter, r *http.Request) { |
15 | var req types.SystemArticleCommentSearchMeRequest | 16 | var req types.SystemArticleCommentSearchMeRequest |
16 | if err := httpx.Parse(r, &req); err != nil { | 17 | if err := httpx.Parse(r, &req); err != nil { |
17 | - httpx.ErrorCtx(r.Context(), w, err) | 18 | + result.HttpResult(r, w, nil, err) |
18 | return | 19 | return |
19 | } | 20 | } |
20 | 21 |
1 | +package comment | ||
2 | + | ||
3 | +import ( | ||
4 | + "net/http" | ||
5 | + | ||
6 | + "github.com/zeromicro/go-zero/rest/httpx" | ||
7 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/comment" | ||
8 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | ||
9 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | ||
10 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata" | ||
11 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/result" | ||
12 | +) | ||
13 | + | ||
14 | +func SystemEditAticleCommentHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
15 | + return func(w http.ResponseWriter, r *http.Request) { | ||
16 | + var req types.SystemEditCommentRequest | ||
17 | + if err := httpx.Parse(r, &req); err != nil { | ||
18 | + httpx.ErrorCtx(r.Context(), w, err) | ||
19 | + return | ||
20 | + } | ||
21 | + | ||
22 | + l := comment.NewSystemEditAticleCommentLogic(r.Context(), svcCtx) | ||
23 | + token := contextdata.GetUserTokenFromCtx(r.Context()) | ||
24 | + req.CompanyId = token.CompanyId | ||
25 | + resp, err := l.SystemEditAticleComment(&req) | ||
26 | + result.HttpResult(r, w, resp, err) | ||
27 | + } | ||
28 | +} |
1 | +package comment | ||
2 | + | ||
3 | +import ( | ||
4 | + "net/http" | ||
5 | + | ||
6 | + "github.com/zeromicro/go-zero/rest/httpx" | ||
7 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/comment" | ||
8 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | ||
9 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | ||
10 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata" | ||
11 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/result" | ||
12 | +) | ||
13 | + | ||
14 | +func SystemEditAticleCommentShowHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
15 | + return func(w http.ResponseWriter, r *http.Request) { | ||
16 | + var req types.SystemEditCommentShowRequest | ||
17 | + if err := httpx.Parse(r, &req); err != nil { | ||
18 | + result.HttpResult(r, w, nil, err) | ||
19 | + return | ||
20 | + } | ||
21 | + | ||
22 | + l := comment.NewSystemEditAticleCommentShowLogic(r.Context(), svcCtx) | ||
23 | + token := contextdata.GetUserTokenFromCtx(r.Context()) | ||
24 | + req.CompanyId = token.CompanyId | ||
25 | + resp, err := l.SystemEditAticleCommentShow(&req) | ||
26 | + result.HttpResult(r, w, resp, err) | ||
27 | + } | ||
28 | +} |
1 | +package comment | ||
2 | + | ||
3 | +import ( | ||
4 | + "net/http" | ||
5 | + | ||
6 | + "github.com/zeromicro/go-zero/rest/httpx" | ||
7 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/comment" | ||
8 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | ||
9 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | ||
10 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata" | ||
11 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/result" | ||
12 | +) | ||
13 | + | ||
14 | +func SystemGetAticleCommentHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
15 | + return func(w http.ResponseWriter, r *http.Request) { | ||
16 | + var req types.SystemGetCommentRequest | ||
17 | + if err := httpx.Parse(r, &req); err != nil { | ||
18 | + result.HttpResult(r, w, nil, err) | ||
19 | + return | ||
20 | + } | ||
21 | + | ||
22 | + l := comment.NewSystemGetAticleCommentLogic(r.Context(), svcCtx) | ||
23 | + token := contextdata.GetUserTokenFromCtx(r.Context()) | ||
24 | + req.CompanyId = token.CompanyId | ||
25 | + resp, err := l.SystemGetAticleComment(&req) | ||
26 | + result.HttpResult(r, w, resp, err) | ||
27 | + } | ||
28 | +} |
1 | +package comment | ||
2 | + | ||
3 | +import ( | ||
4 | + "net/http" | ||
5 | + | ||
6 | + "github.com/zeromicro/go-zero/rest/httpx" | ||
7 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/comment" | ||
8 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | ||
9 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | ||
10 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata" | ||
11 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/result" | ||
12 | +) | ||
13 | + | ||
14 | +func SystemListAticleCommentHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
15 | + return func(w http.ResponseWriter, r *http.Request) { | ||
16 | + var req types.SystemListCommentRequest | ||
17 | + if err := httpx.Parse(r, &req); err != nil { | ||
18 | + result.HttpResult(r, w, nil, err) | ||
19 | + return | ||
20 | + } | ||
21 | + | ||
22 | + l := comment.NewSystemListAticleCommentLogic(r.Context(), svcCtx) | ||
23 | + token := contextdata.GetUserTokenFromCtx(r.Context()) | ||
24 | + req.CompanyId = token.CompanyId | ||
25 | + resp, err := l.SystemListAticleComment(&req) | ||
26 | + result.HttpResult(r, w, resp, err) | ||
27 | + } | ||
28 | +} |
@@ -69,6 +69,26 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { | @@ -69,6 +69,26 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { | ||
69 | Path: "/article_comment/search", | 69 | Path: "/article_comment/search", |
70 | Handler: comment.SystemArticleCommentSearchHandler(serverCtx), | 70 | Handler: comment.SystemArticleCommentSearchHandler(serverCtx), |
71 | }, | 71 | }, |
72 | + { | ||
73 | + Method: http.MethodPost, | ||
74 | + Path: "/article_comment/list", | ||
75 | + Handler: comment.SystemListAticleCommentHandler(serverCtx), | ||
76 | + }, | ||
77 | + { | ||
78 | + Method: http.MethodGet, | ||
79 | + Path: "/article_comment/:id", | ||
80 | + Handler: comment.SystemGetAticleCommentHandler(serverCtx), | ||
81 | + }, | ||
82 | + { | ||
83 | + Method: http.MethodPost, | ||
84 | + Path: "/article_comment/edit_show", | ||
85 | + Handler: comment.SystemEditAticleCommentShowHandler(serverCtx), | ||
86 | + }, | ||
87 | + { | ||
88 | + Method: http.MethodPost, | ||
89 | + Path: "/article_comment/edit", | ||
90 | + Handler: comment.SystemEditAticleCommentHandler(serverCtx), | ||
91 | + }, | ||
72 | }..., | 92 | }..., |
73 | ), | 93 | ), |
74 | rest.WithJwt(serverCtx.Config.SystemAuth.AccessSecret), | 94 | rest.WithJwt(serverCtx.Config.SystemAuth.AccessSecret), |
@@ -38,6 +38,12 @@ func (l *MiniDeleteArticleCommentLogic) MiniDeleteArticleComment(req *types.Mini | @@ -38,6 +38,12 @@ func (l *MiniDeleteArticleCommentLogic) MiniDeleteArticleComment(req *types.Mini | ||
38 | return nil, xerr.NewErrMsg("没有操作权限") | 38 | return nil, xerr.NewErrMsg("没有操作权限") |
39 | } | 39 | } |
40 | 40 | ||
41 | + if commetInfo.Show == domain.CommentShowDisable { | ||
42 | + resp = &types.MiniDeleteArticleCommentResponse{ | ||
43 | + Id: commetInfo.Id, | ||
44 | + } | ||
45 | + return resp, nil | ||
46 | + } | ||
41 | commetInfo.Show = domain.CommentShowDisable | 47 | commetInfo.Show = domain.CommentShowDisable |
42 | 48 | ||
43 | // 变更回复数量 | 49 | // 变更回复数量 |
@@ -25,6 +25,7 @@ func NewMiniListArticleCommentLogic(ctx context.Context, svcCtx *svc.ServiceCont | @@ -25,6 +25,7 @@ func NewMiniListArticleCommentLogic(ctx context.Context, svcCtx *svc.ServiceCont | ||
25 | } | 25 | } |
26 | } | 26 | } |
27 | 27 | ||
28 | +// 小程序端获取 根据文章id 获取评论列表 | ||
28 | func (l *MiniListArticleCommentLogic) MiniListArticleComment(req *types.MiniListArticleCommentRequest) (resp *types.MiniListArticleCommentResponse, err error) { | 29 | func (l *MiniListArticleCommentLogic) MiniListArticleComment(req *types.MiniListArticleCommentRequest) (resp *types.MiniListArticleCommentResponse, err error) { |
29 | // 先获取最顶层的评论 | 30 | // 先获取最顶层的评论 |
30 | var conn = l.svcCtx.DefaultDBConn() | 31 | var conn = l.svcCtx.DefaultDBConn() |
1 | +package comment | ||
2 | + | ||
3 | +import ( | ||
4 | + "context" | ||
5 | + | ||
6 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | ||
7 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | ||
8 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/db/transaction" | ||
9 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain" | ||
10 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr" | ||
11 | + | ||
12 | + "github.com/zeromicro/go-zero/core/logx" | ||
13 | +) | ||
14 | + | ||
15 | +type SystemEditAticleCommentLogic struct { | ||
16 | + logx.Logger | ||
17 | + ctx context.Context | ||
18 | + svcCtx *svc.ServiceContext | ||
19 | +} | ||
20 | + | ||
21 | +func NewSystemEditAticleCommentLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SystemEditAticleCommentLogic { | ||
22 | + return &SystemEditAticleCommentLogic{ | ||
23 | + Logger: logx.WithContext(ctx), | ||
24 | + ctx: ctx, | ||
25 | + svcCtx: svcCtx, | ||
26 | + } | ||
27 | +} | ||
28 | + | ||
29 | +// 管理后台变更评论的设置 | ||
30 | +func (l *SystemEditAticleCommentLogic) SystemEditAticleComment(req *types.SystemEditCommentRequest) (resp *types.SystemEditCommentResponse, err error) { | ||
31 | + var conn = l.svcCtx.DefaultDBConn() | ||
32 | + commetInfo, err := l.svcCtx.ArticleCommentRepository.FindOne(l.ctx, conn, req.Id) | ||
33 | + if err != nil { | ||
34 | + return nil, xerr.NewErrMsgErr("编辑评论信息失败", err) | ||
35 | + } | ||
36 | + if commetInfo.CompanyId != req.CompanyId { | ||
37 | + return nil, xerr.NewErrMsg("没有操作权限") | ||
38 | + } | ||
39 | + commetInfo.CountAdminLove = req.CountAdminLove | ||
40 | + var increaseCount int | ||
41 | + switch req.Show { | ||
42 | + case 1: | ||
43 | + // 设置为显示评论 | ||
44 | + if commetInfo.Show != domain.CommentShowEnable { | ||
45 | + commetInfo.Show = domain.CommentShowEnable | ||
46 | + increaseCount = 1 | ||
47 | + } | ||
48 | + case 2: | ||
49 | + // 设置为隐藏评论 | ||
50 | + if commetInfo.Show != domain.CommentShowDisable { | ||
51 | + commetInfo.Show = domain.CommentShowDisable | ||
52 | + increaseCount = -1 | ||
53 | + } | ||
54 | + } | ||
55 | + commetInfo.Show = domain.CommentShowEnable | ||
56 | + // 变更回复数量 | ||
57 | + err = transaction.UseTrans(l.ctx, conn.DB(), func(ctx context.Context, c transaction.Conn) error { | ||
58 | + _, err = l.svcCtx.ArticleCommentRepository.Update(ctx, c, commetInfo) | ||
59 | + if err != nil { | ||
60 | + return err | ||
61 | + } | ||
62 | + if increaseCount != 0 { | ||
63 | + // 增加上级评论的回复数量 | ||
64 | + if commetInfo.Pid != 0 { | ||
65 | + err = l.svcCtx.ArticleCommentRepository.IncreaseCountReply(l.ctx, c, increaseCount, commetInfo.Pid) | ||
66 | + if err != nil { | ||
67 | + return err | ||
68 | + } | ||
69 | + } | ||
70 | + // 增加最顶层的评论回复计数 | ||
71 | + if commetInfo.TopId != 0 && commetInfo.Pid != commetInfo.TopId { | ||
72 | + err = l.svcCtx.ArticleCommentRepository.IncreaseCountReply(l.ctx, c, increaseCount, commetInfo.TopId) | ||
73 | + if err != nil { | ||
74 | + return err | ||
75 | + } | ||
76 | + } | ||
77 | + // 增加加段落评论计数 | ||
78 | + if commetInfo.SectionId > 0 { | ||
79 | + err = l.svcCtx.ArticleSectionRepository.IncreaseCountComment(ctx, c, increaseCount, commetInfo.SectionId) | ||
80 | + if err != nil { | ||
81 | + return err | ||
82 | + } | ||
83 | + } | ||
84 | + // 增加文章的评论数 | ||
85 | + err = l.svcCtx.ArticleRepository.IncreaseCountComment(ctx, c, increaseCount, commetInfo.ArticleId) | ||
86 | + if err != nil { | ||
87 | + return err | ||
88 | + } | ||
89 | + } | ||
90 | + return nil | ||
91 | + }, true) | ||
92 | + | ||
93 | + if err != nil { | ||
94 | + return nil, xerr.NewErrMsgErr("编辑评论信息失败", err) | ||
95 | + } | ||
96 | + resp = &types.SystemEditCommentResponse{ | ||
97 | + Id: commetInfo.Id, | ||
98 | + } | ||
99 | + return resp, nil | ||
100 | + | ||
101 | +} |
1 | +package comment | ||
2 | + | ||
3 | +import ( | ||
4 | + "context" | ||
5 | + | ||
6 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | ||
7 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | ||
8 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/db/transaction" | ||
9 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain" | ||
10 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr" | ||
11 | + | ||
12 | + "github.com/zeromicro/go-zero/core/logx" | ||
13 | +) | ||
14 | + | ||
15 | +type SystemEditAticleCommentShowLogic struct { | ||
16 | + logx.Logger | ||
17 | + ctx context.Context | ||
18 | + svcCtx *svc.ServiceContext | ||
19 | +} | ||
20 | + | ||
21 | +func NewSystemEditAticleCommentShowLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SystemEditAticleCommentShowLogic { | ||
22 | + return &SystemEditAticleCommentShowLogic{ | ||
23 | + Logger: logx.WithContext(ctx), | ||
24 | + ctx: ctx, | ||
25 | + svcCtx: svcCtx, | ||
26 | + } | ||
27 | +} | ||
28 | + | ||
29 | +// 管理后台,单独设置评论的隐藏显示 | ||
30 | +func (l *SystemEditAticleCommentShowLogic) SystemEditAticleCommentShow(req *types.SystemEditCommentShowRequest) (resp *types.SystemEditCommentShowResponse, err error) { | ||
31 | + | ||
32 | + resp = &types.SystemEditCommentShowResponse{ | ||
33 | + Id: []int64{}, | ||
34 | + } | ||
35 | + if req.Show == 1 { | ||
36 | + for _, val := range req.Id { | ||
37 | + err = l.enableShow(val, req.CompanyId) | ||
38 | + if err != nil { | ||
39 | + err = xerr.NewErrMsgErr("操作失败,刷新重试", err) | ||
40 | + } else { | ||
41 | + resp.Id = append(resp.Id, val) | ||
42 | + } | ||
43 | + } | ||
44 | + } | ||
45 | + if req.Show == 2 { | ||
46 | + for _, val := range req.Id { | ||
47 | + err = l.disableShow(val, req.CompanyId) | ||
48 | + if err != nil { | ||
49 | + err = xerr.NewErrMsgErr("操作失败,刷新重试", err) | ||
50 | + } else { | ||
51 | + resp.Id = append(resp.Id, val) | ||
52 | + } | ||
53 | + } | ||
54 | + } | ||
55 | + if err != nil { | ||
56 | + return resp, err | ||
57 | + } | ||
58 | + return | ||
59 | +} | ||
60 | + | ||
61 | +func (l *SystemEditAticleCommentShowLogic) disableShow(commentId int64, companyId int64) error { | ||
62 | + var conn = l.svcCtx.DefaultDBConn() | ||
63 | + commetInfo, err := l.svcCtx.ArticleCommentRepository.FindOne(l.ctx, conn, commentId) | ||
64 | + if err != nil { | ||
65 | + return xerr.NewErrMsgErr("删除评论信息失败", err) | ||
66 | + } | ||
67 | + if commetInfo.CompanyId != companyId { | ||
68 | + return xerr.NewErrMsg("没有操作权限") | ||
69 | + } | ||
70 | + if commetInfo.Show == domain.CommentShowDisable { | ||
71 | + return nil | ||
72 | + } | ||
73 | + commetInfo.Show = domain.CommentShowDisable | ||
74 | + // 变更回复数量 | ||
75 | + err = transaction.UseTrans(l.ctx, conn.DB(), func(ctx context.Context, c transaction.Conn) error { | ||
76 | + _, err = l.svcCtx.ArticleCommentRepository.Update(ctx, c, commetInfo) | ||
77 | + if err != nil { | ||
78 | + return err | ||
79 | + } | ||
80 | + // 减少上级评论的回复数量 | ||
81 | + if commetInfo.Pid != 0 { | ||
82 | + err = l.svcCtx.ArticleCommentRepository.IncreaseCountReply(l.ctx, c, -1, commetInfo.Pid) | ||
83 | + if err != nil { | ||
84 | + return err | ||
85 | + } | ||
86 | + } | ||
87 | + // 减少最顶层的评论回复计数 | ||
88 | + if commetInfo.TopId != 0 && commetInfo.Pid != commetInfo.TopId { | ||
89 | + err = l.svcCtx.ArticleCommentRepository.IncreaseCountReply(l.ctx, c, -1, commetInfo.TopId) | ||
90 | + if err != nil { | ||
91 | + return err | ||
92 | + } | ||
93 | + } | ||
94 | + //减少加段落评论计数 | ||
95 | + if commetInfo.SectionId > 0 { | ||
96 | + err = l.svcCtx.ArticleSectionRepository.IncreaseCountComment(ctx, c, -1, commetInfo.SectionId) | ||
97 | + if err != nil { | ||
98 | + return err | ||
99 | + } | ||
100 | + } | ||
101 | + // 减少文章的评论数 | ||
102 | + err = l.svcCtx.ArticleRepository.IncreaseCountComment(ctx, c, -1, commetInfo.ArticleId) | ||
103 | + if err != nil { | ||
104 | + return err | ||
105 | + } | ||
106 | + return nil | ||
107 | + }, true) | ||
108 | + | ||
109 | + if err != nil { | ||
110 | + return xerr.NewErrMsgErr("删除评论信息失败", err) | ||
111 | + } | ||
112 | + return nil | ||
113 | +} | ||
114 | + | ||
115 | +func (l *SystemEditAticleCommentShowLogic) enableShow(commentId int64, companyId int64) error { | ||
116 | + var conn = l.svcCtx.DefaultDBConn() | ||
117 | + commetInfo, err := l.svcCtx.ArticleCommentRepository.FindOne(l.ctx, conn, commentId) | ||
118 | + if err != nil { | ||
119 | + return xerr.NewErrMsgErr("删除评论信息失败", err) | ||
120 | + } | ||
121 | + if commetInfo.CompanyId != companyId { | ||
122 | + return xerr.NewErrMsg("没有操作权限") | ||
123 | + } | ||
124 | + if commetInfo.Show == domain.CommentShowEnable { | ||
125 | + return nil | ||
126 | + } | ||
127 | + commetInfo.Show = domain.CommentShowEnable | ||
128 | + // 变更回复数量 | ||
129 | + err = transaction.UseTrans(l.ctx, conn.DB(), func(ctx context.Context, c transaction.Conn) error { | ||
130 | + _, err = l.svcCtx.ArticleCommentRepository.Update(ctx, c, commetInfo) | ||
131 | + if err != nil { | ||
132 | + return err | ||
133 | + } | ||
134 | + // 增加上级评论的回复数量 | ||
135 | + if commetInfo.Pid != 0 { | ||
136 | + err = l.svcCtx.ArticleCommentRepository.IncreaseCountReply(l.ctx, c, 1, commetInfo.Pid) | ||
137 | + if err != nil { | ||
138 | + return err | ||
139 | + } | ||
140 | + } | ||
141 | + // 增加最顶层的评论回复计数 | ||
142 | + if commetInfo.TopId != 0 && commetInfo.Pid != commetInfo.TopId { | ||
143 | + err = l.svcCtx.ArticleCommentRepository.IncreaseCountReply(l.ctx, c, 1, commetInfo.TopId) | ||
144 | + if err != nil { | ||
145 | + return err | ||
146 | + } | ||
147 | + } | ||
148 | + //增加加段落评论计数 | ||
149 | + if commetInfo.SectionId > 0 { | ||
150 | + err = l.svcCtx.ArticleSectionRepository.IncreaseCountComment(ctx, c, 1, commetInfo.SectionId) | ||
151 | + if err != nil { | ||
152 | + return err | ||
153 | + } | ||
154 | + } | ||
155 | + // 增加文章的评论数 | ||
156 | + err = l.svcCtx.ArticleRepository.IncreaseCountComment(ctx, c, 1, commetInfo.ArticleId) | ||
157 | + if err != nil { | ||
158 | + return err | ||
159 | + } | ||
160 | + return nil | ||
161 | + }, true) | ||
162 | + | ||
163 | + if err != nil { | ||
164 | + return xerr.NewErrMsgErr("删除评论信息失败", err) | ||
165 | + } | ||
166 | + return nil | ||
167 | +} |
1 | +package comment | ||
2 | + | ||
3 | +import ( | ||
4 | + "context" | ||
5 | + | ||
6 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | ||
7 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | ||
8 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr" | ||
9 | + | ||
10 | + "github.com/zeromicro/go-zero/core/logx" | ||
11 | +) | ||
12 | + | ||
13 | +type SystemGetAticleCommentLogic struct { | ||
14 | + logx.Logger | ||
15 | + ctx context.Context | ||
16 | + svcCtx *svc.ServiceContext | ||
17 | +} | ||
18 | + | ||
19 | +func NewSystemGetAticleCommentLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SystemGetAticleCommentLogic { | ||
20 | + return &SystemGetAticleCommentLogic{ | ||
21 | + Logger: logx.WithContext(ctx), | ||
22 | + ctx: ctx, | ||
23 | + svcCtx: svcCtx, | ||
24 | + } | ||
25 | +} | ||
26 | + | ||
27 | +func (l *SystemGetAticleCommentLogic) SystemGetAticleComment(req *types.SystemGetCommentRequest) (resp *types.SystemGetCommentResponse, err error) { | ||
28 | + var conn = l.svcCtx.DefaultDBConn() | ||
29 | + | ||
30 | + commentInfo, err := l.svcCtx.ArticleCommentRepository.FindOne(l.ctx, conn, req.Id) | ||
31 | + if err != nil { | ||
32 | + return nil, xerr.NewErrMsgErr("获取评论详情失败", err) | ||
33 | + } | ||
34 | + if commentInfo.CompanyId != req.CompanyId { | ||
35 | + return nil, xerr.NewErrMsg("没有查看权限") | ||
36 | + } | ||
37 | + resp = &types.SystemGetCommentResponse{ | ||
38 | + Id: commentInfo.Id, | ||
39 | + Pid: commentInfo.Pid, | ||
40 | + TopId: commentInfo.TopId, | ||
41 | + ArticleId: commentInfo.ArticleId, | ||
42 | + ArticleTitle: "", | ||
43 | + FromUserId: commentInfo.FromUserId, | ||
44 | + FromUser: types.CommentAuthor{ | ||
45 | + Id: commentInfo.FromUserId, | ||
46 | + Name: commentInfo.FromUser.Name, | ||
47 | + Avatar: commentInfo.FromUser.Avatar, | ||
48 | + Position: commentInfo.FromUser.Position, | ||
49 | + Company: commentInfo.FromUser.Company, | ||
50 | + }, | ||
51 | + CreatedAt: commentInfo.CreatedAt, | ||
52 | + SectionContent: commentInfo.SectionContent, | ||
53 | + Content: commentInfo.Content, | ||
54 | + Show: int(commentInfo.Show), | ||
55 | + CountReply: commentInfo.CountReply, | ||
56 | + CountUserLove: commentInfo.CountUserLove, | ||
57 | + CountAdminLove: commentInfo.CountAdminLove, | ||
58 | + } | ||
59 | + return resp, nil | ||
60 | +} |
1 | +package comment | ||
2 | + | ||
3 | +import ( | ||
4 | + "context" | ||
5 | + | ||
6 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | ||
7 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | ||
8 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr" | ||
9 | + | ||
10 | + "github.com/zeromicro/go-zero/core/logx" | ||
11 | +) | ||
12 | + | ||
13 | +type SystemListAticleCommentLogic struct { | ||
14 | + logx.Logger | ||
15 | + ctx context.Context | ||
16 | + svcCtx *svc.ServiceContext | ||
17 | +} | ||
18 | + | ||
19 | +func NewSystemListAticleCommentLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SystemListAticleCommentLogic { | ||
20 | + return &SystemListAticleCommentLogic{ | ||
21 | + Logger: logx.WithContext(ctx), | ||
22 | + ctx: ctx, | ||
23 | + svcCtx: svcCtx, | ||
24 | + } | ||
25 | +} | ||
26 | + | ||
27 | +// 管理后台评论列表 | ||
28 | +func (l *SystemListAticleCommentLogic) SystemListAticleComment(req *types.SystemListCommentRequest) (resp *types.SystemListCommentResponse, err error) { | ||
29 | + var conn = l.svcCtx.DefaultDBConn() | ||
30 | + | ||
31 | + cnt, commentList, err := l.svcCtx.ArticleCommentRepository.CustomSearchBy(l.ctx, conn, req.CompanyId, req.Page, req.Size, | ||
32 | + req.TopId, req.ArticleTitle, req.Content, req.FromUser, req.Show, | ||
33 | + ) | ||
34 | + if err != nil { | ||
35 | + return nil, xerr.NewErrMsgErr("获取评论列表失败", err) | ||
36 | + } | ||
37 | + | ||
38 | + resp = &types.SystemListCommentResponse{ | ||
39 | + Total: cnt, | ||
40 | + List: make([]types.SystemCommentItem, len(commentList)), | ||
41 | + } | ||
42 | + | ||
43 | + for i, val := range commentList { | ||
44 | + resp.List[i] = types.SystemCommentItem{ | ||
45 | + Id: val.Id, | ||
46 | + Pid: val.Pid, | ||
47 | + TopId: val.TopId, | ||
48 | + ArticleTitle: val.ArticleTitle, | ||
49 | + FromUserId: val.FromUserId, | ||
50 | + FromUser: types.CommentAuthor{ | ||
51 | + Id: val.FromUser.Id, | ||
52 | + Name: val.FromUser.Name, | ||
53 | + Avatar: val.FromUser.Avatar, | ||
54 | + Position: val.FromUser.Position, | ||
55 | + Company: val.FromUser.Company, | ||
56 | + }, | ||
57 | + CreatedAt: val.CreatedAt, | ||
58 | + Content: val.Content, | ||
59 | + Show: val.Show, | ||
60 | + CountReply: val.CountReply, | ||
61 | + CountUserLove: val.CountUserLove, | ||
62 | + CountAdminLove: val.CountAdminLove, | ||
63 | + } | ||
64 | + } | ||
65 | + | ||
66 | + return resp, nil | ||
67 | +} |
@@ -3,6 +3,8 @@ package user | @@ -3,6 +3,8 @@ package user | ||
3 | import ( | 3 | import ( |
4 | "context" | 4 | "context" |
5 | "fmt" | 5 | "fmt" |
6 | + "strconv" | ||
7 | + | ||
6 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | 8 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" |
7 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | 9 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" |
8 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain" | 10 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain" |
@@ -10,7 +12,6 @@ import ( | @@ -10,7 +12,6 @@ import ( | ||
10 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata" | 12 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata" |
11 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/tool" | 13 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/tool" |
12 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr" | 14 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr" |
13 | - "strconv" | ||
14 | 15 | ||
15 | "github.com/zeromicro/go-zero/core/logx" | 16 | "github.com/zeromicro/go-zero/core/logx" |
16 | ) | 17 | ) |
@@ -94,3 +95,10 @@ func (l *SystemUserInfoLogic) SystemUserInfo(req *types.SystemUserInfoRequest) ( | @@ -94,3 +95,10 @@ func (l *SystemUserInfoLogic) SystemUserInfo(req *types.SystemUserInfoRequest) ( | ||
94 | } | 95 | } |
95 | return | 96 | return |
96 | } | 97 | } |
98 | + | ||
99 | +// 后台登录时 ,检查/设置公司的初始数据 | ||
100 | +func (l *SystemUserInfoLogic) initSystemData(companyId int64) error { | ||
101 | + // TODO 初始设置文章标签 | ||
102 | + | ||
103 | + return nil | ||
104 | +} |
@@ -168,6 +168,83 @@ type SystemArticleCommentSearchItem struct { | @@ -168,6 +168,83 @@ type SystemArticleCommentSearchItem struct { | ||
168 | Show int `json:"show"` // 显示状态 | 168 | Show int `json:"show"` // 显示状态 |
169 | } | 169 | } |
170 | 170 | ||
171 | +type SystemListCommentRequest struct { | ||
172 | + Page int `json:"page"` | ||
173 | + Size int `json:"size"` | ||
174 | + CompanyId int64 `json:",optional"` // | ||
175 | + TopId int64 `json:"topId"` // 评论的顶层ID | ||
176 | + FromUser string `json:"fromUser,optional"` // 用户 | ||
177 | + Show int `json:"show,optional"` // 显示状态 | ||
178 | + BeginTime int64 `json:"beginTime,optional"` // 填写评论的开始时间 | ||
179 | + EndTime int64 `json:"endTime,optional"` // 填写评论的结束时间 | ||
180 | + ArticleTitle string `json:"articleTitle,optional"` // | ||
181 | + Content string `json:"content,optional"` // | ||
182 | +} | ||
183 | + | ||
184 | +type SystemListCommentResponse struct { | ||
185 | + Total int `json:"total"` | ||
186 | + List []SystemCommentItem `json:"list"` | ||
187 | +} | ||
188 | + | ||
189 | +type SystemCommentItem struct { | ||
190 | + Id int64 `json:"id"` //评论id | ||
191 | + Pid int64 `json:"pid"` // | ||
192 | + TopId int64 `json:"topId"` // | ||
193 | + ArticleId int64 `json:"articleId"` //对应的文章id | ||
194 | + ArticleTitle string `json:"articleTitle"` //文章标题 | ||
195 | + FromUserId int64 `json:"fromUserId"` //填写评论的人 | ||
196 | + FromUser CommentAuthor `json:"fromUser"` //填写评论的人 | ||
197 | + CreatedAt int64 `json:"createdAt"` //评论的填写时间 | ||
198 | + Content string `json:"content"` //评论的内容 | ||
199 | + Show int `json:"show"` //是否展示 [1显示] [2不显示] | ||
200 | + CountReply int `json:"countReplay"` //回复数量 | ||
201 | + CountUserLove int `json:"countUserLove"` //用户点赞数量 | ||
202 | + CountAdminLove int `json:"countAdminLove"` //运营点赞数量 | ||
203 | +} | ||
204 | + | ||
205 | +type SystemGetCommentRequest struct { | ||
206 | + CompanyId int64 `path:",optional"` | ||
207 | + Id int64 `path:"id"` | ||
208 | +} | ||
209 | + | ||
210 | +type SystemGetCommentResponse struct { | ||
211 | + Id int64 `json:"id"` //评论id | ||
212 | + Pid int64 `json:"pid"` // | ||
213 | + TopId int64 `json:"topId"` // | ||
214 | + ArticleId int64 `json:"articleId"` //对应的文章id | ||
215 | + ArticleTitle string `json:"articleTitle"` //文章标题 | ||
216 | + FromUserId int64 `json:"fromUserId"` //填写评论的人 | ||
217 | + FromUser CommentAuthor `json:"fromUser"` //填写评论的人 | ||
218 | + CreatedAt int64 `json:"createdAt"` //评论的填写时间 | ||
219 | + SectionContent string `json:"sectionContent"` //引用的段落内容 | ||
220 | + Content string `json:"content"` // 评论的内容 | ||
221 | + Show int `json:"show"` //是否展示 [1显示] [2不显示] | ||
222 | + CountReply int `json:"countReplay"` //回复数量 | ||
223 | + CountUserLove int `json:"countUserLove"` //用户点赞数量 | ||
224 | + CountAdminLove int `json:"countAdminLove"` //运营点赞数量 | ||
225 | +} | ||
226 | + | ||
227 | +type SystemEditCommentShowRequest struct { | ||
228 | + CompanyId int64 `json:",optional"` | ||
229 | + Id []int64 `json:"id"` | ||
230 | + Show int `json:"show"` //[1 显示评论] [2: 隐藏评论] | ||
231 | +} | ||
232 | + | ||
233 | +type SystemEditCommentShowResponse struct { | ||
234 | + Id []int64 `json:"id"` | ||
235 | +} | ||
236 | + | ||
237 | +type SystemEditCommentRequest struct { | ||
238 | + CompanyId int64 `json:",optional"` | ||
239 | + Id int64 `json:"id"` | ||
240 | + Show int `json:"show"` //[1 显示评论] [2: 隐藏评论] | ||
241 | + CountAdminLove int `json:"countAdminLove,optional"` | ||
242 | +} | ||
243 | + | ||
244 | +type SystemEditCommentResponse struct { | ||
245 | + Id int64 `json:"id"` | ||
246 | +} | ||
247 | + | ||
171 | type MessageSystemRequest struct { | 248 | type MessageSystemRequest struct { |
172 | Page int `json:"page"` | 249 | Page int `json:"page"` |
173 | Size int `json:"size"` | 250 | Size int `json:"size"` |
@@ -70,3 +70,18 @@ func (m *ArticleComment) CachePrimaryKeyFunc() string { | @@ -70,3 +70,18 @@ func (m *ArticleComment) CachePrimaryKeyFunc() string { | ||
70 | } | 70 | } |
71 | return fmt.Sprintf("%v:cache:%v:primarykey:%v", domain.ProjectName, m.TableName(), "key") | 71 | return fmt.Sprintf("%v:cache:%v:primarykey:%v", domain.ProjectName, m.TableName(), "key") |
72 | } | 72 | } |
73 | + | ||
74 | +type ArticleCommentShow struct { | ||
75 | + Id int64 //评论id | ||
76 | + Pid int64 | ||
77 | + TopId int64 | ||
78 | + ArticleTitle string //文章标题 | ||
79 | + FromUserId int64 // 评论填写人的id | ||
80 | + FromUser domain.UserSimple `gorm:"type:jsonb;serializer:json"` | ||
81 | + Content string // 评论内容 | ||
82 | + CountReply int // 回复数量 | ||
83 | + CountUserLove int // 用户点赞数量 | ||
84 | + CountAdminLove int // 运营点赞数量 | ||
85 | + Show int // 评论的展示状态(0显示、1不显示) | ||
86 | + CreatedAt int64 // 评论的创建时间 | ||
87 | +} |
@@ -325,6 +325,98 @@ func (repository *ArticleCommentRepository) Top5Comment(ctx context.Context, con | @@ -325,6 +325,98 @@ func (repository *ArticleCommentRepository) Top5Comment(ctx context.Context, con | ||
325 | } | 325 | } |
326 | return dms, nil | 326 | return dms, nil |
327 | } | 327 | } |
328 | + | ||
329 | +func (repository *ArticleCommentRepository) CustomSearchBy(ctx context.Context, conn transaction.Conn, companyId int64, page int, size int, | ||
330 | + topId int64, articleTitle string, contentLike string, fromUserName string, show int) (int, []*domain.ArticleCommentShow, error) { | ||
331 | + | ||
332 | + if size <= 0 { | ||
333 | + size = 20 | ||
334 | + } | ||
335 | + if page <= 0 { | ||
336 | + page = 1 | ||
337 | + } | ||
338 | + | ||
339 | + where := " and article_comment.company_id=? " | ||
340 | + condition := []interface{}{companyId} | ||
341 | + | ||
342 | + if len(articleTitle) > 0 { | ||
343 | + where += ` and article.title like ? ` | ||
344 | + condition = append(condition, "%"+articleTitle+"%") | ||
345 | + } | ||
346 | + if len(contentLike) > 0 { | ||
347 | + where += ` and article_comment."content" like ? ` | ||
348 | + condition = append(condition, "%"+contentLike+"%") | ||
349 | + } | ||
350 | + | ||
351 | + if len(fromUserName) > 0 { | ||
352 | + where += ` and article_comment.from_user ->>'name' like ? ` | ||
353 | + condition = append(condition, "%"+fromUserName+"%") | ||
354 | + } | ||
355 | + if show > 0 { | ||
356 | + where += ` and article_comment."show" =? ` | ||
357 | + condition = append(condition, show) | ||
358 | + } | ||
359 | + | ||
360 | + if topId >= 0 { | ||
361 | + where += ` and article_comment."top_id"= ? ` | ||
362 | + condition = append(condition, topId) | ||
363 | + } | ||
364 | + countSql := `select | ||
365 | + count(*) | ||
366 | + from article_comment | ||
367 | + join article on article.id = article_comment.article_id | ||
368 | + where 1=1 ` + where | ||
369 | + | ||
370 | + var cnt int | ||
371 | + db := conn.DB() | ||
372 | + result := db.Raw(countSql, condition...).Scan(&cnt) | ||
373 | + if result.Error != nil { | ||
374 | + return 0, nil, result.Error | ||
375 | + } | ||
376 | + | ||
377 | + dataSql := `select | ||
378 | + article.title as article_title , | ||
379 | + article_comment.id , | ||
380 | + article_comment.pid, | ||
381 | + article_comment.top_id, | ||
382 | + article_comment.from_user_id , | ||
383 | + article_comment.from_user, | ||
384 | + article_comment."content" , | ||
385 | + article_comment.created_at , | ||
386 | + article_comment.count_reply , | ||
387 | + article_comment.count_user_love , | ||
388 | + article_comment.count_admin_love , | ||
389 | + article_comment."show" | ||
390 | + from article_comment | ||
391 | + join article on article.id = article_comment.article_id | ||
392 | + where 1=1` + where + ` order by article_comment.id desc limit ? offset ? ` | ||
393 | + | ||
394 | + condition = append(condition, size, (page-1)*size) | ||
395 | + | ||
396 | + ms := []models.ArticleCommentShow{} | ||
397 | + result = db.Raw(dataSql, condition...).Scan(&ms) | ||
398 | + if result.Error != nil { | ||
399 | + return 0, nil, result.Error | ||
400 | + } | ||
401 | + d := []*domain.ArticleCommentShow{} | ||
402 | + for _, val := range ms { | ||
403 | + d = append(d, &domain.ArticleCommentShow{ | ||
404 | + ArticleTitle: val.ArticleTitle, | ||
405 | + Id: val.Id, | ||
406 | + FromUserId: val.FromUserId, | ||
407 | + FromUser: val.FromUser, | ||
408 | + Content: val.Content, | ||
409 | + CountReply: val.CountReply, | ||
410 | + CountUserLove: val.CountUserLove, | ||
411 | + CountAdminLove: val.CountAdminLove, | ||
412 | + Show: val.Show, | ||
413 | + CreatedAt: val.CreatedAt, | ||
414 | + }) | ||
415 | + } | ||
416 | + return cnt, d, nil | ||
417 | + | ||
418 | +} | ||
419 | + | ||
328 | func NewArticleCommentRepository(cache *cache.CachedRepository) domain.ArticleCommentRepository { | 420 | func NewArticleCommentRepository(cache *cache.CachedRepository) domain.ArticleCommentRepository { |
329 | return &ArticleCommentRepository{CachedRepository: cache} | 421 | return &ArticleCommentRepository{CachedRepository: cache} |
330 | } | 422 | } |
@@ -435,7 +435,7 @@ func (repository *ArticleRepository) CustomSearchBy(ctx context.Context, conn tr | @@ -435,7 +435,7 @@ func (repository *ArticleRepository) CustomSearchBy(ctx context.Context, conn tr | ||
435 | tx = tx.Where("article_and_tag.tag_id=?", tagId) | 435 | tx = tx.Where("article_and_tag.tag_id=?", tagId) |
436 | } else if len(tagCategory) > 0 { | 436 | } else if len(tagCategory) > 0 { |
437 | tx = tx.Joins(`join article_and_tag on article.id = article_and_tag.article_id`) | 437 | tx = tx.Joins(`join article_and_tag on article.id = article_and_tag.article_id`) |
438 | - tx = tx.Where(`article_and_tag.tag_id =any(select article_tag.id from article_tag where category =%s )`, tagCategory) | 438 | + tx = tx.Where(`article_and_tag.tag_id =any(select article_tag.id from article_tag where category =? )`, tagCategory) |
439 | } | 439 | } |
440 | if len(titleLike) > 0 { | 440 | if len(titleLike) > 0 { |
441 | tx = tx.Where("article.title like ?", "%"+titleLike+"%") | 441 | tx = tx.Where("article.title like ?", "%"+titleLike+"%") |
@@ -33,6 +33,8 @@ func (repository *ArticleTagRepository) Insert(ctx context.Context, conn transac | @@ -33,6 +33,8 @@ func (repository *ArticleTagRepository) Insert(ctx context.Context, conn transac | ||
33 | 33 | ||
34 | } | 34 | } |
35 | 35 | ||
36 | +// func (repository *ArticleTagRepository) CreateInBatches | ||
37 | + | ||
36 | func (repository *ArticleTagRepository) Update(ctx context.Context, conn transaction.Conn, dm *domain.ArticleTag) (*domain.ArticleTag, error) { | 38 | func (repository *ArticleTagRepository) Update(ctx context.Context, conn transaction.Conn, dm *domain.ArticleTag) (*domain.ArticleTag, error) { |
37 | var ( | 39 | var ( |
38 | err error | 40 | err error |
@@ -50,6 +50,21 @@ func (show CommentShow) Named() string { | @@ -50,6 +50,21 @@ func (show CommentShow) Named() string { | ||
50 | return "" | 50 | return "" |
51 | } | 51 | } |
52 | 52 | ||
53 | +type ArticleCommentShow struct { | ||
54 | + Id int64 // 评论id | ||
55 | + Pid int64 | ||
56 | + TopId int64 | ||
57 | + ArticleTitle string // 文章标题 | ||
58 | + FromUserId int64 // 评论填写人的id | ||
59 | + FromUser UserSimple // 评论填写人 | ||
60 | + Content string // 评论内容 | ||
61 | + CountReply int // 回复数量 | ||
62 | + CountUserLove int // 用户点赞数量 | ||
63 | + CountAdminLove int // 运营点赞数量 | ||
64 | + Show int // 评论的展示状态(0显示、1不显示) | ||
65 | + CreatedAt int64 // 评论的创建时间 | ||
66 | +} | ||
67 | + | ||
53 | type ArticleCommentRepository interface { | 68 | type ArticleCommentRepository interface { |
54 | Insert(ctx context.Context, conn transaction.Conn, dm *ArticleComment) (*ArticleComment, error) | 69 | Insert(ctx context.Context, conn transaction.Conn, dm *ArticleComment) (*ArticleComment, error) |
55 | Update(ctx context.Context, conn transaction.Conn, dm *ArticleComment) (*ArticleComment, error) | 70 | Update(ctx context.Context, conn transaction.Conn, dm *ArticleComment) (*ArticleComment, error) |
@@ -60,4 +75,7 @@ type ArticleCommentRepository interface { | @@ -60,4 +75,7 @@ type ArticleCommentRepository interface { | ||
60 | IncreaseCountUserLove(ctx context.Context, conn transaction.Conn, incr int, commentId int64) error //点赞数量变动 | 75 | IncreaseCountUserLove(ctx context.Context, conn transaction.Conn, incr int, commentId int64) error //点赞数量变动 |
61 | IncreaseCountReply(ctx context.Context, conn transaction.Conn, incr int, commentId int64) error // 评论回复数量变动 | 76 | IncreaseCountReply(ctx context.Context, conn transaction.Conn, incr int, commentId int64) error // 评论回复数量变动 |
62 | Top5Comment(ctx context.Context, conn transaction.Conn, companyId int64, articleId int64) ([]*ArticleComment, error) | 77 | Top5Comment(ctx context.Context, conn transaction.Conn, companyId int64, articleId int64) ([]*ArticleComment, error) |
78 | + // 特定的查询 | ||
79 | + CustomSearchBy(ctx context.Context, conn transaction.Conn, companyId int64, page int, size int, | ||
80 | + topId int64, articleTitle string, contentLike string, fromUserName string, show int) (int, []*ArticleCommentShow, error) | ||
63 | } | 81 | } |
deploy/k8s/.gitkeep
0 → 100644
deploy/k8s/dev/.gitkeep
0 → 100644
deploy/k8s/dev/install.sh
0 → 100644
1 | +#!/bin/bash | ||
2 | +export PATH=/root/local/bin:$PATH | ||
3 | +kubectl -n mmm-suplus-test get pods | grep -q sumifcc-discuss | ||
4 | +if [ "$?" == "1" ];then | ||
5 | + kubectl create -f /tmp/test/sumifcc-discuss/sumifcc-discuss.yaml --record | ||
6 | + kubectl -n mmm-suplus-test get svc | grep -q sumifcc-discuss | ||
7 | + if [ "$?" == "0" ];then | ||
8 | + echo "sumifcc-discuss service install success!" | ||
9 | + else | ||
10 | + echo "sumifcc-discuss service install fail!" | ||
11 | + fi | ||
12 | + kubectl -n mmm-suplus-test get pods | grep -q sumifcc-discuss | ||
13 | + if [ "$?" == "0" ];then | ||
14 | + echo "sumifcc-discuss deployment install success!" | ||
15 | + else | ||
16 | + echo "sumifcc-discuss deployment install fail!" | ||
17 | + fi | ||
18 | +else | ||
19 | + kubectl delete -f /tmp/test/sumifcc-discuss/sumifcc-discuss.yaml | ||
20 | + kubectl -n mmm-suplus-test get svc | grep -q sumifcc-discuss | ||
21 | + while [ "$?" == "0" ] | ||
22 | + do | ||
23 | + kubectl -n mmm-suplus-test get svc | grep -q sumifcc-discuss | ||
24 | + done | ||
25 | + kubectl -n mmm-suplus-test get pods | grep -q sumifcc-discuss | ||
26 | + while [ "$?" == "0" ] | ||
27 | + do | ||
28 | + kubectl -n mmm-suplus-test get pods | grep -q sumifcc-discuss | ||
29 | + done | ||
30 | + kubectl create -f /tmp/test/sumifcc-discuss/sumifcc-discuss.yaml --record | ||
31 | + kubectl -n mmm-suplus-test get svc | grep -q sumifcc-discuss | ||
32 | + if [ "$?" == "0" ];then | ||
33 | + echo "sumifcc-discuss service update success!" | ||
34 | + else | ||
35 | + echo "sumifcc-discuss service update fail!" | ||
36 | + fi | ||
37 | + kubectl -n mmm-suplus-test get pods | grep -q sumifcc-discuss | ||
38 | + if [ "$?" == "0" ];then | ||
39 | + echo "sumifcc-discuss deployment update success!" | ||
40 | + else | ||
41 | + echo "sumifcc-discuss deployment update fail!" | ||
42 | + fi | ||
43 | +fi |
@@ -10,7 +10,7 @@ type Auth struct { | @@ -10,7 +10,7 @@ type Auth struct { | ||
10 | } | 10 | } |
11 | type Config struct { | 11 | type Config struct { |
12 | DB struct { | 12 | DB struct { |
13 | - DataSource string | 13 | + DataSource string `json:",env=DataSource"` |
14 | } `json:",optional"` | 14 | } `json:",optional"` |
15 | Cache cache.CacheConf `json:",optional"` | 15 | Cache cache.CacheConf `json:",optional"` |
16 | DTM DTM `json:",optional"` | 16 | DTM DTM `json:",optional"` |
-
请 注册 或 登录 后发表评论