You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
/**
|
|
|
|
* @Author: jager
|
|
|
|
* @Email: lhj168os@gmail.com
|
|
|
|
* @File: soup
|
|
|
|
* @Date: 2021/12/31 2:44 下午
|
|
|
|
* @package: soup
|
|
|
|
* @Version: v1.0.0
|
|
|
|
*
|
|
|
|
* @Description:
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
package soup
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/gin-gonic/gin"
|
|
|
|
"github.com/jageros/hawox/errcode"
|
|
|
|
"github.com/jageros/hawox/httpx"
|
|
|
|
"idata/internal/apity"
|
|
|
|
"idata/internal/service/user"
|
|
|
|
"idata/internal/types"
|
|
|
|
)
|
|
|
|
|
|
|
|
func GetRandSoup(ctx *gin.Context) {
|
|
|
|
uid, ok := httpx.DecodeUrlVal(ctx, "uid")
|
|
|
|
if !ok {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
var opened bool
|
|
|
|
err := user.OperateSync(uid, func(u types.RWUser) {
|
|
|
|
opened = u.ApiCanReq(apity.Soup)
|
|
|
|
if opened && !u.IsVip() {
|
|
|
|
u.SetScore(u.Score() - 1)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
if err != nil {
|
|
|
|
httpx.ErrInterrupt(ctx, errcode.WithErrcode(1, err))
|
|
|
|
return
|
|
|
|
}
|
|
|
|
if !opened {
|
|
|
|
httpx.ErrInterrupt(ctx, errcode.New(1, "未获得此Api权限"))
|
|
|
|
return
|
|
|
|
}
|
|
|
|
text := getContent()
|
|
|
|
httpx.PkgMsgWrite(ctx, map[string]interface{}{"context": text})
|
|
|
|
}
|