Commit babaca33 by chenxianqi

update

parent cd528437
......@@ -203,11 +203,10 @@ func (c *PublicController) Read() {
// get user
user := c.GetUserInfo()
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(id)
readCount, err := c.MessageRepository.GetReadCount(user.ID)
if err == nil {
readCount = 0
}
......@@ -454,6 +453,16 @@ func (c *PublicController) Upload() {
// CancelMessage cancel a message
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{}
if err := json.Unmarshal(c.Ctx.Input.RequestBody, &removeMessageRequestDto); err != nil {
c.JSON(configs.ResponseFail, "参数有误,请检查!", nil)
......@@ -488,31 +497,12 @@ func (c *PublicController) GetMessageHistoryList() {
c.JSON(configs.ResponseFail, "参数有误,请检查!", nil)
}
// validation
valid := validation.Validation{}
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)
// get user
user := c.GetUserInfo()
if user == nil {
c.JSON(configs.ResponseFail, "fail,用户不存在!", nil)
}
/// 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)
}
messagePaginationDto.Account = user.ID
// Timestamp == 0
if messagePaginationDto.Timestamp == 0 {
......
......@@ -39,7 +39,7 @@ func init() {
beego.NSRouter("/robot/:platform", &controllers.PublicController{}, "get:Robot"),
beego.NSRouter("/read", &controllers.PublicController{}, "get:Read"),
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("/robot_info/:id", &controllers.PublicController{}, "get:RobotInfo"),
beego.NSRouter("/clean_read", &controllers.PublicController{}, "get:CleanRead"),
......
......@@ -87,6 +87,9 @@ func (r *MessageRepository) GetUserMessages(messagePaginationDto models.MessageP
logs.Warn("GetUserMessages get user messages0------------", err)
return nil, err
}
if messagePaginationDto.PageSize == 0 {
messagePaginationDto.PageSize = 20
}
var end = messageCount.Count
start := int(messageCount.Count) - messagePaginationDto.PageSize
if start <= 0 {
......
......@@ -888,8 +888,7 @@ export default {
let timestamp = this.messages.length == 0 ? parseInt((new Date().getTime() + " ").substr(0, 10)) : this.messages[0].timestamp
axios.post('/public/messages',{
"timestamp": timestamp,
"page_size": pageSize,
"account": uid
"page_size": pageSize
})
.then(response => {
let messages = response.data.data.list || []
......
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 sign in to comment