1
This commit is contained in:
parent
9fa89967ca
commit
a50dc649a6
@ -1,248 +0,0 @@
|
||||
package system
|
||||
|
||||
import (
|
||||
"adminsever/constant"
|
||||
"encoding/json"
|
||||
"f5"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
"q5"
|
||||
)
|
||||
|
||||
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 {
|
||||
Mailtype int `binding:"required" json:"mailtype"`
|
||||
Usertype int `json:"usertype"`
|
||||
To string `json:"to"`
|
||||
From string `json:"from"`
|
||||
Subject string `binding:"required" json:"subject"`
|
||||
Mailsubtype int `binding:"required" json:"mailsubtype"`
|
||||
Sendtime int `binding:"required" json:"sendtime"`
|
||||
Expiretime int `binding:"required" json:"expiretime"`
|
||||
Content string `binding:"required" json:"content"`
|
||||
Attachments string `json:"attachments"`
|
||||
Ext string `json:"ext"`
|
||||
}
|
||||
|
||||
func (this *EmailApi) SendEmail(c *gin.Context) {
|
||||
emailMgr := emailReq{}
|
||||
if err := c.ShouldBindJSON(&emailMgr); err != nil {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"code": 1,
|
||||
"message": err.Error(),
|
||||
})
|
||||
return
|
||||
}
|
||||
params := map[string]string{
|
||||
"c": "MailMgr",
|
||||
"a": "sendMail",
|
||||
"gameid": constant.GAMEID,
|
||||
"to": emailMgr.To,
|
||||
"from": emailMgr.From,
|
||||
"mailtype": q5.ToString(emailMgr.Mailtype),
|
||||
"mailsubtype": q5.ToString(emailMgr.Mailsubtype),
|
||||
"usertype": q5.ToString(emailMgr.Usertype),
|
||||
"content": emailMgr.Content,
|
||||
"subject": emailMgr.Subject,
|
||||
"sendtime": q5.ToString(emailMgr.Sendtime),
|
||||
"expiretime": q5.ToString(emailMgr.Expiretime),
|
||||
"attachments": emailMgr.Attachments,
|
||||
"ext": "",
|
||||
"key": constant.EMAIL_KEY,
|
||||
}
|
||||
|
||||
f5.GetHttpCliMgr().SyncSendGoStyleRequest(SendEmailAPI, params, func(response f5.HttpCliResponse) {
|
||||
err := response.GetErr()
|
||||
data := response.GetRawData()
|
||||
if err != nil {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"code": 1,
|
||||
"message": err.Error(),
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
var resData struct {
|
||||
errcode int
|
||||
errmsg string
|
||||
}
|
||||
_ = json.Unmarshal([]byte(data), &resData)
|
||||
if resData.errcode != 0 {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"code": 1,
|
||||
"message": resData.errmsg,
|
||||
})
|
||||
return
|
||||
}
|
||||
})
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"code": 0,
|
||||
"message": "success",
|
||||
})
|
||||
}
|
||||
|
||||
func (this *EmailApi) EmailList(c *gin.Context) {
|
||||
params := map[string]string{
|
||||
"key": constant.EMAIL_KEY,
|
||||
"gameid": constant.GAMEID,
|
||||
}
|
||||
f5.GetHttpCliMgr().SyncSendGoStyleRequest(EmailListAPI, params, func(response f5.HttpCliResponse) {
|
||||
err := response.GetErr()
|
||||
data := response.GetRawData()
|
||||
if err != nil {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"code": 1,
|
||||
"message": err.Error(),
|
||||
})
|
||||
return
|
||||
}
|
||||
rspObj := struct {
|
||||
Errcode int `json:"errcode"`
|
||||
Errmsg string `json:"errmsg"`
|
||||
Maillist []struct {
|
||||
Subject string `json:"subject"`
|
||||
Gameid int `json:"gameid"`
|
||||
Mailid string `json:"mailid"`
|
||||
To string `json:"to"`
|
||||
From string `json:"from"`
|
||||
Sendtime int `json:"sendtime"`
|
||||
Expiretime int `json:"expiretime"`
|
||||
Mailtype int `json:"mailtype"`
|
||||
Mailsubtype int `json:"mailsubtype"`
|
||||
Content string `json:"content"`
|
||||
Ext string `json:"ext"`
|
||||
Attachments []struct {
|
||||
Itemid int `json:"itemid"`
|
||||
Itemnum int `json:"itemnum"`
|
||||
} `json:"attachments"`
|
||||
} `json:"maillist"`
|
||||
}{}
|
||||
_ = json.Unmarshal([]byte(data), &rspObj)
|
||||
|
||||
if rspObj.Errcode != 0 {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"code": 1,
|
||||
"message": rspObj.Errmsg,
|
||||
})
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"code": 0,
|
||||
"message": "success",
|
||||
"data": rspObj.Maillist,
|
||||
})
|
||||
return
|
||||
})
|
||||
}
|
||||
|
||||
func (this *EmailApi) UpdateEmail(c *gin.Context) {
|
||||
mailMgr := struct {
|
||||
Mailid string `binding:"required" json:"mailid"`
|
||||
Subject string `binding:"required" json:"subject"`
|
||||
Content string `binding:"required" json:"content"`
|
||||
Sendtime int `binding:"required" json:"sendtime"`
|
||||
Expiretime int `binding:"required" json:"expiretime"`
|
||||
Ext string `json:"ext"`
|
||||
Attachments string `json:"attachments"`
|
||||
}{}
|
||||
|
||||
if err := c.ShouldBindJSON(&mailMgr); err != nil {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"code": 1,
|
||||
"message": err.Error(),
|
||||
})
|
||||
return
|
||||
}
|
||||
params := map[string]string{
|
||||
"c": "MailMgr",
|
||||
"a": "updateMail",
|
||||
"gameid": constant.GAMEID,
|
||||
"mailid": mailMgr.Mailid,
|
||||
"content": mailMgr.Content,
|
||||
"subject": mailMgr.Subject,
|
||||
"sendtime": q5.ToString(mailMgr.Sendtime),
|
||||
"expiretime": q5.ToString(mailMgr.Expiretime),
|
||||
"attachments": mailMgr.Attachments,
|
||||
"ext": "",
|
||||
"key": constant.EMAIL_KEY,
|
||||
}
|
||||
|
||||
f5.GetHttpCliMgr().SyncSendGoStyleRequest(UpdateEmailAPI, params, func(response f5.HttpCliResponse) {
|
||||
err := response.GetErr()
|
||||
data := response.GetRawData()
|
||||
if err != nil {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"code": 1,
|
||||
"message": err.Error(),
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
var resData struct {
|
||||
errcode int
|
||||
errmsg string
|
||||
}
|
||||
_ = json.Unmarshal([]byte(data), &resData)
|
||||
if resData.errcode != 0 {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"code": 1,
|
||||
"message": resData.errmsg,
|
||||
})
|
||||
return
|
||||
}
|
||||
})
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"code": 0,
|
||||
"message": "success",
|
||||
})
|
||||
}
|
||||
|
||||
func (this *EmailApi) DelEmail(c *gin.Context) {
|
||||
mailid := c.Param("mailid")
|
||||
params := map[string]string{
|
||||
"c": "MailMgr",
|
||||
"a": "deleteMail",
|
||||
"gameid": constant.GAMEID,
|
||||
"mailid": mailid,
|
||||
"key": constant.EMAIL_KEY,
|
||||
}
|
||||
|
||||
f5.GetHttpCliMgr().SyncSendGoStyleRequest(DeleteEmailAPI, params, func(response f5.HttpCliResponse) {
|
||||
err := response.GetErr()
|
||||
data := response.GetRawData()
|
||||
if err != nil {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"code": 1,
|
||||
"message": err.Error(),
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
var resData struct {
|
||||
errcode int
|
||||
errmsg string
|
||||
}
|
||||
_ = json.Unmarshal([]byte(data), &resData)
|
||||
if resData.errcode != 0 {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"code": 1,
|
||||
"message": resData.errmsg,
|
||||
})
|
||||
return
|
||||
}
|
||||
})
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"code": 0,
|
||||
"message": "success",
|
||||
})
|
||||
}
|
@ -4,7 +4,6 @@ type ApiGroup struct {
|
||||
UserApi
|
||||
AnncApi
|
||||
AuditApi
|
||||
EmailApi
|
||||
MailApi
|
||||
UserGroupApi
|
||||
BattleServerApi
|
||||
|
@ -31,3 +31,8 @@ const (
|
||||
MAIL_TYPE_ALL = 2
|
||||
MAIL_TYPE_END = iota
|
||||
)
|
||||
|
||||
const (
|
||||
EVENT_MAIL_UPDATE = "mail.update"
|
||||
EVENT_UPSER_GROUP_UPDATE = "user_group.update"
|
||||
)
|
||||
|
@ -19,7 +19,6 @@ func (this *routerMgr) Init() {
|
||||
this.system.InitUserRouter(priGroup, pubGroup)
|
||||
this.system.InitAnncRouter(priGroup)
|
||||
this.system.InitAuditRouter(priGroup)
|
||||
this.system.InitEmailRouter(priGroup)
|
||||
this.system.InitMailRouter(priGroup)
|
||||
this.system.InitBattleServerRouter(priGroup)
|
||||
f5.GetSysLog().Info("routerMgr.init")
|
||||
|
@ -4,7 +4,6 @@ type RouterGroup struct {
|
||||
UserRouter
|
||||
AnncRouter
|
||||
AuditRouter
|
||||
EmailRoute
|
||||
MailRoute
|
||||
BattleServerRoute
|
||||
}
|
||||
|
@ -1,19 +0,0 @@
|
||||
package system
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"main/api/v1"
|
||||
)
|
||||
|
||||
type EmailRoute struct{}
|
||||
|
||||
func (this *EmailRoute) InitEmailRouter(priRouter *gin.RouterGroup) {
|
||||
priUserRouter := priRouter.Group("email")
|
||||
emailApi := v1.ApiGroupApp.SystemApiGroup.EmailApi
|
||||
{
|
||||
priUserRouter.POST("send", emailApi.SendEmail)
|
||||
priUserRouter.GET("list", emailApi.EmailList)
|
||||
priUserRouter.PUT("update", emailApi.UpdateEmail)
|
||||
priUserRouter.DELETE("delete/:mailid", emailApi.DelEmail)
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user