Merge remote-tracking branch 'origin/dev' into dev
正在显示
17 个修改的文件
包含
319 行增加
和
14 行删除
| @@ -18,9 +18,17 @@ service Core { | @@ -18,9 +18,17 @@ service Core { | ||
| 18 | @handler commonSmsCode | 18 | @handler commonSmsCode |
| 19 | post /common/sms/code (CommonSmsCodeRequest) returns (CommonSmsCodeResposne) | 19 | post /common/sms/code (CommonSmsCodeRequest) returns (CommonSmsCodeResposne) |
| 20 | 20 | ||
| 21 | + @doc "微信二维码" | ||
| 22 | + @handler miniQrcodeInvite | ||
| 23 | + post /mini/qrcode (MiniQrCodeRequest) | ||
| 24 | + | ||
| 21 | @doc "日志查询" | 25 | @doc "日志查询" |
| 22 | @handler commonGetLog | 26 | @handler commonGetLog |
| 23 | get /log/:module | 27 | get /log/:module |
| 28 | + | ||
| 29 | + @doc "清理缓存" | ||
| 30 | + @handler commonGetClearCache | ||
| 31 | + get /clear | ||
| 24 | } | 32 | } |
| 25 | 33 | ||
| 26 | // 短信验证码 | 34 | // 短信验证码 |
| @@ -32,3 +40,11 @@ type( | @@ -32,3 +40,11 @@ type( | ||
| 32 | 40 | ||
| 33 | } | 41 | } |
| 34 | ) | 42 | ) |
| 43 | + | ||
| 44 | +type( | ||
| 45 | + MiniQrCodeRequest{ | ||
| 46 | + Page string `json:"page"` // 微信页面入口 | ||
| 47 | + Path string `json:"path"` // | ||
| 48 | + Scene string `json:"scene"` // 参数 | ||
| 49 | + } | ||
| 50 | +) |
| @@ -34,6 +34,9 @@ service Core { | @@ -34,6 +34,9 @@ service Core { | ||
| 34 | @doc "用户信息" | 34 | @doc "用户信息" |
| 35 | @handler miniUserInfo | 35 | @handler miniUserInfo |
| 36 | post /mini/user/info (MiniUserInfoRequest) returns (MiniUserInfoResponse) | 36 | post /mini/user/info (MiniUserInfoRequest) returns (MiniUserInfoResponse) |
| 37 | + @doc "编辑用户信息" | ||
| 38 | + @handler miniEditUserInfo | ||
| 39 | + post /mini/user/info/edit (MiniEditUserInfoRequest) returns (MiniEditUserInfoResponse) | ||
| 37 | @doc "用户统计" | 40 | @doc "用户统计" |
| 38 | @handler miniUserStatistics | 41 | @handler miniUserStatistics |
| 39 | post /mini/user/statistics (UserStatisticsRequest) returns (UserStatisticsResponse) | 42 | post /mini/user/statistics (UserStatisticsRequest) returns (UserStatisticsResponse) |
| @@ -79,6 +82,15 @@ service Core { | @@ -79,6 +82,15 @@ service Core { | ||
| 79 | } | 82 | } |
| 80 | 83 | ||
| 81 | type( | 84 | type( |
| 85 | + MiniEditUserInfoRequest{ | ||
| 86 | + Avatar *string `json:"avatar"` | ||
| 87 | + } | ||
| 88 | + MiniEditUserInfoResponse{ | ||
| 89 | + | ||
| 90 | + } | ||
| 91 | +) | ||
| 92 | + | ||
| 93 | +type( | ||
| 82 | MiniUserLoginRequest { | 94 | MiniUserLoginRequest { |
| 83 | LoginType string `json:"loginType"` // 登录类型 wechat-login whchat-phone-login phone-password-login phone-smscode-login | 95 | LoginType string `json:"loginType"` // 登录类型 wechat-login whchat-phone-login phone-password-login phone-smscode-login |
| 84 | WechatAuthCode string `json:"wechatAuthcode,optional"` // 微信登录 授权码 | 96 | WechatAuthCode string `json:"wechatAuthcode,optional"` // 微信登录 授权码 |
| @@ -342,9 +354,10 @@ type( | @@ -342,9 +354,10 @@ type( | ||
| 342 | ItemFlag int `json:"itemFlag"` //0:默认查询所有 1:他的帖子 2:他的评论/回复 4:他收到的赞 8:TA的圆桌讨论 16:被采纳 | 354 | ItemFlag int `json:"itemFlag"` //0:默认查询所有 1:他的帖子 2:他的评论/回复 4:他收到的赞 8:TA的圆桌讨论 16:被采纳 |
| 343 | } | 355 | } |
| 344 | UserStatisticsResponse{ | 356 | UserStatisticsResponse{ |
| 345 | - TotalArticle int `json:"totalArticle"` | ||
| 346 | - TotalComment int `json:"totalComment"` | ||
| 347 | - TotalLoved int `json:"totalLoved"` | 357 | + TotalArticle int `json:"totalArticle"` // 累计发布文章 |
| 358 | + TotalComment int `json:"totalComment"` // 累计发布评论 | ||
| 359 | + TotalLoved int `json:"totalLoved"` // 累计赞别人 | ||
| 360 | + TotalBeLoved int `json:"totalBeLoved"` // 累计收到的赞 | ||
| 348 | } | 361 | } |
| 349 | StatisticsItem{ | 362 | StatisticsItem{ |
| 350 | ItemFlag int `json:"itemFlag"` // 1:他的帖子 2:他的评论/回复 4:他收到的赞 8:TA的圆桌讨论 16:被采纳 | 363 | ItemFlag int `json:"itemFlag"` // 1:他的帖子 2:他的评论/回复 4:他收到的赞 8:TA的圆桌讨论 16:被采纳 |
| 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 | + if err != nil { | ||
| 24 | + result.HttpResult(r, w, resp, err) | ||
| 25 | + } | ||
| 26 | + w.Header().Set("Content-Disposition", "attachment; filename="+"qrcode.png") | ||
| 27 | + w.Header().Set("Content-Type", "application/octet-stream") | ||
| 28 | + w.Write(resp) | ||
| 29 | + } | ||
| 30 | +} |
| @@ -27,10 +27,20 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { | @@ -27,10 +27,20 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { | ||
| 27 | Handler: common.CommonSmsCodeHandler(serverCtx), | 27 | Handler: common.CommonSmsCodeHandler(serverCtx), |
| 28 | }, | 28 | }, |
| 29 | { | 29 | { |
| 30 | + Method: http.MethodPost, | ||
| 31 | + Path: "/mini/qrcode", | ||
| 32 | + Handler: common.MiniQrcodeInviteHandler(serverCtx), | ||
| 33 | + }, | ||
| 34 | + { | ||
| 30 | Method: http.MethodGet, | 35 | Method: http.MethodGet, |
| 31 | Path: "/log/:module", | 36 | Path: "/log/:module", |
| 32 | Handler: common.CommonGetLogHandler(serverCtx), | 37 | Handler: common.CommonGetLogHandler(serverCtx), |
| 33 | }, | 38 | }, |
| 39 | + { | ||
| 40 | + Method: http.MethodGet, | ||
| 41 | + Path: "/clear", | ||
| 42 | + Handler: common.CommonGetClearCacheHandler(serverCtx), | ||
| 43 | + }, | ||
| 34 | }, | 44 | }, |
| 35 | rest.WithPrefix("/v1"), | 45 | rest.WithPrefix("/v1"), |
| 36 | ) | 46 | ) |
| @@ -212,6 +222,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { | @@ -212,6 +222,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { | ||
| 212 | }, | 222 | }, |
| 213 | { | 223 | { |
| 214 | Method: http.MethodPost, | 224 | Method: http.MethodPost, |
| 225 | + Path: "/mini/user/info/edit", | ||
| 226 | + Handler: user.MiniEditUserInfoHandler(serverCtx), | ||
| 227 | + }, | ||
| 228 | + { | ||
| 229 | + Method: http.MethodPost, | ||
| 215 | Path: "/mini/user/statistics", | 230 | Path: "/mini/user/statistics", |
| 216 | Handler: user.MiniUserStatisticsHandler(serverCtx), | 231 | Handler: user.MiniUserStatisticsHandler(serverCtx), |
| 217 | }, | 232 | }, |
| 1 | +package user | ||
| 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/user" | ||
| 8 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | ||
| 9 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | ||
| 10 | +) | ||
| 11 | + | ||
| 12 | +func MiniEditUserInfoHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
| 13 | + return func(w http.ResponseWriter, r *http.Request) { | ||
| 14 | + var req types.MiniEditUserInfoRequest | ||
| 15 | + if err := httpx.Parse(r, &req); err != nil { | ||
| 16 | + httpx.ErrorCtx(r.Context(), w, err) | ||
| 17 | + return | ||
| 18 | + } | ||
| 19 | + | ||
| 20 | + l := user.NewMiniEditUserInfoLogic(r.Context(), svcCtx) | ||
| 21 | + resp, err := l.MiniEditUserInfo(&req) | ||
| 22 | + if err != nil { | ||
| 23 | + httpx.ErrorCtx(r.Context(), w, err) | ||
| 24 | + } else { | ||
| 25 | + httpx.OkJsonCtx(r.Context(), w, resp) | ||
| 26 | + } | ||
| 27 | + } | ||
| 28 | +} |
| @@ -154,7 +154,7 @@ func (l *MiniCreateArticleLogic) MiniCreateArticle(req *types.MiniArticleCreateR | @@ -154,7 +154,7 @@ func (l *MiniCreateArticleLogic) MiniCreateArticle(req *types.MiniArticleCreateR | ||
| 154 | WhoRead: whoRead, | 154 | WhoRead: whoRead, |
| 155 | WhoReview: whoReview, | 155 | WhoReview: whoReview, |
| 156 | Location: domain.Location{ | 156 | Location: domain.Location{ |
| 157 | - Longitude: req.Location.Latitude, | 157 | + Longitude: req.Location.Longitude, |
| 158 | Latitude: req.Location.Latitude, | 158 | Latitude: req.Location.Latitude, |
| 159 | Descript: req.Location.Descript, | 159 | Descript: req.Location.Descript, |
| 160 | }, | 160 | }, |
| 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 | + "github.com/samber/lo" | ||
| 6 | + "github.com/silenceper/wechat/v2/miniprogram/qrcode" | ||
| 7 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr" | ||
| 8 | + | ||
| 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 | + "github.com/zeromicro/go-zero/core/logx" | ||
| 13 | +) | ||
| 14 | + | ||
| 15 | +type MiniQrcodeInviteLogic struct { | ||
| 16 | + logx.Logger | ||
| 17 | + ctx context.Context | ||
| 18 | + svcCtx *svc.ServiceContext | ||
| 19 | +} | ||
| 20 | + | ||
| 21 | +func NewMiniQrcodeInviteLogic(ctx context.Context, svcCtx *svc.ServiceContext) *MiniQrcodeInviteLogic { | ||
| 22 | + return &MiniQrcodeInviteLogic{ | ||
| 23 | + Logger: logx.WithContext(ctx), | ||
| 24 | + ctx: ctx, | ||
| 25 | + svcCtx: svcCtx, | ||
| 26 | + } | ||
| 27 | +} | ||
| 28 | + | ||
| 29 | +func (l *MiniQrcodeInviteLogic) MiniQrcodeInvite(req *types.MiniQrCodeRequest) (resp []byte, err error) { | ||
| 30 | + q := l.svcCtx.MiniProgram.GetQRCode() | ||
| 31 | + var data []byte | ||
| 32 | + data, err = q.GetWXACodeUnlimit(qrcode.QRCoder{ | ||
| 33 | + Page: req.Page, | ||
| 34 | + Path: req.Page, | ||
| 35 | + Scene: req.Scene, | ||
| 36 | + CheckPath: lo.ToPtr(false), | ||
| 37 | + EnvVersion: "release", | ||
| 38 | + }) | ||
| 39 | + if err != nil { | ||
| 40 | + return nil, xerr.NewErr(err) | ||
| 41 | + } | ||
| 42 | + return data, nil | ||
| 43 | +} |
| @@ -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 | } |
| 1 | +package user | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "context" | ||
| 5 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | ||
| 6 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | ||
| 7 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/db/transaction" | ||
| 8 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain" | ||
| 9 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata" | ||
| 10 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr" | ||
| 11 | + | ||
| 12 | + "github.com/zeromicro/go-zero/core/logx" | ||
| 13 | +) | ||
| 14 | + | ||
| 15 | +type MiniEditUserInfoLogic struct { | ||
| 16 | + logx.Logger | ||
| 17 | + ctx context.Context | ||
| 18 | + svcCtx *svc.ServiceContext | ||
| 19 | +} | ||
| 20 | + | ||
| 21 | +func NewMiniEditUserInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *MiniEditUserInfoLogic { | ||
| 22 | + return &MiniEditUserInfoLogic{ | ||
| 23 | + Logger: logx.WithContext(ctx), | ||
| 24 | + ctx: ctx, | ||
| 25 | + svcCtx: svcCtx, | ||
| 26 | + } | ||
| 27 | +} | ||
| 28 | + | ||
| 29 | +func (l *MiniEditUserInfoLogic) MiniEditUserInfo(req *types.MiniEditUserInfoRequest) (resp *types.MiniEditUserInfoResponse, err error) { | ||
| 30 | + var ( | ||
| 31 | + conn = l.svcCtx.DefaultDBConn() | ||
| 32 | + user *domain.User | ||
| 33 | + userToken = contextdata.GetUserTokenFromCtx(l.ctx) | ||
| 34 | + ) | ||
| 35 | + user, err = l.svcCtx.UserRepository.FindOne(l.ctx, conn, userToken.UserId) | ||
| 36 | + if err != nil { | ||
| 37 | + return nil, err | ||
| 38 | + } | ||
| 39 | + if err = transaction.UseTrans(l.ctx, l.svcCtx.DB, func(ctx context.Context, conn transaction.Conn) error { | ||
| 40 | + user.Avatar = *req.Avatar | ||
| 41 | + if user, err = l.svcCtx.UserRepository.UpdateWithVersion(ctx, conn, user); err != nil { | ||
| 42 | + return err | ||
| 43 | + } | ||
| 44 | + return nil | ||
| 45 | + }, true); err != nil { | ||
| 46 | + return nil, xerr.NewErrMsgErr("更新头像失败", err) | ||
| 47 | + } | ||
| 48 | + resp = &types.MiniEditUserInfoResponse{} | ||
| 49 | + return | ||
| 50 | +} |
| @@ -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 | } |
| @@ -35,6 +35,7 @@ func (l *SystemUserStatisticsLogic) SystemUserStatistics(req *types.UserStatisti | @@ -35,6 +35,7 @@ func (l *SystemUserStatisticsLogic) SystemUserStatistics(req *types.UserStatisti | ||
| 35 | TotalArticle: s.TotalArticle, | 35 | TotalArticle: s.TotalArticle, |
| 36 | TotalComment: s.TotalComment, | 36 | TotalComment: s.TotalComment, |
| 37 | TotalLoved: s.TotalLoved, | 37 | TotalLoved: s.TotalLoved, |
| 38 | + TotalBeLoved: s.TotalBeLoved, | ||
| 38 | } | 39 | } |
| 39 | return | 40 | return |
| 40 | } | 41 | } |
| @@ -57,8 +58,13 @@ func StatisticsItems(ctx context.Context, svcCtx *svc.ServiceContext, companyId, | @@ -57,8 +58,13 @@ func StatisticsItems(ctx context.Context, svcCtx *svc.ServiceContext, companyId, | ||
| 57 | } | 58 | } |
| 58 | if (itemFlag & TotalLoved) > 0 { | 59 | if (itemFlag & TotalLoved) > 0 { |
| 59 | var total int64 | 60 | var total int64 |
| 60 | - total, _, _ = svcCtx.UserLoveFlagRepository.Find(ctx, conn, domain.IndexCompanyId(companyId)().WithCountOnly().MustWithKV("userId", userId)) | ||
| 61 | - s.TotalComment = int(total) | 61 | + total, _, _ = svcCtx.UserLoveFlagRepository.Find(ctx, conn, domain.IndexCompanyId(0)().WithCountOnly().MustWithKV("userId", userId)) |
| 62 | + s.TotalLoved = int(total) | ||
| 63 | + } | ||
| 64 | + if (itemFlag & TotalBeLoved) > 0 { | ||
| 65 | + var total int64 | ||
| 66 | + total, _, _ = svcCtx.UserLoveFlagRepository.Find(ctx, conn, domain.IndexCompanyId(0)().WithCountOnly().MustWithKV("toUserId", userId)) | ||
| 67 | + s.TotalBeLoved = int(total) | ||
| 62 | } | 68 | } |
| 63 | return | 69 | return |
| 64 | } | 70 | } |
| @@ -67,12 +73,14 @@ type Statistics struct { | @@ -67,12 +73,14 @@ type Statistics struct { | ||
| 67 | TotalArticle int `json:"totalArticle"` | 73 | TotalArticle int `json:"totalArticle"` |
| 68 | TotalComment int `json:"totalComment"` | 74 | TotalComment int `json:"totalComment"` |
| 69 | TotalLoved int `json:"totalLoved"` | 75 | TotalLoved int `json:"totalLoved"` |
| 76 | + TotalBeLoved int `json:"totalBeLoved"` | ||
| 70 | } | 77 | } |
| 71 | 78 | ||
| 72 | const ( | 79 | const ( |
| 73 | - TotalArticle = 1 | ||
| 74 | - TotalComment = 2 | ||
| 75 | - TotalLoved = 4 | 80 | + TotalArticle = 1 // 累计发布文章 |
| 81 | + TotalComment = 2 // 累计发布评论 | ||
| 82 | + TotalLoved = 4 // 累计赞别人 | ||
| 83 | + TotalBeLoved = 8 // 累计收到的赞 | ||
| 76 | ) | 84 | ) |
| 77 | 85 | ||
| 78 | func NewStatisticsItem(itemFlag int, value float64) types.StatisticsItem { | 86 | func NewStatisticsItem(itemFlag int, value float64) types.StatisticsItem { |
| 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" |
| @@ -44,6 +48,8 @@ type ServiceContext struct { | @@ -44,6 +48,8 @@ type ServiceContext struct { | ||
| 44 | ApiAuthService authlib.ApiAuthService | 48 | ApiAuthService authlib.ApiAuthService |
| 45 | SmsService smslib.SMSService | 49 | SmsService smslib.SMSService |
| 46 | 50 | ||
| 51 | + MiniProgram *miniprogram.MiniProgram | ||
| 52 | + | ||
| 47 | LoginStatusCheck rest.Middleware | 53 | LoginStatusCheck rest.Middleware |
| 48 | LogRequest rest.Middleware | 54 | LogRequest rest.Middleware |
| 49 | } | 55 | } |
| @@ -57,6 +63,11 @@ func NewServiceContext(c config.Config) *ServiceContext { | @@ -57,6 +63,11 @@ func NewServiceContext(c config.Config) *ServiceContext { | ||
| 57 | apiAuth := authlib.ApiAuthService{ | 63 | apiAuth := authlib.ApiAuthService{ |
| 58 | Service: gateway.NewService(c.ApiAuth.Name, c.ApiAuth.Host, c.ApiAuth.Timeout), | 64 | Service: gateway.NewService(c.ApiAuth.Name, c.ApiAuth.Host, c.ApiAuth.Timeout), |
| 59 | } | 65 | } |
| 66 | + miniProgram := wechat.NewWechat().GetMiniProgram(&miniConfig.Config{ | ||
| 67 | + AppID: c.Wechat.AppID, | ||
| 68 | + AppSecret: c.Wechat.AppSecret, | ||
| 69 | + Cache: minicache.NewMemory(), | ||
| 70 | + }) | ||
| 60 | return &ServiceContext{ | 71 | return &ServiceContext{ |
| 61 | Config: c, | 72 | Config: c, |
| 62 | DB: db, | 73 | DB: db, |
| @@ -65,6 +76,7 @@ func NewServiceContext(c config.Config) *ServiceContext { | @@ -65,6 +76,7 @@ func NewServiceContext(c config.Config) *ServiceContext { | ||
| 65 | SmsService: smslib.SMSService{Service: gateway.NewService("短信服务", "https://sms.fjmaimaimai.com:9897", time.Second*5)}, | 76 | SmsService: smslib.SMSService{Service: gateway.NewService("短信服务", "https://sms.fjmaimaimai.com:9897", time.Second*5)}, |
| 66 | LoginStatusCheck: middleware.NewLoginStatusCheckMiddleware(apiAuth).Handle, | 77 | LoginStatusCheck: middleware.NewLoginStatusCheckMiddleware(apiAuth).Handle, |
| 67 | LogRequest: middleware.NewLogRequestMiddleware(c.LogRequest).Handle, | 78 | LogRequest: middleware.NewLogRequestMiddleware(c.LogRequest).Handle, |
| 79 | + MiniProgram: miniProgram, | ||
| 68 | 80 | ||
| 69 | ArticleBackupRepository: repository.NewArticleBackupRepository(cache.NewCachedRepository(mlCache)), | 81 | ArticleBackupRepository: repository.NewArticleBackupRepository(cache.NewCachedRepository(mlCache)), |
| 70 | ArticleCommentRepository: repository.NewArticleCommentRepository(cache.NewCachedRepository(mlCache)), | 82 | 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"` // 人员的名字 |
| @@ -411,6 +416,13 @@ type TagOptionValue struct { | @@ -411,6 +416,13 @@ type TagOptionValue struct { | ||
| 411 | Value int64 `json:"value"` // 标签ID | 416 | Value int64 `json:"value"` // 标签ID |
| 412 | } | 417 | } |
| 413 | 418 | ||
| 419 | +type MiniEditUserInfoRequest struct { | ||
| 420 | + Avatar *string `json:"avatar"` | ||
| 421 | +} | ||
| 422 | + | ||
| 423 | +type MiniEditUserInfoResponse struct { | ||
| 424 | +} | ||
| 425 | + | ||
| 414 | type MiniUserLoginRequest struct { | 426 | type MiniUserLoginRequest struct { |
| 415 | LoginType string `json:"loginType"` // 登录类型 wechat-login whchat-phone-login phone-password-login phone-smscode-login | 427 | LoginType string `json:"loginType"` // 登录类型 wechat-login whchat-phone-login phone-password-login phone-smscode-login |
| 416 | WechatAuthCode string `json:"wechatAuthcode,optional"` // 微信登录 授权码 | 428 | WechatAuthCode string `json:"wechatAuthcode,optional"` // 微信登录 授权码 |
| @@ -637,9 +649,10 @@ type UserStatisticsRequest struct { | @@ -637,9 +649,10 @@ type UserStatisticsRequest struct { | ||
| 637 | } | 649 | } |
| 638 | 650 | ||
| 639 | type UserStatisticsResponse struct { | 651 | type UserStatisticsResponse struct { |
| 640 | - TotalArticle int `json:"totalArticle"` | ||
| 641 | - TotalComment int `json:"totalComment"` | ||
| 642 | - TotalLoved int `json:"totalLoved"` | 652 | + TotalArticle int `json:"totalArticle"` // 累计发布文章 |
| 653 | + TotalComment int `json:"totalComment"` // 累计发布评论 | ||
| 654 | + TotalLoved int `json:"totalLoved"` // 累计赞别人 | ||
| 655 | + TotalBeLoved int `json:"totalBeLoved"` // 累计收到的赞 | ||
| 643 | } | 656 | } |
| 644 | 657 | ||
| 645 | type StatisticsItem struct { | 658 | type StatisticsItem struct { |
| @@ -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" |
-
请 注册 或 登录 后发表评论