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.

47 lines
916 B
Go

3 years ago
/**
* @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"
3 years ago
"github.com/jageros/hawox/errcode"
3 years ago
"github.com/jageros/hawox/httpx"
3 years ago
"idata/internal/apity"
"idata/internal/service/user"
"idata/internal/types"
3 years ago
)
func GetRandSoup(ctx *gin.Context) {
3 years ago
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
}
3 years ago
text := getContent()
httpx.PkgMsgWrite(ctx, map[string]interface{}{"context": text})
}