1
This commit is contained in:
parent
fc51af56cf
commit
de0c40124f
@ -6,6 +6,8 @@ require q5 v1.0.0
|
||||
|
||||
require f5 v1.0.0
|
||||
|
||||
require jccommon v1.0.0
|
||||
|
||||
require mt v1.0.0
|
||||
|
||||
require mtb v1.0.0 // indirect
|
||||
@ -55,6 +57,8 @@ replace q5 => ../../third_party/q5
|
||||
|
||||
replace f5 => ../../third_party/f5
|
||||
|
||||
replace jccommon => ../jccommon
|
||||
|
||||
replace mt => ./mt
|
||||
|
||||
replace mtb => ./mtb
|
||||
|
@ -3,6 +3,7 @@ package mail
|
||||
import (
|
||||
"q5"
|
||||
"f5"
|
||||
"jccommon"
|
||||
"main/common"
|
||||
"main/constant"
|
||||
"sync"
|
||||
@ -46,6 +47,7 @@ func (this *mailMgr) Init() {
|
||||
f5.GetApp().RegisterCaHandle("Mail", "getUnreadMailCnt", this.CaGetUnreadMailCnt)
|
||||
f5.GetApp().RegisterCaHandle("Mail", "getAttachment", this.CaGetAttachment)
|
||||
f5.GetApp().RegisterCaHandle("Mail", "deleteMails", this.CaDeleteMails)
|
||||
f5.GetApp().RegisterCaHandle("MailMgr", "sendMail", this.CaSendMail)
|
||||
this.timerWp = f5.GetTimer().SetIntervalWp(
|
||||
300,
|
||||
func (e int32, args* q5.Args) {
|
||||
@ -215,6 +217,112 @@ func (this *mailMgr) CaDeleteMails(c *gin.Context) {
|
||||
c.JSON(200, rspObj)
|
||||
}
|
||||
|
||||
func (this *mailMgr) CaSendMail(c *gin.Context) {
|
||||
reqJson := struct {
|
||||
UniKey string `json:"unikey"`
|
||||
Subject string `json:"subject"`
|
||||
Content string `json:"content"`
|
||||
Recipients []string`json:"recipients"`
|
||||
SendTime int32 `json:"sendtime"`
|
||||
ExpireTime int32 `json:"expiretime"`
|
||||
Attachments []*common.AttachmentDto `json:"attachments"`
|
||||
}{}
|
||||
if err := c.ShouldBindJSON(&reqJson); err != nil {
|
||||
c.JSON(200, gin.H{
|
||||
"code": 1,
|
||||
"message": err.Error(),
|
||||
})
|
||||
return
|
||||
}
|
||||
rspObj := struct {
|
||||
ErrCode int32 `json:"errcode"`
|
||||
ErrMsg string `json:"errmsg"`
|
||||
}{}
|
||||
|
||||
if reqJson.UniKey == "" {
|
||||
rspObj.ErrCode = 500
|
||||
rspObj.ErrMsg = "unikey param error"
|
||||
c.JSON(200, rspObj)
|
||||
return
|
||||
}
|
||||
/*
|
||||
if reqJson.Subject == "" {
|
||||
c.JSON(200, rspObj)
|
||||
return
|
||||
}*/
|
||||
if reqJson.Content == "" {
|
||||
rspObj.ErrCode = 500
|
||||
rspObj.ErrMsg = "unikey param error"
|
||||
c.JSON(200, rspObj)
|
||||
return
|
||||
}
|
||||
if len(reqJson.Recipients) <= 0 {
|
||||
rspObj.ErrCode = 500
|
||||
rspObj.ErrMsg = "recipients param error"
|
||||
c.JSON(200, rspObj)
|
||||
return
|
||||
}
|
||||
if f5.GetApp().GetRealSeconds() >= q5.ToInt64(reqJson.ExpireTime) {
|
||||
rspObj.ErrCode = 500
|
||||
rspObj.ErrMsg = "expiretime param error"
|
||||
c.JSON(200, rspObj)
|
||||
return
|
||||
}
|
||||
for _, val := range reqJson.Attachments {
|
||||
if val.ItemId == 0 {
|
||||
rspObj.ErrCode = 500
|
||||
rspObj.ErrMsg = "Attachments param error"
|
||||
c.JSON(200, rspObj)
|
||||
return
|
||||
}
|
||||
if val.ItemNum <= 0 || val.ItemNum > 10000 * 100 {
|
||||
rspObj.ErrCode = 500
|
||||
rspObj.ErrMsg = "Attachments param error"
|
||||
c.JSON(200, rspObj)
|
||||
return
|
||||
}
|
||||
}
|
||||
mailId := f5.GetApp().NewLockNodeUuid()
|
||||
nowTime := f5.GetApp().GetRealSeconds()
|
||||
f5.GetGoStyleDb().Insert(
|
||||
constant.MAIL_DB,
|
||||
"t_mail",
|
||||
[][]string{
|
||||
{"mail_id", q5.ToString(mailId)},
|
||||
{"mail_type", q5.ToString(jccommon.MAIL_TYPE_GROUP)},
|
||||
{"unikey", reqJson.UniKey},
|
||||
{"subject", reqJson.Subject},
|
||||
{"content", reqJson.Content},
|
||||
{"recipients", q5.EncodeJson(reqJson.Recipients)},
|
||||
{"attachments", q5.EncodeJson(reqJson.Attachments)},
|
||||
{"sendtime", q5.ToString(reqJson.SendTime)},
|
||||
{"expiretime", q5.ToString(reqJson.ExpireTime)},
|
||||
{"user_reg_start_time", q5.ToString(0)},
|
||||
{"user_reg_end_time", q5.ToString(nowTime + 3600 * 24 * 365 * 10)},
|
||||
{"createtime", q5.ToString(nowTime)},
|
||||
{"modifytime", q5.ToString(nowTime)},
|
||||
},
|
||||
func (err error, lastInsertId int64, rowsAffected int64) {
|
||||
if err != nil {
|
||||
rspObj.ErrCode = 500
|
||||
rspObj.ErrMsg = err.Error()
|
||||
return
|
||||
}
|
||||
f5.GetGoStyleDb().Insert(
|
||||
constant.MAIL_DB,
|
||||
"t_mail",
|
||||
[][]string{
|
||||
{"event_name", constant.EVENT_MAIL_UPDATE},
|
||||
{"param1", q5.ToString(mailId)},
|
||||
{"createtime", q5.ToString(nowTime)},
|
||||
{"modifytime", q5.ToString(nowTime)},
|
||||
},
|
||||
func (err error, lastInsertId int64, rowsAffected int64) {
|
||||
c.JSON(200, rspObj)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
func (this *mailMgr) traversePlayerMail(hum common.Player, cb func(*mail) bool) {
|
||||
stop := false
|
||||
traversedMails := make(map[int64]*mail, 10)
|
||||
|
@ -9,6 +9,12 @@ import (
|
||||
func CaAuth(c *gin.Context) {
|
||||
accountId := c.DefaultQuery("account_id", "")
|
||||
sessionId := c.DefaultQuery("session_id", "")
|
||||
class := c.DefaultQuery("c", "")
|
||||
action := c.DefaultQuery("a", "")
|
||||
if class == "MailMgr" && action == "sendMail" {
|
||||
c.Next()
|
||||
return
|
||||
}
|
||||
hum := GetPlayerMgr().GetPlayerByAccountId(accountId)
|
||||
if hum == nil {
|
||||
hum = GetPlayerMgr().ForceCreatePlayer(accountId, sessionId)
|
||||
|
Loading…
x
Reference in New Issue
Block a user