|
@@ -4,6 +4,8 @@ import (
|
|
"eta/eta_api/global"
|
|
"eta/eta_api/global"
|
|
"eta/eta_api/utils"
|
|
"eta/eta_api/utils"
|
|
"time"
|
|
"time"
|
|
|
|
+
|
|
|
|
+ "github.com/rdlucklib/rdluck_tools/paging"
|
|
)
|
|
)
|
|
|
|
|
|
|
|
|
|
@@ -14,6 +16,9 @@ type EdbInspectionMessage struct {
|
|
AdminId int64 `gorm:"column:admin_id"`
|
|
AdminId int64 `gorm:"column:admin_id"`
|
|
Message string `gorm:"column:message"`
|
|
Message string `gorm:"column:message"`
|
|
IsRead int8 `gorm:"column:is_read"`
|
|
IsRead int8 `gorm:"column:is_read"`
|
|
|
|
+ Source int8 `gorm:"column:source"`
|
|
|
|
+ TerminalCode string `gorm:"column:terminal_code"`
|
|
|
|
+ InspectionTime time.Time `gorm:"column:inspection_time"`
|
|
CreateTime time.Time `gorm:"column:create_time"`
|
|
CreateTime time.Time `gorm:"column:create_time"`
|
|
ModifyTime time.Time `gorm:"column:modify_time"`
|
|
ModifyTime time.Time `gorm:"column:modify_time"`
|
|
}
|
|
}
|
|
@@ -82,4 +87,76 @@ func (m *EdbInspectionMessage) UpdateSendStatus(sendStatus int8) (err error) {
|
|
sql := `UPDATE edb_inspection_message SET send_status = ?, modify_time = ? WHERE message_id = ?`
|
|
sql := `UPDATE edb_inspection_message SET send_status = ?, modify_time = ? WHERE message_id = ?`
|
|
err = global.DbMap[utils.DbNameIndex].Exec(sql, sendStatus, time.Now(), m.MessageId).Error
|
|
err = global.DbMap[utils.DbNameIndex].Exec(sql, sendStatus, time.Now(), m.MessageId).Error
|
|
return
|
|
return
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+func (m *EdbInspectionMessage) GetCountByCondition(cond string, pars []interface{}) (count int64, err error) {
|
|
|
|
+ sql := `SELECT COUNT(*) FROM edb_inspection_message WHERE 1=1` + cond
|
|
|
|
+ err = global.DbMap[utils.DbNameIndex].Raw(sql, pars...).Scan(&count).Error
|
|
|
|
+ return
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+type EdbInspectionMessageResp struct {
|
|
|
|
+ MessageId int64
|
|
|
|
+ AdminId int64
|
|
|
|
+ InspectionRecordId int64
|
|
|
|
+ Content string
|
|
|
|
+ Remark string
|
|
|
|
+ IsRead int8
|
|
|
|
+ Source int8
|
|
|
|
+ TerminalCode string
|
|
|
|
+ InspectionTime string
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+type EdbInspectionMessageListResp struct {
|
|
|
|
+ List []*EdbInspectionMessageResp `json:"list"`
|
|
|
|
+ Paging *paging.PagingItem `json:"paging"`
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+type EdbInspectionMessageReadReq struct {
|
|
|
|
+ MessageId int64
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+func BatchModifyEdbInspectionMessageIsRead(ids []int64, adminId int) (err error) {
|
|
|
|
+ if len(ids) == 0 {
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ o := global.DbMap[utils.DbNameIndex]
|
|
|
|
+ sql := `UPDATE edb_inspection_message SET is_read =1, modify_time = ? WHERE admin_id =? AND is_read = 0 AND message_id IN (` + utils.GetOrmInReplace(len(ids)) + `)`
|
|
|
|
+ err = o.Exec(sql, time.Now(), adminId, ids).Error
|
|
|
|
+ return
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+func GetEdbInspectionMessageById(id int) (item *EdbInspectionMessage, err error) {
|
|
|
|
+ o := global.DbMap[utils.DbNameIndex]
|
|
|
|
+ sql := "SELECT * FROM edb_inspection_message WHERE message_id =?"
|
|
|
|
+ err = o.Raw(sql, id).First(&item).Error
|
|
|
|
+ return
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+func GetEdbInspectionMessageByAdminId(adminId int) (items []*EdbInspectionMessage, err error) {
|
|
|
|
+ o := global.DbMap[utils.DbNameIndex]
|
|
|
|
+ sql := "SELECT * FROM edb_inspection_message WHERE admin_id =? AND is_read = 0 ORDER BY create_time DESC"
|
|
|
|
+ err = o.Raw(sql, adminId).Find(&items).Error
|
|
|
|
+ return
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+func GetEdbInspectionMessageCountByAdminId(adminId int) (count int, err error) {
|
|
|
|
+ o := global.DbMap[utils.DbNameIndex]
|
|
|
|
+ sql := "SELECT COUNT(*) FROM edb_inspection_message WHERE admin_id =? ORDER BY is_read ASC, create_time DESC"
|
|
|
|
+ err = o.Raw(sql, adminId).Scan(&count).Error
|
|
|
|
+ return
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+func GetEdbInspectionMessagePageByAdminId(adminId, startSize, pageSize int) (items []*EdbInspectionMessage, err error) {
|
|
|
|
+ o := global.DbMap[utils.DbNameIndex]
|
|
|
|
+ sql := "SELECT * FROM edb_inspection_message WHERE admin_id =? ORDER BY is_read ASC, create_time DESC LIMIT?,?"
|
|
|
|
+ err = o.Raw(sql, adminId, startSize, pageSize).Find(&items).Error
|
|
|
|
+ return
|
|
}
|
|
}
|