3 Star 1 Fork 919

高煜涛/gin-vue-admin

forked from pixel/gin-vue-admin 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
user_bind_manage.go 7.14 KB
一键复制 编辑 原始数据 按行查看 历史
package user
import (
"gitee.com/g-qs/gin-vue-admin/server/global"
"gitee.com/g-qs/gin-vue-admin/server/model/common/response"
"gitee.com/g-qs/gin-vue-admin/server/model/user"
userReq "gitee.com/g-qs/gin-vue-admin/server/model/user/request"
"gitee.com/g-qs/gin-vue-admin/server/service"
"gitee.com/g-qs/gin-vue-admin/server/utils"
"github.com/gin-gonic/gin"
"go.uber.org/zap"
"strconv"
)
type UserBindManageApi struct {
}
var BindService = service.ServiceGroupApp.UserServiceGroup.UserBindManageService
// CreateUserBindManage 创建用户绑定健管师
// @Tags UserBindManage
// @Summary 创建用户绑定健管师
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body user.UserBindManage true "创建用户绑定健管师"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"创建成功"}"
// @Router /Bind/createUserBindManage [post]
func (BindApi *UserBindManageApi) CreateUserBindManage(c *gin.Context) {
var Bind user.UserBindManage
err := c.ShouldBindJSON(&Bind)
if err != nil {
response.FailWithMessage(err.Error(), c)
return
}
id := utils.GetUserID(c)
Bind.Uid = id
if err := BindService.CreateUserBindManage(&Bind); err != nil {
global.GVA_LOG.Error("提交失败!", zap.Error(err))
response.FailWithMessage(err.Error(), c)
} else {
response.OkWithMessage("提交成功", c)
}
}
// GetBindUserList 获取绑定用户列表
// @Tags UserBindManage
// @Summary 获取绑定用户列表
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data query userReq.UserBindManageSearch true "获取绑定用户列表"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
// @Router /Bind/getUserBindManageList [get]
func (BindApi *UserBindManageApi) GetBindUserList(c *gin.Context) {
var pageInfo userReq.UserBindManageSearch
err := c.ShouldBindQuery(&pageInfo)
if err != nil {
response.FailWithMessage(err.Error(), c)
return
}
if list, total, err := BindService.GetBindUserInfoList(pageInfo); err != nil {
global.GVA_LOG.Error("获取失败!", zap.Error(err))
response.FailWithMessage("获取失败", c)
} else {
response.OkWithDetailed(response.PageResult{
List: list,
Total: total,
Page: pageInfo.Page,
PageSize: pageInfo.PageSize,
}, "获取成功", c)
}
}
// UpdateBindStatus 更改绑定状态
// @Tags UserBindManage
// @Summary 更改绑定状态
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body user.UserBindManage true "更改绑定状态"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"操作成功"}"
// @Router /Bind/updateBindStatus [put]
func (BindApi *UserBindManageApi) UpdateBindStatus(c *gin.Context) {
var Bind user.UserBindManage
err := c.ShouldBindJSON(&Bind)
if err != nil {
response.FailWithMessage(err.Error(), c)
return
}
if err := BindService.UpdateBindStatus(Bind.ID, strconv.Itoa(int(Bind.Status))); err != nil {
global.GVA_LOG.Error("操作失败!", zap.Error(err))
response.FailWithMessage("操作失败", c)
} else {
response.OkWithMessage("操作成功", c)
}
}
// DeleteUserBindManage 删除用户绑定健管师
// @Tags UserBindManage
// @Summary 删除用户绑定健管师
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body user.UserBindManage true "删除用户绑定健管师"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"删除成功"}"
// @Router /Bind/deleteUserBindManage [delete]
func (BindApi *UserBindManageApi) DeleteUserBindManage(c *gin.Context) {
id := c.Query("ID")
if err := BindService.DeleteUserBindManage(id); err != nil {
global.GVA_LOG.Error("删除失败!", zap.Error(err))
response.FailWithMessage("删除失败", c)
} else {
response.OkWithMessage("删除成功", c)
}
}
// DeleteUserBindManageByIds 批量删除用户绑定健管师
// @Tags UserBindManage
// @Summary 批量删除用户绑定健管师
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body request.IdsReq true "批量删除用户绑定健管师"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"批量删除成功"}"
// @Router /Bind/deleteUserBindManageByIds [delete]
func (BindApi *UserBindManageApi) DeleteUserBindManageByIds(c *gin.Context) {
ids := c.QueryArray("ids[]")
if err := BindService.DeleteUserBindManageByIds(ids); err != nil {
global.GVA_LOG.Error("批量删除失败!", zap.Error(err))
response.FailWithMessage("批量删除失败", c)
} else {
response.OkWithMessage("批量删除成功", c)
}
}
// UpdateUserBindManage 更新用户绑定健管师
// @Tags UserBindManage
// @Summary 更新用户绑定健管师
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body user.UserBindManage true "更新用户绑定健管师"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"更新成功"}"
// @Router /Bind/updateUserBindManage [put]
func (BindApi *UserBindManageApi) UpdateUserBindManage(c *gin.Context) {
var Bind user.UserBindManage
err := c.ShouldBindJSON(&Bind)
if err != nil {
response.FailWithMessage(err.Error(), c)
return
}
if err := BindService.UpdateUserBindManage(Bind); err != nil {
global.GVA_LOG.Error("更新失败!", zap.Error(err))
response.FailWithMessage("更新失败", c)
} else {
response.OkWithMessage("更新成功", c)
}
}
// FindUserBindManage 用id查询用户绑定健管师
// @Tags UserBindManage
// @Summary 用id查询用户绑定健管师
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data query user.UserBindManage true "用id查询用户绑定健管师"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"查询成功"}"
// @Router /Bind/findUserBindManage [get]
func (BindApi *UserBindManageApi) FindUserBindManage(c *gin.Context) {
id := c.Query("ID")
if reBind, err := BindService.GetUserBindManage(id); err != nil {
global.GVA_LOG.Error("查询失败!", zap.Error(err))
response.FailWithMessage("查询失败", c)
} else {
response.OkWithData(gin.H{"reBind": reBind}, c)
}
}
// GetUserBindManageList 分页获取用户绑定健管师列表
// @Tags UserBindManage
// @Summary 分页获取用户绑定健管师列表
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data query userReq.UserBindManageSearch true "分页获取用户绑定健管师列表"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
// @Router /Bind/getUserBindManageList [get]
func (BindApi *UserBindManageApi) GetUserBindManageList(c *gin.Context) {
var pageInfo userReq.UserBindManageSearch
err := c.ShouldBindQuery(&pageInfo)
if err != nil {
response.FailWithMessage(err.Error(), c)
return
}
if list, total, err := BindService.GetUserBindManageInfoList(pageInfo); err != nil {
global.GVA_LOG.Error("获取失败!", zap.Error(err))
response.FailWithMessage("获取失败", c)
} else {
response.OkWithDetailed(response.PageResult{
List: list,
Total: total,
Page: pageInfo.Page,
PageSize: pageInfo.PageSize,
}, "获取成功", c)
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/g-qs/gin-vue-admin.git
git@gitee.com:g-qs/gin-vue-admin.git
g-qs
gin-vue-admin
gin-vue-admin
a5c0f301b910

搜索帮助