Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
杨树贤
/
kefu_server
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
babaca33
authored
Mar 19, 2020
by
chenxianqi
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
update
parent
cd528437
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
20 additions
and
28 deletions
controllers/public_controller.go
routers/router.go
services/message_service.go
ui/kefu_client/src/App.vue
controllers/public_controller.go
View file @
babaca33
...
@@ -203,11 +203,10 @@ func (c *PublicController) Read() {
...
@@ -203,11 +203,10 @@ func (c *PublicController) Read() {
// get user
// get user
user
:=
c
.
GetUserInfo
()
user
:=
c
.
GetUserInfo
()
if
user
==
nil
{
if
user
==
nil
{
c
.
JSON
(
configs
.
ResponseSucess
,
"查询成功!"
,
""
)
c
.
JSON
(
configs
.
ResponseSucess
,
"查询成功!"
,
0
)
}
}
id
,
_
:=
strconv
.
ParseInt
(
c
.
Ctx
.
Input
.
Param
(
":id"
),
10
,
64
)
readCount
,
err
:=
c
.
MessageRepository
.
GetReadCount
(
user
.
ID
)
readCount
,
err
:=
c
.
MessageRepository
.
GetReadCount
(
id
)
if
err
==
nil
{
if
err
==
nil
{
readCount
=
0
readCount
=
0
}
}
...
@@ -454,6 +453,16 @@ func (c *PublicController) Upload() {
...
@@ -454,6 +453,16 @@ func (c *PublicController) Upload() {
// CancelMessage cancel a message
// CancelMessage cancel a message
func
(
c
*
PublicController
)
CancelMessage
()
{
func
(
c
*
PublicController
)
CancelMessage
()
{
// get user
user
:=
c
.
GetUserInfo
()
if
user
==
nil
{
// GetAdminAuthInfo
auth
:=
c
.
GetAdminAuthInfo
()
if
auth
==
nil
{
c
.
JSON
(
configs
.
ResponseFail
,
"撤回失败!"
,
nil
)
}
}
removeMessageRequestDto
:=
models
.
RemoveMessageRequestDto
{}
removeMessageRequestDto
:=
models
.
RemoveMessageRequestDto
{}
if
err
:=
json
.
Unmarshal
(
c
.
Ctx
.
Input
.
RequestBody
,
&
removeMessageRequestDto
);
err
!=
nil
{
if
err
:=
json
.
Unmarshal
(
c
.
Ctx
.
Input
.
RequestBody
,
&
removeMessageRequestDto
);
err
!=
nil
{
c
.
JSON
(
configs
.
ResponseFail
,
"参数有误,请检查!"
,
nil
)
c
.
JSON
(
configs
.
ResponseFail
,
"参数有误,请检查!"
,
nil
)
...
@@ -488,31 +497,12 @@ func (c *PublicController) GetMessageHistoryList() {
...
@@ -488,31 +497,12 @@ func (c *PublicController) GetMessageHistoryList() {
c
.
JSON
(
configs
.
ResponseFail
,
"参数有误,请检查!"
,
nil
)
c
.
JSON
(
configs
.
ResponseFail
,
"参数有误,请检查!"
,
nil
)
}
}
// validation
// get user
valid
:=
validation
.
Validation
{}
user
:=
c
.
GetUserInfo
()
valid
.
Required
(
messagePaginationDto
.
Account
,
"account"
)
.
Message
(
"account不能为空!"
)
valid
.
Required
(
messagePaginationDto
.
PageSize
,
"page_size"
)
.
Message
(
"page_size不能为空!"
)
if
valid
.
HasErrors
()
{
for
_
,
err
:=
range
valid
.
Errors
{
c
.
JSON
(
configs
.
ResponseFail
,
err
.
Message
,
nil
)
}
}
// exist user
user
:=
c
.
UserRepository
.
GetUser
(
messagePaginationDto
.
Account
)
if
user
==
nil
{
if
user
==
nil
{
c
.
JSON
(
configs
.
ResponseFail
,
"fail,用户不存在!"
,
nil
)
c
.
JSON
(
configs
.
ResponseFail
,
"fail,用户不存在!"
,
nil
)
}
}
messagePaginationDto
.
Account
=
user
.
ID
/// validation TOKEN
token
:=
c
.
Ctx
.
Input
.
Header
(
"token"
)
if
token
==
""
{
c
.
JSON
(
configs
.
ResponseFail
,
"参数有误,请检查!"
,
nil
)
}
if
token
!=
user
.
Token
{
c
.
JSON
(
configs
.
ResponseFail
,
"fail,用户不存在!"
,
nil
)
}
// Timestamp == 0
// Timestamp == 0
if
messagePaginationDto
.
Timestamp
==
0
{
if
messagePaginationDto
.
Timestamp
==
0
{
...
...
routers/router.go
View file @
babaca33
...
@@ -39,7 +39,7 @@ func init() {
...
@@ -39,7 +39,7 @@ func init() {
beego
.
NSRouter
(
"/robot/:platform"
,
&
controllers
.
PublicController
{},
"get:Robot"
),
beego
.
NSRouter
(
"/robot/:platform"
,
&
controllers
.
PublicController
{},
"get:Robot"
),
beego
.
NSRouter
(
"/read"
,
&
controllers
.
PublicController
{},
"get:Read"
),
beego
.
NSRouter
(
"/read"
,
&
controllers
.
PublicController
{},
"get:Read"
),
beego
.
NSRouter
(
"/secret"
,
&
controllers
.
PublicController
{},
"get:UploadSecret"
),
beego
.
NSRouter
(
"/secret"
,
&
controllers
.
PublicController
{},
"get:UploadSecret"
),
beego
.
NSRouter
(
"/activity
/?:id
"
,
&
controllers
.
PublicController
{},
"get:LastActivity"
),
beego
.
NSRouter
(
"/activity"
,
&
controllers
.
PublicController
{},
"get:LastActivity"
),
beego
.
NSRouter
(
"/company"
,
&
controllers
.
PublicController
{},
"get:GetCompanyInfo"
),
beego
.
NSRouter
(
"/company"
,
&
controllers
.
PublicController
{},
"get:GetCompanyInfo"
),
beego
.
NSRouter
(
"/robot_info/:id"
,
&
controllers
.
PublicController
{},
"get:RobotInfo"
),
beego
.
NSRouter
(
"/robot_info/:id"
,
&
controllers
.
PublicController
{},
"get:RobotInfo"
),
beego
.
NSRouter
(
"/clean_read"
,
&
controllers
.
PublicController
{},
"get:CleanRead"
),
beego
.
NSRouter
(
"/clean_read"
,
&
controllers
.
PublicController
{},
"get:CleanRead"
),
...
...
services/message_service.go
View file @
babaca33
...
@@ -87,6 +87,9 @@ func (r *MessageRepository) GetUserMessages(messagePaginationDto models.MessageP
...
@@ -87,6 +87,9 @@ func (r *MessageRepository) GetUserMessages(messagePaginationDto models.MessageP
logs
.
Warn
(
"GetUserMessages get user messages0------------"
,
err
)
logs
.
Warn
(
"GetUserMessages get user messages0------------"
,
err
)
return
nil
,
err
return
nil
,
err
}
}
if
messagePaginationDto
.
PageSize
==
0
{
messagePaginationDto
.
PageSize
=
20
}
var
end
=
messageCount
.
Count
var
end
=
messageCount
.
Count
start
:=
int
(
messageCount
.
Count
)
-
messagePaginationDto
.
PageSize
start
:=
int
(
messageCount
.
Count
)
-
messagePaginationDto
.
PageSize
if
start
<=
0
{
if
start
<=
0
{
...
...
ui/kefu_client/src/App.vue
View file @
babaca33
...
@@ -888,8 +888,7 @@ export default {
...
@@ -888,8 +888,7 @@ export default {
let
timestamp
=
this
.
messages
.
length
==
0
?
parseInt
((
new
Date
().
getTime
()
+
" "
).
substr
(
0
,
10
))
:
this
.
messages
[
0
].
timestamp
let
timestamp
=
this
.
messages
.
length
==
0
?
parseInt
((
new
Date
().
getTime
()
+
" "
).
substr
(
0
,
10
))
:
this
.
messages
[
0
].
timestamp
axios
.
post
(
'/public/messages'
,{
axios
.
post
(
'/public/messages'
,{
"timestamp"
:
timestamp
,
"timestamp"
:
timestamp
,
"page_size"
:
pageSize
,
"page_size"
:
pageSize
"account"
:
uid
})
})
.
then
(
response
=>
{
.
then
(
response
=>
{
let
messages
=
response
.
data
.
data
.
list
||
[]
let
messages
=
response
.
data
.
data
.
list
||
[]
...
...
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