作者 yangfu

1.推送修改

... ... @@ -8,6 +8,7 @@ import (
"openapi/pkg/infrastructure/push/getui"
"openapi/pkg/infrastructure/repository"
"openapi/pkg/infrastructure/utils"
"strings"
)
//推送信息
... ... @@ -105,9 +106,12 @@ func NotificationOriginal(header *protocol.RequestHeader, request *protocol.Push
//更新设备信息
func UpdateDevice(header *protocol.RequestHeader, request *protocol.UpdateDeviceRequest) (rsp *protocol.UpdateDeviceResponse, err error) {
var ()
var (
device *protocol.Device
)
rsp = &protocol.UpdateDeviceResponse{}
rep, _ := repository.NewPushDeviceRepository(nil)
if _, err = rep.FindOne(map[string]interface{}{"uid": request.Muid}); err != nil {
if device, err = rep.FindOne(map[string]interface{}{"uid": request.Muid}); err != nil {
if err == protocol.ERR_DB_NOT_FOUND {
err = nil
rep.Save(request)
... ... @@ -116,6 +120,10 @@ func UpdateDevice(header *protocol.RequestHeader, request *protocol.UpdateDevice
log.Error(err)
return
}
if device.ClientId == strings.TrimSpace(request.ClientId) && device.DeviceToken == strings.TrimSpace(request.DeviceToken) {
err = protocol.NewSuccessWithMessage("更新成功")
return
}
if err = rep.UpdateDevice(request.Muid, request.ClientId, request.DeviceToken); err != nil {
log.Error(err)
}
... ...