正在显示
46 个修改的文件
包含
681 行增加
和
150 行删除
@@ -14,13 +14,29 @@ info( | @@ -14,13 +14,29 @@ info( | ||
14 | group: common | 14 | group: common |
15 | ) | 15 | ) |
16 | service Core { | 16 | service Core { |
17 | + @doc "日志查询" | ||
18 | + @handler commonGetLog | ||
19 | + get /log/:module | ||
20 | +} | ||
21 | + | ||
22 | +// 通用接口 | ||
23 | +@server( | ||
24 | + prefix: v1 | ||
25 | + middleware: LogRequest | ||
26 | + group: common | ||
27 | +) | ||
28 | +service Core { | ||
17 | @doc "短信验证码" | 29 | @doc "短信验证码" |
18 | @handler commonSmsCode | 30 | @handler commonSmsCode |
19 | post /common/sms/code (CommonSmsCodeRequest) returns (CommonSmsCodeResposne) | 31 | post /common/sms/code (CommonSmsCodeRequest) returns (CommonSmsCodeResposne) |
20 | 32 | ||
21 | - @doc "日志查询" | ||
22 | - @handler commonGetLog | ||
23 | - get /log/:module | 33 | + @doc "微信二维码" |
34 | + @handler miniQrcodeInvite | ||
35 | + post /mini/qrcode (MiniQrCodeRequest) | ||
36 | + | ||
37 | + @doc "清理缓存" | ||
38 | + @handler commonGetClearCache | ||
39 | + get /clear | ||
24 | } | 40 | } |
25 | 41 | ||
26 | // 短信验证码 | 42 | // 短信验证码 |
@@ -31,4 +47,11 @@ type( | @@ -31,4 +47,11 @@ type( | ||
31 | CommonSmsCodeResposne{ | 47 | CommonSmsCodeResposne{ |
32 | 48 | ||
33 | } | 49 | } |
50 | +) | ||
51 | + | ||
52 | +type( | ||
53 | + MiniQrCodeRequest{ | ||
54 | + Page string `json:"page"` // 微信页面入口 | ||
55 | + Scene string `json:"scene"` // 参数 | ||
56 | + } | ||
34 | ) | 57 | ) |
@@ -52,19 +52,20 @@ type ( | @@ -52,19 +52,20 @@ type ( | ||
52 | MessageBusinessItem { | 52 | MessageBusinessItem { |
53 | Id int64 `json:"id"` | 53 | Id int64 `json:"id"` |
54 | Type int `json:"type"` // 分类 (1回复 2点赞 3被采纳) | 54 | Type int `json:"type"` // 分类 (1回复 2点赞 3被采纳) |
55 | - OptType int `json:"optType"` // 操作类型(1针对文章、2针对评论、3针对圆桌) | 55 | + OptType int `json:"optType"` // 操作类型(1针对文章或段落、2针对评论、3针对圆桌) |
56 | CompanyId int64 `json:"companyId"` // 操作人公司ID | 56 | CompanyId int64 `json:"companyId"` // 操作人公司ID |
57 | UserId int64 `json:"userId"` // 操作人用户ID | 57 | UserId int64 `json:"userId"` // 操作人用户ID |
58 | RecipientId int64 `json:"recipientId"` // 接收者ID | 58 | RecipientId int64 `json:"recipientId"` // 接收者ID |
59 | ArticleId int64 `json:"articleId"` // 文章ID | 59 | ArticleId int64 `json:"articleId"` // 文章ID |
60 | - CommentId int64 `json:"commentId"` // 评论ID | ||
61 | - DiscussionId int64 `json:"discussionId"` // 圆桌ID | ||
62 | - DiscussionOpinionId int64 `json:"discussionOpinionId"` // 观点ID | ||
63 | - Content string `json:"content"` // 消息内容 | 60 | +// CommentId int64 `json:"commentId"` // 评论ID |
61 | +// DiscussionId int64 `json:"discussionId"` // 圆桌ID | ||
62 | +// DiscussionOpinionId int64 `json:"discussionOpinionId"` // 观点ID | ||
63 | +// Content string `json:"content"` // 消息内容 | ||
64 | CreatedAt int64 `json:"createdAt"` // 创建时间 | 64 | CreatedAt int64 `json:"createdAt"` // 创建时间 |
65 | User *SimpleUser `json:"user"` // 操作人 | 65 | User *SimpleUser `json:"user"` // 操作人 |
66 | Article *SimpleArticle `json:"article"` // 文章 | 66 | Article *SimpleArticle `json:"article"` // 文章 |
67 | - Comment *SimpleComment `json:"comment"` // 评论(不一定是自己,可能是被人@到) | 67 | + Comment *SimpleComment `json:"comment"` // 评论 |
68 | + CommentParent *SimpleComment `json:"commentParent"` // 被回复的评论 | ||
68 | } | 69 | } |
69 | 70 | ||
70 | SimpleUser { | 71 | SimpleUser { |
@@ -30,6 +30,9 @@ service Core { | @@ -30,6 +30,9 @@ service Core { | ||
30 | @doc "角色列表搜索" | 30 | @doc "角色列表搜索" |
31 | @handler systemSearchRole | 31 | @handler systemSearchRole |
32 | post /system/role/search (RoleSearchRequest) returns (RoleSearchResponse) | 32 | post /system/role/search (RoleSearchRequest) returns (RoleSearchResponse) |
33 | + @doc "角色权限列表" | ||
34 | + @handler systemGetRoleAuths | ||
35 | + get /system/role/auths | ||
33 | } | 36 | } |
34 | 37 | ||
35 | type ( | 38 | type ( |
@@ -258,14 +258,15 @@ type ( | @@ -258,14 +258,15 @@ type ( | ||
258 | } | 258 | } |
259 | 259 | ||
260 | SimpleComment { | 260 | SimpleComment { |
261 | - Id int64 `json:"id"` | ||
262 | - Content string `json:"content"` // 评论内容 | ||
263 | - CountLove int `json:"countLove"` // 点赞数量 | ||
264 | - CountComment int `json:"countComment"` // 评论数量 | ||
265 | - Show int `json:"show"` // 评论的展示状态(0显示、1不显示) | 261 | + Id int64 `json:"id"` |
262 | + Content string `json:"content"` // 评论内容 | ||
263 | + Show int `json:"show"` // 评论的展示状态(0显示、1不显示) | ||
264 | + AtWho []CommentAtWho `json:"atWho"` // 填写评论时@的人 | ||
265 | + MatchUrl map[string]string `json:"matchUrl"` // 评论内容中的url文本 | ||
266 | + CountReply int `json:"countReply"` // 用户回复数量 | ||
267 | + CountUserLove int `json:"countUserLove"` // 用户点赞数量 | ||
266 | } | 268 | } |
267 | 269 | ||
268 | - | ||
269 | MiniBeLikedRequest{ | 270 | MiniBeLikedRequest{ |
270 | Page int `json:"page"` | 271 | Page int `json:"page"` |
271 | Size int `json:"size"` | 272 | Size int `json:"size"` |
1 | +package common | ||
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/common" | ||
8 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | ||
9 | +) | ||
10 | + | ||
11 | +func CommonGetClearCacheHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
12 | + return func(w http.ResponseWriter, r *http.Request) { | ||
13 | + l := common.NewCommonGetClearCacheLogic(r.Context(), svcCtx) | ||
14 | + err := l.CommonGetClearCache() | ||
15 | + if err != nil { | ||
16 | + httpx.ErrorCtx(r.Context(), w, err) | ||
17 | + } else { | ||
18 | + httpx.Ok(w) | ||
19 | + } | ||
20 | + } | ||
21 | +} |
1 | +package common | ||
2 | + | ||
3 | +import ( | ||
4 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/result" | ||
5 | + "net/http" | ||
6 | + | ||
7 | + "github.com/zeromicro/go-zero/rest/httpx" | ||
8 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/common" | ||
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/types" | ||
11 | +) | ||
12 | + | ||
13 | +func MiniQrcodeInviteHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
14 | + return func(w http.ResponseWriter, r *http.Request) { | ||
15 | + var req types.MiniQrCodeRequest | ||
16 | + if err := httpx.Parse(r, &req); err != nil { | ||
17 | + httpx.ErrorCtx(r.Context(), w, err) | ||
18 | + return | ||
19 | + } | ||
20 | + | ||
21 | + l := common.NewMiniQrcodeInviteLogic(r.Context(), svcCtx) | ||
22 | + resp, err := l.MiniQrcodeInvite(&req) | ||
23 | + result.HttpResult(r, w, resp, err) | ||
24 | + } | ||
25 | +} |
1 | +package role | ||
2 | + | ||
3 | +import ( | ||
4 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/result" | ||
5 | + "net/http" | ||
6 | + | ||
7 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/role" | ||
8 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | ||
9 | +) | ||
10 | + | ||
11 | +func SystemGetRoleAuthsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
12 | + return func(w http.ResponseWriter, r *http.Request) { | ||
13 | + l := role.NewSystemGetRoleAuthsLogic(r.Context(), svcCtx) | ||
14 | + resp, err := l.SystemGetRoleAuths() | ||
15 | + result.HttpResult(r, w, resp, err) | ||
16 | + } | ||
17 | +} |
@@ -22,11 +22,6 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { | @@ -22,11 +22,6 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { | ||
22 | server.AddRoutes( | 22 | server.AddRoutes( |
23 | []rest.Route{ | 23 | []rest.Route{ |
24 | { | 24 | { |
25 | - Method: http.MethodPost, | ||
26 | - Path: "/common/sms/code", | ||
27 | - Handler: common.CommonSmsCodeHandler(serverCtx), | ||
28 | - }, | ||
29 | - { | ||
30 | Method: http.MethodGet, | 25 | Method: http.MethodGet, |
31 | Path: "/log/:module", | 26 | Path: "/log/:module", |
32 | Handler: common.CommonGetLogHandler(serverCtx), | 27 | Handler: common.CommonGetLogHandler(serverCtx), |
@@ -41,6 +36,30 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { | @@ -41,6 +36,30 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { | ||
41 | []rest.Route{ | 36 | []rest.Route{ |
42 | { | 37 | { |
43 | Method: http.MethodPost, | 38 | Method: http.MethodPost, |
39 | + Path: "/common/sms/code", | ||
40 | + Handler: common.CommonSmsCodeHandler(serverCtx), | ||
41 | + }, | ||
42 | + { | ||
43 | + Method: http.MethodPost, | ||
44 | + Path: "/mini/qrcode", | ||
45 | + Handler: common.MiniQrcodeInviteHandler(serverCtx), | ||
46 | + }, | ||
47 | + { | ||
48 | + Method: http.MethodGet, | ||
49 | + Path: "/clear", | ||
50 | + Handler: common.CommonGetClearCacheHandler(serverCtx), | ||
51 | + }, | ||
52 | + }..., | ||
53 | + ), | ||
54 | + rest.WithPrefix("/v1"), | ||
55 | + ) | ||
56 | + | ||
57 | + server.AddRoutes( | ||
58 | + rest.WithMiddlewares( | ||
59 | + []rest.Middleware{serverCtx.LogRequest}, | ||
60 | + []rest.Route{ | ||
61 | + { | ||
62 | + Method: http.MethodPost, | ||
44 | Path: "/article_comment", | 63 | Path: "/article_comment", |
45 | Handler: comment.MiniCreateArticleCommentHandler(serverCtx), | 64 | Handler: comment.MiniCreateArticleCommentHandler(serverCtx), |
46 | }, | 65 | }, |
@@ -574,6 +593,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { | @@ -574,6 +593,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { | ||
574 | Path: "/system/role/search", | 593 | Path: "/system/role/search", |
575 | Handler: role.SystemSearchRoleHandler(serverCtx), | 594 | Handler: role.SystemSearchRoleHandler(serverCtx), |
576 | }, | 595 | }, |
596 | + { | ||
597 | + Method: http.MethodGet, | ||
598 | + Path: "/system/role/auths", | ||
599 | + Handler: role.SystemGetRoleAuthsHandler(serverCtx), | ||
600 | + }, | ||
577 | }..., | 601 | }..., |
578 | ), | 602 | ), |
579 | rest.WithJwt(serverCtx.Config.SystemAuth.AccessSecret), | 603 | rest.WithJwt(serverCtx.Config.SystemAuth.AccessSecret), |
@@ -357,7 +357,7 @@ func (l *MiniSetUserLikeLogic) setUserLikeComment(req *types.MiniSetUserLikeRequ | @@ -357,7 +357,7 @@ func (l *MiniSetUserLikeLogic) setUserLikeComment(req *types.MiniSetUserLikeRequ | ||
357 | 357 | ||
358 | // 创建点赞消息 | 358 | // 创建点赞消息 |
359 | var messageLogic = message.NewMiniBusinessLogic(l.ctx, l.svcCtx) | 359 | var messageLogic = message.NewMiniBusinessLogic(l.ctx, l.svcCtx) |
360 | - err = messageLogic.LikeComment(c, commentInfo.ArticleId, commentInfo.Id, commentInfo.FromUserId) | 360 | + err = messageLogic.LikeComment(c, commentInfo.ArticleId, commentInfo.Id, commentInfo.Pid, commentInfo.FromUserId) |
361 | if err != nil { | 361 | if err != nil { |
362 | return err | 362 | return err |
363 | } | 363 | } |
@@ -205,9 +205,9 @@ func (l *MiniCreateArticleCommentLogic) MiniCreateArticleComment(req *types.Mini | @@ -205,9 +205,9 @@ func (l *MiniCreateArticleCommentLogic) MiniCreateArticleComment(req *types.Mini | ||
205 | atAllIds = append(atAllIds, atWhoIds...) | 205 | atAllIds = append(atAllIds, atWhoIds...) |
206 | var messageLogic = message.NewMiniBusinessLogic(l.ctx, l.svcCtx) | 206 | var messageLogic = message.NewMiniBusinessLogic(l.ctx, l.svcCtx) |
207 | if pComment != nil { | 207 | if pComment != nil { |
208 | - err = messageLogic.CommentReply(c, pComment.ArticleId, pComment.SectionId, pComment.Id, req.Content, atAllIds) // 对评论回复 | 208 | + err = messageLogic.CommentReply(c, req.ArtitcleId, newComment.Id, pComment.Id, atAllIds) // 对评论回复 |
209 | } else { | 209 | } else { |
210 | - err = messageLogic.CommentArticle(c, req.ArtitcleId, req.SectionId, req.Content, atAllIds) // 对文章回复 | 210 | + err = messageLogic.CommentArticle(c, req.ArtitcleId, newComment.Id, atAllIds) // 对文章回复 |
211 | } | 211 | } |
212 | if err != nil { | 212 | if err != nil { |
213 | return err | 213 | return err |
1 | +package common | ||
2 | + | ||
3 | +import ( | ||
4 | + "context" | ||
5 | + "fmt" | ||
6 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr" | ||
7 | + "strings" | ||
8 | + | ||
9 | + "github.com/zeromicro/go-zero/core/logx" | ||
10 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | ||
11 | +) | ||
12 | + | ||
13 | +type CommonGetClearCacheLogic struct { | ||
14 | + logx.Logger | ||
15 | + ctx context.Context | ||
16 | + svcCtx *svc.ServiceContext | ||
17 | +} | ||
18 | + | ||
19 | +func NewCommonGetClearCacheLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CommonGetClearCacheLogic { | ||
20 | + return &CommonGetClearCacheLogic{ | ||
21 | + Logger: logx.WithContext(ctx), | ||
22 | + ctx: ctx, | ||
23 | + svcCtx: svcCtx, | ||
24 | + } | ||
25 | +} | ||
26 | + | ||
27 | +func (l *CommonGetClearCacheLogic) CommonGetClearCache() error { | ||
28 | + var ( | ||
29 | + appName = l.svcCtx.Config.Name | ||
30 | + success int | ||
31 | + ) | ||
32 | + if strings.TrimSpace(appName) == "" { | ||
33 | + return nil | ||
34 | + } | ||
35 | + keyPattern := fmt.Sprintf("%s*", appName) | ||
36 | + list, err := l.svcCtx.Redis.Keys(keyPattern) | ||
37 | + if err != nil { | ||
38 | + return xerr.NewErrMsg(err.Error()) | ||
39 | + } | ||
40 | + for _, key := range list { | ||
41 | + if _, err = l.svcCtx.Redis.Del(key); err == nil { | ||
42 | + success++ | ||
43 | + } | ||
44 | + } | ||
45 | + logx.Infof("清理缓存:%d/%d", success, len(list)) | ||
46 | + return nil | ||
47 | +} |
1 | +package common | ||
2 | + | ||
3 | +import ( | ||
4 | + "context" | ||
5 | + "encoding/json" | ||
6 | + "fmt" | ||
7 | + "github.com/samber/lo" | ||
8 | + "github.com/silenceper/wechat/v2/miniprogram/qrcode" | ||
9 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/gateway/openlib" | ||
10 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/tool" | ||
11 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr" | ||
12 | + | ||
13 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | ||
14 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | ||
15 | + | ||
16 | + "github.com/zeromicro/go-zero/core/logx" | ||
17 | +) | ||
18 | + | ||
19 | +type MiniQrcodeInviteLogic struct { | ||
20 | + logx.Logger | ||
21 | + ctx context.Context | ||
22 | + svcCtx *svc.ServiceContext | ||
23 | +} | ||
24 | + | ||
25 | +func NewMiniQrcodeInviteLogic(ctx context.Context, svcCtx *svc.ServiceContext) *MiniQrcodeInviteLogic { | ||
26 | + return &MiniQrcodeInviteLogic{ | ||
27 | + Logger: logx.WithContext(ctx), | ||
28 | + ctx: ctx, | ||
29 | + svcCtx: svcCtx, | ||
30 | + } | ||
31 | +} | ||
32 | + | ||
33 | +func (l *MiniQrcodeInviteLogic) MiniQrcodeInvite(req *types.MiniQrCodeRequest) (resp interface{}, err error) { | ||
34 | + var ( | ||
35 | + q = l.svcCtx.MiniProgram.GetQRCode() | ||
36 | + cacheData = fmt.Sprintf("%s?%s", req.Page, req.Scene) | ||
37 | + cacheKey = fmt.Sprintf("%s:qrcode:%s", l.svcCtx.Config.Name, tool.Md5ByString(cacheData)) | ||
38 | + ok bool | ||
39 | + qrcodeCache QrcodeCache | ||
40 | + ) | ||
41 | + // 从缓存获取 | ||
42 | + if ok, err = l.svcCtx.Redis.ExistsCtx(l.ctx, cacheKey); ok && err == nil { | ||
43 | + tmpCacheData, _ := l.svcCtx.Redis.Get(cacheKey) | ||
44 | + if err = json.Unmarshal([]byte(tmpCacheData), &qrcodeCache); err == nil { | ||
45 | + if qrcodeCache.CacheData == cacheData { | ||
46 | + return MiniQrCodeResponse{ | ||
47 | + Path: qrcodeCache.QrcodeUrl, | ||
48 | + }, nil | ||
49 | + } | ||
50 | + } | ||
51 | + } | ||
52 | + | ||
53 | + var data []byte | ||
54 | + data, err = q.GetWXACodeUnlimit(qrcode.QRCoder{ | ||
55 | + Page: req.Page, | ||
56 | + Path: req.Page, | ||
57 | + Scene: req.Scene, | ||
58 | + CheckPath: lo.ToPtr(false), | ||
59 | + EnvVersion: "release", | ||
60 | + }) | ||
61 | + if err != nil { | ||
62 | + return nil, xerr.NewErr(err) | ||
63 | + } | ||
64 | + var result *openlib.DataPutFile | ||
65 | + result, err = l.svcCtx.OpenApiService.PutFile(l.ctx, openlib.RequestPutFile{ | ||
66 | + File: data, | ||
67 | + }) | ||
68 | + if err != nil { | ||
69 | + return nil, xerr.NewErr(err) | ||
70 | + } | ||
71 | + if result == nil || len(*result) == 0 || (*result)[0].Path == "" { | ||
72 | + return nil, xerr.NewErr(fmt.Errorf("上传失败")) | ||
73 | + } | ||
74 | + | ||
75 | + // 设置缓存 | ||
76 | + jsonData, err := json.Marshal(QrcodeCache{ | ||
77 | + CacheData: cacheData, | ||
78 | + QrcodeUrl: (*result)[0].Path, | ||
79 | + }) | ||
80 | + l.svcCtx.Redis.Set(cacheKey, string(jsonData)) | ||
81 | + | ||
82 | + return MiniQrCodeResponse{ | ||
83 | + Path: (*result)[0].Path, | ||
84 | + }, err | ||
85 | +} | ||
86 | + | ||
87 | +type MiniQrCodeResponse struct { | ||
88 | + Path string `json:"path"` | ||
89 | +} | ||
90 | + | ||
91 | +type QrcodeCache struct { | ||
92 | + CacheData string | ||
93 | + QrcodeUrl string | ||
94 | +} |
@@ -57,6 +57,6 @@ func NewCompany(item *domain.Company) types.Company { | @@ -57,6 +57,6 @@ func NewCompany(item *domain.Company) types.Company { | ||
57 | Id: item.Id, | 57 | Id: item.Id, |
58 | Name: item.Name, | 58 | Name: item.Name, |
59 | Code: item.Code, | 59 | Code: item.Code, |
60 | - Logo: item.Logo, | 60 | + Logo: lo.Ternary(item.Logo != "", item.Logo, domain.DefaultCompanyLog), |
61 | } | 61 | } |
62 | } | 62 | } |
@@ -50,8 +50,7 @@ func (l *MiniBusinessLogic) MiniBusiness(req *types.MessageRequest, msgType doma | @@ -50,8 +50,7 @@ func (l *MiniBusinessLogic) MiniBusiness(req *types.MessageRequest, msgType doma | ||
50 | var userIdMap = map[int64]*domain.User{} | 50 | var userIdMap = map[int64]*domain.User{} |
51 | var articleIdMap = map[int64]*domain.Article{} | 51 | var articleIdMap = map[int64]*domain.Article{} |
52 | var commentIdMap = map[int64]*domain.ArticleComment{} | 52 | var commentIdMap = map[int64]*domain.ArticleComment{} |
53 | - //var discussionIdMap = map[int64]int{} | ||
54 | - //var discussionOpinionIdMap = map[int64]int{} | 53 | + |
55 | for _, item := range list { | 54 | for _, item := range list { |
56 | if item.CompanyId != 0 { | 55 | if item.CompanyId != 0 { |
57 | companyIdMap[item.CompanyId] = nil | 56 | companyIdMap[item.CompanyId] = nil |
@@ -65,19 +64,15 @@ func (l *MiniBusinessLogic) MiniBusiness(req *types.MessageRequest, msgType doma | @@ -65,19 +64,15 @@ func (l *MiniBusinessLogic) MiniBusiness(req *types.MessageRequest, msgType doma | ||
65 | if item.CommentId != 0 { | 64 | if item.CommentId != 0 { |
66 | commentIdMap[item.CommentId] = nil | 65 | commentIdMap[item.CommentId] = nil |
67 | } | 66 | } |
68 | - //if item.DiscussionId != 0 { | ||
69 | - // discussionIdMap[item.DiscussionId] = 0 | ||
70 | - //} | ||
71 | - //if item.DiscussionOpinionId != 0 { | ||
72 | - // discussionOpinionIdMap[item.DiscussionOpinionId] = 0 | ||
73 | - //} | 67 | + if item.CommentParentId != 0 { |
68 | + commentIdMap[item.CommentParentId] = nil | ||
69 | + } | ||
74 | } | 70 | } |
75 | var companyIds = make([]int64, 0) // 公司ID | 71 | var companyIds = make([]int64, 0) // 公司ID |
76 | var userIds = make([]int64, 0) // 用户ID | 72 | var userIds = make([]int64, 0) // 用户ID |
77 | var articleIds = make([]int64, 0) // 文章ID | 73 | var articleIds = make([]int64, 0) // 文章ID |
78 | - var commentIds = make([]int64, 0) // 评论ID | ||
79 | - //var discussionIds = make([]int64, 0) // 讨论ID 暂时搁置 | ||
80 | - //var discussionOpinionIds = make([]int64, 0) // 观点ID | 74 | + var commentIds = make([]int64, 0) // 评论ID(包含回复的评论) |
75 | + | ||
81 | for k, _ := range companyIdMap { | 76 | for k, _ := range companyIdMap { |
82 | companyIds = append(companyIds, k) | 77 | companyIds = append(companyIds, k) |
83 | } | 78 | } |
@@ -90,12 +85,6 @@ func (l *MiniBusinessLogic) MiniBusiness(req *types.MessageRequest, msgType doma | @@ -90,12 +85,6 @@ func (l *MiniBusinessLogic) MiniBusiness(req *types.MessageRequest, msgType doma | ||
90 | for k, _ := range commentIdMap { | 85 | for k, _ := range commentIdMap { |
91 | commentIds = append(commentIds, k) | 86 | commentIds = append(commentIds, k) |
92 | } | 87 | } |
93 | - //for k, _ := range discussionIdMap { | ||
94 | - // discussionIds = append(discussionIds, k) | ||
95 | - //} | ||
96 | - //for k, _ := range discussionOpinionIdMap { | ||
97 | - // discussionOpinionIds = append(discussionOpinionIds, k) | ||
98 | - //} | ||
99 | 88 | ||
100 | // 获取公司 | 89 | // 获取公司 |
101 | if len(companyIds) > 0 { | 90 | if len(companyIds) > 0 { |
@@ -166,13 +155,10 @@ func (l *MiniBusinessLogic) MiniBusiness(req *types.MessageRequest, msgType doma | @@ -166,13 +155,10 @@ func (l *MiniBusinessLogic) MiniBusiness(req *types.MessageRequest, msgType doma | ||
166 | UserId: item.UserId, | 155 | UserId: item.UserId, |
167 | RecipientId: item.RecipientId, | 156 | RecipientId: item.RecipientId, |
168 | ArticleId: item.ArticleId, | 157 | ArticleId: item.ArticleId, |
169 | - CommentId: item.CommentId, | ||
170 | - //DiscussionId: item.DiscussionId, | ||
171 | - //DiscussionOpinionId: item.DiscussionOpinionId, | ||
172 | - Content: item.Content, | ||
173 | - CreatedAt: item.CreatedAt, | 158 | + CreatedAt: item.CreatedAt, |
174 | } | 159 | } |
175 | 160 | ||
161 | + // 发布者 | ||
176 | if v, ok := userIdMap[item.UserId]; ok && v != nil { | 162 | if v, ok := userIdMap[item.UserId]; ok && v != nil { |
177 | to.User = &types.SimpleUser{ | 163 | to.User = &types.SimpleUser{ |
178 | Id: v.Id, | 164 | Id: v.Id, |
@@ -187,6 +173,7 @@ func (l *MiniBusinessLogic) MiniBusiness(req *types.MessageRequest, msgType doma | @@ -187,6 +173,7 @@ func (l *MiniBusinessLogic) MiniBusiness(req *types.MessageRequest, msgType doma | ||
187 | } | 173 | } |
188 | } | 174 | } |
189 | 175 | ||
176 | + // 文章 | ||
190 | if v, ok := articleIdMap[item.ArticleId]; ok && v != nil { | 177 | if v, ok := articleIdMap[item.ArticleId]; ok && v != nil { |
191 | to.Article = &types.SimpleArticle{ | 178 | to.Article = &types.SimpleArticle{ |
192 | Id: v.Id, | 179 | Id: v.Id, |
@@ -197,13 +184,41 @@ func (l *MiniBusinessLogic) MiniBusiness(req *types.MessageRequest, msgType doma | @@ -197,13 +184,41 @@ func (l *MiniBusinessLogic) MiniBusiness(req *types.MessageRequest, msgType doma | ||
197 | } | 184 | } |
198 | } | 185 | } |
199 | 186 | ||
187 | + // 评论 | ||
200 | if v, ok := commentIdMap[item.CommentId]; ok && v != nil { | 188 | if v, ok := commentIdMap[item.CommentId]; ok && v != nil { |
201 | to.Comment = &types.SimpleComment{ | 189 | to.Comment = &types.SimpleComment{ |
202 | - Id: v.Id, | ||
203 | - Content: v.Content, | ||
204 | - CountLove: v.CountUserLove, | ||
205 | - CountComment: v.CountReply, | ||
206 | - Show: int(v.Show), | 190 | + Id: v.Id, |
191 | + Content: v.Content, | ||
192 | + Show: int(v.Show), | ||
193 | + CountReply: v.CountReply, | ||
194 | + CountUserLove: v.CountUserLove, | ||
195 | + MatchUrl: v.MatchUrl, | ||
196 | + } | ||
197 | + to.Comment.AtWho = make([]types.CommentAtWho, 0) | ||
198 | + for _, who := range v.AtWho { | ||
199 | + to.Comment.AtWho = append(to.Comment.AtWho, types.CommentAtWho{ | ||
200 | + Id: who.Id, | ||
201 | + Name: who.Name, | ||
202 | + }) | ||
203 | + } | ||
204 | + } | ||
205 | + | ||
206 | + // 被回复的评论 | ||
207 | + if v, ok := commentIdMap[item.CommentParentId]; ok && v != nil { | ||
208 | + to.CommentParent = &types.SimpleComment{ | ||
209 | + Id: v.Id, | ||
210 | + Content: v.Content, | ||
211 | + Show: int(v.Show), | ||
212 | + CountReply: v.CountReply, | ||
213 | + CountUserLove: v.CountUserLove, | ||
214 | + MatchUrl: v.MatchUrl, | ||
215 | + } | ||
216 | + to.CommentParent.AtWho = make([]types.CommentAtWho, 0) | ||
217 | + for _, who := range v.AtWho { | ||
218 | + to.CommentParent.AtWho = append(to.CommentParent.AtWho, types.CommentAtWho{ | ||
219 | + Id: who.Id, | ||
220 | + Name: who.Name, | ||
221 | + }) | ||
207 | } | 222 | } |
208 | } | 223 | } |
209 | 224 | ||
@@ -213,23 +228,23 @@ func (l *MiniBusinessLogic) MiniBusiness(req *types.MessageRequest, msgType doma | @@ -213,23 +228,23 @@ func (l *MiniBusinessLogic) MiniBusiness(req *types.MessageRequest, msgType doma | ||
213 | } | 228 | } |
214 | 229 | ||
215 | // CommentArticle 评论文章 | 230 | // CommentArticle 评论文章 |
216 | -func (l *MiniBusinessLogic) CommentArticle(conn transaction.Conn, articleId int64, sectionId int64, content string, at []int64) (err error) { | ||
217 | - return l.createMessage(conn, domain.MsgTypeReply, domain.OptTypeArticle, articleId, sectionId, 0, content, at) | 231 | +func (l *MiniBusinessLogic) CommentArticle(conn transaction.Conn, articleId int64, commentId int64, at []int64) (err error) { |
232 | + return l.createMessage(conn, domain.MsgTypeReply, domain.OptTypeArticle, articleId, commentId, 0, at) | ||
218 | } | 233 | } |
219 | 234 | ||
220 | // CommentReply 评论回复 | 235 | // CommentReply 评论回复 |
221 | -func (l *MiniBusinessLogic) CommentReply(conn transaction.Conn, articleId int64, sectionId int64, commentId int64, content string, at []int64) (err error) { | ||
222 | - return l.createMessage(conn, domain.MsgTypeReply, domain.OptTypeComment, articleId, sectionId, commentId, content, at) | 236 | +func (l *MiniBusinessLogic) CommentReply(conn transaction.Conn, articleId int64, commentId int64, commentParentId int64, at []int64) (err error) { |
237 | + return l.createMessage(conn, domain.MsgTypeReply, domain.OptTypeComment, articleId, commentId, commentParentId, at) | ||
223 | } | 238 | } |
224 | 239 | ||
225 | // LikeArticle 点赞文章 | 240 | // LikeArticle 点赞文章 |
226 | func (l *MiniBusinessLogic) LikeArticle(conn transaction.Conn, articleId int64, at int64) (err error) { | 241 | func (l *MiniBusinessLogic) LikeArticle(conn transaction.Conn, articleId int64, at int64) (err error) { |
227 | - return l.createMessage(conn, domain.MsgTypeLike, domain.OptTypeArticle, articleId, 0, 0, "", []int64{at}) | 242 | + return l.createMessage(conn, domain.MsgTypeLike, domain.OptTypeArticle, articleId, 0, 0, []int64{at}) |
228 | } | 243 | } |
229 | 244 | ||
230 | // LikeComment 点赞评论 | 245 | // LikeComment 点赞评论 |
231 | -func (l *MiniBusinessLogic) LikeComment(conn transaction.Conn, articleId int64, commentId int64, at int64) (err error) { | ||
232 | - return l.createMessage(conn, domain.MsgTypeLike, domain.OptTypeComment, articleId, 0, commentId, "", []int64{at}) | 246 | +func (l *MiniBusinessLogic) LikeComment(conn transaction.Conn, articleId int64, commentId int64, commentParentId int64, at int64) (err error) { |
247 | + return l.createMessage(conn, domain.MsgTypeLike, domain.OptTypeComment, articleId, commentId, commentParentId, []int64{at}) | ||
233 | } | 248 | } |
234 | 249 | ||
235 | // UnLikeArticle 取消点赞文章 | 250 | // UnLikeArticle 取消点赞文章 |
@@ -247,24 +262,22 @@ func (l *MiniBusinessLogic) createMessage( | @@ -247,24 +262,22 @@ func (l *MiniBusinessLogic) createMessage( | ||
247 | msgType domain.MsgBusinessType, | 262 | msgType domain.MsgBusinessType, |
248 | optType domain.MsgBusinessOpt, | 263 | optType domain.MsgBusinessOpt, |
249 | articleId int64, | 264 | articleId int64, |
250 | - sectionId int64, | ||
251 | commentId int64, | 265 | commentId int64, |
252 | - content string, | 266 | + commentParentId int64, |
253 | at []int64) (err error) { | 267 | at []int64) (err error) { |
254 | 268 | ||
255 | var userToken = contextdata.GetUserTokenFromCtx(l.ctx) | 269 | var userToken = contextdata.GetUserTokenFromCtx(l.ctx) |
256 | // 评论中携带了 @其他用户 | 270 | // 评论中携带了 @其他用户 |
257 | for i := range at { | 271 | for i := range at { |
258 | var msg = &domain.MessageBusiness{ | 272 | var msg = &domain.MessageBusiness{ |
259 | - Type: msgType, | ||
260 | - OptType: optType, | ||
261 | - CompanyId: userToken.CompanyId, | ||
262 | - UserId: userToken.UserId, | ||
263 | - RecipientId: at[i], | ||
264 | - ArticleId: articleId, | ||
265 | - SectionId: sectionId, | ||
266 | - CommentId: commentId, | ||
267 | - Content: content, | 273 | + Type: msgType, |
274 | + OptType: optType, | ||
275 | + CompanyId: userToken.CompanyId, | ||
276 | + UserId: userToken.UserId, | ||
277 | + RecipientId: at[i], | ||
278 | + ArticleId: articleId, | ||
279 | + CommentId: commentId, | ||
280 | + CommentParentId: commentParentId, | ||
268 | } | 281 | } |
269 | msg, err = l.svcCtx.MessageBusinessRepository.Insert(l.ctx, conn, msg) | 282 | msg, err = l.svcCtx.MessageBusinessRepository.Insert(l.ctx, conn, msg) |
270 | if err != nil { | 283 | if err != nil { |
1 | +package role | ||
2 | + | ||
3 | +import ( | ||
4 | + "context" | ||
5 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain" | ||
6 | + | ||
7 | + "github.com/zeromicro/go-zero/core/logx" | ||
8 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | ||
9 | +) | ||
10 | + | ||
11 | +type SystemGetRoleAuthsLogic struct { | ||
12 | + logx.Logger | ||
13 | + ctx context.Context | ||
14 | + svcCtx *svc.ServiceContext | ||
15 | +} | ||
16 | + | ||
17 | +func NewSystemGetRoleAuthsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SystemGetRoleAuthsLogic { | ||
18 | + return &SystemGetRoleAuthsLogic{ | ||
19 | + Logger: logx.WithContext(ctx), | ||
20 | + ctx: ctx, | ||
21 | + svcCtx: svcCtx, | ||
22 | + } | ||
23 | +} | ||
24 | + | ||
25 | +func (l *SystemGetRoleAuthsLogic) SystemGetRoleAuths() (interface{}, error) { | ||
26 | + return map[string]interface{}{ | ||
27 | + "list": domain.Auths, | ||
28 | + }, nil | ||
29 | +} |
@@ -107,11 +107,19 @@ func (l *MiniMyBeLikedLogic) NewItemSimple(love *domain.UserLoveFlag, company *d | @@ -107,11 +107,19 @@ func (l *MiniMyBeLikedLogic) NewItemSimple(love *domain.UserLoveFlag, company *d | ||
107 | 107 | ||
108 | if comment != nil { | 108 | if comment != nil { |
109 | item.Comment = &types.SimpleComment{ | 109 | item.Comment = &types.SimpleComment{ |
110 | - Id: comment.Id, | ||
111 | - Content: comment.Content, | ||
112 | - CountLove: comment.CountUserLove, | ||
113 | - CountComment: comment.CountReply, | ||
114 | - Show: int(comment.Show), | 110 | + Id: comment.Id, |
111 | + Content: comment.Content, | ||
112 | + Show: int(comment.Show), | ||
113 | + CountReply: comment.CountReply, | ||
114 | + CountUserLove: comment.CountUserLove, | ||
115 | + MatchUrl: comment.MatchUrl, | ||
116 | + } | ||
117 | + item.Comment.AtWho = make([]types.CommentAtWho, 0) | ||
118 | + for _, who := range comment.AtWho { | ||
119 | + item.Comment.AtWho = append(item.Comment.AtWho, types.CommentAtWho{ | ||
120 | + Id: who.Id, | ||
121 | + Name: who.Name, | ||
122 | + }) | ||
115 | } | 123 | } |
116 | } | 124 | } |
117 | 125 |
@@ -107,11 +107,19 @@ func (l *MiniMyLikeLogic) NewItemSimple(love *domain.UserLoveFlag, company *doma | @@ -107,11 +107,19 @@ func (l *MiniMyLikeLogic) NewItemSimple(love *domain.UserLoveFlag, company *doma | ||
107 | 107 | ||
108 | if comment != nil { | 108 | if comment != nil { |
109 | item.Comment = &types.SimpleComment{ | 109 | item.Comment = &types.SimpleComment{ |
110 | - Id: comment.Id, | ||
111 | - Content: comment.Content, | ||
112 | - CountLove: comment.CountUserLove, | ||
113 | - CountComment: comment.CountReply, | ||
114 | - Show: int(comment.Show), | 110 | + Id: comment.Id, |
111 | + Content: comment.Content, | ||
112 | + Show: int(comment.Show), | ||
113 | + CountReply: comment.CountReply, | ||
114 | + CountUserLove: comment.CountUserLove, | ||
115 | + MatchUrl: comment.MatchUrl, | ||
116 | + } | ||
117 | + item.Comment.AtWho = make([]types.CommentAtWho, 0) | ||
118 | + for _, who := range comment.AtWho { | ||
119 | + item.Comment.AtWho = append(item.Comment.AtWho, types.CommentAtWho{ | ||
120 | + Id: who.Id, | ||
121 | + Name: who.Name, | ||
122 | + }) | ||
115 | } | 123 | } |
116 | } | 124 | } |
117 | 125 |
@@ -52,6 +52,9 @@ func (l *SystemUserAccountSaveLogic) SystemUserAccountSave(req *types.SystemUser | @@ -52,6 +52,9 @@ func (l *SystemUserAccountSaveLogic) SystemUserAccountSave(req *types.SystemUser | ||
52 | if err != nil { | 52 | if err != nil { |
53 | return nil, xerr.NewErrMsgErr("申请失败", err) | 53 | return nil, xerr.NewErrMsgErr("申请失败", err) |
54 | } | 54 | } |
55 | + if user != nil { | ||
56 | + return nil, xerr.NewErrMsgErr("用户手机号已存在", err) | ||
57 | + } | ||
55 | if err = transaction.UseTrans(l.ctx, l.svcCtx.DB, func(ctx context.Context, conn transaction.Conn) error { | 58 | if err = transaction.UseTrans(l.ctx, l.svcCtx.DB, func(ctx context.Context, conn transaction.Conn) error { |
56 | user = &domain.User{ | 59 | user = &domain.User{ |
57 | CompanyId: company.Id, | 60 | CompanyId: company.Id, |
@@ -87,8 +87,12 @@ func (l *SystemUserInfoLogic) SystemUserInfo(req *types.SystemUserInfoRequest) ( | @@ -87,8 +87,12 @@ func (l *SystemUserInfoLogic) SystemUserInfo(req *types.SystemUserInfoRequest) ( | ||
87 | company.Logo = response.CurrentCompany.Logo | 87 | company.Logo = response.CurrentCompany.Logo |
88 | changed = true | 88 | changed = true |
89 | } | 89 | } |
90 | + if company.Logo == "" { | ||
91 | + company.Logo = domain.DefaultCompanyLog | ||
92 | + changed = true | ||
93 | + } | ||
90 | if changed { | 94 | if changed { |
91 | - if company, err = l.svcCtx.CompanyRepository.UpdateWithVersion(l.ctx, conn, company); err != nil { | 95 | + if company, err = l.svcCtx.CompanyRepository.Update(l.ctx, conn, company); err != nil { |
92 | return nil, xerr.NewErrMsgErr("获取用户资料失败", err) | 96 | return nil, xerr.NewErrMsgErr("获取用户资料失败", err) |
93 | } | 97 | } |
94 | } | 98 | } |
@@ -112,55 +116,55 @@ func (l *SystemUserInfoLogic) initSystemData(companyId int64) error { | @@ -112,55 +116,55 @@ func (l *SystemUserInfoLogic) initSystemData(companyId int64) error { | ||
112 | if cnt == 0 { | 116 | if cnt == 0 { |
113 | articleTags := []*domain.ArticleTag{ | 117 | articleTags := []*domain.ArticleTag{ |
114 | { | 118 | { |
115 | - Id: 0, CompanyId: companyId, Image: domain.Image{Url: "", Width: 0, Height: 0}, | 119 | + Id: 0, CompanyId: companyId, Image: domain.Image{Url: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/test/20231115/object/index_imp_01.png", Width: 0, Height: 0}, |
116 | Name: "紧急重要", Category: "紧急重要", Remark: "优先解决", SortBy: 1, | 120 | Name: "紧急重要", Category: "紧急重要", Remark: "优先解决", SortBy: 1, |
117 | }, | 121 | }, |
118 | { | 122 | { |
119 | - Id: 0, CompanyId: companyId, Image: domain.Image{Url: "", Width: 0, Height: 0}, | 123 | + Id: 0, CompanyId: companyId, Image: domain.Image{Url: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/test/20231115/object/index_imp_04.png", Width: 0, Height: 0}, |
120 | Name: "不紧急不重要", Category: "紧急重要", Remark: "给别人做", SortBy: 2, | 124 | Name: "不紧急不重要", Category: "紧急重要", Remark: "给别人做", SortBy: 2, |
121 | }, | 125 | }, |
122 | { | 126 | { |
123 | - Id: 0, CompanyId: companyId, Image: domain.Image{Url: "", Width: 0, Height: 0}, | 127 | + Id: 0, CompanyId: companyId, Image: domain.Image{Url: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/test/20231115/object/index_imp_03.png", Width: 0, Height: 0}, |
124 | Name: "紧急不重要", Category: "紧急重要", Remark: "有空再做", SortBy: 3, | 128 | Name: "紧急不重要", Category: "紧急重要", Remark: "有空再做", SortBy: 3, |
125 | }, | 129 | }, |
126 | { | 130 | { |
127 | - Id: 0, CompanyId: companyId, Image: domain.Image{Url: "", Width: 0, Height: 0}, | 131 | + Id: 0, CompanyId: companyId, Image: domain.Image{Url: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/test/20231115/object/index_imp_02.png", Width: 0, Height: 0}, |
128 | Name: "不紧急重要", Category: "紧急重要", Remark: "制定计划去做", SortBy: 4, | 132 | Name: "不紧急重要", Category: "紧急重要", Remark: "制定计划去做", SortBy: 4, |
129 | }, | 133 | }, |
130 | { | 134 | { |
131 | - Id: 0, CompanyId: companyId, Image: domain.Image{Url: "", Width: 0, Height: 0}, | 135 | + Id: 0, CompanyId: companyId, Image: domain.Image{Url: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/test/20231115/object/index_chance_03.png", Width: 0, Height: 0}, |
132 | Name: "大机会高风险", Category: "机会风险", Remark: "谨慎考虑专项讨论", SortBy: 5, | 136 | Name: "大机会高风险", Category: "机会风险", Remark: "谨慎考虑专项讨论", SortBy: 5, |
133 | }, | 137 | }, |
134 | { | 138 | { |
135 | - Id: 0, CompanyId: companyId, Image: domain.Image{Url: "", Width: 0, Height: 0}, | 139 | + Id: 0, CompanyId: companyId, Image: domain.Image{Url: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/test/20231115/object/index_chance_02.png", Width: 0, Height: 0}, |
136 | Name: "大机会中风险", Category: "机会风险", Remark: "加大关注值得尝试", SortBy: 6, | 140 | Name: "大机会中风险", Category: "机会风险", Remark: "加大关注值得尝试", SortBy: 6, |
137 | }, | 141 | }, |
138 | { | 142 | { |
139 | - Id: 0, CompanyId: companyId, Image: domain.Image{Url: "", Width: 0, Height: 0}, | 143 | + Id: 0, CompanyId: companyId, Image: domain.Image{Url: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/test/20231115/object/index_chance_01.png", Width: 0, Height: 0}, |
140 | Name: "大机会低风险", Category: "机会风险", Remark: "全员投入抓紧落实", SortBy: 7, | 144 | Name: "大机会低风险", Category: "机会风险", Remark: "全员投入抓紧落实", SortBy: 7, |
141 | }, | 145 | }, |
142 | { | 146 | { |
143 | - Id: 0, CompanyId: companyId, Image: domain.Image{Url: "", Width: 0, Height: 0}, | 147 | + Id: 0, CompanyId: companyId, Image: domain.Image{Url: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/test/20231115/object/index_chance_04.png", Width: 0, Height: 0}, |
144 | Name: "中机会高风险", Category: "机会风险", Remark: "专人跟踪成立项目", SortBy: 8, | 148 | Name: "中机会高风险", Category: "机会风险", Remark: "专人跟踪成立项目", SortBy: 8, |
145 | }, | 149 | }, |
146 | { | 150 | { |
147 | - Id: 0, CompanyId: companyId, Image: domain.Image{Url: "", Width: 0, Height: 0}, | 151 | + Id: 0, CompanyId: companyId, Image: domain.Image{Url: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/test/20231115/object/index_chance_05.png", Width: 0, Height: 0}, |
148 | Name: "中机会中风险", Category: "机会风险", Remark: "讨论落实", SortBy: 9, | 152 | Name: "中机会中风险", Category: "机会风险", Remark: "讨论落实", SortBy: 9, |
149 | }, | 153 | }, |
150 | { | 154 | { |
151 | - Id: 0, CompanyId: companyId, Image: domain.Image{Url: "", Width: 0, Height: 0}, | 155 | + Id: 0, CompanyId: companyId, Image: domain.Image{Url: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/test/20231115/object/index_chance_06.png", Width: 0, Height: 0}, |
152 | Name: "中机会低风险", Category: "机会风险", Remark: "解决问题多手准备", SortBy: 10, | 156 | Name: "中机会低风险", Category: "机会风险", Remark: "解决问题多手准备", SortBy: 10, |
153 | }, | 157 | }, |
154 | { | 158 | { |
155 | - Id: 0, CompanyId: companyId, Image: domain.Image{Url: "", Width: 0, Height: 0}, | 159 | + Id: 0, CompanyId: companyId, Image: domain.Image{Url: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/test/20231115/object/index_chance_07.png", Width: 0, Height: 0}, |
156 | Name: "小机会高风险", Category: "机会风险", Remark: "有空看看", SortBy: 11, | 160 | Name: "小机会高风险", Category: "机会风险", Remark: "有空看看", SortBy: 11, |
157 | }, | 161 | }, |
158 | { | 162 | { |
159 | - Id: 0, CompanyId: companyId, Image: domain.Image{Url: "", Width: 0, Height: 0}, | 163 | + Id: 0, CompanyId: companyId, Image: domain.Image{Url: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/test/20231115/object/index_chance_08.png", Width: 0, Height: 0}, |
160 | Name: "小机会中风险", Category: "机会风险", Remark: "持续监控做好控制", SortBy: 12, | 164 | Name: "小机会中风险", Category: "机会风险", Remark: "持续监控做好控制", SortBy: 12, |
161 | }, | 165 | }, |
162 | { | 166 | { |
163 | - Id: 0, CompanyId: companyId, Image: domain.Image{Url: "", Width: 0, Height: 0}, | 167 | + Id: 0, CompanyId: companyId, Image: domain.Image{Url: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/test/20231115/object/index_chance_09.png", Width: 0, Height: 0}, |
164 | Name: "小机会低风险", Category: "机会风险", Remark: "全员警戒马上解决", SortBy: 13, | 168 | Name: "小机会低风险", Category: "机会风险", Remark: "全员警戒马上解决", SortBy: 13, |
165 | }, | 169 | }, |
166 | } | 170 | } |
1 | package svc | 1 | package svc |
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | + "github.com/silenceper/wechat/v2" | ||
5 | + minicache "github.com/silenceper/wechat/v2/cache" | ||
6 | + "github.com/silenceper/wechat/v2/miniprogram" | ||
7 | + miniConfig "github.com/silenceper/wechat/v2/miniprogram/config" | ||
4 | "github.com/zeromicro/go-zero/core/stores/redis" | 8 | "github.com/zeromicro/go-zero/core/stores/redis" |
5 | "github.com/zeromicro/go-zero/rest" | 9 | "github.com/zeromicro/go-zero/rest" |
6 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/config" | 10 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/config" |
@@ -10,6 +14,7 @@ import ( | @@ -10,6 +14,7 @@ import ( | ||
10 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain" | 14 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain" |
11 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/gateway" | 15 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/gateway" |
12 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/gateway/authlib" | 16 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/gateway/authlib" |
17 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/gateway/openlib" | ||
13 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/gateway/smslib" | 18 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/gateway/smslib" |
14 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/cache" | 19 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/cache" |
15 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/database" | 20 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/database" |
@@ -43,6 +48,9 @@ type ServiceContext struct { | @@ -43,6 +48,9 @@ type ServiceContext struct { | ||
43 | 48 | ||
44 | ApiAuthService authlib.ApiAuthService | 49 | ApiAuthService authlib.ApiAuthService |
45 | SmsService smslib.SMSService | 50 | SmsService smslib.SMSService |
51 | + OpenApiService openlib.OpenApiService | ||
52 | + | ||
53 | + MiniProgram *miniprogram.MiniProgram | ||
46 | 54 | ||
47 | LoginStatusCheck rest.Middleware | 55 | LoginStatusCheck rest.Middleware |
48 | LogRequest rest.Middleware | 56 | LogRequest rest.Middleware |
@@ -57,14 +65,21 @@ func NewServiceContext(c config.Config) *ServiceContext { | @@ -57,14 +65,21 @@ func NewServiceContext(c config.Config) *ServiceContext { | ||
57 | apiAuth := authlib.ApiAuthService{ | 65 | apiAuth := authlib.ApiAuthService{ |
58 | Service: gateway.NewService(c.ApiAuth.Name, c.ApiAuth.Host, c.ApiAuth.Timeout), | 66 | Service: gateway.NewService(c.ApiAuth.Name, c.ApiAuth.Host, c.ApiAuth.Timeout), |
59 | } | 67 | } |
68 | + miniProgram := wechat.NewWechat().GetMiniProgram(&miniConfig.Config{ | ||
69 | + AppID: c.Wechat.AppID, | ||
70 | + AppSecret: c.Wechat.AppSecret, | ||
71 | + Cache: minicache.NewMemory(), | ||
72 | + }) | ||
60 | return &ServiceContext{ | 73 | return &ServiceContext{ |
61 | Config: c, | 74 | Config: c, |
62 | DB: db, | 75 | DB: db, |
63 | Redis: redis, | 76 | Redis: redis, |
64 | ApiAuthService: apiAuth, | 77 | ApiAuthService: apiAuth, |
65 | SmsService: smslib.SMSService{Service: gateway.NewService("短信服务", "https://sms.fjmaimaimai.com:9897", time.Second*5)}, | 78 | SmsService: smslib.SMSService{Service: gateway.NewService("短信服务", "https://sms.fjmaimaimai.com:9897", time.Second*5)}, |
79 | + OpenApiService: openlib.OpenApiService{Service: gateway.NewService("开发接口服务", "https://mmm-open-api-test.fjmaimaimai.com", time.Second*5)}, | ||
66 | LoginStatusCheck: middleware.NewLoginStatusCheckMiddleware(apiAuth).Handle, | 80 | LoginStatusCheck: middleware.NewLoginStatusCheckMiddleware(apiAuth).Handle, |
67 | LogRequest: middleware.NewLogRequestMiddleware(c.LogRequest).Handle, | 81 | LogRequest: middleware.NewLogRequestMiddleware(c.LogRequest).Handle, |
82 | + MiniProgram: miniProgram, | ||
68 | 83 | ||
69 | ArticleBackupRepository: repository.NewArticleBackupRepository(cache.NewCachedRepository(mlCache)), | 84 | ArticleBackupRepository: repository.NewArticleBackupRepository(cache.NewCachedRepository(mlCache)), |
70 | ArticleCommentRepository: repository.NewArticleCommentRepository(cache.NewCachedRepository(mlCache)), | 85 | ArticleCommentRepository: repository.NewArticleCommentRepository(cache.NewCachedRepository(mlCache)), |
@@ -8,6 +8,11 @@ type CommonSmsCodeRequest struct { | @@ -8,6 +8,11 @@ type CommonSmsCodeRequest struct { | ||
8 | type CommonSmsCodeResposne struct { | 8 | type CommonSmsCodeResposne struct { |
9 | } | 9 | } |
10 | 10 | ||
11 | +type MiniQrCodeRequest struct { | ||
12 | + Page string `json:"page"` // 微信页面入口 | ||
13 | + Scene string `json:"scene"` // 参数 | ||
14 | +} | ||
15 | + | ||
11 | type CommentAuthor struct { | 16 | type CommentAuthor struct { |
12 | Id int64 `json:"id"` // 人员id | 17 | Id int64 `json:"id"` // 人员id |
13 | Name string `json:"name"` // 人员的名字 | 18 | Name string `json:"name"` // 人员的名字 |
@@ -281,21 +286,18 @@ type MessageBusinessResponse struct { | @@ -281,21 +286,18 @@ type MessageBusinessResponse struct { | ||
281 | } | 286 | } |
282 | 287 | ||
283 | type MessageBusinessItem struct { | 288 | type MessageBusinessItem struct { |
284 | - Id int64 `json:"id"` | ||
285 | - Type int `json:"type"` // 分类 (1回复 2点赞 3被采纳) | ||
286 | - OptType int `json:"optType"` // 操作类型(1针对文章、2针对评论、3针对圆桌) | ||
287 | - CompanyId int64 `json:"companyId"` // 操作人公司ID | ||
288 | - UserId int64 `json:"userId"` // 操作人用户ID | ||
289 | - RecipientId int64 `json:"recipientId"` // 接收者ID | ||
290 | - ArticleId int64 `json:"articleId"` // 文章ID | ||
291 | - CommentId int64 `json:"commentId"` // 评论ID | ||
292 | - DiscussionId int64 `json:"discussionId"` // 圆桌ID | ||
293 | - DiscussionOpinionId int64 `json:"discussionOpinionId"` // 观点ID | ||
294 | - Content string `json:"content"` // 消息内容 | ||
295 | - CreatedAt int64 `json:"createdAt"` // 创建时间 | ||
296 | - User *SimpleUser `json:"user"` // 操作人 | ||
297 | - Article *SimpleArticle `json:"article"` // 文章 | ||
298 | - Comment *SimpleComment `json:"comment"` // 评论(不一定是自己,可能是被人@到) | 289 | + Id int64 `json:"id"` |
290 | + Type int `json:"type"` // 分类 (1回复 2点赞 3被采纳) | ||
291 | + OptType int `json:"optType"` // 操作类型(1针对文章或段落、2针对评论、3针对圆桌) | ||
292 | + CompanyId int64 `json:"companyId"` // 操作人公司ID | ||
293 | + UserId int64 `json:"userId"` // 操作人用户ID | ||
294 | + RecipientId int64 `json:"recipientId"` // 接收者ID | ||
295 | + ArticleId int64 `json:"articleId"` // 文章ID | ||
296 | + CreatedAt int64 `json:"createdAt"` // 创建时间 | ||
297 | + User *SimpleUser `json:"user"` // 操作人 | ||
298 | + Article *SimpleArticle `json:"article"` // 文章 | ||
299 | + Comment *SimpleComment `json:"comment"` // 评论 | ||
300 | + CommentParent *SimpleComment `json:"commentParent"` // 被回复的评论 | ||
299 | } | 301 | } |
300 | 302 | ||
301 | type SimpleUser struct { | 303 | type SimpleUser struct { |
@@ -596,11 +598,13 @@ type MyLikeItem struct { | @@ -596,11 +598,13 @@ type MyLikeItem struct { | ||
596 | } | 598 | } |
597 | 599 | ||
598 | type SimpleComment struct { | 600 | type SimpleComment struct { |
599 | - Id int64 `json:"id"` | ||
600 | - Content string `json:"content"` // 评论内容 | ||
601 | - CountLove int `json:"countLove"` // 点赞数量 | ||
602 | - CountComment int `json:"countComment"` // 评论数量 | ||
603 | - Show int `json:"show"` // 评论的展示状态(0显示、1不显示) | 601 | + Id int64 `json:"id"` |
602 | + Content string `json:"content"` // 评论内容 | ||
603 | + Show int `json:"show"` // 评论的展示状态(0显示、1不显示) | ||
604 | + AtWho []CommentAtWho `json:"atWho"` // 填写评论时@的人 | ||
605 | + MatchUrl map[string]string `json:"matchUrl"` // 评论内容中的url文本 | ||
606 | + CountReply int `json:"countReply"` // 用户回复数量 | ||
607 | + CountUserLove int `json:"countUserLove"` // 用户点赞数量 | ||
604 | } | 608 | } |
605 | 609 | ||
606 | type MiniBeLikedRequest struct { | 610 | type MiniBeLikedRequest struct { |
cmd/discuss/api/public/index_chance_01.png
0 → 100644
8.2 KB
cmd/discuss/api/public/index_chance_02.png
0 → 100644
6.5 KB
cmd/discuss/api/public/index_chance_03.png
0 → 100644
9.5 KB
cmd/discuss/api/public/index_chance_04.png
0 → 100644
6.2 KB
cmd/discuss/api/public/index_chance_05.png
0 → 100644
7.3 KB
cmd/discuss/api/public/index_chance_06.png
0 → 100644
7.4 KB
cmd/discuss/api/public/index_chance_07.png
0 → 100644
8.2 KB
cmd/discuss/api/public/index_chance_08.png
0 → 100644
6.5 KB
cmd/discuss/api/public/index_chance_09.png
0 → 100644
7.3 KB
cmd/discuss/api/public/index_imp_01.png
0 → 100644
11.6 KB
cmd/discuss/api/public/index_imp_02.png
0 → 100644
10.3 KB
cmd/discuss/api/public/index_imp_03.png
0 → 100644
10.6 KB
cmd/discuss/api/public/index_imp_04.png
0 → 100644
11.3 KB
@@ -21,6 +21,7 @@ type Article struct { | @@ -21,6 +21,7 @@ type Article struct { | ||
21 | Author domain.UserSimple `gorm:"type:jsonb;serializer:json"` // 发布人 | 21 | Author domain.UserSimple `gorm:"type:jsonb;serializer:json"` // 发布人 |
22 | Title string // 文章标题 | 22 | Title string // 文章标题 |
23 | Images []domain.Image `gorm:"type:jsonb;serializer:json"` // 图片 | 23 | Images []domain.Image `gorm:"type:jsonb;serializer:json"` // 图片 |
24 | + Videos []domain.Video `gorm:"type:jsonb;serializer:json"` // 视频 | ||
24 | WhoRead []int64 `gorm:"type:jsonb;serializer:json"` // 谁可以看 | 25 | WhoRead []int64 `gorm:"type:jsonb;serializer:json"` // 谁可以看 |
25 | WhoReview []int64 `gorm:"type:jsonb;serializer:json"` // 评论人 | 26 | WhoReview []int64 `gorm:"type:jsonb;serializer:json"` // 评论人 |
26 | Location domain.Location `gorm:"type:jsonb;serializer:json"` // 坐标 | 27 | Location domain.Location `gorm:"type:jsonb;serializer:json"` // 坐标 |
@@ -10,21 +10,20 @@ import ( | @@ -10,21 +10,20 @@ import ( | ||
10 | 10 | ||
11 | // MessageBusiness 消息中心业务 | 11 | // MessageBusiness 消息中心业务 |
12 | type MessageBusiness struct { | 12 | type MessageBusiness struct { |
13 | - Id int64 // 唯一标识 | ||
14 | - Type int `json:"type"` // 分类 (1回复 2点赞 3被采纳) | ||
15 | - OptType int `json:"optType"` // 操作类型(1针对文章、2针对评论、3针对圆桌) | ||
16 | - CompanyId int64 `json:"companyId"` // 操作人公司ID | ||
17 | - UserId int64 `json:"userId"` // 操作人用户ID | ||
18 | - RecipientId int64 `json:"recipientId"` // 接收人用户ID | ||
19 | - ArticleId int64 `json:"articleId,omitempty"` // 文章ID | ||
20 | - SectionId int64 `json:"sectionId,omitempty"` // 段落ID | ||
21 | - CommentId int64 `json:"commentId,omitempty"` // 评论ID | ||
22 | - Content string `json:"content,omitempty"` // 消息内容 | ||
23 | - CreatedAt int64 `json:",omitempty"` | ||
24 | - UpdatedAt int64 `json:",omitempty"` | ||
25 | - DeletedAt int64 `json:",omitempty"` | ||
26 | - Version int `json:",omitempty"` | ||
27 | - IsDel soft_delete.DeletedAt `gorm:"softDelete:flag,DeletedAtField:DeletedAt"` | 13 | + Id int64 // 唯一标识 |
14 | + Type int `json:"type"` // 分类 (1回复 2点赞 3被采纳) | ||
15 | + OptType int `json:"optType"` // 操作类型(1针对文章、2针对评论、3针对圆桌) | ||
16 | + CompanyId int64 `json:"companyId"` // 操作人公司ID | ||
17 | + UserId int64 `json:"userId"` // 操作人用户ID | ||
18 | + RecipientId int64 `json:"recipientId"` // 接收人用户ID | ||
19 | + ArticleId int64 `json:"articleId"` // 文章ID | ||
20 | + CommentId int64 `json:"commentId"` // 评论来源ID | ||
21 | + CommentParentId int64 `json:"commentParentId"` // 评论上级ID | ||
22 | + CreatedAt int64 `json:",omitempty"` | ||
23 | + UpdatedAt int64 `json:",omitempty"` | ||
24 | + DeletedAt int64 `json:",omitempty"` | ||
25 | + Version int `json:",omitempty"` | ||
26 | + IsDel soft_delete.DeletedAt `gorm:"softDelete:flag,DeletedAtField:DeletedAt"` | ||
28 | //DiscussionId int64 `json:"discussionId,omitempty"` // 圆桌ID | 27 | //DiscussionId int64 `json:"discussionId,omitempty"` // 圆桌ID |
29 | //DiscussionOpinionId int64 `json:"discussionOpinionId,omitempty"` // 观点ID | 28 | //DiscussionOpinionId int64 `json:"discussionOpinionId,omitempty"` // 观点ID |
30 | } | 29 | } |
@@ -305,6 +305,7 @@ func (repository *ArticleRepository) ModelToDomainModel(from *models.Article) (* | @@ -305,6 +305,7 @@ func (repository *ArticleRepository) ModelToDomainModel(from *models.Article) (* | ||
305 | Tags: from.Tags, | 305 | Tags: from.Tags, |
306 | Summary: from.Summary, | 306 | Summary: from.Summary, |
307 | MatchUrl: from.MatchUrl, | 307 | MatchUrl: from.MatchUrl, |
308 | + Videos: from.Videos, | ||
308 | } | 309 | } |
309 | return to, nil | 310 | return to, nil |
310 | } | 311 | } |
@@ -333,6 +334,7 @@ func (repository *ArticleRepository) DomainModelToModel(from *domain.Article) (* | @@ -333,6 +334,7 @@ func (repository *ArticleRepository) DomainModelToModel(from *domain.Article) (* | ||
333 | Show: int(from.Show), | 334 | Show: int(from.Show), |
334 | Summary: from.Summary, | 335 | Summary: from.Summary, |
335 | MatchUrl: from.MatchUrl, | 336 | MatchUrl: from.MatchUrl, |
337 | + Videos: from.Videos, | ||
336 | } | 338 | } |
337 | // err := copier.Copy(to, from) | 339 | // err := copier.Copy(to, from) |
338 | return to, nil | 340 | return to, nil |
@@ -18,6 +18,7 @@ type Article struct { | @@ -18,6 +18,7 @@ type Article struct { | ||
18 | Author UserSimple `json:"author"` // 发布人 | 18 | Author UserSimple `json:"author"` // 发布人 |
19 | Title string `json:"title"` // 文章标题 | 19 | Title string `json:"title"` // 文章标题 |
20 | Images []Image `json:"images"` // 图片 | 20 | Images []Image `json:"images"` // 图片 |
21 | + Videos []Video `json:"videos"` // 视频 | ||
21 | WhoRead []int64 `json:"whoRead"` // 谁可以看 | 22 | WhoRead []int64 `json:"whoRead"` // 谁可以看 |
22 | WhoReview []int64 `json:"whoReview"` // 评论人 | 23 | WhoReview []int64 `json:"whoReview"` // 评论人 |
23 | Location Location `json:"location"` // 坐标 | 24 | Location Location `json:"location"` // 坐标 |
@@ -33,3 +33,5 @@ func (m *Company) Identify() interface{} { | @@ -33,3 +33,5 @@ func (m *Company) Identify() interface{} { | ||
33 | } | 33 | } |
34 | return m.Id | 34 | return m.Id |
35 | } | 35 | } |
36 | + | ||
37 | +var DefaultCompanyLog = "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/test/20231114/object/1699934114_3r7QHThtbWfEDWh7CAHSzzWytFPzsjF6.png" |
@@ -6,21 +6,22 @@ import ( | @@ -6,21 +6,22 @@ import ( | ||
6 | ) | 6 | ) |
7 | 7 | ||
8 | type MessageBusiness struct { | 8 | type MessageBusiness struct { |
9 | - Id int64 // 唯一标识 | ||
10 | - Type MsgBusinessType `json:"type"` // 分类 (1回复 2点赞 3被采纳) | ||
11 | - OptType MsgBusinessOpt `json:"optType"` // 操作类型(1针对文章、2针对评论、3针对圆桌) | ||
12 | - CompanyId int64 `json:"companyId"` // 操作人公司ID | ||
13 | - UserId int64 `json:"userId"` // 操作人用户ID | ||
14 | - RecipientId int64 `json:"recipientId"` // 接收人用户ID | ||
15 | - ArticleId int64 `json:"articleId"` // 文章ID | ||
16 | - SectionId int64 `json:"sectionId"` // 段落ID | ||
17 | - CommentId int64 `json:"commentId"` // 评论ID | ||
18 | - Content string `json:"content"` // 消息内容 | ||
19 | - CreatedAt int64 `json:",omitempty"` | ||
20 | - UpdatedAt int64 `json:",omitempty"` | ||
21 | - DeletedAt int64 `json:",omitempty"` | ||
22 | - Version int `json:",omitempty"` | ||
23 | - | 9 | + Id int64 // 唯一标识 |
10 | + Type MsgBusinessType `json:"type"` // 分类 (1回复 2点赞 3被采纳) | ||
11 | + OptType MsgBusinessOpt `json:"optType"` // 操作类型(1针对文章或段落、2针对评论、3针对圆桌) | ||
12 | + CompanyId int64 `json:"companyId"` // 操作人公司ID | ||
13 | + UserId int64 `json:"userId"` // 操作人用户ID | ||
14 | + RecipientId int64 `json:"recipientId"` // 接收人用户ID | ||
15 | + ArticleId int64 `json:"articleId"` // 文章ID | ||
16 | + CommentId int64 `json:"commentId"` // 评论来源ID | ||
17 | + CommentParentId int64 `json:"commentParentId"` // 评论上级ID | ||
18 | + CreatedAt int64 `json:",omitempty"` | ||
19 | + UpdatedAt int64 `json:",omitempty"` | ||
20 | + DeletedAt int64 `json:",omitempty"` | ||
21 | + Version int `json:",omitempty"` | ||
22 | + | ||
23 | + //SectionId int64 `json:"sectionId"` // 段落ID | ||
24 | + //Content string `json:"content"` // 消息内容 | ||
24 | //DiscussionId int64 `json:"discussionId"` // 圆桌ID | 25 | //DiscussionId int64 `json:"discussionId"` // 圆桌ID |
25 | //DiscussionOpinionId int64 `json:"discussionOpinionId"` // 观点ID | 26 | //DiscussionOpinionId int64 `json:"discussionOpinionId"` // 观点ID |
26 | } | 27 | } |
@@ -52,7 +52,7 @@ type Auth struct { | @@ -52,7 +52,7 @@ type Auth struct { | ||
52 | } | 52 | } |
53 | 53 | ||
54 | var Auths = []Auth{ | 54 | var Auths = []Auth{ |
55 | - NewAuth(1001, "邀请注册", "MINI_INVITE-REGISTRATION", 0), | 55 | + NewAuth(1001, "运营管理", "MINI_OPERATIONS-MANAGEMENT", 0), |
56 | NewAuth(1002, "帖子定性", "SYSTEM_POST-JUDGMENT", 0), | 56 | NewAuth(1002, "帖子定性", "SYSTEM_POST-JUDGMENT", 0), |
57 | //NewAuth(1003, "圆桌判定", "SYSTEM_STUDENT-MANAGE", 0), | 57 | //NewAuth(1003, "圆桌判定", "SYSTEM_STUDENT-MANAGE", 0), |
58 | //NewAuth(1004, "圆桌运营", "SYSTEM_FEEDBACK-MANAGE", 0), | 58 | //NewAuth(1004, "圆桌运营", "SYSTEM_FEEDBACK-MANAGE", 0), |
@@ -7,6 +7,14 @@ type Image struct { | @@ -7,6 +7,14 @@ type Image struct { | ||
7 | Height int `json:"height"` // 图片高度 | 7 | Height int `json:"height"` // 图片高度 |
8 | } | 8 | } |
9 | 9 | ||
10 | +// 视频信息 | ||
11 | +type Video struct { | ||
12 | + Url string `json:"url"` //视频文件的地址 | ||
13 | + Cover string `json:"cover"` //封面 | ||
14 | + Width int `json:"width"` //封面图片宽 | ||
15 | + Height int `json:"height"` //封面图片长 | ||
16 | +} | ||
17 | + | ||
10 | // 坐标位置 | 18 | // 坐标位置 |
11 | type Location struct { | 19 | type Location struct { |
12 | Longitude float64 `json:"longitude"` //经度 | 20 | Longitude float64 `json:"longitude"` //经度 |
@@ -15,8 +15,8 @@ type UserLoveFlag struct { | @@ -15,8 +15,8 @@ type UserLoveFlag struct { | ||
15 | CommentId int64 `json:"commentId"` // 点赞评论时,填评论id | 15 | CommentId int64 `json:"commentId"` // 点赞评论时,填评论id |
16 | CommentAuthor int64 `json:"commentAuthor"` // 评论的填写人 | 16 | CommentAuthor int64 `json:"commentAuthor"` // 评论的填写人 |
17 | ToUserId int64 `json:"toUserId"` // 点赞的接受人 | 17 | ToUserId int64 `json:"toUserId"` // 点赞的接受人 |
18 | - UserId int64 `json:"userId"` // 点赞的人 | ||
19 | - CompanyId int64 `json:"companyId"` // | 18 | + UserId int64 `json:"userId"` // 点赞人 |
19 | + CompanyId int64 `json:"companyId"` // 点赞人的公司 | ||
20 | CreatedAt int64 `json:"createdAt,omitempty"` | 20 | CreatedAt int64 `json:"createdAt,omitempty"` |
21 | UpdatedAt int64 `json:"updatedAt,omitempty"` | 21 | UpdatedAt int64 `json:"updatedAt,omitempty"` |
22 | DeletedAt int64 `json:"deletedAt,omitempty"` | 22 | DeletedAt int64 `json:"deletedAt,omitempty"` |
@@ -14,7 +14,7 @@ import ( | @@ -14,7 +14,7 @@ import ( | ||
14 | 14 | ||
15 | type Service struct { | 15 | type Service struct { |
16 | Timeout time.Duration | 16 | Timeout time.Duration |
17 | - host string | 17 | + Host string |
18 | Interceptor func(msg string) | 18 | Interceptor func(msg string) |
19 | ServiceName string | 19 | ServiceName string |
20 | service httpc.Service | 20 | service httpc.Service |
@@ -25,7 +25,7 @@ func NewService(name string, host string, timeout time.Duration, opts ...httpc.O | @@ -25,7 +25,7 @@ func NewService(name string, host string, timeout time.Duration, opts ...httpc.O | ||
25 | //client.Timeout = timeout | 25 | //client.Timeout = timeout |
26 | 26 | ||
27 | service := Service{ | 27 | service := Service{ |
28 | - host: host, | 28 | + Host: host, |
29 | service: httpc.NewServiceWithClient(name, client, opts...), | 29 | service: httpc.NewServiceWithClient(name, client, opts...), |
30 | } | 30 | } |
31 | return service | 31 | return service |
@@ -37,7 +37,7 @@ func (gateway Service) Do(ctx context.Context, url string, method string, val in | @@ -37,7 +37,7 @@ func (gateway Service) Do(ctx context.Context, url string, method string, val in | ||
37 | begin = time.Now() | 37 | begin = time.Now() |
38 | body []byte | 38 | body []byte |
39 | ) | 39 | ) |
40 | - response, err := gateway.service.Do(ctx, method, gateway.host+url, val) | 40 | + response, err := gateway.service.Do(ctx, method, gateway.Host+url, val) |
41 | defer func() { | 41 | defer func() { |
42 | jsonParam, _ := json.Marshal(val) | 42 | jsonParam, _ := json.Marshal(val) |
43 | jsonData, _ := json.Marshal(result) | 43 | jsonData, _ := json.Marshal(result) |
@@ -45,7 +45,7 @@ func (gateway Service) Do(ctx context.Context, url string, method string, val in | @@ -45,7 +45,7 @@ func (gateway Service) Do(ctx context.Context, url string, method string, val in | ||
45 | result = err.Error() | 45 | result = err.Error() |
46 | } | 46 | } |
47 | if gateway.Interceptor != nil { | 47 | if gateway.Interceptor != nil { |
48 | - gateway.Interceptor(fmt.Sprintf("【网关】%v | %v%v | %v : %v \n-->> %v \n<<-- %v", time.Since(begin), gateway.host, url, strings.ToUpper(method), | 48 | + gateway.Interceptor(fmt.Sprintf("【网关】%v | %v%v | %v : %v \n-->> %v \n<<-- %v", time.Since(begin), gateway.Host, url, strings.ToUpper(method), |
49 | result, | 49 | result, |
50 | string(jsonParam), | 50 | string(jsonParam), |
51 | string(jsonData), | 51 | string(jsonData), |
@@ -84,6 +84,62 @@ func (gateway Service) Do(ctx context.Context, url string, method string, val in | @@ -84,6 +84,62 @@ func (gateway Service) Do(ctx context.Context, url string, method string, val in | ||
84 | return nil | 84 | return nil |
85 | } | 85 | } |
86 | 86 | ||
87 | +func (gateway Service) HandlerResponse(ctx context.Context, request *http.Request, response *http.Response, val, result interface{}) error { | ||
88 | + var ( | ||
89 | + baseResponse = Response{} | ||
90 | + begin = time.Now() | ||
91 | + body []byte | ||
92 | + err error | ||
93 | + ) | ||
94 | + defer func() { | ||
95 | + jsonParam, _ := json.Marshal(val) | ||
96 | + jsonData, _ := json.Marshal(result) | ||
97 | + if err != nil { | ||
98 | + result = err.Error() | ||
99 | + } | ||
100 | + if gateway.Interceptor != nil { | ||
101 | + gateway.Interceptor(fmt.Sprintf("【网关】%v | %v%v | %v : %v \n-->> %v \n<<-- %v", time.Since(begin), gateway.Host, request.URL.Path, request.Method, | ||
102 | + result, | ||
103 | + string(jsonParam), | ||
104 | + string(jsonData), | ||
105 | + )) | ||
106 | + } | ||
107 | + }() | ||
108 | + if err != nil { | ||
109 | + return err | ||
110 | + } | ||
111 | + if response.StatusCode != http.StatusOK { | ||
112 | + return HttpError{ | ||
113 | + Base: Response{ | ||
114 | + Code: response.StatusCode, | ||
115 | + Msg: response.Status, | ||
116 | + }, | ||
117 | + } | ||
118 | + } | ||
119 | + body, err = Bytes(response) | ||
120 | + if err != nil { | ||
121 | + return err | ||
122 | + } | ||
123 | + if err = json.Unmarshal(body, &baseResponse); err != nil { | ||
124 | + return err | ||
125 | + } | ||
126 | + if baseResponse.Code != 0 { | ||
127 | + return HttpError{ | ||
128 | + Base: Response{ | ||
129 | + Code: baseResponse.Code, | ||
130 | + Msg: baseResponse.Msg, | ||
131 | + }, | ||
132 | + } | ||
133 | + } | ||
134 | + if err = mapping.UnmarshalJsonBytes(baseResponse.Data, result); err != nil { | ||
135 | + return err | ||
136 | + } | ||
137 | + return nil | ||
138 | +} | ||
139 | + | ||
140 | +func (gateway Service) GetService() httpc.Service { | ||
141 | + return gateway.service | ||
142 | +} | ||
87 | func Bytes(resp *http.Response) ([]byte, error) { | 143 | func Bytes(resp *http.Response) ([]byte, error) { |
88 | var body []byte | 144 | var body []byte |
89 | if resp.Body == nil { | 145 | if resp.Body == nil { |
1 | +package openlib | ||
2 | + | ||
3 | +import ( | ||
4 | + "bytes" | ||
5 | + "context" | ||
6 | + "encoding/json" | ||
7 | + "github.com/zeromicro/go-zero/core/mapping" | ||
8 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/gateway" | ||
9 | + "io" | ||
10 | + "io/ioutil" | ||
11 | + "mime/multipart" | ||
12 | + "net/http" | ||
13 | + "net/url" | ||
14 | +) | ||
15 | + | ||
16 | +type OpenApiService struct { | ||
17 | + gateway.Service | ||
18 | +} | ||
19 | + | ||
20 | +func (svc *OpenApiService) PutFile(ctx context.Context, request RequestPutFile) (*DataPutFile, error) { | ||
21 | + var result DataPutFile | ||
22 | + r, _ := buildRequest(ctx, http.MethodPost, svc.Host+"/v1/vod/putObject", request) | ||
23 | + response, err := svc.GetService().DoRequest(r) | ||
24 | + if err != nil { | ||
25 | + return nil, err | ||
26 | + } | ||
27 | + if err := svc.HandlerResponse(ctx, r, response, nil, &result); err != nil { | ||
28 | + return nil, err | ||
29 | + } | ||
30 | + return &result, nil | ||
31 | +} | ||
32 | + | ||
33 | +func buildRequest(ctx context.Context, method, tmpUrl string, data any) (*http.Request, error) { | ||
34 | + u, err := url.Parse(tmpUrl) | ||
35 | + if err != nil { | ||
36 | + return nil, err | ||
37 | + } | ||
38 | + | ||
39 | + var val map[string]map[string]any | ||
40 | + if data != nil { | ||
41 | + val, err = mapping.Marshal(data) | ||
42 | + if err != nil { | ||
43 | + return nil, err | ||
44 | + } | ||
45 | + } | ||
46 | + | ||
47 | + var reader io.Reader | ||
48 | + jsonVars, hasJsonBody := val["json"] | ||
49 | + if hasJsonBody { | ||
50 | + var buf bytes.Buffer | ||
51 | + enc := json.NewEncoder(&buf) | ||
52 | + if err := enc.Encode(jsonVars); err != nil { | ||
53 | + return nil, err | ||
54 | + } | ||
55 | + | ||
56 | + reader = &buf | ||
57 | + } | ||
58 | + | ||
59 | + req, err := http.NewRequestWithContext(ctx, method, u.String(), reader) | ||
60 | + if err != nil { | ||
61 | + return nil, err | ||
62 | + } | ||
63 | + fileVars, hasFile := val["file"] | ||
64 | + if hasFile { | ||
65 | + if err = fillFile(req, fileVars); err != nil { | ||
66 | + return nil, err | ||
67 | + } | ||
68 | + } | ||
69 | + if hasJsonBody { | ||
70 | + req.Header.Set("Content-Type", "application/json; charset=utf-8") | ||
71 | + } | ||
72 | + | ||
73 | + return req, nil | ||
74 | +} | ||
75 | + | ||
76 | +func fillFile(req *http.Request, val map[string]any) error { | ||
77 | + if len(val) == 0 { | ||
78 | + return nil | ||
79 | + } | ||
80 | + pr, pw := io.Pipe() | ||
81 | + bodyWriter := multipart.NewWriter(pw) | ||
82 | + go func() { | ||
83 | + for k, v := range val { | ||
84 | + fileWriter, err := bodyWriter.CreateFormFile(k, k) | ||
85 | + if err != nil { | ||
86 | + return | ||
87 | + } | ||
88 | + //fh, err := os.Open(v.(string)) | ||
89 | + //if err != nil { | ||
90 | + // return err | ||
91 | + //} | ||
92 | + fh := bytes.NewBuffer(v.([]byte)) | ||
93 | + // iocopy | ||
94 | + _, err = io.Copy(fileWriter, fh) | ||
95 | + if err != nil { | ||
96 | + return | ||
97 | + } | ||
98 | + } | ||
99 | + bodyWriter.Close() | ||
100 | + pw.Close() | ||
101 | + }() | ||
102 | + req.Header.Set("Content-Type", bodyWriter.FormDataContentType()) | ||
103 | + req.Body = ioutil.NopCloser(pr) | ||
104 | + req.Header.Set("Transfer-Encoding", "chunked") | ||
105 | + return nil | ||
106 | +} |
1 | +package openlib | ||
2 | + | ||
3 | +type ( | ||
4 | + RequestPutFile struct { | ||
5 | + File []byte `file:"file.png"` | ||
6 | + } | ||
7 | + DataPutFile []*DataUploadItem | ||
8 | + | ||
9 | + DataUploadItem struct { | ||
10 | + Host string `json:"host"` | ||
11 | + Key string `json:"key"` | ||
12 | + Path string `json:"path"` | ||
13 | + FileName string `json:"fileName"` | ||
14 | + } | ||
15 | +) |
-
请 注册 或 登录 后发表评论