mirror of
https://gitee.com/XM-GO/PandaX.git
synced 2026-04-23 02:48:34 +08:00
【升级go 1.18】
This commit is contained in:
@@ -28,7 +28,7 @@ func (g *GenTableApi) GetDBTableList(rc *ctx.ReqCtx) {
|
||||
pageSize := ginx.QueryInt(rc.GinCtx, "pageSize", 10)
|
||||
tableName := rc.GinCtx.Query("tableName")
|
||||
list, total := g.GenTableApp.FindDbTablesListPage(pageNum, pageSize, entity.DBTables{TableName: tableName})
|
||||
rc.ResData = map[string]interface{}{
|
||||
rc.ResData = map[string]any{
|
||||
"data": list,
|
||||
"total": total,
|
||||
"pageNum": pageNum,
|
||||
@@ -51,7 +51,7 @@ func (g *GenTableApi) GetTablePage(rc *ctx.ReqCtx) {
|
||||
tableName := rc.GinCtx.Query("tableName")
|
||||
tableComment := rc.GinCtx.Query("tableComment")
|
||||
list, total := g.GenTableApp.FindListPage(pageNum, pageSize, entity.DevGenTable{TableName: tableName, TableComment: tableComment})
|
||||
rc.ResData = map[string]interface{}{
|
||||
rc.ResData = map[string]any{
|
||||
"data": list,
|
||||
"total": total,
|
||||
"pageNum": pageNum,
|
||||
@@ -69,7 +69,7 @@ func (g *GenTableApi) GetTablePage(rc *ctx.ReqCtx) {
|
||||
func (g *GenTableApi) GetTableInfo(rc *ctx.ReqCtx) {
|
||||
tableId := ginx.PathParamInt(rc.GinCtx, "tableId")
|
||||
result := g.GenTableApp.FindOne(entity.DevGenTable{TableId: int64(tableId)}, true)
|
||||
mp := make(map[string]interface{})
|
||||
mp := make(map[string]any)
|
||||
mp["list"] = result.Columns
|
||||
mp["info"] = result
|
||||
rc.ResData = mp
|
||||
@@ -85,7 +85,7 @@ func (g *GenTableApi) GetTableInfo(rc *ctx.ReqCtx) {
|
||||
func (g *GenTableApi) GetTableInfoByName(rc *ctx.ReqCtx) {
|
||||
tableName := rc.GinCtx.Query("tableName")
|
||||
result := g.GenTableApp.FindOne(entity.DevGenTable{TableName: tableName}, true)
|
||||
mp := make(map[string]interface{})
|
||||
mp := make(map[string]any)
|
||||
mp["list"] = result.Columns
|
||||
mp["info"] = result
|
||||
rc.ResData = mp
|
||||
|
||||
@@ -323,7 +323,7 @@ func (s *toolsGenTableColumn) GenTableInit(tableName string) entity.DevGenTable
|
||||
}
|
||||
|
||||
// 视图预览
|
||||
func Preview(tableId int64) map[string]interface{} {
|
||||
func Preview(tableId int64) map[string]any {
|
||||
t1, err := template.ParseFiles("resource/template/go/entity.template")
|
||||
biz.ErrIsNil(err, "entity模版读取失败")
|
||||
|
||||
@@ -362,7 +362,7 @@ func Preview(tableId int64) map[string]interface{} {
|
||||
var b7 bytes.Buffer
|
||||
err = t7.Execute(&b7, tab)
|
||||
|
||||
mp := make(map[string]interface{})
|
||||
mp := make(map[string]any)
|
||||
mp["template/entity.template"] = b1.String()
|
||||
mp["template/service.template"] = b2.String()
|
||||
mp["template/api.template"] = b3.String()
|
||||
|
||||
@@ -41,7 +41,7 @@ var DevGenTableModelDao SysGenTableModel = &devGenTableModelImpl{
|
||||
|
||||
func (m *devGenTableModelImpl) FindDbTablesListPage(page, pageSize int, data entity.DBTables) (*[]entity.DBTables, int64) {
|
||||
list := make([]entity.DBTables, 0)
|
||||
pgdata := make([]map[string]interface{}, 0)
|
||||
pgdata := make([]map[string]any, 0)
|
||||
var total int64 = 0
|
||||
offset := pageSize * (page - 1)
|
||||
if config.Conf.Server.DbType != "mysql" && config.Conf.Server.DbType != "postgresql" {
|
||||
|
||||
@@ -52,7 +52,7 @@ func (j *JobApi) GetJobList(rc *ctx.ReqCtx) {
|
||||
status := rc.GinCtx.Query("status")
|
||||
|
||||
list, total := j.JobApp.FindListPage(pageNum, pageSize, entity.SysJob{JobName: jobName, JobGroup: jobGroup, Status: status})
|
||||
rc.ResData = map[string]interface{}{
|
||||
rc.ResData = map[string]any{
|
||||
"data": list,
|
||||
"total": total,
|
||||
"pageNum": pageNum,
|
||||
|
||||
@@ -18,7 +18,7 @@ func InitJob() {
|
||||
type CronHandle struct {
|
||||
}
|
||||
|
||||
func (t CronHandle) Exec(arg interface{}) error {
|
||||
func (t CronHandle) Exec(arg any) error {
|
||||
str := time.Now().Format(timeFormat) + " [INFO] JobCore ExamplesOne exec success"
|
||||
// TODO: 这里需要注意 Examples 传入参数是 string 所以 arg.(string);请根据对应的类型进行转化;
|
||||
switch arg.(type) {
|
||||
|
||||
@@ -8,9 +8,9 @@ type Job interface {
|
||||
}
|
||||
|
||||
type JobsExec interface {
|
||||
Exec(arg interface{}) error
|
||||
Exec(arg any) error
|
||||
}
|
||||
|
||||
func CallExec(e JobsExec, arg interface{}) error {
|
||||
func CallExec(e JobsExec, arg any) error {
|
||||
return e.Exec(arg)
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ func (l *LogJobApi) GetJobLogList(rc *ctx.ReqCtx) {
|
||||
status := rc.GinCtx.Query("status")
|
||||
|
||||
list, total := l.LogJobApp.FindListPage(pageNum, pageSize, entity.LogJob{Name: name, JobGroup: jobGroup, Status: status})
|
||||
rc.ResData = map[string]interface{}{
|
||||
rc.ResData = map[string]any{
|
||||
"data": list,
|
||||
"total": total,
|
||||
"pageNum": pageNum,
|
||||
|
||||
@@ -27,9 +27,8 @@ func (l *LogLoginApi) GetLoginLogList(rc *ctx.ReqCtx) {
|
||||
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{}{
|
||||
rc.ResData = map[string]any{
|
||||
"data": list,
|
||||
"total": total,
|
||||
"pageNum": pageNum,
|
||||
|
||||
@@ -31,7 +31,7 @@ func (l *LogOperApi) GetOperLogList(rc *ctx.ReqCtx) {
|
||||
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{}{
|
||||
rc.ResData = map[string]any{
|
||||
"data": list,
|
||||
"total": total,
|
||||
"pageNum": pageNum,
|
||||
|
||||
@@ -45,7 +45,7 @@ func (p *ResEmailsApi) GetResEmailsList(rc *ctx.ReqCtx) {
|
||||
data.Secret = utils.DdmPassword(data.Secret)
|
||||
li[i] = data
|
||||
}
|
||||
rc.ResData = map[string]interface{}{
|
||||
rc.ResData = map[string]any{
|
||||
"data": list,
|
||||
"total": total,
|
||||
"pageNum": pageNum,
|
||||
|
||||
@@ -48,7 +48,7 @@ func (p *ResOssesApi) GetResOssesList(rc *ctx.ReqCtx) {
|
||||
data.SecretKey = utils.DdmKey(data.SecretKey)
|
||||
li[i] = data
|
||||
}
|
||||
rc.ResData = map[string]interface{}{
|
||||
rc.ResData = map[string]any{
|
||||
"data": list,
|
||||
"total": total,
|
||||
"pageNum": pageNum,
|
||||
|
||||
@@ -63,7 +63,7 @@ func (s *SystemApiApi) GetApiList(rc *ctx.ReqCtx) {
|
||||
apiGroup := rc.GinCtx.Query("apiGroup")
|
||||
api := entity.SysApi{Path: path, Description: description, Method: method, ApiGroup: apiGroup}
|
||||
list, total := s.ApiApp.FindListPage(pageNum, pageSize, api)
|
||||
rc.ResData = map[string]interface{}{
|
||||
rc.ResData = map[string]any{
|
||||
"data": list,
|
||||
"total": total,
|
||||
"pageNum": pageNum,
|
||||
|
||||
@@ -33,7 +33,7 @@ func (p *ConfigApi) GetConfigList(rc *ctx.ReqCtx) {
|
||||
config := entity.SysConfig{ConfigName: configName, ConfigKey: configKey, ConfigType: configType}
|
||||
list, total := p.ConfigApp.FindListPage(pageNum, pageSize, config)
|
||||
|
||||
rc.ResData = map[string]interface{}{
|
||||
rc.ResData = map[string]any{
|
||||
"data": list,
|
||||
"total": total,
|
||||
"pageNum": pageNum,
|
||||
|
||||
@@ -35,7 +35,7 @@ func (m *DeptApi) GetDeptTreeRoleSelect(rc *ctx.ReqCtx) {
|
||||
if roleId != 0 {
|
||||
deptIds = m.RoleApp.GetRoleDeptId(entity.SysRole{RoleId: int64(roleId)})
|
||||
}
|
||||
rc.ResData = map[string]interface{}{
|
||||
rc.ResData = map[string]any{
|
||||
"depts": result,
|
||||
"checkedKeys": deptIds,
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ func (p *DictApi) GetDictTypeList(rc *ctx.ReqCtx) {
|
||||
dictType := rc.GinCtx.Query("dictType")
|
||||
|
||||
list, total := p.DictType.FindListPage(pageNum, pageSize, entity.SysDictType{Status: status, DictName: dictName, DictType: dictType})
|
||||
rc.ResData = map[string]interface{}{
|
||||
rc.ResData = map[string]any{
|
||||
"data": list,
|
||||
"total": total,
|
||||
"pageNum": pageNum,
|
||||
|
||||
@@ -57,7 +57,7 @@ func (m *MenuApi) GetMenuTreeRoleSelect(rc *ctx.ReqCtx) {
|
||||
if roleId != 0 {
|
||||
menuIds = m.RoleApp.GetRoleMeunId(entity.SysRole{RoleId: int64(roleId)})
|
||||
}
|
||||
rc.ResData = map[string]interface{}{
|
||||
rc.ResData = map[string]any{
|
||||
"menus": result,
|
||||
"checkedKeys": menuIds,
|
||||
}
|
||||
@@ -128,7 +128,7 @@ func (m *MenuApi) InsertMenu(rc *ctx.ReqCtx) {
|
||||
m.MenuApp.Insert(menu)
|
||||
permis := m.RoleMenuApp.GetPermis(rc.LoginAccount.RoleId)
|
||||
menus := m.MenuApp.SelectMenuRole(rc.LoginAccount.RoleKey)
|
||||
rc.ResData = map[string]interface{}{
|
||||
rc.ResData = map[string]any{
|
||||
"permissions": permis,
|
||||
"menus": Build(*menus),
|
||||
}
|
||||
@@ -149,7 +149,7 @@ func (m *MenuApi) UpdateMenu(rc *ctx.ReqCtx) {
|
||||
m.MenuApp.Update(menu)
|
||||
permis := m.RoleMenuApp.GetPermis(rc.LoginAccount.RoleId)
|
||||
menus := m.MenuApp.SelectMenuRole(rc.LoginAccount.RoleKey)
|
||||
rc.ResData = map[string]interface{}{
|
||||
rc.ResData = map[string]any{
|
||||
"permissions": permis,
|
||||
"menus": Build(*menus),
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ func (p *NoticeApi) GetNoticeList(rc *ctx.ReqCtx) {
|
||||
notice := entity.SysNotice{NoticeType: noticeType, Title: title, DeptIds: ids}
|
||||
list, total := p.NoticeApp.FindListPage(pageNum, pageSize, notice)
|
||||
|
||||
rc.ResData = map[string]interface{}{
|
||||
rc.ResData = map[string]any{
|
||||
"data": list,
|
||||
"total": total,
|
||||
"pageNum": pageNum,
|
||||
|
||||
@@ -39,7 +39,7 @@ func (p *PostApi) GetPostList(rc *ctx.ReqCtx) {
|
||||
post := entity.SysPost{Status: status, PostName: postName, PostCode: postCode}
|
||||
list, total := p.PostApp.FindListPage(pageNum, pageSize, post)
|
||||
|
||||
rc.ResData = map[string]interface{}{
|
||||
rc.ResData = map[string]any{
|
||||
"data": list,
|
||||
"total": total,
|
||||
"pageNum": pageNum,
|
||||
|
||||
@@ -44,7 +44,7 @@ func (r *RoleApi) GetRoleList(rc *ctx.ReqCtx) {
|
||||
role := entity.SysRole{Status: status, RoleName: roleName, RoleKey: roleKey}
|
||||
list, total := r.RoleApp.FindListPage(pageNum, pageSize, role)
|
||||
|
||||
rc.ResData = map[string]interface{}{
|
||||
rc.ResData = map[string]any{
|
||||
"data": list,
|
||||
"total": total,
|
||||
"pageNum": pageNum,
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/gorilla/websocket"
|
||||
"github.com/kakuilan/kgo"
|
||||
@@ -21,7 +22,7 @@ const (
|
||||
)
|
||||
|
||||
func (s *System) ServerInfo(g *gin.Context) {
|
||||
osDic := make(map[string]interface{}, 0)
|
||||
osDic := make(map[string]any, 0)
|
||||
osDic["goOs"] = runtime.GOOS
|
||||
osDic["arch"] = runtime.GOARCH
|
||||
osDic["mem"] = runtime.MemProfileRate
|
||||
@@ -29,26 +30,23 @@ func (s *System) ServerInfo(g *gin.Context) {
|
||||
osDic["version"] = runtime.Version()
|
||||
osDic["numGoroutine"] = runtime.NumGoroutine()
|
||||
|
||||
used, free, total := kgo.KOS.DiskUsage("/")
|
||||
diskDic := make(map[string]interface{}, 0)
|
||||
diskDic["total"] = total / GB
|
||||
diskDic["free"] = free / GB
|
||||
diskDic["used"] = used / GB
|
||||
diskDic["progress"] = int64((float64(used) / float64(total)) * 100)
|
||||
info := kgo.KOS.GetSystemInfo()
|
||||
diskDic := make(map[string]any, 0)
|
||||
diskDic["total"] = info.DiskTotal / GB
|
||||
diskDic["free"] = info.DiskFree / GB
|
||||
diskDic["used"] = info.DiskUsed / GB
|
||||
diskDic["progress"] = int64((float64(info.DiskUsed) / float64(info.DiskTotal)) * 100)
|
||||
|
||||
used2, free2, total2 := kgo.KOS.MemoryUsage(true)
|
||||
memDic := make(map[string]interface{}, 0)
|
||||
memDic["total"] = total2 / GB
|
||||
memDic["used"] = used2 / GB
|
||||
memDic["free"] = free2 / GB
|
||||
memDic["progress"] = int64((float64(used2) / float64(total2)) * 100)
|
||||
memDic := make(map[string]any, 0)
|
||||
memDic["total"] = info.MemTotal / GB
|
||||
memDic["used"] = info.MemUsed / GB
|
||||
memDic["free"] = info.MemFree / GB
|
||||
memDic["progress"] = int64((float64(info.MemUsed) / float64(info.MemTotal)) * 100)
|
||||
|
||||
cpuDic := make(map[string]interface{}, 0)
|
||||
used3, idle, total3 := kgo.KOS.CpuUsage()
|
||||
cpuDic["total"] = total3 / GB
|
||||
cpuDic["used"] = used3 / GB
|
||||
cpuDic["free"] = idle / GB
|
||||
cpuDic["progress"] = int64((float64(used3) / float64(total3)) * 100)
|
||||
cpuDic := make(map[string]any, 0)
|
||||
cpuDic["num"] = info.CpuNum
|
||||
cpuDic["used"] = fmt.Sprintf("%.2f", info.CpuUser*100)
|
||||
cpuDic["free"] = fmt.Sprintf("%.2f", info.CpuFree*100)
|
||||
|
||||
g.JSON(http.StatusOK, gin.H{
|
||||
"code": 200,
|
||||
@@ -63,19 +61,19 @@ func (s *System) ServerInfo(g *gin.Context) {
|
||||
func (s *System) ConnectWs(g *gin.Context) {
|
||||
wsConn, err := ws.Upgrader.Upgrade(g.Writer, g.Request, nil)
|
||||
defer func() {
|
||||
if err := recover(); err != nil {
|
||||
wsConn.WriteMessage(websocket.TextMessage, []byte(err.(error).Error()))
|
||||
if err := recover(); &err != nil {
|
||||
wsConn.WriteMessage(websocket.TextMessage, []byte(fmt.Sprintf("websocket 失败: %v", err)))
|
||||
wsConn.Close()
|
||||
}
|
||||
}()
|
||||
|
||||
if err != nil {
|
||||
panic(biz.NewBizErr("升级websocket失败"))
|
||||
panic(any(biz.NewBizErr("升级websocket失败")))
|
||||
}
|
||||
// 权限校验
|
||||
rc := ctx.NewReqCtxWithGin(g)
|
||||
if err = ctx.PermissionHandler(rc); err != nil {
|
||||
panic(biz.NewBizErr("没有权限"))
|
||||
panic(any(biz.NewBizErr("没有权限")))
|
||||
}
|
||||
|
||||
// 登录账号信息
|
||||
|
||||
@@ -43,7 +43,7 @@ type UserApi struct {
|
||||
// @Router /system/user/getCaptcha [get]
|
||||
func (u *UserApi) GenerateCaptcha(c *gin.Context) {
|
||||
id, image := captcha.Generate()
|
||||
c.JSON(http.StatusOK, map[string]interface{}{"base64Captcha": image, "captchaId": id})
|
||||
c.JSON(http.StatusOK, map[string]any{"base64Captcha": image, "captchaId": id})
|
||||
}
|
||||
|
||||
// @Tags Base
|
||||
@@ -55,7 +55,7 @@ func (u *UserApi) RefreshToken(rc *ctx.ReqCtx) {
|
||||
tokenStr := rc.GinCtx.Request.Header.Get("X-TOKEN")
|
||||
token, err := ctx.RefreshToken(tokenStr)
|
||||
biz.ErrIsNil(err, "刷新token失败")
|
||||
rc.ResData = map[string]interface{}{"token": token, "expire": time.Now().Unix() + config.Conf.Jwt.ExpireTime}
|
||||
rc.ResData = map[string]any{"token": token, "expire": time.Now().Unix() + config.Conf.Jwt.ExpireTime}
|
||||
}
|
||||
|
||||
// @Tags Base
|
||||
@@ -89,7 +89,7 @@ func (u *UserApi) Login(rc *ctx.ReqCtx) {
|
||||
|
||||
biz.ErrIsNil(err, "生成Token失败")
|
||||
|
||||
rc.ResData = map[string]interface{}{
|
||||
rc.ResData = map[string]any{
|
||||
"token": token,
|
||||
"expire": time.Now().Unix() + config.Conf.Jwt.ExpireTime,
|
||||
}
|
||||
@@ -128,7 +128,7 @@ func (u *UserApi) Auth(rc *ctx.ReqCtx) {
|
||||
permis := u.RoleMenuApp.GetPermis(role.RoleId)
|
||||
menus := u.MenuApp.SelectMenuRole(role.RoleKey)
|
||||
|
||||
rc.ResData = map[string]interface{}{
|
||||
rc.ResData = map[string]any{
|
||||
"user": userData,
|
||||
"role": role,
|
||||
"permissions": permis,
|
||||
@@ -183,7 +183,7 @@ func (u *UserApi) GetSysUserList(rc *ctx.ReqCtx) {
|
||||
user.DeptId = int64(deptId)
|
||||
list, total := u.UserApp.FindListPage(pageNum, pageSize, user)
|
||||
|
||||
rc.ResData = map[string]interface{}{
|
||||
rc.ResData = map[string]any{
|
||||
"data": list,
|
||||
"total": total,
|
||||
"pageNum": pageNum,
|
||||
@@ -216,7 +216,7 @@ func (u *UserApi) GetSysUserProfile(rc *ctx.ReqCtx) {
|
||||
roleIds := make([]int64, 0)
|
||||
roleIds = append(roleIds, rc.LoginAccount.RoleId)
|
||||
|
||||
rc.ResData = map[string]interface{}{
|
||||
rc.ResData = map[string]any{
|
||||
"data": user,
|
||||
"postIds": postIds,
|
||||
"roleIds": roleIds,
|
||||
@@ -287,7 +287,7 @@ func (u *UserApi) GetSysUser(rc *ctx.ReqCtx) {
|
||||
|
||||
posts := u.PostApp.FindList(entity.SysPost{})
|
||||
|
||||
rc.ResData = map[string]interface{}{
|
||||
rc.ResData = map[string]any{
|
||||
"data": result,
|
||||
"postIds": result.PostIds,
|
||||
"roleIds": result.RoleIds,
|
||||
@@ -306,7 +306,7 @@ func (u *UserApi) GetSysUserInit(rc *ctx.ReqCtx) {
|
||||
roles := u.RoleApp.FindList(entity.SysRole{})
|
||||
|
||||
posts := u.PostApp.FindList(entity.SysPost{})
|
||||
mp := make(map[string]interface{}, 2)
|
||||
mp := make(map[string]any, 2)
|
||||
mp["roles"] = roles
|
||||
mp["posts"] = posts
|
||||
rc.ResData = mp
|
||||
@@ -334,7 +334,7 @@ func (u *UserApi) GetUserRolePost(rc *ctx.ReqCtx) {
|
||||
po := u.PostApp.FindOne(kgo.KConv.Str2Int64(postId))
|
||||
posts = append(posts, *po)
|
||||
}
|
||||
mp := make(map[string]interface{}, 2)
|
||||
mp := make(map[string]any, 2)
|
||||
mp["roles"] = roles
|
||||
mp["posts"] = posts
|
||||
rc.ResData = mp
|
||||
|
||||
@@ -84,9 +84,8 @@ func (m *sysMenuModelImpl) FindList(data entity.SysMenu) *[]entity.SysMenu {
|
||||
}
|
||||
|
||||
func (m *sysMenuModelImpl) Update(data entity.SysMenu) *entity.SysMenu {
|
||||
err := global.Db.Table(m.table).Updates(&data).Error
|
||||
err := global.Db.Table(m.table).Select("*").Updates(data).Error
|
||||
biz.ErrIsNil(err, "修改菜单失败")
|
||||
//m.InitPaths(&data)
|
||||
return &data
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user