Merge branch 'master' of git.kingsome.cn:server/game2006go
This commit is contained in:
commit
a1d42ce6e6
@ -16,7 +16,7 @@ func (this *AnncApi) AnncList(c *gin.Context) {
|
|||||||
var anncList []system.Annc
|
var anncList []system.Annc
|
||||||
err := f5.GetApp().GetOrmDb(constant.ADMIN_DB).Find(&anncList).Error
|
err := f5.GetApp().GetOrmDb(constant.ADMIN_DB).Find(&anncList).Error
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.JSON(http.StatusBadRequest, gin.H{
|
c.JSON(http.StatusOK, gin.H{
|
||||||
"code": 1,
|
"code": 1,
|
||||||
"message": err.Error(),
|
"message": err.Error(),
|
||||||
})
|
})
|
||||||
@ -30,17 +30,9 @@ func (this *AnncApi) AnncList(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (this *AnncApi) AddAnnc(c *gin.Context) {
|
func (this *AnncApi) AddAnnc(c *gin.Context) {
|
||||||
//type form struct {
|
|
||||||
// Title string `binding:"required" json:"title"`
|
|
||||||
// Version string `binding:"required" json:"version"`
|
|
||||||
// Model uint `binding:"required" json:"model"`
|
|
||||||
// Type uint `json:"type"`
|
|
||||||
// Content string `binding:"required" json:"content"`
|
|
||||||
//}
|
|
||||||
//formReq := form{}
|
|
||||||
annc := system.Annc{}
|
annc := system.Annc{}
|
||||||
if err := c.ShouldBindJSON(&annc); err != nil {
|
if err := c.ShouldBindJSON(&annc); err != nil {
|
||||||
c.JSON(http.StatusBadRequest, gin.H{
|
c.JSON(http.StatusOK, gin.H{
|
||||||
"code": 1,
|
"code": 1,
|
||||||
"message": err.Error(),
|
"message": err.Error(),
|
||||||
})
|
})
|
||||||
@ -49,7 +41,7 @@ func (this *AnncApi) AddAnnc(c *gin.Context) {
|
|||||||
var count int64
|
var count int64
|
||||||
f5.GetApp().GetOrmDb(constant.ADMIN_DB).Table("t_announcement").Where("model = ?", annc.Model).Where("type = ?", annc.Type).Count(&count)
|
f5.GetApp().GetOrmDb(constant.ADMIN_DB).Table("t_announcement").Where("model = ?", annc.Model).Where("type = ?", annc.Type).Count(&count)
|
||||||
if count > 0 {
|
if count > 0 {
|
||||||
c.JSON(http.StatusBadRequest, gin.H{
|
c.JSON(http.StatusOK, gin.H{
|
||||||
"code": 1,
|
"code": 1,
|
||||||
"message": "无法再插入同类型的公告",
|
"message": "无法再插入同类型的公告",
|
||||||
})
|
})
|
||||||
@ -58,7 +50,7 @@ func (this *AnncApi) AddAnnc(c *gin.Context) {
|
|||||||
|
|
||||||
err := f5.GetApp().GetOrmDb(constant.ADMIN_DB).Create(&annc).Error
|
err := f5.GetApp().GetOrmDb(constant.ADMIN_DB).Create(&annc).Error
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.JSON(http.StatusBadRequest, gin.H{
|
c.JSON(http.StatusOK, gin.H{
|
||||||
"code": 1,
|
"code": 1,
|
||||||
"message": err.Error(),
|
"message": err.Error(),
|
||||||
})
|
})
|
||||||
@ -75,7 +67,7 @@ func (this *AnncApi) UpdateAnnc(c *gin.Context) {
|
|||||||
var count int64
|
var count int64
|
||||||
f5.GetApp().GetOrmDb(constant.ADMIN_DB).Table("t_announcement").Where("idx = ?", idx).Count(&count)
|
f5.GetApp().GetOrmDb(constant.ADMIN_DB).Table("t_announcement").Where("idx = ?", idx).Count(&count)
|
||||||
if count < 1 {
|
if count < 1 {
|
||||||
c.JSON(http.StatusBadRequest, gin.H{
|
c.JSON(http.StatusOK, gin.H{
|
||||||
"code": 1,
|
"code": 1,
|
||||||
"message": "不存在的数据",
|
"message": "不存在的数据",
|
||||||
})
|
})
|
||||||
@ -83,7 +75,7 @@ func (this *AnncApi) UpdateAnnc(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
annc := system.Annc{}
|
annc := system.Annc{}
|
||||||
if err := c.ShouldBindJSON(&annc); err != nil {
|
if err := c.ShouldBindJSON(&annc); err != nil {
|
||||||
c.JSON(http.StatusBadRequest, gin.H{
|
c.JSON(http.StatusOK, gin.H{
|
||||||
"code": 1,
|
"code": 1,
|
||||||
"message": err.Error(),
|
"message": err.Error(),
|
||||||
})
|
})
|
||||||
@ -91,7 +83,7 @@ func (this *AnncApi) UpdateAnnc(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
err := f5.GetApp().GetOrmDb(constant.ADMIN_DB).Select("*").Omit("idx").Where("idx = ?", idx).Updates(&annc).Error
|
err := f5.GetApp().GetOrmDb(constant.ADMIN_DB).Select("*").Omit("idx").Where("idx = ?", idx).Updates(&annc).Error
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.JSON(http.StatusBadRequest, gin.H{
|
c.JSON(http.StatusOK, gin.H{
|
||||||
"code": 1,
|
"code": 1,
|
||||||
"message": err.Error(),
|
"message": err.Error(),
|
||||||
})
|
})
|
||||||
|
@ -16,7 +16,7 @@ func (this *AuditApi) AuditList(c *gin.Context) {
|
|||||||
var auditList []system.Audit
|
var auditList []system.Audit
|
||||||
err := f5.GetApp().GetOrmDb(constant.ADMIN_DB).Find(&auditList).Error
|
err := f5.GetApp().GetOrmDb(constant.ADMIN_DB).Find(&auditList).Error
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.JSON(http.StatusBadRequest, gin.H{
|
c.JSON(http.StatusOK, gin.H{
|
||||||
"code": 1,
|
"code": 1,
|
||||||
"message": err.Error(),
|
"message": err.Error(),
|
||||||
})
|
})
|
||||||
@ -32,7 +32,7 @@ func (this *AuditApi) AuditList(c *gin.Context) {
|
|||||||
func (this *AuditApi) AddAudit(c *gin.Context) {
|
func (this *AuditApi) AddAudit(c *gin.Context) {
|
||||||
audit := system.Audit{}
|
audit := system.Audit{}
|
||||||
if err := c.ShouldBindJSON(&audit); err != nil {
|
if err := c.ShouldBindJSON(&audit); err != nil {
|
||||||
c.JSON(http.StatusBadRequest, gin.H{
|
c.JSON(http.StatusOK, gin.H{
|
||||||
"code": 1,
|
"code": 1,
|
||||||
"message": err.Error(),
|
"message": err.Error(),
|
||||||
})
|
})
|
||||||
@ -41,7 +41,7 @@ func (this *AuditApi) AddAudit(c *gin.Context) {
|
|||||||
var count int64
|
var count int64
|
||||||
f5.GetApp().GetOrmDb(constant.ADMIN_DB).Table("t_audit").Where("model = ?", audit.Model).Count(&count)
|
f5.GetApp().GetOrmDb(constant.ADMIN_DB).Table("t_audit").Where("model = ?", audit.Model).Count(&count)
|
||||||
if count > 0 {
|
if count > 0 {
|
||||||
c.JSON(http.StatusBadRequest, gin.H{
|
c.JSON(http.StatusOK, gin.H{
|
||||||
"code": 1,
|
"code": 1,
|
||||||
"message": "无法再插入",
|
"message": "无法再插入",
|
||||||
})
|
})
|
||||||
@ -50,7 +50,7 @@ func (this *AuditApi) AddAudit(c *gin.Context) {
|
|||||||
|
|
||||||
err := f5.GetApp().GetOrmDb(constant.ADMIN_DB).Create(&audit).Error
|
err := f5.GetApp().GetOrmDb(constant.ADMIN_DB).Create(&audit).Error
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.JSON(http.StatusBadRequest, gin.H{
|
c.JSON(http.StatusOK, gin.H{
|
||||||
"code": 1,
|
"code": 1,
|
||||||
"message": err.Error(),
|
"message": err.Error(),
|
||||||
})
|
})
|
||||||
@ -67,7 +67,7 @@ func (this *AuditApi) UpdateAudit(c *gin.Context) {
|
|||||||
var count int64
|
var count int64
|
||||||
f5.GetApp().GetOrmDb(constant.ADMIN_DB).Table("t_audit").Where("idx = ?", idx).Count(&count)
|
f5.GetApp().GetOrmDb(constant.ADMIN_DB).Table("t_audit").Where("idx = ?", idx).Count(&count)
|
||||||
if count < 1 {
|
if count < 1 {
|
||||||
c.JSON(http.StatusBadRequest, gin.H{
|
c.JSON(http.StatusOK, gin.H{
|
||||||
"code": 1,
|
"code": 1,
|
||||||
"message": "不存在的数据",
|
"message": "不存在的数据",
|
||||||
})
|
})
|
||||||
@ -75,7 +75,7 @@ func (this *AuditApi) UpdateAudit(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
audit := system.Audit{}
|
audit := system.Audit{}
|
||||||
if err := c.ShouldBindJSON(&audit); err != nil {
|
if err := c.ShouldBindJSON(&audit); err != nil {
|
||||||
c.JSON(http.StatusBadRequest, gin.H{
|
c.JSON(http.StatusOK, gin.H{
|
||||||
"code": 1,
|
"code": 1,
|
||||||
"message": err.Error(),
|
"message": err.Error(),
|
||||||
})
|
})
|
||||||
@ -83,7 +83,7 @@ func (this *AuditApi) UpdateAudit(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
err := f5.GetApp().GetOrmDb(constant.ADMIN_DB).Select("*").Omit("idx").Where("idx = ?", idx).Updates(&audit).Error
|
err := f5.GetApp().GetOrmDb(constant.ADMIN_DB).Select("*").Omit("idx").Where("idx = ?", idx).Updates(&audit).Error
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.JSON(http.StatusBadRequest, gin.H{
|
c.JSON(http.StatusOK, gin.H{
|
||||||
"code": 1,
|
"code": 1,
|
||||||
"message": err.Error(),
|
"message": err.Error(),
|
||||||
})
|
})
|
||||||
|
@ -2,8 +2,8 @@ package system
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"adminsever/constant"
|
"adminsever/constant"
|
||||||
|
"encoding/json"
|
||||||
"f5"
|
"f5"
|
||||||
"fmt"
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"net/http"
|
"net/http"
|
||||||
"q5"
|
"q5"
|
||||||
@ -11,6 +11,11 @@ import (
|
|||||||
|
|
||||||
type EmailApi struct {
|
type EmailApi struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
url = "https://" + constant.EMAIL_URL_DEV + "/webapp/index.php"
|
||||||
|
)
|
||||||
|
|
||||||
type emailReq struct {
|
type emailReq struct {
|
||||||
Mailtype int `binding:"required" json:"mailtype"`
|
Mailtype int `binding:"required" json:"mailtype"`
|
||||||
Usertype int `json:"usertype"`
|
Usertype int `json:"usertype"`
|
||||||
@ -28,13 +33,15 @@ type emailReq struct {
|
|||||||
func (this *EmailApi) SendEmail(c *gin.Context) {
|
func (this *EmailApi) SendEmail(c *gin.Context) {
|
||||||
emailMgr := emailReq{}
|
emailMgr := emailReq{}
|
||||||
if err := c.ShouldBindJSON(&emailMgr); err != nil {
|
if err := c.ShouldBindJSON(&emailMgr); err != nil {
|
||||||
c.JSON(http.StatusBadRequest, gin.H{
|
c.JSON(http.StatusOK, gin.H{
|
||||||
"code": 1,
|
"code": 1,
|
||||||
"message": err.Error(),
|
"message": err.Error(),
|
||||||
})
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
params := map[string]string{
|
params := map[string]string{
|
||||||
|
"c": "MailMgr",
|
||||||
|
"a": "sendMail",
|
||||||
"gameid": constant.GAMEID,
|
"gameid": constant.GAMEID,
|
||||||
"to": emailMgr.To,
|
"to": emailMgr.To,
|
||||||
"from": emailMgr.From,
|
"from": emailMgr.From,
|
||||||
@ -50,18 +57,187 @@ func (this *EmailApi) SendEmail(c *gin.Context) {
|
|||||||
"key": constant.EMAIL_KEY,
|
"key": constant.EMAIL_KEY,
|
||||||
}
|
}
|
||||||
|
|
||||||
url := "https://" + constant.EMAIL_URL_DEV + "/webapp/index.php"
|
|
||||||
f5.GetHttpCliMgr().SyncSendGoStyleRequest(url, params, func(response f5.HttpCliResponse) {
|
f5.GetHttpCliMgr().SyncSendGoStyleRequest(url, params, func(response f5.HttpCliResponse) {
|
||||||
err := response.GetErr()
|
err := response.GetErr()
|
||||||
data := response.GetRawData()
|
data := response.GetRawData()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.JSON(http.StatusBadRequest, gin.H{
|
c.JSON(http.StatusOK, gin.H{
|
||||||
"code": 1,
|
"code": 1,
|
||||||
"message": err.Error(),
|
"message": err.Error(),
|
||||||
})
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
fmt.Println(data)
|
|
||||||
|
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{
|
||||||
|
"c": "MailMgr",
|
||||||
|
"a": "getMailList",
|
||||||
|
"key": constant.EMAIL_KEY,
|
||||||
|
"gameid": constant.GAMEID,
|
||||||
|
}
|
||||||
|
f5.GetHttpCliMgr().SyncSendGoStyleRequest(url, 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(url, 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(url, 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{
|
c.JSON(http.StatusOK, gin.H{
|
||||||
"code": 0,
|
"code": 0,
|
||||||
|
@ -29,7 +29,7 @@ func (this *UserApi) Login(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
reqJson := loginForm{}
|
reqJson := loginForm{}
|
||||||
if err := c.ShouldBindJSON(&reqJson); err != nil {
|
if err := c.ShouldBindJSON(&reqJson); err != nil {
|
||||||
c.JSON(http.StatusBadRequest, gin.H{
|
c.JSON(http.StatusOK, gin.H{
|
||||||
"code": 1,
|
"code": 1,
|
||||||
"message": err.Error(),
|
"message": err.Error(),
|
||||||
})
|
})
|
||||||
|
@ -13,8 +13,8 @@ func Auth() gin.HandlerFunc {
|
|||||||
strArr := strings.Split(token, "|")
|
strArr := strings.Split(token, "|")
|
||||||
authToken := GetApp().GetSessionAccountId(strArr[0])
|
authToken := GetApp().GetSessionAccountId(strArr[0])
|
||||||
if token == "" || token != authToken {
|
if token == "" || token != authToken {
|
||||||
c.JSON(http.StatusUnauthorized, gin.H{
|
c.JSON(http.StatusOK, gin.H{
|
||||||
"code": 1,
|
"code": 50014,
|
||||||
"message": "未登录或非法访问",
|
"message": "未登录或非法访问",
|
||||||
})
|
})
|
||||||
/*
|
/*
|
||||||
|
@ -12,5 +12,8 @@ func (this *AnncRouter) InitEmailRouter(priRouter *gin.RouterGroup) {
|
|||||||
emailApi := v1.ApiGroupApp.SystemApiGroup.EmailApi
|
emailApi := v1.ApiGroupApp.SystemApiGroup.EmailApi
|
||||||
{
|
{
|
||||||
priUserRouter.POST("send", emailApi.SendEmail)
|
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