作者 yangfu

Merge branch 'dev' into test

@@ -52,7 +52,7 @@ type ( @@ -52,7 +52,7 @@ 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针对文章、1针对评论、2针对圆桌) 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
@@ -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"` // 微信登录 授权码
@@ -212,6 +212,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { @@ -212,6 +212,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
212 }, 212 },
213 { 213 {
214 Method: http.MethodPost, 214 Method: http.MethodPost,
  215 + Path: "/mini/user/info/edit",
  216 + Handler: user.MiniEditUserInfoHandler(serverCtx),
  217 + },
  218 + {
  219 + Method: http.MethodPost,
215 Path: "/mini/user/statistics", 220 Path: "/mini/user/statistics",
216 Handler: user.MiniUserStatisticsHandler(serverCtx), 221 Handler: user.MiniUserStatisticsHandler(serverCtx),
217 }, 222 },
  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 +}
  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 +}
@@ -278,7 +278,7 @@ type MessageBusinessResponse struct { @@ -278,7 +278,7 @@ type MessageBusinessResponse struct {
278 type MessageBusinessItem struct { 278 type MessageBusinessItem struct {
279 Id int64 `json:"id"` 279 Id int64 `json:"id"`
280 Type int `json:"type"` // 分类 (1回复 2点赞 3被采纳) 280 Type int `json:"type"` // 分类 (1回复 2点赞 3被采纳)
281 - OptType int `json:"optType"` // 操作类型(1针对文章、1针对评论、2针对圆桌) 281 + OptType int `json:"optType"` // 操作类型(1针对文章、2针对评论、3针对圆桌)
282 CompanyId int64 `json:"companyId"` // 操作人公司ID 282 CompanyId int64 `json:"companyId"` // 操作人公司ID
283 UserId int64 `json:"userId"` // 操作人用户ID 283 UserId int64 `json:"userId"` // 操作人用户ID
284 RecipientId int64 `json:"recipientId"` // 接收者ID 284 RecipientId int64 `json:"recipientId"` // 接收者ID
@@ -402,6 +402,13 @@ type TagOptionValue struct { @@ -402,6 +402,13 @@ type TagOptionValue struct {
402 Value int64 `json:"value"` // 标签ID 402 Value int64 `json:"value"` // 标签ID
403 } 403 }
404 404
  405 +type MiniEditUserInfoRequest struct {
  406 + Avatar *string `json:"avatar"`
  407 +}
  408 +
  409 +type MiniEditUserInfoResponse struct {
  410 +}
  411 +
405 type MiniUserLoginRequest struct { 412 type MiniUserLoginRequest struct {
406 LoginType string `json:"loginType"` // 登录类型 wechat-login whchat-phone-login phone-password-login phone-smscode-login 413 LoginType string `json:"loginType"` // 登录类型 wechat-login whchat-phone-login phone-password-login phone-smscode-login
407 WechatAuthCode string `json:"wechatAuthcode,optional"` // 微信登录 授权码 414 WechatAuthCode string `json:"wechatAuthcode,optional"` // 微信登录 授权码
@@ -12,7 +12,7 @@ import ( @@ -12,7 +12,7 @@ import (
12 type MessageBusiness struct { 12 type MessageBusiness struct {
13 Id int64 // 唯一标识 13 Id int64 // 唯一标识
14 Type int `json:"type"` // 分类 (1回复 2点赞 3被采纳) 14 Type int `json:"type"` // 分类 (1回复 2点赞 3被采纳)
15 - OptType int `json:"optType"` // 操作类型(1针对文章、1针对评论、2针对圆桌) 15 + OptType int `json:"optType"` // 操作类型(1针对文章、2针对评论、3针对圆桌)
16 CompanyId int64 `json:"companyId"` // 操作人公司ID 16 CompanyId int64 `json:"companyId"` // 操作人公司ID
17 UserId int64 `json:"userId"` // 操作人用户ID 17 UserId int64 `json:"userId"` // 操作人用户ID
18 RecipientId int64 `json:"recipientId"` // 接收人用户ID 18 RecipientId int64 `json:"recipientId"` // 接收人用户ID
@@ -8,7 +8,7 @@ import ( @@ -8,7 +8,7 @@ import (
8 type MessageBusiness struct { 8 type MessageBusiness struct {
9 Id int64 // 唯一标识 9 Id int64 // 唯一标识
10 Type MsgBusinessType `json:"type"` // 分类 (1回复 2点赞 3被采纳) 10 Type MsgBusinessType `json:"type"` // 分类 (1回复 2点赞 3被采纳)
11 - OptType MsgBusinessOpt `json:"optType"` // 操作类型(1针对文章、1针对评论、2针对圆桌) 11 + OptType MsgBusinessOpt `json:"optType"` // 操作类型(1针对文章、2针对评论、3针对圆桌)
12 CompanyId int64 `json:"companyId"` // 操作人公司ID 12 CompanyId int64 `json:"companyId"` // 操作人公司ID
13 UserId int64 `json:"userId"` // 操作人用户ID 13 UserId int64 `json:"userId"` // 操作人用户ID
14 RecipientId int64 `json:"recipientId"` // 接收人用户ID 14 RecipientId int64 `json:"recipientId"` // 接收人用户ID