Add admin战斗服务器列表, 邮件更换remote request api
This commit is contained in:
parent
0c572b19d2
commit
cb551a45b5
89
server/adminserver/api/v1/system/battle_server.go
Normal file
89
server/adminserver/api/v1/system/battle_server.go
Normal file
@ -0,0 +1,89 @@
|
||||
package system
|
||||
|
||||
import (
|
||||
"adminsever/constant"
|
||||
"adminsever/model/system"
|
||||
"f5"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type BattleServerApi struct{}
|
||||
|
||||
func (s *BattleServerApi) Add(c *gin.Context) {
|
||||
server := system.BattleServer{}
|
||||
if err := c.ShouldBindJSON(&server); err != nil {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"code": 1,
|
||||
"message": err.Error(),
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
err := f5.GetApp().GetOrmDb(constant.ADMIN_DB).Create(&server).Error
|
||||
if err != nil {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"code": 1,
|
||||
"message": err.Error(),
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// response
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"code": 0,
|
||||
"message": "success",
|
||||
"data": "",
|
||||
})
|
||||
}
|
||||
|
||||
func (s *BattleServerApi) List(c *gin.Context) {
|
||||
var battleServers []system.BattleServer
|
||||
err := f5.GetApp().GetOrmDb(constant.ADMIN_DB).Find(&battleServers).Error
|
||||
if err != nil {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"code": 1,
|
||||
"message": err.Error(),
|
||||
})
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"code": 0,
|
||||
"message": "success",
|
||||
"data": battleServers,
|
||||
})
|
||||
}
|
||||
|
||||
func (s *BattleServerApi) Update(c *gin.Context) {
|
||||
entity := system.BattleServer{}
|
||||
if err := c.ShouldBindJSON(&entity); err != nil {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"code": 1,
|
||||
"message": err.Error(),
|
||||
})
|
||||
return
|
||||
}
|
||||
var count int64
|
||||
f5.GetApp().GetOrmDb(constant.ADMIN_DB).Table(entity.TableName()).Where("idx = ?", entity.Idx).Count(&count)
|
||||
if count < 1 {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"code": 1,
|
||||
"message": "不存在的数据",
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
err := f5.GetApp().GetOrmDb(constant.ADMIN_DB).Select("*").Omit("idx").Where("idx = ?", entity.Idx).Updates(&entity).Error
|
||||
if err != nil {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"code": 1,
|
||||
"message": err.Error(),
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"code": 0,
|
||||
"message": "success",
|
||||
})
|
||||
}
|
@ -14,6 +14,10 @@ type EmailApi struct {
|
||||
|
||||
var (
|
||||
url = "https://" + constant.EMAIL_URL_DEV + "/webapp/index.php"
|
||||
SendEmailAPI = "http://localhost:9992/mail_mgr/sendMail"
|
||||
EmailListAPI = "http://localhost:9992/mail_mgr/getMailList"
|
||||
DeleteEmailAPI = "http://localhost:9992/mail_mgr/deleteMail"
|
||||
UpdateEmailAPI = "http://localhost:9992/mail_mgr/updateMail"
|
||||
)
|
||||
|
||||
type emailReq struct {
|
||||
@ -57,7 +61,7 @@ func (this *EmailApi) SendEmail(c *gin.Context) {
|
||||
"key": constant.EMAIL_KEY,
|
||||
}
|
||||
|
||||
f5.GetHttpCliMgr().SyncSendGoStyleRequest(url, params, func(response f5.HttpCliResponse) {
|
||||
f5.GetHttpCliMgr().SyncSendGoStyleRequest(SendEmailAPI, params, func(response f5.HttpCliResponse) {
|
||||
err := response.GetErr()
|
||||
data := response.GetRawData()
|
||||
if err != nil {
|
||||
@ -89,12 +93,10 @@ func (this *EmailApi) SendEmail(c *gin.Context) {
|
||||
|
||||
func (this *EmailApi) EmailList(c *gin.Context) {
|
||||
params := map[string]string{
|
||||
"c": "MailMgr",
|
||||
"a": "getMailList",
|
||||
"key": constant.EMAIL_KEY,
|
||||
"gameid": constant.GAMEID,
|
||||
}
|
||||
f5.GetHttpCliMgr().SyncSendGoStyleRequest(url, params, func(response f5.HttpCliResponse) {
|
||||
f5.GetHttpCliMgr().SyncSendGoStyleRequest(EmailListAPI, params, func(response f5.HttpCliResponse) {
|
||||
err := response.GetErr()
|
||||
data := response.GetRawData()
|
||||
if err != nil {
|
||||
@ -175,7 +177,7 @@ func (this *EmailApi) UpdateEmail(c *gin.Context) {
|
||||
"key": constant.EMAIL_KEY,
|
||||
}
|
||||
|
||||
f5.GetHttpCliMgr().SyncSendGoStyleRequest(url, params, func(response f5.HttpCliResponse) {
|
||||
f5.GetHttpCliMgr().SyncSendGoStyleRequest(UpdateEmailAPI, params, func(response f5.HttpCliResponse) {
|
||||
err := response.GetErr()
|
||||
data := response.GetRawData()
|
||||
if err != nil {
|
||||
@ -215,7 +217,7 @@ func (this *EmailApi) DelEmail(c *gin.Context) {
|
||||
"key": constant.EMAIL_KEY,
|
||||
}
|
||||
|
||||
f5.GetHttpCliMgr().SyncSendGoStyleRequest(url, params, func(response f5.HttpCliResponse) {
|
||||
f5.GetHttpCliMgr().SyncSendGoStyleRequest(DeleteEmailAPI, params, func(response f5.HttpCliResponse) {
|
||||
err := response.GetErr()
|
||||
data := response.GetRawData()
|
||||
if err != nil {
|
||||
|
@ -5,4 +5,5 @@ type ApiGroup struct {
|
||||
AnncApi
|
||||
AuditApi
|
||||
EmailApi
|
||||
BattleServerApi
|
||||
}
|
||||
|
@ -19,5 +19,6 @@ const (
|
||||
const (
|
||||
GAMEID = "2006"
|
||||
EMAIL_URL_DEV = "gamemail-test.kingsome.cn"
|
||||
API_MAIL_HOST_DEV = "localhost:9992"
|
||||
EMAIL_KEY = "520d8eeb8cf1d833a42c820432c020b2fd60f4b7|" + EMAIL_URL_DEV
|
||||
)
|
||||
|
12
server/adminserver/model/system/battle_server.go
Normal file
12
server/adminserver/model/system/battle_server.go
Normal file
@ -0,0 +1,12 @@
|
||||
package system
|
||||
|
||||
type BattleServer struct {
|
||||
Idx int `json:"idx"`
|
||||
Name string `json:"name"`
|
||||
Host string `json:"host"`
|
||||
IsEnable int `json:"is_enable"`
|
||||
}
|
||||
|
||||
func (s BattleServer) TableName() string {
|
||||
return "t_battle_servers"
|
||||
}
|
@ -20,6 +20,7 @@ func (this *routerMgr) Init() {
|
||||
this.system.InitAnncRouter(priGroup)
|
||||
this.system.InitAuditRouter(priGroup)
|
||||
this.system.InitEmailRouter(priGroup)
|
||||
this.system.InitBattleServerRouter(priGroup)
|
||||
f5.GetSysLog().Info("routerMgr.init")
|
||||
}
|
||||
|
||||
|
@ -5,4 +5,5 @@ type RouterGroup struct {
|
||||
AnncRouter
|
||||
AuditRouter
|
||||
EmailRoute
|
||||
BattleServerRoute
|
||||
}
|
||||
|
18
server/adminserver/router/system/sys_battle_server.go
Normal file
18
server/adminserver/router/system/sys_battle_server.go
Normal file
@ -0,0 +1,18 @@
|
||||
package system
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"main/api/v1"
|
||||
)
|
||||
|
||||
type BattleServerRoute struct{}
|
||||
|
||||
func (r *BattleServerRoute) InitBattleServerRouter(priRouter *gin.RouterGroup) {
|
||||
priUserRouter := priRouter.Group("battle_server")
|
||||
api := v1.ApiGroupApp.SystemApiGroup.BattleServerApi
|
||||
{
|
||||
priUserRouter.POST("add", api.Add)
|
||||
priUserRouter.GET("list", api.List)
|
||||
priUserRouter.PUT("update", api.Update)
|
||||
}
|
||||
}
|
@ -7,7 +7,7 @@ import (
|
||||
|
||||
type EmailRoute struct{}
|
||||
|
||||
func (this *AnncRouter) InitEmailRouter(priRouter *gin.RouterGroup) {
|
||||
func (this *EmailRoute) InitEmailRouter(priRouter *gin.RouterGroup) {
|
||||
priUserRouter := priRouter.Group("email")
|
||||
emailApi := v1.ApiGroupApp.SystemApiGroup.EmailApi
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user