You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

45 lines
1.1 KiB

package user
import (
"yunyan/comm"
redissys "yunyan/lego/sys/redis"
"yunyan/pb"
"fmt"
"github.com/redis/go-redis/v9"
)
// @Summary 上报用户行为
// @Description 上报用户行为
// @Tags User
// @Accept json
// @Produce json
// @Security BearerAuth
// @Param user body pb.UserPushActionReq true "上报用户行为"
// @Success 200 {object} comm.HttpResult{data=pb.UserPushActionResp} "成功返回"
// @Router /api/home/user_pushaction [post]
func (this *apiComp) PushAction(session comm.IUserSession, req *pb.UserPushActionReq) (resp *pb.UserPushActionResp, errdata *pb.ErrorData) {
var (
pip redis.Pipeliner
err error
)
pip = redissys.Conn().Pipeline()
for k, v := range req.Actions {
if err = pip.HIncrBy(session, redissys.RKey(fmt.Sprintf("%s:%s", comm.TableUseRecordLog, session.GetUserId())), k, int64(v)).Err(); err != nil {
errdata = &pb.ErrorData{
Code: pb.ErrorCode_DBError,
Message: err.Error(),
}
return
}
}
if _, err = pip.Exec(session); err != nil {
errdata = &pb.ErrorData{
Code: pb.ErrorCode_DBError,
Message: err.Error(),
}
return
}
resp = &pb.UserPushActionResp{}
return
}