Commit cec30e8a by yuzixun

添加APP端已经接收的接口

parent 36e5806e
......@@ -52,4 +52,17 @@ class PushsController < ApplicationController
render json: { code: -1, message: 'token 错误/过期'}
end
end
def received
param! :notification_id, Integer, required: true
param! :user_id, Integer, required: true
param! :app_type, String, required: true
param! :device_model, String, required: true
notification_stat = NotificationStatistic.find_by(user_id: params[:user_id], notification_id: params[:notification_id], app_type: params[:app_type])
notification_stat.update(device_model: params[:device_model], is_received: true) if notification_stat.present?
render json: { code: 0, message: "success" }
end
end
......@@ -17,9 +17,11 @@ class NotificationStatistic < ApplicationRecord
device_ids_opts.each do |platform, client_ids|
client_ids.each do |client_id|
next if message[:id].blank?
NotificationStatistic.create(
organization_id: igetui_opts[:organization_id],
user_id: message[:user_id],
user_id: message[:user_id] || igetui_opts[:user_id],
notification_id: message[:id],
client_id: client_id,
platform: platform,
......
......@@ -2,6 +2,7 @@ Rails.application.routes.draw do
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
post 'api/v1/token', to: 'pushs#token'
post 'api/v1/push', to: 'pushs#push'
put 'api/v1/received', to: 'pushs#received'
require 'sidekiq/web'
mount Sidekiq::Web => '/sidekiq'
......
class CreateNotificationStatistics < ActiveRecord::Migration[5.2]
def change
create_table :notification_statistics do |t|
t.integer :organization_id, comment: "关联公司"
t.integer :user_id, comment: "关联用户" # user id
t.integer :notification_id, comment: "关联通知ID" # id
t.boolean :is_received, comment: "是否收到" # APP 上报
t.integer :organization_id, index: true, comment: "关联公司"
t.integer :user_id, index: true, comment: "关联用户" # user id
t.integer :notification_id, index: true, comment: "关联通知ID" # id
t.boolean :is_received, default: false, comment: "是否收到" # APP 上报
t.string :client_id, comment: "个推ClientID" # 接口调用
t.integer :platform, comment: "推送平台" #
t.integer :device_platform, comment: "系统" # device_platform
......
......@@ -14675,7 +14675,7 @@ ActiveRecord::Schema.define(version: 2020_02_28_052609) do
t.integer "organization_id", comment: "关联公司"
t.integer "user_id", comment: "关联用户"
t.integer "notification_id", comment: "关联通知ID"
t.boolean "is_received", comment: "是否收到"
t.boolean "is_received", default: false, comment: "是否收到"
t.string "client_id", comment: "个推ClientID"
t.integer "platform", comment: "推送平台"
t.integer "device_platform", comment: "系统"
......@@ -14684,6 +14684,9 @@ ActiveRecord::Schema.define(version: 2020_02_28_052609) do
t.string "ip", comment: "IP地址"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["notification_id"], name: "index_notification_statistics_on_notification_id"
t.index ["organization_id"], name: "index_notification_statistics_on_organization_id"
t.index ["user_id"], name: "index_notification_statistics_on_user_id"
end
create_table "notifications", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC", force: :cascade do |t|
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment