1
This commit is contained in:
parent
7579af6485
commit
fcf5da2e10
@ -1,62 +1,8 @@
|
||||
package common
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type AttachmentDto struct {
|
||||
ItemId int32 `json:"itemid"`
|
||||
ItemNum int32 `json:"itemnum"`
|
||||
}
|
||||
|
||||
type MailDto struct {
|
||||
MailId string `json:"mailid"`
|
||||
From string `json:"from"`
|
||||
To string `json:"to"`
|
||||
Subject string `json:"subject"`
|
||||
Content string `json:"content"`
|
||||
Flags int32 `json:"flags"`
|
||||
SendTime int32 `json:"sendtime"`
|
||||
ExpireTime int32 `json:"expiretime"`
|
||||
MailType int32 `json:"mailtype"`
|
||||
MailSubType int32 `json:"mailsubtype"`
|
||||
Ext string `json:"ext"`
|
||||
Attachments []*AttachmentDto `json:"attachments"`
|
||||
}
|
||||
|
||||
type App interface {
|
||||
Run(func(), func())
|
||||
}
|
||||
|
||||
type Player interface {
|
||||
Lock() bool
|
||||
UnLock()
|
||||
GetAccountId() string
|
||||
GetRegisterTime() int32
|
||||
|
||||
MarkMails([]Mail) error
|
||||
GetAttachment([]Mail) error
|
||||
DeleteMails([]Mail) error
|
||||
IsReadable(Mail) bool
|
||||
IsUnread(Mail) bool
|
||||
}
|
||||
|
||||
type PlayerMgr interface {
|
||||
GetPlayerByAccountId(string) Player
|
||||
ForceCreatePlayer(string, string) Player
|
||||
}
|
||||
|
||||
type Mail interface {
|
||||
GetMailId() int64
|
||||
IsValid(Player) bool
|
||||
GetExpireTime() int32
|
||||
}
|
||||
|
||||
type MailMgr interface{
|
||||
CaGetMailList(c *gin.Context)
|
||||
CaMarkMail(c *gin.Context)
|
||||
CaGetUnreadMailCnt(c *gin.Context)
|
||||
CaGetAttachment(c *gin.Context)
|
||||
CaDeleteMails(c *gin.Context)
|
||||
HasTask() bool
|
||||
}
|
||||
|
@ -2,7 +2,6 @@ package constant
|
||||
|
||||
const (
|
||||
APP_MODULE_IDX = iota
|
||||
MAIL_MGR_MODULE_IDX
|
||||
CONTROLLER_MGR_MODULE_IDX
|
||||
MAX_MODULE_IDX
|
||||
)
|
||||
|
@ -9,20 +9,14 @@ import (
|
||||
|
||||
var modules [constant.MAX_MODULE_IDX]q5.Module
|
||||
var initOrders = []int32{
|
||||
constant.MAIL_MGR_MODULE_IDX,
|
||||
}
|
||||
|
||||
var app common.App
|
||||
var mailMgr common.MailMgr
|
||||
|
||||
func GetApp() common.App {
|
||||
return app
|
||||
}
|
||||
|
||||
func GetMailMgr() common.MailMgr {
|
||||
return mailMgr
|
||||
}
|
||||
|
||||
|
||||
func RegModule(idx int32, m q5.Module) {
|
||||
fmt.Printf("RegModule module %d\n", idx)
|
||||
@ -32,10 +26,6 @@ func RegModule(idx int32, m q5.Module) {
|
||||
{
|
||||
app = m.(common.App)
|
||||
}
|
||||
case constant.MAIL_MGR_MODULE_IDX:
|
||||
{
|
||||
mailMgr = m.(common.MailMgr)
|
||||
}
|
||||
default:
|
||||
{
|
||||
panic("unknow module")
|
||||
|
@ -1,69 +0,0 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"q5"
|
||||
"f5"
|
||||
"main/constant"
|
||||
)
|
||||
|
||||
type inbox struct {
|
||||
|
||||
}
|
||||
|
||||
var Inbox = new(inbox)
|
||||
|
||||
func (this *inbox) Mark(accountId string, mailId int64, nowTime int64, expireTime int32) error {
|
||||
var result error
|
||||
f5.GetGoStyleDb().Upsert(
|
||||
constant.MAIL_DB,
|
||||
"t_inbox",
|
||||
[][]string{
|
||||
{"account_id", accountId},
|
||||
{"mail_id", q5.ToString(mailId)},
|
||||
},
|
||||
[][]string{
|
||||
{"state", q5.ToString(constant.INBOX_STATE_READ)},
|
||||
{"expiretime", q5.ToString(expireTime)},
|
||||
{"modifytime", q5.ToString(nowTime)},
|
||||
},
|
||||
[][]string{
|
||||
{"account_id", accountId},
|
||||
{"mail_id", q5.ToString(mailId)},
|
||||
{"state", q5.ToString(constant.INBOX_STATE_READ)},
|
||||
{"expiretime", q5.ToString(expireTime)},
|
||||
{"createtime", q5.ToString(nowTime)},
|
||||
{"modifytime", q5.ToString(nowTime)},
|
||||
},
|
||||
func (err error, lastInsertId int64, rowsAffected int64) {
|
||||
result = err
|
||||
})
|
||||
return result
|
||||
}
|
||||
|
||||
func (this *inbox) Delete(accountId string, mailId int64, nowTime int64, expireTime int32) error {
|
||||
var result error
|
||||
f5.GetGoStyleDb().Upsert(
|
||||
constant.MAIL_DB,
|
||||
"t_inbox",
|
||||
[][]string{
|
||||
{"account_id", accountId},
|
||||
{"mail_id", q5.ToString(mailId)},
|
||||
},
|
||||
[][]string{
|
||||
{"state", q5.ToString(constant.INBOX_STATE_DELETED)},
|
||||
{"expiretime", q5.ToString(expireTime)},
|
||||
{"modifytime", q5.ToString(nowTime)},
|
||||
},
|
||||
[][]string{
|
||||
{"account_id", accountId},
|
||||
{"mail_id", q5.ToString(mailId)},
|
||||
{"state", q5.ToString(constant.INBOX_STATE_DELETED)},
|
||||
{"expiretime", q5.ToString(expireTime)},
|
||||
{"createtime", q5.ToString(nowTime)},
|
||||
{"modifytime", q5.ToString(nowTime)},
|
||||
},
|
||||
func (err error, lastInsertId int64, rowsAffected int64) {
|
||||
result = err
|
||||
})
|
||||
return result
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user