1 Star 0 Fork 0

mq-go/bluebell

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
vote.go 965 Bytes
一键复制 编辑 原始数据 按行查看 历史
柒染 提交于 2023-10-03 19:58 +08:00 . 按照时间和分数排序
package controller
import (
"strconv"
"gitee.com/mq-go/bluebell/logic"
"gitee.com/mq-go/bluebell/models"
"github.com/gin-gonic/gin"
"go.uber.org/zap"
)
func PostVoteController(c *gin.Context) {
//获取参数
param := new(models.Vote)
err := c.ShouldBindJSON(param)
if err != nil {
//参数错误
zap.L().Error("Post Vote param err : " + err.Error())
HandlerValidatorError(c, err)
return
}
//获取用户
userId := GetAuthJwtToken(c)
if userId == 0 {
zap.L().Error("GetAuthJwtToken err : token无效")
RequestJson(c, "请重新登录")
return
}
userID := strconv.Itoa(userId)
//实现投票
err = logic.VoteForPost(c, userID, param)
if err != nil {
//参数错误
zap.L().Error("Vote For Post err : " + err.Error())
if err.Error() == "投票时间已过" || err.Error() == "不允许重复投票" {
RequestJson(c, err)
}
RequestJson(c, "服务端错误")
return
}
//返回响应
RequestJson(c, "投票成功")
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/mq-go/bluebell.git
git@gitee.com:mq-go/bluebell.git
mq-go
bluebell
bluebell
d993e0e507c7

搜索帮助