作者 yangfu

1.推送修改,推送设备信息存储

... ... @@ -108,6 +108,7 @@ func UpdateDevice(header *protocol.RequestHeader, request *protocol.UpdateDevice
rep, _ := repository.NewPushDeviceRepository(nil)
if _, err = rep.FindOne(map[string]interface{}{"uid": request.Muid}); err != nil {
if err == protocol.ERR_DB_NOT_FOUND {
err = nil
rep.Save(request)
return
}
... ...
... ... @@ -31,6 +31,7 @@ func (repository *PushDeviceRepository) FindOne(queryOptions map[string]interfac
qs := o.QueryTable(model.TableName()).Filter("uid", queryOptions["uid"])
err := qs.One(model)
if err != nil {
err = domain.ERR_DB_NOT_FOUND
return nil, err
}
return repository.transformBgormModelToDomainModel(model)
... ... @@ -54,7 +55,7 @@ func (repository *PushDeviceRepository) Find(queryOptions map[string]interface{}
func (repository *PushDeviceRepository) UpdateDevice(uid int64, clientId, deviceToken string) error {
o := orm.NewOrm()
_, err := o.Raw("UPDATE push_device_info SET client_id=?,device_token = ? where uid=?", clientId, deviceToken, uid).Exec()
_, err := o.Raw("UPDATE push_device_info SET client_id=?,device_token = ?,update_at=now() where uid=?", clientId, deviceToken, uid).Exec()
if err != nil {
return err
}
... ...