项目目录优化,任务模块后端代码

This commit is contained in:
PandaGoAdmin
2021-12-23 17:23:27 +08:00
parent 0caf81660c
commit 21ff92a93c
67 changed files with 802 additions and 206 deletions

89
apps/log/api/log_login.go Normal file
View File

@@ -0,0 +1,89 @@
package api
import (
"pandax/apps/log/entity"
"pandax/apps/log/services"
"pandax/base/ctx"
"pandax/base/ginx"
"pandax/base/utils"
)
type LogLoginApi struct {
LogLoginApp services.LogLoginModel
}
// @Summary 登录日志列表
// @Description 获取JSON
// @Tags 登录日志
// @Param status query string false "status"
// @Param username query string false "username"
// @Param pageSize query int false "页条数"
// @Param pageNum query int false "页码"
// @Success 200 {string} string "{"code": 200, "data": [...]}"
// @Router /system/log/list [get]
// @Security
func (l *LogLoginApi) GetLoginLogList(rc *ctx.ReqCtx) {
pageNum := ginx.QueryInt(rc.GinCtx, "pageNum", 1)
pageSize := ginx.QueryInt(rc.GinCtx, "pageSize", 10)
loginLocation := rc.GinCtx.Query("loginLocation")
username := rc.GinCtx.Query("username")
list, total := l.LogLoginApp.FindListPage(pageNum, pageSize, entity.LogLogin{LoginLocation: loginLocation, Username: username})
rc.ResData = map[string]interface{}{
"data": list,
"total": total,
"pageNum": pageNum,
"pageSize": pageSize,
}
}
// @Summary 通过编码获取登录日志
// @Description 获取JSON
// @Tags 登录日志
// @Param infoId path int true "infoId"
// @Success 200 {string} string "{"code": 200, "data": [...]}"
// @Router /system/log/logLogin/{infoId} [get]
// @Security
func (l *LogLoginApi) GetLoginLog(rc *ctx.ReqCtx) {
infoId := ginx.PathParamInt(rc.GinCtx, rc.GinCtx.Param("infoId"))
rc.ResData = l.LogLoginApp.FindOne(int64(infoId))
}
// @Summary 修改登录日志
// @Description 获取JSON
// @Tags 登录日志
// @Accept application/json
// @Product application/json
// @Param data body entity.LogLogin true "body"
// @Success 200 {string} string "{"code": 200, "message": "添加成功"}"
// @Success 200 {string} string "{"code": 400, "message": "添加失败"}"
// @Router /system/log/logLogin [put]
// @Security X-TOKEN
func (l *LogLoginApi) UpdateLoginLog(rc *ctx.ReqCtx) {
var log entity.LogLogin
ginx.BindJsonAndValid(rc.GinCtx, &log)
l.LogLoginApp.Update(log)
}
// @Summary 批量删除登录日志
// @Description 删除数据
// @Tags 登录日志
// @Param infoId path string true "以逗号(,分割的infoId"
// @Success 200 {string} string "{"code": 200, "message": "删除成功"}"
// @Success 200 {string} string "{"code": 400, "message": "删除失败"}"
// @Router /system/log/logLogin/{infoId} [delete]
func (l *LogLoginApi) DeleteLoginLog(rc *ctx.ReqCtx) {
infoIds := rc.GinCtx.Param("infoId")
group := utils.IdsStrToIdsIntGroup(infoIds)
l.LogLoginApp.Delete(group)
}
// @Summary 清空登录日志
// @Description 删除数据
// @Tags 登录日志
// @Success 200 {string} string "{"code": 200, "message": "删除成功"}"
// @Success 200 {string} string "{"code": 400, "message": "删除失败"}"
// @Router /system/log/logLogin/all [delete]
func (l *LogLoginApi) DeleteAll(rc *ctx.ReqCtx) {
l.LogLoginApp.DeleteAll()
}

76
apps/log/api/log_oper.go Normal file
View File

@@ -0,0 +1,76 @@
package api
import (
"log"
"pandax/apps/log/entity"
"pandax/apps/log/services"
"pandax/base/ctx"
"pandax/base/ginx"
"pandax/base/utils"
)
type LogOperApi struct {
LogOperApp services.LogOperModel
}
// @Summary 操作日志列表
// @Description 获取JSON
// @Tags 操作日志
// @Param status query string false "status"
// @Param operName query string false "operName"
// @Param pageSize query int false "页条数"
// @Param pageNum query int false "页码"
// @Success 200 {string} string "{"code": 200, "data": [...]}"
// @Router /system/log/list [get]
// @Security
func (l *LogOperApi) GetOperLogList(rc *ctx.ReqCtx) {
pageNum := ginx.QueryInt(rc.GinCtx, "pageNum", 1)
pageSize := ginx.QueryInt(rc.GinCtx, "pageSize", 10)
businessType := rc.GinCtx.Query("businessType")
operName := rc.GinCtx.Query("operName")
title := rc.GinCtx.Query("title")
list, total := l.LogOperApp.FindListPage(pageNum, pageSize, entity.LogOper{BusinessType: businessType, OperName: operName, Title: title})
rc.ResData = map[string]interface{}{
"data": list,
"total": total,
"pageNum": pageNum,
"pageSize": pageSize,
}
}
// @Summary 通过编码获取操作日志
// @Description 获取JSON
// @Tags 操作日志
// @Param operId path int true "operId"
// @Success 200 {string} string "{"code": 200, "data": [...]}"
// @Router /system/log/logOper/{operId} [get]
// @Security
func (l *LogOperApi) GetOperLog(rc *ctx.ReqCtx) {
operId := ginx.PathParamInt(rc.GinCtx, rc.GinCtx.Param("operId"))
rc.ResData = l.LogOperApp.FindOne(int64(operId))
}
// @Summary 批量删除操作日志
// @Description 删除数据
// @Tags 操作日志
// @Param operId path string true "以逗号(,分割的operId"
// @Success 200 {string} string "{"code": 200, "message": "删除成功"}"
// @Success 200 {string} string "{"code": 400, "message": "删除失败"}"
// @Router /system/log/logOper/{operId} [delete]
func (l *LogOperApi) DeleteOperLog(rc *ctx.ReqCtx) {
operIds := rc.GinCtx.Param("operId")
group := utils.IdsStrToIdsIntGroup(operIds)
log.Println("group", group)
l.LogOperApp.Delete(group)
}
// @Summary 清空操作日志
// @Description 删除数据
// @Tags 操作日志
// @Success 200 {string} string "{"code": 200, "message": "删除成功"}"
// @Success 200 {string} string "{"code": 400, "message": "删除失败"}"
// @Router /system/log/logOper/all [delete]
func (l *LogOperApi) DeleteAll(rc *ctx.ReqCtx) {
l.LogOperApp.DeleteAll()
}