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.
219 lines
6.9 KiB
219 lines
6.9 KiB
package v1
|
|
|
|
import (
|
|
"pure-admin/api/sys"
|
|
"pure-admin/global"
|
|
"pure-admin/model"
|
|
"pure-admin/model/request"
|
|
"pure-admin/model/response"
|
|
"pure-admin/service"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
"go.uber.org/zap"
|
|
)
|
|
|
|
// @Tags User
|
|
// @Summary 创建User
|
|
// @Security ApiKeyAuth
|
|
// @accept application/json
|
|
// @Produce application/json
|
|
// @Param data body model.User true "创建User"
|
|
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
|
|
// @Router /user/createUser [post]
|
|
func CreateUser(c *gin.Context) {
|
|
var user model.User
|
|
_ = c.ShouldBindJSON(&user)
|
|
if err := service.CreateUser(user); err != nil {
|
|
global.MG_LOG.Error("创建失败!", zap.Any("err", err))
|
|
response.FailWithMessage("创建失败", c)
|
|
} else {
|
|
response.OkWithMessage("创建成功", c)
|
|
}
|
|
}
|
|
|
|
// @Tags User
|
|
// @Summary 删除User
|
|
// @Security ApiKeyAuth
|
|
// @accept application/json
|
|
// @Produce application/json
|
|
// @Param data body model.User true "删除User"
|
|
// @Success 200 {string} string "{"success":true,"data":{},"msg":"删除成功"}"
|
|
// @Router /user/deleteUser [delete]
|
|
func DeleteUser(c *gin.Context) {
|
|
var user model.User
|
|
_ = c.ShouldBindJSON(&user)
|
|
if err := service.DeleteUser(user); err != nil {
|
|
global.MG_LOG.Error("删除失败!", zap.Any("err", err))
|
|
response.FailWithMessage("删除失败", c)
|
|
} else {
|
|
response.OkWithMessage("删除成功", c)
|
|
}
|
|
}
|
|
|
|
// @Tags User
|
|
// @Summary 批量删除User
|
|
// @Security ApiKeyAuth
|
|
// @accept application/json
|
|
// @Produce application/json
|
|
// @Param data body request.IdsReq true "批量删除User"
|
|
// @Success 200 {string} string "{"success":true,"data":{},"msg":"批量删除成功"}"
|
|
// @Router /user/deleteUserByIds [delete]
|
|
func DeleteUserByIds(c *gin.Context) {
|
|
var IDS request.IdsReq
|
|
_ = c.ShouldBindJSON(&IDS)
|
|
if err := service.DeleteUserByIds(IDS); err != nil {
|
|
global.MG_LOG.Error("批量删除失败!", zap.Any("err", err))
|
|
response.FailWithMessage("批量删除失败", c)
|
|
} else {
|
|
response.OkWithMessage("批量删除成功", c)
|
|
}
|
|
}
|
|
|
|
// @Tags User
|
|
// @Summary 更新User
|
|
// @Security ApiKeyAuth
|
|
// @accept application/json
|
|
// @Produce application/json
|
|
// @Param data body model.User true "更新User"
|
|
// @Success 200 {string} string "{"success":true,"data":{},"msg":"更新成功"}"
|
|
// @Router /user/updateUser [put]
|
|
func UpdateUser(c *gin.Context) {
|
|
var user model.User
|
|
_ = c.ShouldBindJSON(&user)
|
|
if err := service.UpdateUser(user); err != nil {
|
|
global.MG_LOG.Error("更新失败!", zap.Any("err", err))
|
|
response.FailWithMessage("更新失败", c)
|
|
} else {
|
|
response.OkWithMessage("更新成功", c)
|
|
}
|
|
}
|
|
|
|
// @Tags User
|
|
// @Summary 用id查询User
|
|
// @Security ApiKeyAuth
|
|
// @accept application/json
|
|
// @Produce application/json
|
|
// @Param data query request.UserSearchByID true "用id查询User"
|
|
// @Success 200 {object} model.UserSimple "{"success":true,"data":{},"msg":"查询成功"}"
|
|
// @Router /user/findUser [get]
|
|
func FindUser(c *gin.Context) {
|
|
var user request.UserSearchByID
|
|
_ = c.ShouldBindQuery(&user)
|
|
if err, reuser := service.GetUser(user.UserID); err != nil {
|
|
global.MG_LOG.Error("查询失败!", zap.Any("err", err))
|
|
response.FailWithMessage("查询失败", c)
|
|
} else {
|
|
response.OkWithData(gin.H{"reuser": reuser}, c)
|
|
}
|
|
}
|
|
|
|
// @Tags User
|
|
// @Summary 分页获取User列表
|
|
// @Security ApiKeyAuth
|
|
// @accept application/json
|
|
// @Produce application/json
|
|
// @Param data query request.UserSimpleSearch true "分页获取User列表"
|
|
// @Success 200 {object} model.UserSimple "{"success":true,"data":{},"msg":"获取成功"}"
|
|
// @Router /user/getUserList [get]
|
|
func GetUserList(c *gin.Context) {
|
|
var pageInfo request.UserSimpleSearch
|
|
_ = c.ShouldBindQuery(&pageInfo)
|
|
if err, list, total := service.GetUserInfoList(pageInfo, sys.GetUserAppid(c)); err != nil {
|
|
global.MG_LOG.Error("获取失败!", zap.Any("err", err))
|
|
response.FailWithMessage("获取失败", c)
|
|
} else {
|
|
response.OkWithDetailed(response.PageResult{
|
|
List: list,
|
|
Total: total,
|
|
Page: pageInfo.Page,
|
|
PageSize: pageInfo.PageSize,
|
|
}, "获取成功", c)
|
|
}
|
|
}
|
|
|
|
// @Tags User
|
|
// @Summary 分页获取系统User列表
|
|
// @Security ApiKeyAuth
|
|
// @accept application/json
|
|
// @Produce application/json
|
|
// @Param data query request.UserSimpleSearch true "分页获取User列表"
|
|
// @Success 200 {object} model.UserSimple "{"success":true,"data":{},"msg":"获取成功"}"
|
|
// @Router /user/getUserList [post]
|
|
func GetSysUserList(c *gin.Context) {
|
|
var pageInfo request.UserSimpleSearch
|
|
_ = c.ShouldBind(&pageInfo)
|
|
if err, list, total := service.GetSysUserInfoList(pageInfo, sys.GetUserAppid(c)); err != nil {
|
|
global.MG_LOG.Error("获取失败!", zap.Any("err", err))
|
|
response.FailWithMessage("获取失败", c)
|
|
} else {
|
|
response.OkWithDetailed(response.PageResult{
|
|
List: list,
|
|
Total: total,
|
|
Page: pageInfo.Page,
|
|
PageSize: pageInfo.PageSize,
|
|
}, "获取成功", c)
|
|
}
|
|
}
|
|
|
|
// @Tags User
|
|
// @Summary 获取网红认证审核记录
|
|
// @Security ApiKeyAuth
|
|
// @accept application/json
|
|
// @Produce application/json
|
|
// @Param data query request.PlatformAuthSearch true "分页获取User列表"
|
|
// @Success 200 {object} model.PlatformAuthSimple "{"success":true,"data":{},"msg":"获取成功"}"
|
|
// @Router /user/platformAuth [get]
|
|
func PlatformAuth(c *gin.Context) {
|
|
var pageInfo request.PlatformAuthSearch
|
|
_ = c.ShouldBindQuery(&pageInfo)
|
|
if err, list, total := service.GetPlatformAuthList(pageInfo); err != nil {
|
|
global.MG_LOG.Error("获取失败!", zap.Any("err", err))
|
|
response.FailWithMessage("获取失败", c)
|
|
} else {
|
|
response.OkWithDetailed(response.PageResult{
|
|
List: list,
|
|
Total: total,
|
|
Page: pageInfo.Page,
|
|
PageSize: pageInfo.PageSize,
|
|
}, "获取成功", c)
|
|
}
|
|
}
|
|
|
|
// @Tags User
|
|
// @Summary 网红认证审核
|
|
// @Security ApiKeyAuth
|
|
// @accept application/json
|
|
// @Produce application/json
|
|
// @Param data body request.PlatformAuthCheck true "分页获取User列表"
|
|
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
|
|
// @Router /user/platformAuth [put]
|
|
func CheckPlatformAuth(c *gin.Context) {
|
|
var auth request.PlatformAuthCheck
|
|
_ = c.ShouldBindJSON(&auth)
|
|
userID := sys.GetUserUuid(c)
|
|
if err := service.CheckPlatformAuth(&auth, userID); err != nil {
|
|
global.MG_LOG.Error("审核失败!", zap.Any("err", err))
|
|
response.FailWithMessage("审核失败", c)
|
|
} else {
|
|
response.OkWithMessage("审核成功", c)
|
|
}
|
|
}
|
|
|
|
// @Tags User
|
|
// @Summary 用户禁用启用
|
|
// @Security ApiKeyAuth
|
|
// @accept application/json
|
|
// @Produce application/json
|
|
// @Param data body request.UserStatus true "分页获取User列表"
|
|
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
|
|
// @Router /user/userStatus [put]
|
|
func UpdateUserStatus(c *gin.Context) {
|
|
var auth request.UserStatus
|
|
_ = c.ShouldBind(&auth)
|
|
if err := service.UpdateUserStatus(&auth, sys.GetUserAppid(c), sys.GetUserUuid(c)); err != nil {
|
|
global.MG_LOG.Error("审核失败!", zap.Any("err", err))
|
|
response.FailWithMessage("审核失败,"+err.Error(), c)
|
|
} else {
|
|
response.OkWithMessage("审核成功", c)
|
|
}
|
|
}
|
|
|