调整
This commit is contained in:
parent
5b75032ef1
commit
f8c5fcec47
10
bin/adminserver/config/audit.json
Normal file
10
bin/adminserver/config/audit.json
Normal file
@ -0,0 +1,10 @@
|
||||
[
|
||||
{
|
||||
"version": "1.0.0",
|
||||
"model": 1
|
||||
},
|
||||
{
|
||||
"version": "1.0.0",
|
||||
"model": 2
|
||||
}
|
||||
]
|
@ -2,9 +2,11 @@ package system
|
||||
|
||||
import (
|
||||
"f5"
|
||||
"fmt"
|
||||
"main/constant"
|
||||
"main/model/system"
|
||||
"net/http"
|
||||
"q5"
|
||||
"strconv"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
@ -13,6 +15,37 @@ import (
|
||||
type AuditApi struct {
|
||||
}
|
||||
|
||||
func (aa *AuditApi) Init() {
|
||||
audits := []struct {
|
||||
Version string `json:"version" binding:"required" `
|
||||
Model uint `json:"model" binding:"required" `
|
||||
}{}
|
||||
|
||||
if jsonStr, err := f5.ReadJsonFile("../config/audit.json"); err == nil {
|
||||
if err := q5.DecodeJson(jsonStr, &audits); err != nil {
|
||||
panic(fmt.Sprintf("parse metafile error %s %s", "audit.json", err))
|
||||
}
|
||||
} else {
|
||||
panic(fmt.Sprintf("load metafile error %s %s", "audit.json", err))
|
||||
}
|
||||
|
||||
for _, item := range audits {
|
||||
audit := new(system.Audit)
|
||||
var count int64 = 0
|
||||
f5.GetApp().GetOrmDb(constant.CONF_DB).Table(audit.TableName()).Where("model = ?", item.Model).Count(&count)
|
||||
if count > 0 {
|
||||
continue
|
||||
}
|
||||
|
||||
audit.Version = item.Version
|
||||
audit.IsAuditing = 0
|
||||
audit.Model = item.Model
|
||||
if err := f5.GetApp().GetOrmDb(constant.CONF_DB).Create(audit).Error; err != nil {
|
||||
f5.GetSysLog().Error("添加audit 失败:%s, %d", item.Version, item.Model)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (this *AuditApi) AuditList(c *gin.Context) {
|
||||
var auditList []system.Audit
|
||||
err := f5.GetApp().GetOrmDb(constant.CONF_DB).Find(&auditList).Error
|
||||
|
@ -2,6 +2,7 @@ package system
|
||||
|
||||
import (
|
||||
"f5"
|
||||
"fmt"
|
||||
"main/constant"
|
||||
"main/model/system"
|
||||
"net/http"
|
||||
@ -13,6 +14,38 @@ import (
|
||||
type GameSwitchApi struct {
|
||||
}
|
||||
|
||||
func (gs *GameSwitchApi) Init() {
|
||||
switches := []struct {
|
||||
Name string `json:"switch_name"`
|
||||
Desc string `json:"switch_desc"`
|
||||
}{}
|
||||
|
||||
if jsonStr, err := f5.ReadJsonFile("../config/game_switch.json"); err == nil {
|
||||
if err := q5.DecodeJson(jsonStr, &switches); err != nil {
|
||||
panic(fmt.Sprintf("parse metafile error %s %s", "game_switch.json", err))
|
||||
}
|
||||
} else {
|
||||
panic(fmt.Sprintf("load metafile error %s %s", "game_switch.json", err))
|
||||
}
|
||||
|
||||
nowDaySeconds := int32(f5.GetApp().GetRealSeconds())
|
||||
for _, item := range switches {
|
||||
if err := f5.GetApp().GetOrmDb(constant.CONF_DB).Where("switch_name = ?", item.Name).Take(new(system.GameSwitch)).Error; err == nil {
|
||||
continue
|
||||
}
|
||||
|
||||
gswitch := new(system.GameSwitch)
|
||||
gswitch.Name = item.Name
|
||||
gswitch.Opened = 0
|
||||
gswitch.Remark = item.Desc
|
||||
gswitch.CreateTime = nowDaySeconds
|
||||
gswitch.ModifyTime = nowDaySeconds
|
||||
if err := f5.GetApp().GetOrmDb(constant.CONF_DB).Create(gswitch).Error; err != nil {
|
||||
f5.GetSysLog().Error("添加game switch 失败:%s, %s", item.Name, item.Desc)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (this *GameSwitchApi) List(c *gin.Context) {
|
||||
pagesize := c.DefaultQuery("pagesize", "10")
|
||||
page := c.DefaultQuery("page", "")
|
||||
|
@ -13,10 +13,11 @@ type GameSwitchRoute struct {
|
||||
func (this *GameSwitchRoute) InitGameSwitchRouter(priRouter *gin.RouterGroup) {
|
||||
group := priRouter.Group("game_switch")
|
||||
api := v1.ApiGroupApp.SystemApiGroup.GameSwitchApi
|
||||
api.Init()
|
||||
{
|
||||
group.POST("add", middleware.Permission("api/v1/game_switch/add", api.Add))
|
||||
//group.POST("add", middleware.Permission("api/v1/game_switch/add", api.Add))
|
||||
group.POST("edit", middleware.Permission("api/v1/game_switch/edit", api.Edit))
|
||||
group.POST("del", middleware.Permission("api/v1/game_switch/del", api.Del))
|
||||
//group.POST("del", middleware.Permission("api/v1/game_switch/del", api.Del))
|
||||
group.GET("list", middleware.Permission("api/v1/game_switch/list", api.List))
|
||||
}
|
||||
}
|
||||
|
@ -12,9 +12,10 @@ type AuditRouter struct{}
|
||||
func (ar *AnncRouter) InitAuditRouter(priRouter *gin.RouterGroup) {
|
||||
priUserRouter := priRouter.Group("audit")
|
||||
auditApi := v1.ApiGroupApp.SystemApiGroup.AuditApi
|
||||
auditApi.Init()
|
||||
{
|
||||
priUserRouter.GET("auditList", middleware.Permission("api/v1/audit/auditList", auditApi.AuditList))
|
||||
priUserRouter.POST("addAudit", middleware.Permission("api/v1/audit/addAudit", auditApi.AddAudit))
|
||||
// priUserRouter.POST("addAudit", middleware.Permission("api/v1/audit/addAudit", auditApi.AddAudit))
|
||||
priUserRouter.PUT("updateAudit/:idx", middleware.Permission("api/v1/audit/updateAudit", auditApi.UpdateAudit))
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user