This commit is contained in:
aozhiwei 2024-04-19 09:13:16 +08:00
parent ad820a2f2b
commit d3d6985a99
2 changed files with 34 additions and 0 deletions

View File

@ -17,3 +17,8 @@ const (
MAIL_TYPE_GROUP = 2
MAIL_TYPE_ALL = 3
)
const (
INBOX_STATE_READ = 1
INBOX_STATE_DELETED = 2
)

View File

@ -1,8 +1,11 @@
package player
import (
"q5"
"f5"
"sync"
"main/common"
"main/constant"
)
type mail struct {
@ -26,6 +29,9 @@ func (this *player) init() {
func (this *player) Lock() {
this.lock.Lock()
if !this.loaded {
this.load()
}
}
func (this *player) UnLock() {
@ -54,6 +60,29 @@ func (this *player) checkLock() {
}
}
func (this *player) load() {
f5.GetGoStyleDb().RawQuery(
constant.MAIL_DB,
"SELECT * FROM t_inbox WHERE account_id=? AND expiretime>?",
[]string{
this.GetAccountId(),
q5.ToString(f5.GetApp().GetNowSeconds() - 3600 * 24 * 1),
},
func (err error, ds *f5.DataSet) {
if err != nil {
return
}
for ds.Next() {
p := new(mail)
p.mailId = q5.ToInt64(ds.GetByName("mail_id"))
p.state = q5.ToInt32(ds.GetByName("state"))
p.expireTime = q5.ToInt32(ds.GetByName("expiretime"))
this.mailHash[p.mailId] = p
}
this.loaded = true
})
}
func newPlayer() *player {
p := new(player)
p.init()