Merge branch 'dev' of http://gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss into dev
正在显示
5 个修改的文件
包含
38 行增加
和
12 行删除
| @@ -33,12 +33,17 @@ func main() { | @@ -33,12 +33,17 @@ func main() { | ||
| 33 | 33 | ||
| 34 | // 服务初始化 | 34 | // 服务初始化 |
| 35 | opts := make([]rest.RunOption, 0) | 35 | opts := make([]rest.RunOption, 0) |
| 36 | - opt := rest.WithCustomCors(func(header http.Header) { | 36 | + opts = append(opts, rest.WithCustomCors(func(header http.Header) { |
| 37 | header.Set("Access-Control-Allow-Headers", "*") | 37 | header.Set("Access-Control-Allow-Headers", "*") |
| 38 | }, func(writer http.ResponseWriter) { | 38 | }, func(writer http.ResponseWriter) { |
| 39 | 39 | ||
| 40 | - }) | ||
| 41 | - opts = append(opts, opt) | 40 | + })) |
| 41 | + opts = append(opts, rest.WithUnauthorizedCallback(func(w http.ResponseWriter, r *http.Request, err error) { | ||
| 42 | + if err != nil { | ||
| 43 | + logx.Debugf("unauthorized: %s \n", err.Error()) | ||
| 44 | + } | ||
| 45 | + })) | ||
| 46 | + | ||
| 42 | server := rest.MustNewServer(c.RestConf, opts...) | 47 | server := rest.MustNewServer(c.RestConf, opts...) |
| 43 | defer server.Stop() | 48 | defer server.Stop() |
| 44 | ctx := svc.NewServiceContext(c) | 49 | ctx := svc.NewServiceContext(c) |
| @@ -73,6 +78,7 @@ func systemSetup(c config.Config) { | @@ -73,6 +78,7 @@ func systemSetup(c config.Config) { | ||
| 73 | httpx.SetErrorHandlerCtx(func(ctx context.Context, err error) (int, any) { | 78 | httpx.SetErrorHandlerCtx(func(ctx context.Context, err error) (int, any) { |
| 74 | return http.StatusOK, result.Error(xerr.ServerCommonError, err.Error()) | 79 | return http.StatusOK, result.Error(xerr.ServerCommonError, err.Error()) |
| 75 | }) | 80 | }) |
| 81 | + | ||
| 76 | // 系统成功应答包装 | 82 | // 系统成功应答包装 |
| 77 | httpx.SetOkHandler(func(ctx context.Context, a any) any { | 83 | httpx.SetOkHandler(func(ctx context.Context, a any) any { |
| 78 | return result.Success(a) | 84 | return result.Success(a) |
| @@ -10,11 +10,12 @@ import ( | @@ -10,11 +10,12 @@ import ( | ||
| 10 | type Config struct { | 10 | type Config struct { |
| 11 | rest.RestConf | 11 | rest.RestConf |
| 12 | config.Config | 12 | config.Config |
| 13 | - Redis redis.RedisConf `json:",optional"` | ||
| 14 | - SystemAuth config.Auth | ||
| 15 | - MiniAuth config.Auth | ||
| 16 | - Migrate bool `json:",optional,default=true"` | ||
| 17 | - ApiAuth ApiService | 13 | + Redis redis.RedisConf `json:",optional"` |
| 14 | + SystemAuth config.Auth | ||
| 15 | + MiniAuth config.Auth | ||
| 16 | + Migrate bool `json:",optional,default=true"` | ||
| 17 | + ApiAuth ApiService | ||
| 18 | + DebugSmsCode string `json:",optional,default=999512"` | ||
| 18 | } | 19 | } |
| 19 | 20 | ||
| 20 | type ApiService struct { | 21 | type ApiService struct { |
| @@ -32,7 +32,9 @@ func (l *MiniBusinessLogic) MiniBusiness(req *types.MessageRequest, msgType doma | @@ -32,7 +32,9 @@ func (l *MiniBusinessLogic) MiniBusiness(req *types.MessageRequest, msgType doma | ||
| 32 | 32 | ||
| 33 | 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(). |
| 34 | WithOffsetLimit(req.Page, req.Size). | 34 | WithOffsetLimit(req.Page, req.Size). |
| 35 | - WithKV("type", msgType)) | 35 | + WithKV("type", msgType). |
| 36 | + WithKV("companyId", userToken.CompanyId). | ||
| 37 | + WithKV("recipientId", userToken.UserId)) | ||
| 36 | if err != nil { | 38 | if err != nil { |
| 37 | return nil, err | 39 | return nil, err |
| 38 | } | 40 | } |
| @@ -119,10 +119,14 @@ func (c WxClientLogin) PhonePasswordLogin(phone string, password string) (*domai | @@ -119,10 +119,14 @@ func (c WxClientLogin) PhonePasswordLogin(phone string, password string) (*domai | ||
| 119 | 119 | ||
| 120 | func (c WxClientLogin) PhoneSmsCodeLogin(phone string, code string) (*domain.LoginInfo, error) { | 120 | func (c WxClientLogin) PhoneSmsCodeLogin(phone string, code string) (*domain.LoginInfo, error) { |
| 121 | var ( | 121 | var ( |
| 122 | - users []*domain.User | ||
| 123 | - err error | 122 | + users []*domain.User |
| 123 | + err error | ||
| 124 | + skipCheckSmsCode bool = false | ||
| 124 | ) | 125 | ) |
| 125 | - if _, err = c.l.svcCtx.SmsService.CheckSmsCode(c.l.ctx, smslib.RequestCheckSmsCode{Phone: phone, Code: code}); err != nil { | 126 | + if c.l.svcCtx.Config.DebugSmsCode != "" && c.l.svcCtx.Config.DebugSmsCode == code { |
| 127 | + skipCheckSmsCode = true | ||
| 128 | + } | ||
| 129 | + if _, err = c.l.svcCtx.SmsService.CheckSmsCode(c.l.ctx, smslib.RequestCheckSmsCode{Phone: phone, Code: code}); err != nil && !skipCheckSmsCode { | ||
| 126 | return nil, xerr.NewErrMsgErr(err.Error(), err) | 130 | return nil, xerr.NewErrMsgErr(err.Error(), err) |
| 127 | } | 131 | } |
| 128 | conn := c.l.svcCtx.DefaultDBConn() | 132 | conn := c.l.svcCtx.DefaultDBConn() |
deploy/database/v1.0.0 升级脚本.sql
0 → 100644
| 1 | +-- 用户表 | ||
| 2 | +-- (公司ID)索引 | ||
| 3 | +CREATE INDEX IF NOT EXISTS idx_user_company_id ON "public"."user" USING btree(company_id); | ||
| 4 | +-- (手机号)索引 | ||
| 5 | +CREATE INDEX IF NOT EXISTS idx_user_phone ON "public"."user" USING btree(phone); | ||
| 6 | + | ||
| 7 | +-- 用户关注表 | ||
| 8 | +-- (发起人)索引 | ||
| 9 | +CREATE INDEX IF NOT EXISTS idx_user_follow_from_user_id on "public".user_follow USING btree(from_user_id); | ||
| 10 | + | ||
| 11 | +-- 角色表 | ||
| 12 | +-- (公司ID)索引 | ||
| 13 | +CREATE INDEX IF NOT EXISTS idx_role_company_id ON "public"."role" USING btree(company_id); |
-
请 注册 或 登录 后发表评论