调整
This commit is contained in:
parent
ac37ef7821
commit
6a85ce7f7d
@ -10,6 +10,7 @@ import (
|
||||
"q5"
|
||||
|
||||
"fmt"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
@ -22,7 +23,18 @@ func (this *MailApi) ListMail(c *gin.Context) {
|
||||
reqObj := struct {
|
||||
Subject string `json:"subject"`
|
||||
Content string `json:"content"`
|
||||
CreateTime struct {
|
||||
Start int32 `json:"start"`
|
||||
End int32 `json:"end"`
|
||||
} `json:"createtime"`
|
||||
SendTime struct {
|
||||
Start int32 `json:"start"`
|
||||
End int32 `json:"end"`
|
||||
} `json:"sendtime"`
|
||||
CreateAddress string `json:"create_address"`
|
||||
UpdateAddress string `json:"update_address"`
|
||||
}{}
|
||||
|
||||
if err := c.ShouldBindJSON(&reqObj); err != nil {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"code": 1,
|
||||
@ -44,6 +56,25 @@ func (this *MailApi) ListMail(c *gin.Context) {
|
||||
if reqObj.Content != "" {
|
||||
q5.AppendSlice(&subFilters, f5.GetDbFilter().Like("content", reqObj.Content).And())
|
||||
}
|
||||
|
||||
if reqObj.CreateTime.End > 0 {
|
||||
q5.AppendSlice(&subFilters, f5.GetDbFilter().GE("createtime", q5.SafeToString(reqObj.CreateTime.Start)).And())
|
||||
q5.AppendSlice(&subFilters, f5.GetDbFilter().LE("createtime", q5.SafeToString(reqObj.CreateTime.End)).And())
|
||||
}
|
||||
|
||||
if reqObj.SendTime.End > 0 {
|
||||
q5.AppendSlice(&subFilters, f5.GetDbFilter().GE("sendtime", q5.SafeToString(reqObj.SendTime.Start)).And())
|
||||
q5.AppendSlice(&subFilters, f5.GetDbFilter().LE("sendtime", q5.SafeToString(reqObj.SendTime.End)).And())
|
||||
}
|
||||
|
||||
if reqObj.CreateAddress != "" {
|
||||
q5.AppendSlice(&subFilters, f5.GetDbFilter().EQ("create_address", reqObj.CreateAddress).And())
|
||||
}
|
||||
|
||||
if reqObj.UpdateAddress != "" {
|
||||
q5.AppendSlice(&subFilters, f5.GetDbFilter().EQ("update_address", reqObj.UpdateAddress).And())
|
||||
}
|
||||
|
||||
mails := []*system.Mail{}
|
||||
rspObj := struct {
|
||||
Code int32 `json:"code"`
|
||||
@ -110,6 +141,9 @@ func (this *MailApi) AddMail(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
s := c.MustGet("session").(common.Session)
|
||||
acc := s.GetAccountAddress()
|
||||
|
||||
nowDaySeconds := int32(f5.GetApp().GetRealSeconds())
|
||||
mail := new(system.Mail)
|
||||
mail.MailId = f5.GetApp().NewLockNodeUuid()
|
||||
@ -127,6 +161,8 @@ func (this *MailApi) AddMail(c *gin.Context) {
|
||||
mail.Tag2 = jccommon.MAIL_TAG2_CUSTOM_NORMAL
|
||||
mail.CreateTime = nowDaySeconds
|
||||
mail.ModifyTime = nowDaySeconds
|
||||
mail.CreateAddress = acc
|
||||
mail.UpdateAddress = acc
|
||||
if f5.GetApp().GetOrmDb(constant.MAIL_DB).Create(mail).Error != nil {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"code": 500,
|
||||
@ -177,7 +213,8 @@ func (this *MailApi) EditMail(c *gin.Context) {
|
||||
}
|
||||
|
||||
var count int64 = 0
|
||||
if f5.GetApp().GetOrmDb(constant.MAIL_DB).Table("t_mail").Where("mail_id = ?", reqJson.MailId).Count(&count); count < 1 {
|
||||
mail := new(system.Mail)
|
||||
if f5.GetApp().GetOrmDb(constant.MAIL_DB).Table("t_mail").Take(mail, "mail_id = ?", reqJson.MailId).Count(&count); count < 1 {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"code": 2,
|
||||
"message": "mailid不存在",
|
||||
@ -186,7 +223,6 @@ func (this *MailApi) EditMail(c *gin.Context) {
|
||||
}
|
||||
|
||||
nowDaySeconds := int32(f5.GetApp().GetRealSeconds())
|
||||
mail := new(system.Mail)
|
||||
mail.MailId = reqJson.MailId
|
||||
mail.MailType = reqJson.MailType
|
||||
mail.SendTime = reqJson.SendTime
|
||||
@ -198,6 +234,10 @@ func (this *MailApi) EditMail(c *gin.Context) {
|
||||
mail.Attachments = reqJson.Attachments
|
||||
mail.Recipients = reqJson.Recipients
|
||||
mail.ModifyTime = nowDaySeconds
|
||||
|
||||
s := c.MustGet("session").(common.Session)
|
||||
acc := s.GetAccountAddress()
|
||||
mail.UpdateAddress = acc
|
||||
f5.GetApp().GetOrmDb(constant.MAIL_DB).Save(mail)
|
||||
{
|
||||
e := new(jccommon.MailEvent)
|
||||
|
@ -39,6 +39,8 @@ type Mail struct {
|
||||
ExpireTime int32 `gorm:"column:expiretime" json:"expiretime"`
|
||||
CreateTime int32 `gorm:"column:createtime;<-:create" json:"createtime"`
|
||||
ModifyTime int32 `gorm:"column:modifytime" json:"modifytime"`
|
||||
CreateAddress string `gorm:"column:create_address;<-:create" json:"create_address"`
|
||||
UpdateAddress string `gorm:"column:update_address" json:"update_address"`
|
||||
}
|
||||
|
||||
func (Mail) TableName() string {
|
||||
|
@ -118,6 +118,16 @@ type ConfDb struct {
|
||||
_flags2_ uint64
|
||||
}
|
||||
|
||||
type Item struct {
|
||||
name string
|
||||
id int32
|
||||
type_ int32
|
||||
sub_type int32
|
||||
|
||||
_flags1_ uint64
|
||||
_flags2_ uint64
|
||||
}
|
||||
|
||||
func (this *AdminCluster) GetInstanceId() int32 {
|
||||
return this.instance_id
|
||||
}
|
||||
@ -550,6 +560,38 @@ func (this *ConfDb) HasMaxIdleConns() bool {
|
||||
return (this._flags1_ & (uint64(1) << 7)) > 0
|
||||
}
|
||||
|
||||
func (this *Item) GetName() string {
|
||||
return this.name
|
||||
}
|
||||
|
||||
func (this *Item) HasName() bool {
|
||||
return (this._flags1_ & (uint64(1) << 1)) > 0
|
||||
}
|
||||
|
||||
func (this *Item) GetId() int32 {
|
||||
return this.id
|
||||
}
|
||||
|
||||
func (this *Item) HasId() bool {
|
||||
return (this._flags1_ & (uint64(1) << 2)) > 0
|
||||
}
|
||||
|
||||
func (this *Item) GetType() int32 {
|
||||
return this.type_
|
||||
}
|
||||
|
||||
func (this *Item) HasType() bool {
|
||||
return (this._flags1_ & (uint64(1) << 3)) > 0
|
||||
}
|
||||
|
||||
func (this *Item) GetSubType() int32 {
|
||||
return this.sub_type
|
||||
}
|
||||
|
||||
func (this *Item) HasSubType() bool {
|
||||
return (this._flags1_ & (uint64(1) << 4)) > 0
|
||||
}
|
||||
|
||||
|
||||
func (this *AdminCluster) LoadFromKv(kv map[string]interface{}) {
|
||||
f5.ReadMetaTableField(&this.instance_id, "instance_id", &this._flags1_, 1, kv)
|
||||
@ -634,3 +676,10 @@ func (this *ConfDb) LoadFromKv(kv map[string]interface{}) {
|
||||
f5.ReadMetaTableField(&this.max_open_conns, "max_open_conns", &this._flags1_, 6, kv)
|
||||
f5.ReadMetaTableField(&this.max_idle_conns, "max_idle_conns", &this._flags1_, 7, kv)
|
||||
}
|
||||
|
||||
func (this *Item) LoadFromKv(kv map[string]interface{}) {
|
||||
f5.ReadMetaTableField(&this.name, "name", &this._flags1_, 1, kv)
|
||||
f5.ReadMetaTableField(&this.id, "id", &this._flags1_, 2, kv)
|
||||
f5.ReadMetaTableField(&this.type_, "type", &this._flags1_, 3, kv)
|
||||
f5.ReadMetaTableField(&this.sub_type, "sub_type", &this._flags1_, 4, kv)
|
||||
}
|
||||
|
@ -95,3 +95,11 @@ message ConfDb
|
||||
optional int32 max_open_conns = 6;
|
||||
optional int32 max_idle_conns = 7;
|
||||
}
|
||||
|
||||
message Item
|
||||
{
|
||||
optional string name = 1;
|
||||
optional int32 id = 2;
|
||||
optional int32 type = 3;
|
||||
optional int32 sub_type = 4;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user