Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
app_push
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ikcrm_server
app_push
Commits
cec30e8a
Commit
cec30e8a
authored
Feb 28, 2020
by
yuzixun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加APP端已经接收的接口
parent
36e5806e
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
25 additions
and
6 deletions
+25
-6
app/controllers/pushs_controller.rb
+13
-0
app/models/notification_statistic.rb
+3
-1
config/routes.rb
+1
-0
db/migrate/20200228052609_create_notification_statistics.rb
+4
-4
db/schema.rb
+4
-1
No files found.
app/controllers/pushs_controller.rb
View file @
cec30e8a
...
@@ -52,4 +52,17 @@ class PushsController < ApplicationController
...
@@ -52,4 +52,17 @@ class PushsController < ApplicationController
render
json:
{
code:
-
1
,
message:
'token 错误/过期'
}
render
json:
{
code:
-
1
,
message:
'token 错误/过期'
}
end
end
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
end
app/models/notification_statistic.rb
View file @
cec30e8a
...
@@ -17,9 +17,11 @@ class NotificationStatistic < ApplicationRecord
...
@@ -17,9 +17,11 @@ class NotificationStatistic < ApplicationRecord
device_ids_opts
.
each
do
|
platform
,
client_ids
|
device_ids_opts
.
each
do
|
platform
,
client_ids
|
client_ids
.
each
do
|
client_id
|
client_ids
.
each
do
|
client_id
|
next
if
message
[
:id
].
blank?
NotificationStatistic
.
create
(
NotificationStatistic
.
create
(
organization_id:
igetui_opts
[
:organization_id
],
organization_id:
igetui_opts
[
:organization_id
],
user_id:
message
[
:user_id
],
user_id:
message
[
:user_id
]
||
igetui_opts
[
:user_id
]
,
notification_id:
message
[
:id
],
notification_id:
message
[
:id
],
client_id:
client_id
,
client_id:
client_id
,
platform:
platform
,
platform:
platform
,
...
...
config/routes.rb
View file @
cec30e8a
...
@@ -2,6 +2,7 @@ Rails.application.routes.draw do
...
@@ -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
# 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/token'
,
to:
'pushs#token'
post
'api/v1/push'
,
to:
'pushs#push'
post
'api/v1/push'
,
to:
'pushs#push'
put
'api/v1/received'
,
to:
'pushs#received'
require
'sidekiq/web'
require
'sidekiq/web'
mount
Sidekiq
::
Web
=>
'/sidekiq'
mount
Sidekiq
::
Web
=>
'/sidekiq'
...
...
db/migrate/20200228052609_create_notification_statistics.rb
View file @
cec30e8a
class
CreateNotificationStatistics
<
ActiveRecord
::
Migration
[
5.2
]
class
CreateNotificationStatistics
<
ActiveRecord
::
Migration
[
5.2
]
def
change
def
change
create_table
:notification_statistics
do
|
t
|
create_table
:notification_statistics
do
|
t
|
t
.
integer
:organization_id
,
comment:
"关联公司"
t
.
integer
:organization_id
,
index:
true
,
comment:
"关联公司"
t
.
integer
:user_id
,
comment:
"关联用户"
# user id
t
.
integer
:user_id
,
index:
true
,
comment:
"关联用户"
# user id
t
.
integer
:notification_id
,
comment:
"关联通知ID"
# id
t
.
integer
:notification_id
,
index:
true
,
comment:
"关联通知ID"
# id
t
.
boolean
:is_received
,
comment:
"是否收到"
# APP 上报
t
.
boolean
:is_received
,
default:
false
,
comment:
"是否收到"
# APP 上报
t
.
string
:client_id
,
comment:
"个推ClientID"
# 接口调用
t
.
string
:client_id
,
comment:
"个推ClientID"
# 接口调用
t
.
integer
:platform
,
comment:
"推送平台"
#
t
.
integer
:platform
,
comment:
"推送平台"
#
t
.
integer
:device_platform
,
comment:
"系统"
# device_platform
t
.
integer
:device_platform
,
comment:
"系统"
# device_platform
...
...
db/schema.rb
View file @
cec30e8a
...
@@ -14675,7 +14675,7 @@ ActiveRecord::Schema.define(version: 2020_02_28_052609) do
...
@@ -14675,7 +14675,7 @@ ActiveRecord::Schema.define(version: 2020_02_28_052609) do
t
.
integer
"organization_id"
,
comment:
"关联公司"
t
.
integer
"organization_id"
,
comment:
"关联公司"
t
.
integer
"user_id"
,
comment:
"关联用户"
t
.
integer
"user_id"
,
comment:
"关联用户"
t
.
integer
"notification_id"
,
comment:
"关联通知ID"
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
.
string
"client_id"
,
comment:
"个推ClientID"
t
.
integer
"platform"
,
comment:
"推送平台"
t
.
integer
"platform"
,
comment:
"推送平台"
t
.
integer
"device_platform"
,
comment:
"系统"
t
.
integer
"device_platform"
,
comment:
"系统"
...
@@ -14684,6 +14684,9 @@ ActiveRecord::Schema.define(version: 2020_02_28_052609) do
...
@@ -14684,6 +14684,9 @@ ActiveRecord::Schema.define(version: 2020_02_28_052609) do
t
.
string
"ip"
,
comment:
"IP地址"
t
.
string
"ip"
,
comment:
"IP地址"
t
.
datetime
"created_at"
,
null:
false
t
.
datetime
"created_at"
,
null:
false
t
.
datetime
"updated_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
end
create_table
"notifications"
,
id: :integer
,
options:
"ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC"
,
force: :cascade
do
|
t
|
create_table
"notifications"
,
id: :integer
,
options:
"ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC"
,
force: :cascade
do
|
t
|
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment