We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
查询时需要添加过滤条件,不然会查询到别人的数据。
// TaskDetail 待办详情 func TaskDetail(c *gin.Context) { var taskDetailDTO service.TaskDetailDTO claims, _ := utils.ParseToken(c.GetHeader(conf.TokenKey)) if err := c.ShouldBindUri(&taskDetailDTO); err == nil { res := taskDetailDTO.TaskDetail(claims.ID) c.JSON(http.StatusOK, res) } else { c.JSON(http.StatusOK, serializer.Response{ Status: e.InvalidParams, Data: nil, Message: e.GetMessage(e.InvalidParams), Error: err.Error(), }) } }
type TaskDetailDTO struct { ID uint `uri:"tid" binding:"required"` } // TaskDetail 查询task详情 func (taskDetailDTO *TaskDetailDTO) TaskDetail(uid uint) serializer.Response { var task model.Task if err := model.DB.Model(&task).Where("id = ? and uid = ?", taskDetailDTO.ID, uid).First(&task).Error; err != nil { if gorm.IsRecordNotFoundError(err) { return serializer.Response{ Status: e.ErrorTaskNotFound, Data: nil, Message: e.GetMessage(e.ErrorTaskNotFound), Error: err.Error(), } } else { return serializer.Response{ Status: e.ErrorDatabase, Data: nil, Message: e.GetMessage(e.ErrorDatabase), Error: err.Error(), } } } return serializer.Response{ Status: e.SUCCESS, Data: serializer.BuildTaskDetail(task), Message: e.GetMessage(e.SUCCESS), Error: "", } }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
查询时需要添加过滤条件,不然会查询到别人的数据。
The text was updated successfully, but these errors were encountered: