Parcourir la source

update

master
DengBiao il y a 2 ans
Parent
révision
b9fb32157e
13 fichiers modifiés avec 68 ajouts et 28 suppressions
  1. +11
    -0
      chart/templates/configmap/configmap-prd.yaml
  2. +1
    -1
      chart/templates/server/business.yaml
  3. +1
    -1
      chart/templates/server/connect.yaml
  4. +1
    -1
      chart/templates/server/logic.yaml
  5. +1
    -1
      cmd/business/main.go
  6. +1
    -1
      internal/business/api/business_ext.go
  7. +2
    -2
      internal/business/app/auth_app.go
  8. +2
    -2
      internal/business/comm/db/db_user_push_for_jg.go
  9. +21
    -1
      internal/business/domain/user/service/auth.go
  10. +2
    -2
      internal/logic/domain/message/service/app_push.go
  11. +23
    -16
      internal/logic/domain/message/service/message_service.go
  12. +1
    -0
      pkg/pb/business.ext.pb.go
  13. +1
    -0
      pkg/proto/business.ext.proto

+ 11
- 0
chart/templates/configmap/configmap-prd.yaml Voir le fichier

@@ -0,0 +1,11 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: config
data:
# 类属性键;每一个键都映射到一个简单的值,仅仅支持键值对,不支持嵌套
mysql: "root:ZHIoscnfnuo123@@tcp(zhios123.rwlb.rds.aliyuncs.com:3306)/gim?charset=utf8&parseTime=true"
redisIP: "116.62.62.35:6379"
redisPassword: "dengsanhu"
pushRoomSubscribeNum: "100"
pushAllSubscribeNum: "100"

+ 1
- 1
chart/templates/server/business.yaml Voir le fichier

@@ -18,7 +18,7 @@ spec:
spec:
containers:
- name: business
image: 'registry.cn-shenzhen.aliyuncs.com/fnuoos-prd/zyos-gim-business:202209020-03'
image: 'registry.cn-shenzhen.aliyuncs.com/fnuoos-prd/zyos-gim-business:20221128-01'
imagePullPolicy: Always
ports:
- containerPort: 8000


+ 1
- 1
chart/templates/server/connect.yaml Voir le fichier

@@ -18,7 +18,7 @@ spec:
spec:
containers:
- name: connect
image: 'registry.cn-shenzhen.aliyuncs.com/fnuoos-prd/zyos-gim-connect:202209018-03'
image: 'registry.cn-shenzhen.aliyuncs.com/fnuoos-prd/zyos-gim-connect:20221128-01'
imagePullPolicy: Always
ports:
- containerPort: 8000


+ 1
- 1
chart/templates/server/logic.yaml Voir le fichier

@@ -18,7 +18,7 @@ spec:
spec:
containers:
- name: logic
image: 'registry.cn-shenzhen.aliyuncs.com/fnuoos-prd/zyos-gim-logic:202209018-04'
image: 'registry.cn-shenzhen.aliyuncs.com/fnuoos-prd/zyos-gim-logic:20221128-01'
imagePullPolicy: Always # 在kind中需要指定,不然会强制到远程拉取镜像,导致部署失败
ports:
- containerPort: 8001


+ 1
- 1
cmd/business/main.go Voir le fichier

@@ -18,7 +18,7 @@ import (
)

func main() {
//config.Init()
config.Init()
db.Init()

server := grpc.NewServer(grpc.UnaryInterceptor(interceptor.NewInterceptor("business_interceptor", urlwhitelist.Business)))


+ 1
- 1
internal/business/api/business_ext.go Voir le fichier

@@ -13,7 +13,7 @@ import (
type BusinessExtServer struct{}

func (s *BusinessExtServer) SignIn(ctx context.Context, req *pb.SignInReq) (*pb.SignInResp, error) {
isNew, userId, token, masterId, err := app.AuthApp.SignIn(ctx, req.PhoneNumber, req.Code, req.MasterId, req.DeviceId)
isNew, userId, token, masterId, err := app.AuthApp.SignIn(ctx, req.PhoneNumber, req.Code, req.MasterId, req.DeviceId, req.PushAlia)
if err != nil {
return nil, err
}


+ 2
- 2
internal/business/app/auth_app.go Voir le fichier

@@ -10,8 +10,8 @@ type authApp struct{}
var AuthApp = new(authApp)

// SignIn 长连接登录
func (*authApp) SignIn(ctx context.Context, phoneNumber, code string, masterId, deviceId int64) (bool, int64, string, int64, error) {
return service.AuthService.SignIn(ctx, phoneNumber, code, masterId, deviceId)
func (*authApp) SignIn(ctx context.Context, phoneNumber, code string, masterId, deviceId int64, pushAlia string) (bool, int64, string, int64, error) {
return service.AuthService.SignIn(ctx, phoneNumber, code, masterId, deviceId, pushAlia)
}

// Auth 验证用户是否登录


+ 2
- 2
internal/business/comm/db/db_user_push_for_jg.go Voir le fichier

@@ -15,9 +15,9 @@ type dbUserPushForJg struct{}
var DbUserPushForJg = new(dbUserPushForJg)

// UserPushForJgGetOne 获取一条记录
func (*dbUserPushForJg) UserPushForJgGetOne(key string, masterId int64) (*model.UserPushForJg, error) {
func (*dbUserPushForJg) UserPushForJgGetOne(uid string, masterId int64) (*model.UserPushForJg, error) {
var cfgList model.UserPushForJg
if err := db.DB.Where("`key` = ? and `master_id` = ?", key, masterId).First(&cfgList).Error; err != nil {
if err := db.DB.Where("`uid` = ? and `master_id` = ?", uid, masterId).First(&cfgList).Error; err != nil {
return nil, gerrors.WrapError(err)
}
return &cfgList, nil


+ 21
- 1
internal/business/domain/user/service/auth.go Voir le fichier

@@ -2,12 +2,15 @@ package service

import (
"context"
"errors"
"gim/internal/business/comm/db"
"gim/internal/business/domain/user/model"
"gim/internal/business/domain/user/repo"
"gim/pkg/gerrors"
"gim/pkg/pb"
"gim/pkg/rpc"
"gim/pkg/util"
"strconv"
"time"
)

@@ -16,7 +19,7 @@ type authService struct{}
var AuthService = new(authService)

// SignIn 登录
func (*authService) SignIn(ctx context.Context, phoneNumber, code string, masterId, deviceId int64) (bool, int64, string, int64, error) {
func (*authService) SignIn(ctx context.Context, phoneNumber, code string, masterId, deviceId int64, pushAlia string) (bool, int64, string, int64, error) {
if !Verify(phoneNumber, code) {
return false, 0, "", 0, gerrors.ErrBadCode
}
@@ -58,6 +61,23 @@ func (*authService) SignIn(ctx context.Context, phoneNumber, code string, master
return false, 0, "", 0, err
}

if pushAlia != "" {
userPushForJg, err := db.DbUserPushForJg.UserPushForJgGetOne(strconv.FormatInt(user.Id, 10), masterId)
if err != nil {
return false, 0, "", 0, err
}
if userPushForJg == nil {
save := db.DbUserPushForJg.UserPushForJgInsert(user.Id, masterId, pushAlia)
if !save {
return false, 0, "", 0, errors.New("插入user_push_for_jg记录失败")
}
} else {
update := db.DbUserPushForJg.UserPushForJgUpdate(user.Id, masterId, pushAlia)
if !update {
return false, 0, "", 0, errors.New("修改user_push_for_jg记录失败")
}
}
}
return isNew, user.Id, token, masterId, nil
}



+ 2
- 2
internal/logic/domain/message/service/app_push.go Voir le fichier

@@ -33,8 +33,8 @@ func JgPush(args md3.PushParams) {
if thirdJgPush["jg_push_app_key"] == "" || thirdJgPush["jg_push_app_secret"] == "" {
return
}
alia := db.DbUserPushForJg.UserPushForJgGetWithDb(args.MasterId, args.Uid)
var aud = md2.PushAudience{Alias: []string{alia}}
//alia := db.DbUserPushForJg.UserPushForJgGetWithDb(args.MasterId, args.Uid)
var aud = md2.PushAudience{Alias: []string{args.PushAlia}}
var extras interface{}
var param = md2.PushParam{
Platform: "all",


+ 23
- 16
internal/logic/domain/message/service/message_service.go Voir le fichier

@@ -2,6 +2,7 @@ package service

import (
"context"
"gim/internal/business/comm/db"
svc "gim/internal/business/comm/service"
"gim/internal/logic/domain/message/md"
"gim/internal/logic/domain/message/model"
@@ -157,26 +158,32 @@ func (*messageService) SendToUser(ctx context.Context, sender *pb.Sender, toUser
return 0, err
}

var isPush = false
for i := range devices {
// 消息不需要投递给发送消息的设备
if sender.DeviceId == devices[i].DeviceId {
if sender.DeviceId == devices[i].DeviceId && !isPush {
isOpenAppPush := svc.SysCfgGet(masterId, "is_open_app_push")
if req.ReceiverType == 1 && isOpenAppPush == "1" {
//TODO::接收者类型为`user`, 进行极光推送
CommAddPush(md.PushParams{
MasterId: masterId,
Uid: strconv.FormatInt(req.ReceiverId, 10),
PushAlia: "",
Title: "新消息提醒",
Content: "",
PushType: "zhi_ying_gim",
MessageType: req.MessageType.String(),
SendUserNickname: sender.Nickname,
SendUserAvatarUrl: sender.AvatarUrl,
Memo: sender.SenderType.String(),
Times: time.Now().Format("2006-01-02 15:04:05.000"),
})
uid := strconv.FormatInt(req.ReceiverId, 10)
alia := db.DbUserPushForJg.UserPushForJgGetWithDb(masterId, uid)
if alia != "" {
//TODO::接收者类型为`user`, 进行极光推送
CommAddPush(md.PushParams{
MasterId: masterId,
Uid: uid,
PushAlia: "",
Title: "新消息提醒",
Content: "",
PushType: "zhi_ying_gim",
MessageType: req.MessageType.String(),
SendUserNickname: sender.Nickname,
SendUserAvatarUrl: sender.AvatarUrl,
Memo: sender.SenderType.String(),
Times: time.Now().Format("2006-01-02 15:04:05.000"),
})
isPush = true
}
}
// 消息不需要投递给发送消息的设备
continue
}



+ 1
- 0
pkg/pb/business.ext.pb.go Voir le fichier

@@ -33,6 +33,7 @@ type SignInReq struct {
Code string `protobuf:"bytes,2,opt,name=code,proto3" json:"code,omitempty"` // 验证码
DeviceId int64 `protobuf:"varint,3,opt,name=device_id,json=deviceId,proto3" json:"device_id,omitempty"` // 设备id
MasterId int64 `protobuf:"varint,4,opt,name=master_id,json=masterId,proto3" json:"master_id,omitempty"` // 站长id
PushAlia string `protobuf:"varint,5,opt,name=push_alia,json=pushAlia,proto3" json:"push_alia,omitempty"` // 极光推送-别名
}

func (x *SignInReq) Reset() {


+ 1
- 0
pkg/proto/business.ext.proto Voir le fichier

@@ -22,6 +22,7 @@ message SignInReq {
string code = 2; // 验证码
int64 device_id = 3; // 设备id
int64 master_id = 4; // 站长id
string push_alia = 5; // 极光推送-别名
}
message SignInResp {
bool is_new = 1; // 是否是新用户


Chargement…
Annuler
Enregistrer