package controller import ( "github.com/gin-gonic/gin" "kefu/models" "kefu/tools" "kefu/types" ) //修改访客状态位 func PostVisitorState(c *gin.Context) { position := tools.Str2Int(c.PostForm("position")) state := c.PostForm("state") value := c.PostForm("value") visitorId := c.PostForm("visitor_id") if position == 0 || value == "" || visitorId == "" { c.JSON(200, gin.H{ "code": types.ApiCode.FAILED, "msg": types.ApiCode.GetMessage(types.ApiCode.INVALID), }) return } newState := tools.ReplaceAtPosition(state, position, value) models.UpdateVisitorState(visitorId, newState) c.JSON(200, gin.H{ "code": types.ApiCode.SUCCESS, "msg": types.ApiCode.GetMessage(types.ApiCode.SUCCESS), }) }