package web_user import ( "videoweb/pub/common" "videoweb/pub/common/srvdef" "videoweb/web/service/srv_user" "github.com/gin-gonic/gin" ) // @Tags 用户管理 // @Summary 查询用户列表 // @Accept json // @Produce json // @Param param body srv_user.UserListReq true "查询参数" // @Success 200 {object} srv_user.UserListResp "成功" // @Security ApiKeyAuth // @Router /api/web/user/list [POST] func GetUserList(ctx *gin.Context) { var req srv_user.UserListReq if err := ctx.ShouldBind(&req); err != nil { common.ServerJSON(ctx, srvdef.ErrParamError, nil) return } resp, serr := srv_user.GetUsers(ctx, &req) if serr != nil { common.ServerJSON(ctx, serr.Code, serr.Tips) return } common.ServerJSON(ctx, srvdef.Success, resp) } // @Tags 用户管理 // @Summary 更新用户信息 // @Accept json // @Produce json // @Param param body srv_user.UserUpdateReq true "更新参数" // @Success 200 {string} string "成功" // @Security ApiKeyAuth // @Router /api/web/user/update [POST] func UpdateUser(ctx *gin.Context) { var req srv_user.UserUpdateReq if err := ctx.ShouldBind(&req); err != nil { common.ServerJSON(ctx, srvdef.ErrParamError, nil) return } if serr := srv_user.UpdateUser(ctx, req.Id, req.Param); serr != nil { common.ServerJSON(ctx, serr.Code, serr.Tips) return } common.ServerJSON(ctx, srvdef.Success, "") } // @Tags 用户管理 // @Summary 赠送/扣除用户金币 // @Description coin 为正数表示赠送,为负数表示扣除;操作会自动记录金币流水 // @Accept json // @Produce json // @Param param body srv_user.GiftCoinReq true "赠送参数" // @Success 200 {string} string "成功" // @Security ApiKeyAuth // @Router /api/web/user/giftcoin [POST] func GiftCoin(ctx *gin.Context) { var req srv_user.GiftCoinReq if err := ctx.ShouldBind(&req); err != nil { common.ServerJSON(ctx, srvdef.ErrParamError, nil) return } if serr := srv_user.GiftCoin(ctx, &req); serr != nil { common.ServerJSON(ctx, serr.Code, serr.Tips) return } common.ServerJSON(ctx, srvdef.Success, "") } // @Tags 用户管理 // @Summary 修改用户会员 // @Description 根据会员畅享套餐ID修改用户会员信息,不处理赠送金币 // @Accept json // @Produce json // @Param param body srv_user.UpdateVipReq true "修改会员参数" // @Success 200 {string} string "成功" // @Security ApiKeyAuth // @Router /api/web/user/vip/update [POST] func UpdateVip(ctx *gin.Context) { var req srv_user.UpdateVipReq if err := ctx.ShouldBindJSON(&req); err != nil { common.ServerJSON(ctx, srvdef.ErrParamError, nil) return } if serr := srv_user.UpdateVip(ctx, &req); serr != nil { common.ServerJSON(ctx, serr.Code, serr.Tips) return } common.ServerJSON(ctx, srvdef.Success, "") } // ResetPassword web端按用户ID重置密码 // @Tags 用户管理 // @Summary 重置用户密码 // @Description 传入用户ID和明文密码,服务端按 app 登录相同规则哈希后写入 // @Accept json // @Produce json // @Param param body srv_user.ResetPasswordReq true "重置密码参数" // @Success 200 {string} string "成功" // @Security ApiKeyAuth // @Router /api/web/user/resetPassword [POST] func ResetPassword(ctx *gin.Context) { var req srv_user.ResetPasswordReq if err := ctx.ShouldBindJSON(&req); err != nil { common.ServerJSON(ctx, srvdef.ErrParamError, nil) return } if serr := srv_user.ResetPassword(ctx, &req); serr != nil { common.ServerJSON(ctx, serr.Code, serr.Tips) return } common.ServerJSON(ctx, srvdef.Success, "") }