mirror of
https://gitee.com/XM-GO/PandaX.git
synced 2026-04-23 02:48:34 +08:00
1111
This commit is contained in:
@@ -20,7 +20,7 @@
|
||||
---
|
||||
系统在线文档
|
||||
---
|
||||
* 文档地址 :正在编写中。。。
|
||||
* 文档地址 :https://pandaadmin.gitee.io/pandax-docs
|
||||
|
||||
**> 未来会补充文档和视频,方便友友们使用!**
|
||||
|
||||
@@ -122,9 +122,6 @@
|
||||
* :clipboard: 大屏系统
|
||||
* :clipboard: 报表系统
|
||||
|
||||
## 平台官网
|
||||
|
||||
www.pandax.vip
|
||||
|
||||
## ❤特别鸣谢
|
||||
|
||||
|
||||
53
base/utils/ip.go
Normal file
53
base/utils/ip.go
Normal file
@@ -0,0 +1,53 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net"
|
||||
"pandax/base/httpclient"
|
||||
)
|
||||
|
||||
const ipurl = "http://whois.pconline.com.cn/ipJson.jsp"
|
||||
|
||||
const UNKNOWN = "XX XX"
|
||||
|
||||
//获取真实地址
|
||||
func GetRealAddressByIP(ip string) string {
|
||||
if ip == "127.0.0.1" || ip == "localhost" {
|
||||
return "内部IP"
|
||||
}
|
||||
url := fmt.Sprintf("%s?ip=%s&json=true", ipurl, ip)
|
||||
res := httpclient.NewRequest(url).Get()
|
||||
if res == nil || res.StatusCode != 200 {
|
||||
return UNKNOWN
|
||||
}
|
||||
toMap, err := res.BodyToMap()
|
||||
if err != nil {
|
||||
return UNKNOWN
|
||||
}
|
||||
//fmt.Sprintf("%s %s",toMap["pro"].(string),toMap["city"].(string))
|
||||
return toMap["addr"].(string)
|
||||
}
|
||||
|
||||
// 获取局域网ip地址
|
||||
func GetLocaHonst() string {
|
||||
netInterfaces, err := net.Interfaces()
|
||||
if err != nil {
|
||||
fmt.Println("net.Interfaces failed, err:", err.Error())
|
||||
}
|
||||
|
||||
for i := 0; i < len(netInterfaces); i++ {
|
||||
if (netInterfaces[i].Flags & net.FlagUp) != 0 {
|
||||
addrs, _ := netInterfaces[i].Addrs()
|
||||
|
||||
for _, address := range addrs {
|
||||
if ipnet, ok := address.(*net.IPNet); ok && !ipnet.IP.IsLoopback() {
|
||||
if ipnet.IP.To4() != nil {
|
||||
return ipnet.IP.String()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return ""
|
||||
}
|
||||
@@ -35,9 +35,9 @@ redis:
|
||||
port: 6379
|
||||
|
||||
mysql:
|
||||
host: localhost:3306
|
||||
username: root
|
||||
password: 123456
|
||||
host: 47.104.252.2:3306
|
||||
username: pandax
|
||||
password: pandax
|
||||
db-name: pandax
|
||||
config: charset=utf8&loc=Local&parseTime=true
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ type LogLoginApi struct {
|
||||
// @Description 获取JSON
|
||||
// @Tags 登录日志
|
||||
// @Param status query string false "status"
|
||||
// @Param dictCode query string false "username"
|
||||
// @Param username query string false "username"
|
||||
// @Param pageSize query int false "页条数"
|
||||
// @Param pageNum query int false "页码"
|
||||
// @Success 200 {string} string "{"code": 200, "data": [...]}"
|
||||
|
||||
64
system/api/log_oper.go
Normal file
64
system/api/log_oper.go
Normal file
@@ -0,0 +1,64 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"pandax/base/ctx"
|
||||
"pandax/base/ginx"
|
||||
"pandax/base/utils"
|
||||
"pandax/system/entity"
|
||||
"pandax/system/services"
|
||||
)
|
||||
|
||||
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/logOperList [get]
|
||||
// @Security
|
||||
func (l LogOperApi) GetOperLogList(rc *ctx.ReqCtx) {
|
||||
pageNum := ginx.QueryInt(rc.GinCtx, "pageNum", 1)
|
||||
pageSize := ginx.QueryInt(rc.GinCtx, "pageSize", 10)
|
||||
status := rc.GinCtx.Query("status")
|
||||
operName := rc.GinCtx.Query("operName")
|
||||
title := rc.GinCtx.Query("title")
|
||||
|
||||
list, total := l.LogOperApp.FindListPage(pageNum, pageSize, entity.LogOper{Status: status, 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)
|
||||
l.LogOperApp.Delete(group)
|
||||
}
|
||||
@@ -38,4 +38,25 @@ func InitLogRouter(router *gin.RouterGroup) {
|
||||
logLogin.DELETE(":infoId", func(c *gin.Context) {
|
||||
ctx.NewReqCtxWithGin(c).WithLog(deleteLogLoginLog).Handle(login.DeleteLoginLog)
|
||||
})
|
||||
|
||||
// 操作日志
|
||||
oper := &api.LogOperApi{
|
||||
LogOperApp: services.LogOperModelDao,
|
||||
}
|
||||
logOper := router.Group("logOper")
|
||||
|
||||
logOperListLog := ctx.NewLogInfo("获取操作日志列表")
|
||||
logOper.GET("logOperList", func(c *gin.Context) {
|
||||
ctx.NewReqCtxWithGin(c).WithLog(logOperListLog).Handle(oper.GetOperLogList)
|
||||
})
|
||||
|
||||
getLogOperLog := ctx.NewLogInfo("获取操作日志信息")
|
||||
logOper.GET(":operId", func(c *gin.Context) {
|
||||
ctx.NewReqCtxWithGin(c).WithLog(getLogOperLog).Handle(oper.GetOperLog)
|
||||
})
|
||||
|
||||
deleteLogOperLog := ctx.NewLogInfo("删除操作日志信息")
|
||||
logOper.DELETE(":operId", func(c *gin.Context) {
|
||||
ctx.NewReqCtxWithGin(c).WithLog(deleteLogOperLog).Handle(oper.DeleteOperLog)
|
||||
})
|
||||
}
|
||||
|
||||
67
system/services/log_oper.go
Normal file
67
system/services/log_oper.go
Normal file
@@ -0,0 +1,67 @@
|
||||
package services
|
||||
|
||||
import (
|
||||
"pandax/base/biz"
|
||||
"pandax/base/global"
|
||||
"pandax/system/entity"
|
||||
)
|
||||
|
||||
type (
|
||||
LogOperModel interface {
|
||||
Insert(data entity.LogOper) *entity.LogOper
|
||||
FindOne(infoId int64) *entity.LogOper
|
||||
FindListPage(page, pageSize int, data entity.LogOper) (*[]entity.LogOper, int64)
|
||||
Delete(infoId []int64)
|
||||
}
|
||||
|
||||
logLogOperModelImpl struct {
|
||||
table string
|
||||
}
|
||||
)
|
||||
|
||||
var LogOperModelDao LogOperModel = &logLogOperModelImpl{
|
||||
table: `log_logins`,
|
||||
}
|
||||
|
||||
func (m *logLogOperModelImpl) Insert(data entity.LogOper) *entity.LogOper {
|
||||
data.BusinessType = 1
|
||||
err := global.Db.Table(m.table).Create(&data).Error
|
||||
biz.ErrIsNil(err, "添加操作日志信息失败")
|
||||
|
||||
return &data
|
||||
}
|
||||
|
||||
func (m *logLogOperModelImpl) FindOne(operId int64) *entity.LogOper {
|
||||
resData := new(entity.LogOper)
|
||||
err := global.Db.Table(m.table).Where("`oper_id` = ?", operId).First(resData).Error
|
||||
biz.ErrIsNil(err, "查询操作日志信息失败")
|
||||
return resData
|
||||
}
|
||||
|
||||
func (m *logLogOperModelImpl) FindListPage(page, pageSize int, data entity.LogOper) (*[]entity.LogOper, int64) {
|
||||
list := make([]entity.LogOper, 0)
|
||||
var total int64 = 0
|
||||
offset := pageSize * (page - 1)
|
||||
db := global.Db.Table(m.table)
|
||||
// 此处填写 where参数判断
|
||||
if data.Status != "" {
|
||||
db = db.Where("status = ?", data.Status)
|
||||
}
|
||||
if data.Title != "" {
|
||||
db = db.Where("title like ?", "%"+data.Title+"%")
|
||||
}
|
||||
if data.OperName != "" {
|
||||
db = db.Where("oper_name like ?", "%"+data.OperName+"%")
|
||||
}
|
||||
err := db.Where("`delete_time` IS NULL").Count(&total).Error
|
||||
err = db.Order("create_time desc").Limit(pageSize).Offset(offset).Find(&list).Error
|
||||
|
||||
biz.ErrIsNil(err, "查询操作分页日志信息失败")
|
||||
return &list, total
|
||||
}
|
||||
|
||||
func (m *logLogOperModelImpl) Delete(operIds []int64) {
|
||||
err := global.Db.Table(m.table).Delete(&entity.LogOper{}, "`oper_id` in (?)", operIds).Error
|
||||
biz.ErrIsNil(err, "删除操作日志信息失败")
|
||||
return
|
||||
}
|
||||
Reference in New Issue
Block a user