正在显示
19 个修改的文件
包含
232 行增加
和
39 行删除
@@ -32,5 +32,5 @@ ENV CONFIG_FILE=${CONFIG_FILE} | @@ -32,5 +32,5 @@ ENV CONFIG_FILE=${CONFIG_FILE} | ||
32 | COPY --from=builder /build/api/${PROJECT} ./ | 32 | COPY --from=builder /build/api/${PROJECT} ./ |
33 | COPY --from=builder /build/cmd/discuss/api/etc/${CONFIG_FILE} ./etc/ | 33 | COPY --from=builder /build/cmd/discuss/api/etc/${CONFIG_FILE} ./etc/ |
34 | 34 | ||
35 | -EXPOSE 8080 | 35 | +EXPOSE 8081 |
36 | ENTRYPOINT ./${PROJECT} -f etc/${CONFIG_FILE} | 36 | ENTRYPOINT ./${PROJECT} -f etc/${CONFIG_FILE} |
cmd/discuss/api/dsl/core/common.api
0 → 100644
1 | +syntax = "v1" | ||
2 | + | ||
3 | +info( | ||
4 | + title: "天联鹰蜓" | ||
5 | + desc: "天联鹰蜓" | ||
6 | + author: "email" | ||
7 | + email: "email" | ||
8 | + version: "v1" | ||
9 | +) | ||
10 | + | ||
11 | +// 通用接口 | ||
12 | +@server( | ||
13 | + prefix: v1/common | ||
14 | + group: common | ||
15 | +) | ||
16 | +service Core { | ||
17 | + @doc "短信验证码" | ||
18 | + @handler commonSmsCode | ||
19 | + post /sms/code (CommonSmsCodeRequest) returns (CommonSmsCodeResposne) | ||
20 | +} | ||
21 | + | ||
22 | +// 短信验证码 | ||
23 | +type( | ||
24 | + CommonSmsCodeRequest{ | ||
25 | + Phone string `json:"phone"` | ||
26 | + } | ||
27 | + CommonSmsCodeResposne{ | ||
28 | + | ||
29 | + } | ||
30 | +) |
@@ -16,15 +16,19 @@ info( | @@ -16,15 +16,19 @@ info( | ||
16 | service Core { | 16 | service Core { |
17 | @doc "系统消息" | 17 | @doc "系统消息" |
18 | @handler miniSystem | 18 | @handler miniSystem |
19 | - post /mini/message/system (MessageSystemRequest) returns (MessageSystemResponse) | 19 | + post /mini/message/system (MessageRequest) returns (MessageSystemResponse) |
20 | 20 | ||
21 | - @doc "业务消息" | ||
22 | - @handler miniBusiness | ||
23 | - post /mini/message/business (MessageBusinessRequest) returns (MessageBusinessResponse) | 21 | + @doc "评论消息" |
22 | + @handler miniComment | ||
23 | + post /mini/message/comment (MessageRequest) returns (MessageBusinessResponse) | ||
24 | + | ||
25 | + @doc "点赞消息" | ||
26 | + @handler miniLike | ||
27 | + post /mini/message/like (MessageRequest) returns (MessageBusinessResponse) | ||
24 | } | 28 | } |
25 | 29 | ||
26 | type ( | 30 | type ( |
27 | - MessageSystemRequest { | 31 | + MessageRequest { |
28 | Page int `json:"page"` | 32 | Page int `json:"page"` |
29 | Size int `json:"size"` | 33 | Size int `json:"size"` |
30 | } | 34 | } |
@@ -40,11 +44,6 @@ type ( | @@ -40,11 +44,6 @@ type ( | ||
40 | CreatedAt int64 `json:"createdAt"` // 创建时间 | 44 | CreatedAt int64 `json:"createdAt"` // 创建时间 |
41 | } | 45 | } |
42 | 46 | ||
43 | - MessageBusinessRequest { | ||
44 | - Type int `json:"type"` | ||
45 | - Page int `json:"page"` | ||
46 | - Size int `json:"size"` | ||
47 | - } | ||
48 | MessageBusinessResponse { | 47 | MessageBusinessResponse { |
49 | List []MessageBusinessItem `json:"list"` | 48 | List []MessageBusinessItem `json:"list"` |
50 | Total int64 `json:"total"` | 49 | Total int64 `json:"total"` |
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 CommonSmsCodeHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
14 | + return func(w http.ResponseWriter, r *http.Request) { | ||
15 | + var req types.CommonSmsCodeRequest | ||
16 | + if err := httpx.Parse(r, &req); err != nil { | ||
17 | + httpx.ErrorCtx(r.Context(), w, err) | ||
18 | + return | ||
19 | + } | ||
20 | + | ||
21 | + l := common.NewCommonSmsCodeLogic(r.Context(), svcCtx) | ||
22 | + resp, err := l.CommonSmsCode(&req) | ||
23 | + result.HttpResult(r, w, resp, err) | ||
24 | + } | ||
25 | +} |
1 | package message | 1 | package message |
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain" | ||
4 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/result" | 5 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/result" |
5 | "net/http" | 6 | "net/http" |
6 | 7 | ||
@@ -10,16 +11,16 @@ import ( | @@ -10,16 +11,16 @@ import ( | ||
10 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | 11 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" |
11 | ) | 12 | ) |
12 | 13 | ||
13 | -func MiniBusinessHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | 14 | +func MiniCommentHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { |
14 | return func(w http.ResponseWriter, r *http.Request) { | 15 | return func(w http.ResponseWriter, r *http.Request) { |
15 | - var req types.MessageBusinessRequest | 16 | + var req types.MessageRequest |
16 | if err := httpx.Parse(r, &req); err != nil { | 17 | if err := httpx.Parse(r, &req); err != nil { |
17 | result.ParamErrorResult(r, w, err) | 18 | result.ParamErrorResult(r, w, err) |
18 | return | 19 | return |
19 | } | 20 | } |
20 | 21 | ||
21 | l := message.NewMiniBusinessLogic(r.Context(), svcCtx) | 22 | l := message.NewMiniBusinessLogic(r.Context(), svcCtx) |
22 | - resp, err := l.MiniBusiness(&req) | 23 | + resp, err := l.MiniBusiness(&req, domain.MsgTypeReply) |
23 | result.HttpResult(r, w, resp, err) | 24 | result.HttpResult(r, w, resp, err) |
24 | } | 25 | } |
25 | } | 26 | } |
1 | +package message | ||
2 | + | ||
3 | +import ( | ||
4 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain" | ||
5 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/result" | ||
6 | + "net/http" | ||
7 | + | ||
8 | + "github.com/zeromicro/go-zero/rest/httpx" | ||
9 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/message" | ||
10 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | ||
11 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | ||
12 | +) | ||
13 | + | ||
14 | +func MiniLikeHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
15 | + return func(w http.ResponseWriter, r *http.Request) { | ||
16 | + var req types.MessageRequest | ||
17 | + if err := httpx.Parse(r, &req); err != nil { | ||
18 | + result.ParamErrorResult(r, w, err) | ||
19 | + return | ||
20 | + } | ||
21 | + | ||
22 | + l := message.NewMiniBusinessLogic(r.Context(), svcCtx) | ||
23 | + resp, err := l.MiniBusiness(&req, domain.MsgTypeLike) | ||
24 | + result.HttpResult(r, w, resp, err) | ||
25 | + } | ||
26 | +} |
@@ -12,7 +12,7 @@ import ( | @@ -12,7 +12,7 @@ import ( | ||
12 | 12 | ||
13 | func MiniSystemHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | 13 | func MiniSystemHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { |
14 | return func(w http.ResponseWriter, r *http.Request) { | 14 | return func(w http.ResponseWriter, r *http.Request) { |
15 | - var req types.MessageSystemRequest | 15 | + var req types.MessageRequest |
16 | if err := httpx.Parse(r, &req); err != nil { | 16 | if err := httpx.Parse(r, &req); err != nil { |
17 | result.ParamErrorResult(r, w, err) | 17 | result.ParamErrorResult(r, w, err) |
18 | return | 18 | return |
@@ -6,6 +6,7 @@ import ( | @@ -6,6 +6,7 @@ import ( | ||
6 | 6 | ||
7 | article "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/handler/article" | 7 | article "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/handler/article" |
8 | comment "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/handler/comment" | 8 | comment "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/handler/comment" |
9 | + common "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/handler/common" | ||
9 | company "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/handler/company" | 10 | company "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/handler/company" |
10 | department "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/handler/department" | 11 | department "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/handler/department" |
11 | message "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/handler/message" | 12 | message "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/handler/message" |
@@ -22,6 +23,17 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { | @@ -22,6 +23,17 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { | ||
22 | []rest.Route{ | 23 | []rest.Route{ |
23 | { | 24 | { |
24 | Method: http.MethodPost, | 25 | Method: http.MethodPost, |
26 | + Path: "/sms/code", | ||
27 | + Handler: common.CommonSmsCodeHandler(serverCtx), | ||
28 | + }, | ||
29 | + }, | ||
30 | + rest.WithPrefix("/v1/common"), | ||
31 | + ) | ||
32 | + | ||
33 | + server.AddRoutes( | ||
34 | + []rest.Route{ | ||
35 | + { | ||
36 | + Method: http.MethodPost, | ||
25 | Path: "/article_comment", | 37 | Path: "/article_comment", |
26 | Handler: comment.MiniCreateArticleCommentHandler(serverCtx), | 38 | Handler: comment.MiniCreateArticleCommentHandler(serverCtx), |
27 | }, | 39 | }, |
@@ -104,8 +116,13 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { | @@ -104,8 +116,13 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { | ||
104 | }, | 116 | }, |
105 | { | 117 | { |
106 | Method: http.MethodPost, | 118 | Method: http.MethodPost, |
107 | - Path: "/mini/message/business", | ||
108 | - Handler: message.MiniBusinessHandler(serverCtx), | 119 | + Path: "/mini/message/comment", |
120 | + Handler: message.MiniCommentHandler(serverCtx), | ||
121 | + }, | ||
122 | + { | ||
123 | + Method: http.MethodPost, | ||
124 | + Path: "/mini/message/like", | ||
125 | + Handler: message.MiniLikeHandler(serverCtx), | ||
109 | }, | 126 | }, |
110 | }, | 127 | }, |
111 | rest.WithJwt(serverCtx.Config.MiniAuth.AccessSecret), | 128 | rest.WithJwt(serverCtx.Config.MiniAuth.AccessSecret), |
1 | +package common | ||
2 | + | ||
3 | +import ( | ||
4 | + "context" | ||
5 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/gateway/smslib" | ||
6 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr" | ||
7 | + | ||
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 | + "github.com/zeromicro/go-zero/core/logx" | ||
12 | +) | ||
13 | + | ||
14 | +type CommonSmsCodeLogic struct { | ||
15 | + logx.Logger | ||
16 | + ctx context.Context | ||
17 | + svcCtx *svc.ServiceContext | ||
18 | +} | ||
19 | + | ||
20 | +func NewCommonSmsCodeLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CommonSmsCodeLogic { | ||
21 | + return &CommonSmsCodeLogic{ | ||
22 | + Logger: logx.WithContext(ctx), | ||
23 | + ctx: ctx, | ||
24 | + svcCtx: svcCtx, | ||
25 | + } | ||
26 | +} | ||
27 | + | ||
28 | +func (l *CommonSmsCodeLogic) CommonSmsCode(req *types.CommonSmsCodeRequest) (resp *types.CommonSmsCodeResposne, err error) { | ||
29 | + _, err = l.svcCtx.SmsService.SendSmsCode(l.ctx, smslib.RequestSendSmsCode{ | ||
30 | + Phone: req.Phone, | ||
31 | + }) | ||
32 | + if err != nil { | ||
33 | + return nil, xerr.NewErrMsgErr(err.Error(), err) | ||
34 | + } | ||
35 | + resp = &types.CommonSmsCodeResposne{} | ||
36 | + return | ||
37 | +} |
@@ -26,10 +26,9 @@ func NewMiniBusinessLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Mini | @@ -26,10 +26,9 @@ func NewMiniBusinessLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Mini | ||
26 | } | 26 | } |
27 | } | 27 | } |
28 | 28 | ||
29 | -func (l *MiniBusinessLogic) MiniBusiness(req *types.MessageBusinessRequest) (resp *types.MessageBusinessResponse, err error) { | 29 | +func (l *MiniBusinessLogic) MiniBusiness(req *types.MessageRequest, msgType domain.MsgBusinessType) (resp *types.MessageBusinessResponse, err error) { |
30 | var userToken = contextdata.GetUserTokenFromCtx(l.ctx) | 30 | var userToken = contextdata.GetUserTokenFromCtx(l.ctx) |
31 | var conn = l.svcCtx.DefaultDBConn() | 31 | var conn = l.svcCtx.DefaultDBConn() |
32 | - var msgType = req.Type | ||
33 | 32 | ||
34 | total, list, err := l.svcCtx.MessageBusinessRepository.Find(l.ctx, conn, domain.NewQueryOptions(). | 33 | total, list, err := l.svcCtx.MessageBusinessRepository.Find(l.ctx, conn, domain.NewQueryOptions(). |
35 | WithOffsetLimit(req.Page, req.Size). | 34 | WithOffsetLimit(req.Page, req.Size). |
@@ -100,8 +99,8 @@ func (l *MiniBusinessLogic) MiniBusiness(req *types.MessageBusinessRequest) (res | @@ -100,8 +99,8 @@ func (l *MiniBusinessLogic) MiniBusiness(req *types.MessageBusinessRequest) (res | ||
100 | if len(companyIds) > 0 { | 99 | if len(companyIds) > 0 { |
101 | _, companyList, err := l.svcCtx.CompanyRepository.Find(l.ctx, conn, domain.NewQueryOptions(). | 100 | _, companyList, err := l.svcCtx.CompanyRepository.Find(l.ctx, conn, domain.NewQueryOptions(). |
102 | WithFindOnly(). | 101 | WithFindOnly(). |
103 | - WithKV("ids", userIds). | ||
104 | - WithKV("limit", len(userIds))) | 102 | + WithKV("ids", companyIds). |
103 | + WithKV("limit", len(companyIds))) | ||
105 | if err != nil { | 104 | if err != nil { |
106 | return nil, err | 105 | return nil, err |
107 | } | 106 | } |
@@ -25,7 +25,7 @@ func NewMiniSystemLogic(ctx context.Context, svcCtx *svc.ServiceContext) *MiniSy | @@ -25,7 +25,7 @@ func NewMiniSystemLogic(ctx context.Context, svcCtx *svc.ServiceContext) *MiniSy | ||
25 | } | 25 | } |
26 | } | 26 | } |
27 | 27 | ||
28 | -func (l *MiniSystemLogic) MiniSystem(req *types.MessageSystemRequest) (resp *types.MessageSystemResponse, err error) { | 28 | +func (l *MiniSystemLogic) MiniSystem(req *types.MessageRequest) (resp *types.MessageSystemResponse, err error) { |
29 | var userToken = contextdata.GetUserTokenFromCtx(l.ctx) | 29 | var userToken = contextdata.GetUserTokenFromCtx(l.ctx) |
30 | 30 | ||
31 | total, list, err := l.svcCtx.MessageSystemRepository.Find(l.ctx, l.svcCtx.DefaultDBConn(), domain.NewQueryOptions(). | 31 | total, list, err := l.svcCtx.MessageSystemRepository.Find(l.ctx, l.svcCtx.DefaultDBConn(), domain.NewQueryOptions(). |
@@ -87,15 +87,16 @@ func (l *MiniUserInfoLogic) MiniUserInfo(req *types.MiniUserInfoRequest) (resp * | @@ -87,15 +87,16 @@ func (l *MiniUserInfoLogic) MiniUserInfo(req *types.MiniUserInfoRequest) (resp * | ||
87 | authSet := collection.NewSet() | 87 | authSet := collection.NewSet() |
88 | for _, role := range roles { | 88 | for _, role := range roles { |
89 | for _, auth := range role.Auths { | 89 | for _, auth := range role.Auths { |
90 | - if !authSet.Contains(auth) { | ||
91 | - authSet.Add(auth) | ||
92 | - if item := role.GetAuth(auth); item != nil { | ||
93 | - resp.Auths = append(resp.Auths, types.Auth{ | ||
94 | - Id: item.Id, | ||
95 | - Name: item.Name, | ||
96 | - Code: item.Code, | ||
97 | - }) | ||
98 | - } | 90 | + if authSet.Contains(auth) { |
91 | + continue | ||
92 | + } | ||
93 | + authSet.Add(auth) | ||
94 | + if item := role.GetAuth(auth); item != nil { | ||
95 | + resp.Auths = append(resp.Auths, types.Auth{ | ||
96 | + Id: item.Id, | ||
97 | + Name: item.Name, | ||
98 | + Code: item.Code, | ||
99 | + }) | ||
99 | } | 100 | } |
100 | } | 101 | } |
101 | } | 102 | } |
@@ -7,6 +7,7 @@ import ( | @@ -7,6 +7,7 @@ import ( | ||
7 | "github.com/silenceper/wechat/v2/cache" | 7 | "github.com/silenceper/wechat/v2/cache" |
8 | miniConfig "github.com/silenceper/wechat/v2/miniprogram/config" | 8 | miniConfig "github.com/silenceper/wechat/v2/miniprogram/config" |
9 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain" | 9 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain" |
10 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/gateway/smslib" | ||
10 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/tool" | 11 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/tool" |
11 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr" | 12 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr" |
12 | 13 | ||
@@ -121,6 +122,9 @@ func (c WxClientLogin) PhoneSmsCodeLogin(phone string, code string) (*domain.Log | @@ -121,6 +122,9 @@ func (c WxClientLogin) PhoneSmsCodeLogin(phone string, code string) (*domain.Log | ||
121 | users []*domain.User | 122 | users []*domain.User |
122 | err error | 123 | err error |
123 | ) | 124 | ) |
125 | + if _, err = c.l.svcCtx.SmsService.CheckSmsCode(c.l.ctx, smslib.RequestCheckSmsCode{Phone: phone, Code: code}); err != nil { | ||
126 | + return nil, xerr.NewErrMsgErr(err.Error(), err) | ||
127 | + } | ||
124 | conn := c.l.svcCtx.DefaultDBConn() | 128 | conn := c.l.svcCtx.DefaultDBConn() |
125 | _, users, err = c.l.svcCtx.UserRepository.Find(c.l.ctx, conn, domain.NewQueryOptions(). | 129 | _, users, err = c.l.svcCtx.UserRepository.Find(c.l.ctx, conn, domain.NewQueryOptions(). |
126 | MustWithKV("phone", phone). | 130 | MustWithKV("phone", phone). |
@@ -10,9 +10,11 @@ import ( | @@ -10,9 +10,11 @@ import ( | ||
10 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain" | 10 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain" |
11 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/gateway" | 11 | "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" | 12 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/gateway/authlib" |
13 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/gateway/smslib" | ||
13 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/cache" | 14 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/cache" |
14 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/database" | 15 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/database" |
15 | "gorm.io/gorm" | 16 | "gorm.io/gorm" |
17 | + "time" | ||
16 | ) | 18 | ) |
17 | 19 | ||
18 | type ServiceContext struct { | 20 | type ServiceContext struct { |
@@ -39,6 +41,7 @@ type ServiceContext struct { | @@ -39,6 +41,7 @@ type ServiceContext struct { | ||
39 | UserRepository domain.UserRepository | 41 | UserRepository domain.UserRepository |
40 | 42 | ||
41 | ApiAuthService authlib.ApiAuthService | 43 | ApiAuthService authlib.ApiAuthService |
44 | + SmsService smslib.SMSService | ||
42 | 45 | ||
43 | LoginStatusCheck rest.Middleware | 46 | LoginStatusCheck rest.Middleware |
44 | } | 47 | } |
@@ -57,6 +60,7 @@ func NewServiceContext(c config.Config) *ServiceContext { | @@ -57,6 +60,7 @@ func NewServiceContext(c config.Config) *ServiceContext { | ||
57 | DB: db, | 60 | DB: db, |
58 | Redis: redis, | 61 | Redis: redis, |
59 | ApiAuthService: apiAuth, | 62 | ApiAuthService: apiAuth, |
63 | + SmsService: smslib.SMSService{Service: gateway.NewService("短信服务", "https://sms.fjmaimaimai.com:9897", time.Second*5)}, | ||
60 | LoginStatusCheck: middleware.NewLoginStatusCheckMiddleware(apiAuth).Handle, | 64 | LoginStatusCheck: middleware.NewLoginStatusCheckMiddleware(apiAuth).Handle, |
61 | 65 | ||
62 | ArticleBackupRepository: repository.NewArticleBackupRepository(cache.NewCachedRepository(mlCache)), | 66 | ArticleBackupRepository: repository.NewArticleBackupRepository(cache.NewCachedRepository(mlCache)), |
1 | // Code generated by goctl. DO NOT EDIT. | 1 | // Code generated by goctl. DO NOT EDIT. |
2 | package types | 2 | package types |
3 | 3 | ||
4 | +type CommonSmsCodeRequest struct { | ||
5 | + Phone string `json:"phone"` | ||
6 | +} | ||
7 | + | ||
8 | +type CommonSmsCodeResposne struct { | ||
9 | +} | ||
10 | + | ||
4 | type CommentAuthor struct { | 11 | type CommentAuthor struct { |
5 | Id int64 `json:"id"` // 人员id | 12 | Id int64 `json:"id"` // 人员id |
6 | Name string `json:"name"` // 人员的名字 | 13 | Name string `json:"name"` // 人员的名字 |
@@ -172,7 +179,7 @@ type SystemListCommentRequest struct { | @@ -172,7 +179,7 @@ type SystemListCommentRequest struct { | ||
172 | Page int `json:"page"` | 179 | Page int `json:"page"` |
173 | Size int `json:"size"` | 180 | Size int `json:"size"` |
174 | CompanyId int64 `json:",optional"` // | 181 | CompanyId int64 `json:",optional"` // |
175 | - TopId int64 `json:"topId,optional"` // 评论的顶层ID | 182 | + TopId int64 `json:"topId,optional"` // 评论的顶层ID |
176 | FromUser string `json:"fromUser,optional"` // 用户 | 183 | FromUser string `json:"fromUser,optional"` // 用户 |
177 | Show int `json:"show,optional"` // 显示状态 | 184 | Show int `json:"show,optional"` // 显示状态 |
178 | BeginTime int64 `json:"beginTime,optional"` // 填写评论的开始时间 | 185 | BeginTime int64 `json:"beginTime,optional"` // 填写评论的开始时间 |
@@ -245,7 +252,7 @@ type SystemEditCommentResponse struct { | @@ -245,7 +252,7 @@ type SystemEditCommentResponse struct { | ||
245 | Id int64 `json:"id"` | 252 | Id int64 `json:"id"` |
246 | } | 253 | } |
247 | 254 | ||
248 | -type MessageSystemRequest struct { | 255 | +type MessageRequest struct { |
249 | Page int `json:"page"` | 256 | Page int `json:"page"` |
250 | Size int `json:"size"` | 257 | Size int `json:"size"` |
251 | } | 258 | } |
@@ -263,12 +270,6 @@ type MessageSystemItem struct { | @@ -263,12 +270,6 @@ type MessageSystemItem struct { | ||
263 | CreatedAt int64 `json:"createdAt"` // 创建时间 | 270 | CreatedAt int64 `json:"createdAt"` // 创建时间 |
264 | } | 271 | } |
265 | 272 | ||
266 | -type MessageBusinessRequest struct { | ||
267 | - Type int `json:"type"` | ||
268 | - Page int `json:"page"` | ||
269 | - Size int `json:"size"` | ||
270 | -} | ||
271 | - | ||
272 | type MessageBusinessResponse struct { | 273 | type MessageBusinessResponse struct { |
273 | List []MessageBusinessItem `json:"list"` | 274 | List []MessageBusinessItem `json:"list"` |
274 | Total int64 `json:"total"` | 275 | Total int64 `json:"total"` |
@@ -24,5 +24,8 @@ type HttpError struct { | @@ -24,5 +24,8 @@ type HttpError struct { | ||
24 | } | 24 | } |
25 | 25 | ||
26 | func (e HttpError) Error() string { | 26 | func (e HttpError) Error() string { |
27 | + if e.Base.Code > 0 && e.Base.Msg != "" { | ||
28 | + return e.Base.Msg | ||
29 | + } | ||
27 | return fmt.Sprintf("HttpError code:%d msg:%s", e.Base.Code, e.Base.Msg) | 30 | return fmt.Sprintf("HttpError code:%d msg:%s", e.Base.Code, e.Base.Msg) |
28 | } | 31 | } |
1 | +package smslib | ||
2 | + | ||
3 | +import ( | ||
4 | + "context" | ||
5 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/gateway" | ||
6 | + "net/http" | ||
7 | +) | ||
8 | + | ||
9 | +type SMSService struct { | ||
10 | + gateway.Service | ||
11 | +} | ||
12 | + | ||
13 | +func (svc *SMSService) SendSmsCode(ctx context.Context, request RequestSendSmsCode) (*DataSendSmsCode, error) { | ||
14 | + var result DataSendSmsCode | ||
15 | + if err := svc.Do(ctx, "/service/sendSms", http.MethodPost, request, &result); err != nil { | ||
16 | + return nil, err | ||
17 | + } | ||
18 | + return &result, nil | ||
19 | +} | ||
20 | + | ||
21 | +func (svc *SMSService) CheckSmsCode(ctx context.Context, request RequestCheckSmsCode) (*DataCheckSmsCode, error) { | ||
22 | + var result DataCheckSmsCode | ||
23 | + if err := svc.Do(ctx, "/service/checkSmsCode", http.MethodPost, request, &result); err != nil { | ||
24 | + return nil, err | ||
25 | + } | ||
26 | + return &result, nil | ||
27 | +} |
1 | +package smslib | ||
2 | + | ||
3 | +type ( | ||
4 | + RequestSendSmsCode struct { | ||
5 | + Phone string `json:"phone"` | ||
6 | + } | ||
7 | + DataSendSmsCode struct { | ||
8 | + } | ||
9 | +) | ||
10 | + | ||
11 | +type ( | ||
12 | + RequestCheckSmsCode struct { | ||
13 | + Phone string `json:"phone"` | ||
14 | + Code string `json:"code"` | ||
15 | + } | ||
16 | + DataCheckSmsCode struct { | ||
17 | + } | ||
18 | +) |
-
请 注册 或 登录 后发表评论