Merge remote-tracking branch 'origin/dev' into dev
正在显示
18 个修改的文件
包含
597 行增加
和
24 行删除
@@ -42,12 +42,27 @@ service Core { | @@ -42,12 +42,27 @@ service Core { | ||
42 | 42 | ||
43 | @doc "小程序创建文章进草稿箱" | 43 | @doc "小程序创建文章进草稿箱" |
44 | @handler MiniCreateArticleDraft | 44 | @handler MiniCreateArticleDraft |
45 | - post /article_draft (MiniArticleSearchMeRequest) returns (MiniArticleSearchMeResponse) | 45 | + post /article_draft (MiniArticleDraftCreateRequest) returns (MiniArticleDraftCreateResponse) |
46 | + | ||
47 | + @doc "小程序更新文章草稿" | ||
48 | + @handler MiniUpdateArticleDraft | ||
49 | + put /article_draft (MiniArticleDraftUpdateRequest) returns (MiniArticleDraftUpdateResponse) | ||
50 | + | ||
51 | + @doc "小程序获取我的草稿箱列表" | ||
52 | + @handler MiniSearchArticleDraftMe | ||
53 | + post /article_draft/search/me (MiniArticleDraftSearchMeRequest) returns (MiniArticleDraftSearchMeResponse) | ||
54 | + | ||
55 | + @doc "小程序获取我的草稿内容" | ||
56 | + @handler MiniGetArticleDraftMe | ||
57 | + get /article_draft/me/:id (MiniArticleDraftGetMeRequest) returns (MiniArticleDraftGetMeResponse) | ||
58 | + | ||
59 | + @doc "小程序删除我的草稿内容" | ||
60 | + @handler MiniDeleteArticleDraftMe | ||
61 | + delete /article_draft/me/:id (MiniArticleDraftDeleteMeRequest) returns (MiniArticleDraftDeleteMeResponse) | ||
46 | 62 | ||
47 | @doc "小程序获取文章的编辑记录" | 63 | @doc "小程序获取文章的编辑记录" |
48 | @handler MiniArticleBackupSearch | 64 | @handler MiniArticleBackupSearch |
49 | post /article_backup/search (MiniArticleBackupSearchRequest) returns (MiniArticleBackupSearchResponse) | 65 | post /article_backup/search (MiniArticleBackupSearchRequest) returns (MiniArticleBackupSearchResponse) |
50 | - | ||
51 | } | 66 | } |
52 | 67 | ||
53 | // 管理后台接口 | 68 | // 管理后台接口 |
@@ -160,16 +160,99 @@ type ( | @@ -160,16 +160,99 @@ type ( | ||
160 | } | 160 | } |
161 | ) | 161 | ) |
162 | 162 | ||
163 | -//保存文章到草稿箱 | 163 | +//创建文章到草稿箱 |
164 | type ( | 164 | type ( |
165 | MiniArticleDraftCreateRequest { | 165 | MiniArticleDraftCreateRequest { |
166 | - Template int `json:"template"` // 使用哪个模板进行编辑 0、无 1、演绎式 2、归纳式 | ||
167 | - Content []string `json:"content"` // 填写的内容 | ||
168 | - Title string `json:"title"` //标题 | ||
169 | - Images []string `json:"images"` //图片 | 166 | + CompanyId int64 `json:",optional"` |
167 | + AuthorId int64 `json:",optional"` // 发布人 | ||
168 | + Template int `json:"template"` // 使用哪个模板进行编辑 0、无 1、演绎式 2、归纳式 | ||
169 | + Section []string `json:"section"` // 填写的内容 | ||
170 | + Title string `json:"title"` // 标题 | ||
171 | + Images []string `json:"images"` // 图片 | ||
172 | + WhoRead []int64 `json:"whoRead"` // 谁可以看 | ||
173 | + WhoReview []int64 `json:"whoReview"` // 评论人 | ||
174 | + Location Location `json:"location"` // 坐标 | ||
170 | } | 175 | } |
171 | 176 | ||
172 | - MiniArticleDraftCreateResponse struct{} | 177 | + MiniArticleDraftCreateResponse { |
178 | + Id int64 `json:"id"` | ||
179 | + } | ||
180 | +) | ||
181 | + | ||
182 | +//更新文章草稿 | ||
183 | +type ( | ||
184 | + MiniArticleDraftUpdateRequest { | ||
185 | + Id int64 `json:"id"` | ||
186 | + CompanyId int64 `json:",optional"` | ||
187 | + AuthorId int64 `json:",optional"` // 发布人 | ||
188 | + Template int `json:"template"` // 使用哪个模板进行编辑 0、无 1、演绎式 2、归纳式 | ||
189 | + Section []string `json:"section"` // 填写的内容 | ||
190 | + Title string `json:"title"` // 标题 | ||
191 | + Images []string `json:"images"` // 图片 | ||
192 | + WhoRead []int64 `json:"whoRead"` // 谁可以看 | ||
193 | + WhoReview []int64 `json:"whoReview"` // 评论人 | ||
194 | + Location Location `json:"location"` // 坐标 | ||
195 | + } | ||
196 | + | ||
197 | + MiniArticleDraftUpdateResponse { | ||
198 | + Id int64 `json:"id"` | ||
199 | + } | ||
200 | +) | ||
201 | + | ||
202 | +//获取我的草稿列表 | ||
203 | +type ( | ||
204 | + MiniArticleDraftSearchMeRequest { | ||
205 | + CompanyId int64 `json:",optional"` // 公司id | ||
206 | + AuthorId int64 `json:",optional"` // 发布人 | ||
207 | + Page int `json:"page"` | ||
208 | + Size int `json:"size"` | ||
209 | + } | ||
210 | + | ||
211 | + MiniArticleDraftSearchMeResponse { | ||
212 | + Total int64 `json:"total"` | ||
213 | + List []MiniArticleDraftItem `json:"list"` | ||
214 | + } | ||
215 | + MiniArticleDraftItem { | ||
216 | + Id int64 `json:"id"` | ||
217 | + Template int `json:"template"` // 使用哪个模板进行编辑 0、无 1、演绎式 2、归纳式 | ||
218 | + Section []string `json:"section"` // 填写的内容 | ||
219 | + Title string `json:"title"` // 标题 | ||
220 | + Images []string `json:"images"` // 图片 | ||
221 | + CreatedAt int64 `json:"createdAt"` | ||
222 | + } | ||
223 | +) | ||
224 | + | ||
225 | +//获取我的草稿内容 | ||
226 | +type ( | ||
227 | + MiniArticleDraftGetMeRequest { | ||
228 | + CompanyId int64 `path:",optional"` // 公司id | ||
229 | + AuthorId int64 `path:",optional"` // 发布人 | ||
230 | + Id int64 `path:"id"` | ||
231 | + } | ||
232 | + | ||
233 | + MiniArticleDraftGetMeResponse { | ||
234 | + Id int64 `json:"id"` // | ||
235 | + Template int `json:"template"` // 使用哪个模板进行编辑 0、无 1、演绎式 2、归纳式 | ||
236 | + Section []string `json:"Section"` // 填写的内容 | ||
237 | + Title string `json:"title"` // 标题 | ||
238 | + Images []string `json:"images"` // 图片 | ||
239 | + WhoRead []int64 `json:"whoRead"` // 谁可以看 | ||
240 | + WhoReview []int64 `json:"whoReview"` // 评论人 | ||
241 | + Location Location `json:"location"` // 坐标 | ||
242 | + } | ||
243 | +) | ||
244 | + | ||
245 | +//删除我的草稿内容 | ||
246 | +type ( | ||
247 | + MiniArticleDraftDeleteMeRequest { | ||
248 | + CompanyId int64 `path:",optional"` // 公司id | ||
249 | + AuthorId int64 `path:",optional"` // 发布人 | ||
250 | + Id int64 `path:"id"` | ||
251 | + } | ||
252 | + | ||
253 | + MiniArticleDraftDeleteMeResponse { | ||
254 | + Id int64 `json:"id"` // | ||
255 | + } | ||
173 | ) | 256 | ) |
174 | 257 | ||
175 | type ( | 258 | type ( |
@@ -7,22 +7,23 @@ import ( | @@ -7,22 +7,23 @@ import ( | ||
7 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/article" | 7 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/article" |
8 | "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" |
9 | "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" |
10 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata" | ||
11 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/result" | ||
10 | ) | 12 | ) |
11 | 13 | ||
12 | func MiniCreateArticleDraftHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | 14 | func MiniCreateArticleDraftHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { |
13 | return func(w http.ResponseWriter, r *http.Request) { | 15 | return func(w http.ResponseWriter, r *http.Request) { |
14 | - var req types.MiniArticleSearchMeRequest | 16 | + var req types.MiniArticleDraftCreateRequest |
15 | if err := httpx.Parse(r, &req); err != nil { | 17 | if err := httpx.Parse(r, &req); err != nil { |
16 | httpx.ErrorCtx(r.Context(), w, err) | 18 | httpx.ErrorCtx(r.Context(), w, err) |
17 | return | 19 | return |
18 | } | 20 | } |
19 | 21 | ||
20 | l := article.NewMiniCreateArticleDraftLogic(r.Context(), svcCtx) | 22 | l := article.NewMiniCreateArticleDraftLogic(r.Context(), svcCtx) |
23 | + token := contextdata.GetUserTokenFromCtx(r.Context()) | ||
24 | + req.AuthorId = token.UserId | ||
25 | + req.CompanyId = token.CompanyId | ||
21 | resp, err := l.MiniCreateArticleDraft(&req) | 26 | resp, err := l.MiniCreateArticleDraft(&req) |
22 | - if err != nil { | ||
23 | - httpx.ErrorCtx(r.Context(), w, err) | ||
24 | - } else { | ||
25 | - httpx.OkJsonCtx(r.Context(), w, resp) | ||
26 | - } | 27 | + result.HttpResult(r, w, resp, err) |
27 | } | 28 | } |
28 | } | 29 | } |
1 | +package article | ||
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/article" | ||
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 MiniDeleteArticleDraftMeHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
15 | + return func(w http.ResponseWriter, r *http.Request) { | ||
16 | + var req types.MiniArticleDraftDeleteMeRequest | ||
17 | + if err := httpx.Parse(r, &req); err != nil { | ||
18 | + httpx.ErrorCtx(r.Context(), w, err) | ||
19 | + return | ||
20 | + } | ||
21 | + | ||
22 | + l := article.NewMiniDeleteArticleDraftMeLogic(r.Context(), svcCtx) | ||
23 | + token := contextdata.GetUserTokenFromCtx(r.Context()) | ||
24 | + req.AuthorId = token.UserId | ||
25 | + req.CompanyId = token.CompanyId | ||
26 | + resp, err := l.MiniDeleteArticleDraftMe(&req) | ||
27 | + result.HttpResult(r, w, resp, err) | ||
28 | + } | ||
29 | +} |
1 | +package article | ||
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/article" | ||
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 | +) | ||
11 | + | ||
12 | +func MiniGetArticleDraftMeHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
13 | + return func(w http.ResponseWriter, r *http.Request) { | ||
14 | + var req types.MiniArticleDraftGetMeRequest | ||
15 | + if err := httpx.Parse(r, &req); err != nil { | ||
16 | + httpx.ErrorCtx(r.Context(), w, err) | ||
17 | + return | ||
18 | + } | ||
19 | + | ||
20 | + l := article.NewMiniGetArticleDraftMeLogic(r.Context(), svcCtx) | ||
21 | + resp, err := l.MiniGetArticleDraftMe(&req) | ||
22 | + if err != nil { | ||
23 | + httpx.ErrorCtx(r.Context(), w, err) | ||
24 | + } else { | ||
25 | + httpx.OkJsonCtx(r.Context(), w, resp) | ||
26 | + } | ||
27 | + } | ||
28 | +} |
1 | +package article | ||
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/article" | ||
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 MiniSearchArticleDraftMeHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
15 | + return func(w http.ResponseWriter, r *http.Request) { | ||
16 | + var req types.MiniArticleDraftSearchMeRequest | ||
17 | + if err := httpx.Parse(r, &req); err != nil { | ||
18 | + httpx.ErrorCtx(r.Context(), w, err) | ||
19 | + return | ||
20 | + } | ||
21 | + | ||
22 | + l := article.NewMiniSearchArticleDraftMeLogic(r.Context(), svcCtx) | ||
23 | + token := contextdata.GetUserTokenFromCtx(r.Context()) | ||
24 | + req.AuthorId = token.UserId | ||
25 | + req.CompanyId = token.CompanyId | ||
26 | + resp, err := l.MiniSearchArticleDraftMe(&req) | ||
27 | + result.HttpResult(r, w, resp, err) | ||
28 | + } | ||
29 | +} |
1 | +package article | ||
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/article" | ||
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 MiniUpdateArticleDraftHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
15 | + return func(w http.ResponseWriter, r *http.Request) { | ||
16 | + var req types.MiniArticleDraftUpdateRequest | ||
17 | + if err := httpx.Parse(r, &req); err != nil { | ||
18 | + httpx.ErrorCtx(r.Context(), w, err) | ||
19 | + return | ||
20 | + } | ||
21 | + l := article.NewMiniUpdateArticleDraftLogic(r.Context(), svcCtx) | ||
22 | + token := contextdata.GetUserTokenFromCtx(r.Context()) | ||
23 | + req.AuthorId = token.UserId | ||
24 | + req.CompanyId = token.CompanyId | ||
25 | + resp, err := l.MiniUpdateArticleDraft(&req) | ||
26 | + result.HttpResult(r, w, resp, err) | ||
27 | + } | ||
28 | +} |
@@ -254,6 +254,26 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { | @@ -254,6 +254,26 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { | ||
254 | Handler: article.MiniCreateArticleDraftHandler(serverCtx), | 254 | Handler: article.MiniCreateArticleDraftHandler(serverCtx), |
255 | }, | 255 | }, |
256 | { | 256 | { |
257 | + Method: http.MethodPut, | ||
258 | + Path: "/article_draft", | ||
259 | + Handler: article.MiniUpdateArticleDraftHandler(serverCtx), | ||
260 | + }, | ||
261 | + { | ||
262 | + Method: http.MethodPost, | ||
263 | + Path: "/article_draft/search/me", | ||
264 | + Handler: article.MiniSearchArticleDraftMeHandler(serverCtx), | ||
265 | + }, | ||
266 | + { | ||
267 | + Method: http.MethodGet, | ||
268 | + Path: "/article_draft/me/:id", | ||
269 | + Handler: article.MiniGetArticleDraftMeHandler(serverCtx), | ||
270 | + }, | ||
271 | + { | ||
272 | + Method: http.MethodDelete, | ||
273 | + Path: "/article_draft/me/:id", | ||
274 | + Handler: article.MiniDeleteArticleDraftMeHandler(serverCtx), | ||
275 | + }, | ||
276 | + { | ||
257 | Method: http.MethodPost, | 277 | Method: http.MethodPost, |
258 | Path: "/article_backup/search", | 278 | Path: "/article_backup/search", |
259 | Handler: article.MiniArticleBackupSearchHandler(serverCtx), | 279 | Handler: article.MiniArticleBackupSearchHandler(serverCtx), |
@@ -83,6 +83,7 @@ func (l *MiniArticleMarkUserReadLogic) MiniArticleMarkUserRead(req *types.MiniAr | @@ -83,6 +83,7 @@ func (l *MiniArticleMarkUserReadLogic) MiniArticleMarkUserRead(req *types.MiniAr | ||
83 | if err != nil { | 83 | if err != nil { |
84 | return err | 84 | return err |
85 | } | 85 | } |
86 | + //增加浏览计数 | ||
86 | err = l.svcCtx.ArticleRepository.IncreaseCountRead(ctx, c, 1, articleInfo) | 87 | err = l.svcCtx.ArticleRepository.IncreaseCountRead(ctx, c, 1, articleInfo) |
87 | return err | 88 | return err |
88 | }, true) | 89 | }, true) |
@@ -5,6 +5,8 @@ import ( | @@ -5,6 +5,8 @@ import ( | ||
5 | 5 | ||
6 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | 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" | 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/domain" | ||
9 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr" | ||
8 | 10 | ||
9 | "github.com/zeromicro/go-zero/core/logx" | 11 | "github.com/zeromicro/go-zero/core/logx" |
10 | ) | 12 | ) |
@@ -23,8 +25,43 @@ func NewMiniCreateArticleDraftLogic(ctx context.Context, svcCtx *svc.ServiceCont | @@ -23,8 +25,43 @@ func NewMiniCreateArticleDraftLogic(ctx context.Context, svcCtx *svc.ServiceCont | ||
23 | } | 25 | } |
24 | } | 26 | } |
25 | 27 | ||
26 | -func (l *MiniCreateArticleDraftLogic) MiniCreateArticleDraft(req *types.MiniArticleSearchMeRequest) (resp *types.MiniArticleSearchMeResponse, err error) { | ||
27 | - // todo: add your logic here and delete this line | 28 | +// 保存文章进草稿箱 |
29 | +func (l *MiniCreateArticleDraftLogic) MiniCreateArticleDraft(req *types.MiniArticleDraftCreateRequest) (resp *types.MiniArticleDraftCreateResponse, err error) { | ||
30 | + var conn = l.svcCtx.DefaultDBConn() | ||
28 | 31 | ||
32 | + newDraft := domain.ArticleDraft{ | ||
33 | + Id: 0, | ||
34 | + CompanyId: req.CompanyId, | ||
35 | + CreatedAt: 0, | ||
36 | + UpdatedAt: 0, | ||
37 | + DeletedAt: 0, | ||
38 | + Version: 0, | ||
39 | + Template: req.Template, | ||
40 | + Content: req.Section, | ||
41 | + AuthorId: req.AuthorId, | ||
42 | + Title: req.Title, | ||
43 | + Images: []domain.Image{}, | ||
44 | + WhoRead: req.WhoRead, | ||
45 | + WhoReview: req.WhoReview, | ||
46 | + Location: domain.Location{ | ||
47 | + Longitude: req.Location.Longitude, | ||
48 | + Latitude: req.Location.Latitude, | ||
49 | + Descript: req.Location.Descript, | ||
50 | + }, | ||
51 | + } | ||
52 | + for _, val := range req.Images { | ||
53 | + newDraft.Images = append(newDraft.Images, domain.Image{ | ||
54 | + Url: val, | ||
55 | + }) | ||
56 | + } | ||
57 | + | ||
58 | + _, err = l.svcCtx.ArticleDraftRepository.Insert(l.ctx, conn, &newDraft) | ||
59 | + if err != nil { | ||
60 | + return nil, xerr.NewErrMsgErr("保存草稿失败", err) | ||
61 | + } | ||
62 | + | ||
63 | + resp = &types.MiniArticleDraftCreateResponse{ | ||
64 | + Id: newDraft.Id, | ||
65 | + } | ||
29 | return | 66 | return |
30 | } | 67 | } |
1 | +package article | ||
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 MiniDeleteArticleDraftMeLogic struct { | ||
14 | + logx.Logger | ||
15 | + ctx context.Context | ||
16 | + svcCtx *svc.ServiceContext | ||
17 | +} | ||
18 | + | ||
19 | +func NewMiniDeleteArticleDraftMeLogic(ctx context.Context, svcCtx *svc.ServiceContext) *MiniDeleteArticleDraftMeLogic { | ||
20 | + return &MiniDeleteArticleDraftMeLogic{ | ||
21 | + Logger: logx.WithContext(ctx), | ||
22 | + ctx: ctx, | ||
23 | + svcCtx: svcCtx, | ||
24 | + } | ||
25 | +} | ||
26 | + | ||
27 | +// 删除我的草稿记录 | ||
28 | +func (l *MiniDeleteArticleDraftMeLogic) MiniDeleteArticleDraftMe(req *types.MiniArticleDraftDeleteMeRequest) (resp *types.MiniArticleDraftDeleteMeResponse, err error) { | ||
29 | + var conn = l.svcCtx.DefaultDBConn() | ||
30 | + | ||
31 | + draftInfo, err := l.svcCtx.ArticleDraftRepository.FindOne(l.ctx, conn, req.Id) | ||
32 | + if err != nil { | ||
33 | + return nil, xerr.NewErrMsgErr("删除草稿失败", err) | ||
34 | + } | ||
35 | + if draftInfo.AuthorId != req.AuthorId { | ||
36 | + if err != nil { | ||
37 | + return nil, xerr.NewErrMsg("删除草稿失败") | ||
38 | + } | ||
39 | + } | ||
40 | + _, err = l.svcCtx.ArticleDraftRepository.Delete(l.ctx, conn, draftInfo) | ||
41 | + if err != nil { | ||
42 | + return nil, xerr.NewErrMsgErr("删除草稿失败", err) | ||
43 | + } | ||
44 | + resp = &types.MiniArticleDraftDeleteMeResponse{ | ||
45 | + Id: draftInfo.Id, | ||
46 | + } | ||
47 | + return resp, nil | ||
48 | +} |
1 | +package article | ||
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 MiniGetArticleDraftMeLogic struct { | ||
14 | + logx.Logger | ||
15 | + ctx context.Context | ||
16 | + svcCtx *svc.ServiceContext | ||
17 | +} | ||
18 | + | ||
19 | +func NewMiniGetArticleDraftMeLogic(ctx context.Context, svcCtx *svc.ServiceContext) *MiniGetArticleDraftMeLogic { | ||
20 | + return &MiniGetArticleDraftMeLogic{ | ||
21 | + Logger: logx.WithContext(ctx), | ||
22 | + ctx: ctx, | ||
23 | + svcCtx: svcCtx, | ||
24 | + } | ||
25 | +} | ||
26 | + | ||
27 | +// 获取我的草稿记录 | ||
28 | +func (l *MiniGetArticleDraftMeLogic) MiniGetArticleDraftMe(req *types.MiniArticleDraftGetMeRequest) (resp *types.MiniArticleDraftGetMeResponse, err error) { | ||
29 | + var conn = l.svcCtx.DefaultDBConn() | ||
30 | + | ||
31 | + draftInfo, err := l.svcCtx.ArticleDraftRepository.FindOne(l.ctx, conn, req.Id) | ||
32 | + if err != nil { | ||
33 | + return nil, xerr.NewErrMsgErr("获取草稿失败", err) | ||
34 | + } | ||
35 | + if draftInfo.AuthorId != req.AuthorId { | ||
36 | + if err != nil { | ||
37 | + return nil, xerr.NewErrMsg("获取草稿失败") | ||
38 | + } | ||
39 | + } | ||
40 | + resp = &types.MiniArticleDraftGetMeResponse{ | ||
41 | + Id: draftInfo.Id, | ||
42 | + Template: draftInfo.Template, | ||
43 | + Section: draftInfo.Content, | ||
44 | + Title: draftInfo.Title, | ||
45 | + Images: []string{}, | ||
46 | + WhoRead: draftInfo.WhoRead, | ||
47 | + WhoReview: draftInfo.WhoReview, | ||
48 | + Location: types.Location{ | ||
49 | + Longitude: draftInfo.Location.Longitude, | ||
50 | + Latitude: draftInfo.Location.Latitude, | ||
51 | + Descript: draftInfo.Location.Descript, | ||
52 | + }, | ||
53 | + } | ||
54 | + for _, val := range draftInfo.Images { | ||
55 | + resp.Images = append(resp.Images, val.Url) | ||
56 | + } | ||
57 | + return | ||
58 | +} |
1 | +package article | ||
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/domain" | ||
9 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr" | ||
10 | + | ||
11 | + "github.com/zeromicro/go-zero/core/logx" | ||
12 | +) | ||
13 | + | ||
14 | +type MiniSearchArticleDraftMeLogic struct { | ||
15 | + logx.Logger | ||
16 | + ctx context.Context | ||
17 | + svcCtx *svc.ServiceContext | ||
18 | +} | ||
19 | + | ||
20 | +func NewMiniSearchArticleDraftMeLogic(ctx context.Context, svcCtx *svc.ServiceContext) *MiniSearchArticleDraftMeLogic { | ||
21 | + return &MiniSearchArticleDraftMeLogic{ | ||
22 | + Logger: logx.WithContext(ctx), | ||
23 | + ctx: ctx, | ||
24 | + svcCtx: svcCtx, | ||
25 | + } | ||
26 | +} | ||
27 | + | ||
28 | +func (l *MiniSearchArticleDraftMeLogic) MiniSearchArticleDraftMe(req *types.MiniArticleDraftSearchMeRequest) (resp *types.MiniArticleDraftSearchMeResponse, err error) { | ||
29 | + var conn = l.svcCtx.DefaultDBConn() | ||
30 | + | ||
31 | + queryOption := domain.NewQueryOptions(). | ||
32 | + WithOffsetLimit(req.Page, req.Size). | ||
33 | + MustWithKV("authorId", req.AuthorId) | ||
34 | + | ||
35 | + cnt, draftList, err := l.svcCtx.ArticleDraftRepository.Find(l.ctx, conn, queryOption) | ||
36 | + if err != nil { | ||
37 | + return nil, xerr.NewErrMsgErr("获取草稿列表失败", err) | ||
38 | + } | ||
39 | + resp = &types.MiniArticleDraftSearchMeResponse{ | ||
40 | + Total: cnt, | ||
41 | + List: make([]types.MiniArticleDraftItem, len(draftList)), | ||
42 | + } | ||
43 | + | ||
44 | + for i := range draftList { | ||
45 | + images := []string{} | ||
46 | + for _, val := range draftList[i].Images { | ||
47 | + images = append(images, val.Url) | ||
48 | + } | ||
49 | + resp.List[i] = types.MiniArticleDraftItem{ | ||
50 | + Id: draftList[i].Id, | ||
51 | + Template: draftList[i].Template, | ||
52 | + Section: draftList[i].Content, | ||
53 | + Title: draftList[i].Title, | ||
54 | + Images: images, | ||
55 | + } | ||
56 | + } | ||
57 | + return resp, nil | ||
58 | +} |
@@ -233,7 +233,7 @@ func (l *MiniSetUserLikeLogic) setUserLikeArticle(req *types.MiniSetUserLikeRequ | @@ -233,7 +233,7 @@ func (l *MiniSetUserLikeLogic) setUserLikeArticle(req *types.MiniSetUserLikeRequ | ||
233 | CommentAuthor: 0, | 233 | CommentAuthor: 0, |
234 | UserId: req.UserId, | 234 | UserId: req.UserId, |
235 | } | 235 | } |
236 | - // 去除点赞标识 | 236 | + // 添加点赞标识 |
237 | _, err = l.svcCtx.UserLoveFlagRepository.Insert(ctx, c, &flagInfo) | 237 | _, err = l.svcCtx.UserLoveFlagRepository.Insert(ctx, c, &flagInfo) |
238 | if err != nil { | 238 | if err != nil { |
239 | return err | 239 | return err |
1 | +package article | ||
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/domain" | ||
9 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr" | ||
10 | + | ||
11 | + "github.com/zeromicro/go-zero/core/logx" | ||
12 | +) | ||
13 | + | ||
14 | +type MiniUpdateArticleDraftLogic struct { | ||
15 | + logx.Logger | ||
16 | + ctx context.Context | ||
17 | + svcCtx *svc.ServiceContext | ||
18 | +} | ||
19 | + | ||
20 | +func NewMiniUpdateArticleDraftLogic(ctx context.Context, svcCtx *svc.ServiceContext) *MiniUpdateArticleDraftLogic { | ||
21 | + return &MiniUpdateArticleDraftLogic{ | ||
22 | + Logger: logx.WithContext(ctx), | ||
23 | + ctx: ctx, | ||
24 | + svcCtx: svcCtx, | ||
25 | + } | ||
26 | +} | ||
27 | + | ||
28 | +func (l *MiniUpdateArticleDraftLogic) MiniUpdateArticleDraft(req *types.MiniArticleDraftUpdateRequest) (resp *types.MiniArticleDraftUpdateResponse, err error) { | ||
29 | + var conn = l.svcCtx.DefaultDBConn() | ||
30 | + | ||
31 | + draftInfo, err := l.svcCtx.ArticleDraftRepository.FindOne(l.ctx, conn, req.Id) | ||
32 | + if err != nil { | ||
33 | + return nil, xerr.NewErrMsgErr("更新草稿失败", err) | ||
34 | + } | ||
35 | + if draftInfo.AuthorId != req.AuthorId { | ||
36 | + if err != nil { | ||
37 | + return nil, xerr.NewErrMsg("更新草稿失败") | ||
38 | + } | ||
39 | + } | ||
40 | + draftInfo.Content = req.Section | ||
41 | + draftInfo.Title = req.Title | ||
42 | + draftInfo.Location = domain.Location{ | ||
43 | + Longitude: req.Location.Longitude, | ||
44 | + Latitude: req.Location.Latitude, | ||
45 | + Descript: req.Location.Descript, | ||
46 | + } | ||
47 | + draftInfo.WhoRead = req.WhoRead | ||
48 | + draftInfo.WhoReview = req.WhoReview | ||
49 | + draftInfo.Images = []domain.Image{} | ||
50 | + for _, val := range req.Images { | ||
51 | + draftInfo.Images = append(draftInfo.Images, domain.Image{ | ||
52 | + Url: val, | ||
53 | + }) | ||
54 | + } | ||
55 | + _, err = l.svcCtx.ArticleDraftRepository.Update(l.ctx, conn, draftInfo) | ||
56 | + if err != nil { | ||
57 | + return nil, xerr.NewErrMsgErr("更新草稿失败", err) | ||
58 | + } | ||
59 | + resp = &types.MiniArticleDraftUpdateResponse{ | ||
60 | + Id: draftInfo.Id, | ||
61 | + } | ||
62 | + return | ||
63 | +} |
@@ -147,13 +147,84 @@ type MiniArticleMarkUserReadResponse struct { | @@ -147,13 +147,84 @@ type MiniArticleMarkUserReadResponse struct { | ||
147 | } | 147 | } |
148 | 148 | ||
149 | type MiniArticleDraftCreateRequest struct { | 149 | type MiniArticleDraftCreateRequest struct { |
150 | - Template int `json:"template"` // 使用哪个模板进行编辑 0、无 1、演绎式 2、归纳式 | ||
151 | - Content []string `json:"content"` // 填写的内容 | ||
152 | - Title string `json:"title"` //标题 | ||
153 | - Images []string `json:"images"` //图片 | 150 | + CompanyId int64 `json:",optional"` |
151 | + AuthorId int64 `json:",optional"` // 发布人 | ||
152 | + Template int `json:"template"` // 使用哪个模板进行编辑 0、无 1、演绎式 2、归纳式 | ||
153 | + Section []string `json:"section"` // 填写的内容 | ||
154 | + Title string `json:"title"` // 标题 | ||
155 | + Images []string `json:"images"` // 图片 | ||
156 | + WhoRead []int64 `json:"whoRead"` // 谁可以看 | ||
157 | + WhoReview []int64 `json:"whoReview"` // 评论人 | ||
158 | + Location Location `json:"location"` // 坐标 | ||
154 | } | 159 | } |
155 | 160 | ||
156 | type MiniArticleDraftCreateResponse struct { | 161 | type MiniArticleDraftCreateResponse struct { |
162 | + Id int64 `json:"id"` | ||
163 | +} | ||
164 | + | ||
165 | +type MiniArticleDraftUpdateRequest struct { | ||
166 | + Id int64 `json:"id"` | ||
167 | + CompanyId int64 `json:",optional"` | ||
168 | + AuthorId int64 `json:",optional"` // 发布人 | ||
169 | + Template int `json:"template"` // 使用哪个模板进行编辑 0、无 1、演绎式 2、归纳式 | ||
170 | + Section []string `json:"section"` // 填写的内容 | ||
171 | + Title string `json:"title"` // 标题 | ||
172 | + Images []string `json:"images"` // 图片 | ||
173 | + WhoRead []int64 `json:"whoRead"` // 谁可以看 | ||
174 | + WhoReview []int64 `json:"whoReview"` // 评论人 | ||
175 | + Location Location `json:"location"` // 坐标 | ||
176 | +} | ||
177 | + | ||
178 | +type MiniArticleDraftUpdateResponse struct { | ||
179 | + Id int64 `json:"id"` | ||
180 | +} | ||
181 | + | ||
182 | +type MiniArticleDraftSearchMeRequest struct { | ||
183 | + CompanyId int64 `json:",optional"` // 公司id | ||
184 | + AuthorId int64 `json:",optional"` // 发布人 | ||
185 | + Page int `json:"page"` | ||
186 | + Size int `json:"size"` | ||
187 | +} | ||
188 | + | ||
189 | +type MiniArticleDraftSearchMeResponse struct { | ||
190 | + Total int64 `json:"total"` | ||
191 | + List []MiniArticleDraftItem `json:"list"` | ||
192 | +} | ||
193 | + | ||
194 | +type MiniArticleDraftItem struct { | ||
195 | + Id int64 `json:"id"` | ||
196 | + Template int `json:"template"` // 使用哪个模板进行编辑 0、无 1、演绎式 2、归纳式 | ||
197 | + Section []string `json:"section"` // 填写的内容 | ||
198 | + Title string `json:"title"` // 标题 | ||
199 | + Images []string `json:"images"` // 图片 | ||
200 | + CreatedAt int64 `json:"createdAt"` | ||
201 | +} | ||
202 | + | ||
203 | +type MiniArticleDraftGetMeRequest struct { | ||
204 | + CompanyId int64 `path:",optional"` // 公司id | ||
205 | + AuthorId int64 `path:",optional"` // 发布人 | ||
206 | + Id int64 `path:"id"` | ||
207 | +} | ||
208 | + | ||
209 | +type MiniArticleDraftGetMeResponse struct { | ||
210 | + Id int64 `json:"id"` // | ||
211 | + Template int `json:"template"` // 使用哪个模板进行编辑 0、无 1、演绎式 2、归纳式 | ||
212 | + Section []string `json:"Section"` // 填写的内容 | ||
213 | + Title string `json:"title"` // 标题 | ||
214 | + Images []string `json:"images"` // 图片 | ||
215 | + WhoRead []int64 `json:"whoRead"` // 谁可以看 | ||
216 | + WhoReview []int64 `json:"whoReview"` // 评论人 | ||
217 | + Location Location `json:"location"` // 坐标 | ||
218 | +} | ||
219 | + | ||
220 | +type MiniArticleDraftDeleteMeRequest struct { | ||
221 | + CompanyId int64 `path:",optional"` // 公司id | ||
222 | + AuthorId int64 `path:",optional"` // 发布人 | ||
223 | + Id int64 `path:"id"` | ||
224 | +} | ||
225 | + | ||
226 | +type MiniArticleDraftDeleteMeResponse struct { | ||
227 | + Id int64 `json:"id"` // | ||
157 | } | 228 | } |
158 | 229 | ||
159 | type MiniArticleMarkListRequest struct { | 230 | type MiniArticleMarkListRequest struct { |
@@ -2,6 +2,7 @@ package models | @@ -2,6 +2,7 @@ package models | ||
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | "fmt" | 4 | "fmt" |
5 | + "time" | ||
5 | 6 | ||
6 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain" | 7 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain" |
7 | "gorm.io/gorm" | 8 | "gorm.io/gorm" |
@@ -31,13 +32,14 @@ func (m *ArticleDraft) TableName() string { | @@ -31,13 +32,14 @@ func (m *ArticleDraft) TableName() string { | ||
31 | } | 32 | } |
32 | 33 | ||
33 | func (m *ArticleDraft) BeforeCreate(tx *gorm.DB) (err error) { | 34 | func (m *ArticleDraft) BeforeCreate(tx *gorm.DB) (err error) { |
34 | - // m.CreatedAt = time.Now().Unix() | ||
35 | - // m.UpdatedAt = time.Now().Unix() | 35 | + nowTime := time.Now().Unix() |
36 | + m.CreatedAt = nowTime | ||
37 | + m.UpdatedAt = nowTime | ||
36 | return | 38 | return |
37 | } | 39 | } |
38 | 40 | ||
39 | func (m *ArticleDraft) BeforeUpdate(tx *gorm.DB) (err error) { | 41 | func (m *ArticleDraft) BeforeUpdate(tx *gorm.DB) (err error) { |
40 | - // m.UpdatedAt = time.Now().Unix() | 42 | + m.UpdatedAt = time.Now().Unix() |
41 | return | 43 | return |
42 | } | 44 | } |
43 | 45 |
@@ -6,6 +6,7 @@ import ( | @@ -6,6 +6,7 @@ import ( | ||
6 | 6 | ||
7 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain" | 7 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain" |
8 | "gorm.io/gorm" | 8 | "gorm.io/gorm" |
9 | + "gorm.io/plugin/soft_delete" | ||
9 | ) | 10 | ) |
10 | 11 | ||
11 | type UserReadArticle struct { | 12 | type UserReadArticle struct { |
@@ -13,6 +14,7 @@ type UserReadArticle struct { | @@ -13,6 +14,7 @@ type UserReadArticle struct { | ||
13 | CreatedAt int64 | 14 | CreatedAt int64 |
14 | UpdatedAt int64 | 15 | UpdatedAt int64 |
15 | DeletedAt int64 | 16 | DeletedAt int64 |
17 | + IsDel soft_delete.DeletedAt `gorm:"softDelete:flag,DeletedAtField:DeletedAt"` | ||
16 | Version int | 18 | Version int |
17 | CompanyId int64 | 19 | CompanyId int64 |
18 | UserId int64 | 20 | UserId int64 |
-
请 注册 或 登录 后发表评论