sys_operation_record.go 4.2 KB
Newer Older
G
granty1 已提交
1 2 3
package v1

import (
4
	"gin-vue-admin/global"
G
granty1 已提交
5 6
	"gin-vue-admin/model"
	"gin-vue-admin/model/request"
7
	"gin-vue-admin/model/response"
G
granty1 已提交
8
	"gin-vue-admin/service"
9
	"gin-vue-admin/utils"
G
granty1 已提交
10
	"github.com/gin-gonic/gin"
11
	"go.uber.org/zap"
G
granty1 已提交
12 13 14 15 16 17 18
)

// @Tags SysOperationRecord
// @Summary 创建SysOperationRecord
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
19
// @Param data body model.SysOperationRecord true "创建SysOperationRecord"
G
granty1 已提交
20 21 22 23 24
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
// @Router /sysOperationRecord/createSysOperationRecord [post]
func CreateSysOperationRecord(c *gin.Context) {
	var sysOperationRecord model.SysOperationRecord
	_ = c.ShouldBindJSON(&sysOperationRecord)
S
songzhibin97 已提交
25
	if err := service.CreateSysOperationRecord(sysOperationRecord); err != nil {
26 27
		global.GVA_LOG.Error("创建失败!", zap.Any("err", err))
		response.FailWithMessage("创建失败", c)
G
granty1 已提交
28 29 30 31 32 33 34 35 36 37
	} else {
		response.OkWithMessage("创建成功", c)
	}
}

// @Tags SysOperationRecord
// @Summary 删除SysOperationRecord
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
38
// @Param data body model.SysOperationRecord true "SysOperationRecord模型"
G
granty1 已提交
39 40 41 42 43
// @Success 200 {string} string "{"success":true,"data":{},"msg":"删除成功"}"
// @Router /sysOperationRecord/deleteSysOperationRecord [delete]
func DeleteSysOperationRecord(c *gin.Context) {
	var sysOperationRecord model.SysOperationRecord
	_ = c.ShouldBindJSON(&sysOperationRecord)
S
songzhibin97 已提交
44
	if err := service.DeleteSysOperationRecord(sysOperationRecord); err != nil {
45 46
		global.GVA_LOG.Error("删除失败!", zap.Any("err", err))
		response.FailWithMessage("删除失败", c)
G
granty1 已提交
47 48 49 50 51
	} else {
		response.OkWithMessage("删除成功", c)
	}
}

52 53 54 55 56 57
// @Tags SysOperationRecord
// @Summary 批量删除SysOperationRecord
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body request.IdsReq true "批量删除SysOperationRecord"
58
// @Success 200 {string} string "{"success":true,"data":{},"msg":"批量删除成功"}"
59 60 61 62
// @Router /sysOperationRecord/deleteSysOperationRecordByIds [delete]
func DeleteSysOperationRecordByIds(c *gin.Context) {
	var IDS request.IdsReq
	_ = c.ShouldBindJSON(&IDS)
S
songzhibin97 已提交
63
	if err := service.DeleteSysOperationRecordByIds(IDS); err != nil {
64 65
		global.GVA_LOG.Error("批量删除失败!", zap.Any("err", err))
		response.FailWithMessage("批量删除失败", c)
66
	} else {
67
		response.OkWithMessage("批量删除成功", c)
68 69 70
	}
}

G
granty1 已提交
71 72 73 74 75
// @Tags SysOperationRecord
// @Summary 用id查询SysOperationRecord
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
76
// @Param data body model.SysOperationRecord true "Id"
G
granty1 已提交
77 78 79
// @Success 200 {string} string "{"success":true,"data":{},"msg":"查询成功"}"
// @Router /sysOperationRecord/findSysOperationRecord [get]
func FindSysOperationRecord(c *gin.Context) {
80
	var sysOperationRecord model.SysOperationRecord
G
granty1 已提交
81
	_ = c.ShouldBindQuery(&sysOperationRecord)
82 83 84 85
	if err := utils.Verify(sysOperationRecord, utils.IdVerify); err != nil {
		response.FailWithMessage(err.Error(), c)
		return
	}
86
	if err, resysOperationRecord := service.GetSysOperationRecord(sysOperationRecord.ID); err != nil {
87 88
		global.GVA_LOG.Error("查询失败!", zap.Any("err", err))
		response.FailWithMessage("查询失败", c)
G
granty1 已提交
89
	} else {
90
		response.OkWithDetailed(gin.H{"resysOperationRecord": resysOperationRecord}, "查询成功", c)
G
granty1 已提交
91 92 93 94 95 96 97 98
	}
}

// @Tags SysOperationRecord
// @Summary 分页获取SysOperationRecord列表
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
99
// @Param data body request.SysOperationRecordSearch true "页码, 每页大小, 搜索条件"
G
granty1 已提交
100 101 102 103 104
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
// @Router /sysOperationRecord/getSysOperationRecordList [get]
func GetSysOperationRecordList(c *gin.Context) {
	var pageInfo request.SysOperationRecordSearch
	_ = c.ShouldBindQuery(&pageInfo)
S
songzhibin97 已提交
105
	if err, list, total := service.GetSysOperationRecordInfoList(pageInfo); err != nil {
106 107
		global.GVA_LOG.Error("获取失败!", zap.Any("err", err))
		response.FailWithMessage("获取失败", c)
G
granty1 已提交
108
	} else {
109
		response.OkWithDetailed(response.PageResult{
G
granty1 已提交
110 111 112 113
			List:     list,
			Total:    total,
			Page:     pageInfo.Page,
			PageSize: pageInfo.PageSize,
114
		}, "获取成功", c)
G
granty1 已提交
115 116
	}
}