mirror of
https://github.com/TeaOSLab/EdgeAPI.git
synced 2025-11-07 18:50:26 +08:00
节点运行日志可以按照节点ID设置为已读
This commit is contained in:
@@ -342,8 +342,8 @@ func (this *NodeLogDAO) CountAllUnreadNodeLogs(tx *dbs.Tx) (int64, error) {
|
||||
Count()
|
||||
}
|
||||
|
||||
// UpdateNodeLogsRead 设置日志为已读
|
||||
func (this *NodeLogDAO) UpdateNodeLogsRead(tx *dbs.Tx, nodeLogIds []int64) error {
|
||||
// UpdateNodeLogIdsRead 设置一组日志为已读
|
||||
func (this *NodeLogDAO) UpdateNodeLogIdsRead(tx *dbs.Tx, nodeLogIds []int64) error {
|
||||
for _, logId := range nodeLogIds {
|
||||
err := this.Query(tx).
|
||||
Pk(logId).
|
||||
@@ -356,6 +356,16 @@ func (this *NodeLogDAO) UpdateNodeLogsRead(tx *dbs.Tx, nodeLogIds []int64) error
|
||||
return nil
|
||||
}
|
||||
|
||||
// UpdateNodeLogsRead 设置节点日志为已读
|
||||
func (this *NodeLogDAO) UpdateNodeLogsRead(tx *dbs.Tx, role nodeconfigs.NodeRole, nodeId int64) error {
|
||||
return this.Query(tx).
|
||||
Attr("role", role).
|
||||
Attr("nodeId", nodeId).
|
||||
Attr("isRead", false).
|
||||
Set("isRead", true).
|
||||
UpdateQuickly()
|
||||
}
|
||||
|
||||
// UpdateAllNodeLogsRead 设置所有日志为已读
|
||||
func (this *NodeLogDAO) UpdateAllNodeLogsRead(tx *dbs.Tx) error {
|
||||
return this.Query(tx).
|
||||
|
||||
@@ -148,10 +148,20 @@ func (this *NodeLogService) UpdateNodeLogsRead(ctx context.Context, req *pb.Upda
|
||||
}
|
||||
|
||||
var tx = this.NullTx()
|
||||
err = models.SharedNodeLogDAO.UpdateNodeLogsRead(tx, req.NodeLogIds)
|
||||
if len(req.NodeLogIds) > 0 {
|
||||
err = models.SharedNodeLogDAO.UpdateNodeLogIdsRead(tx, req.NodeLogIds)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
if req.NodeId > 0 && len(req.Role) > 0 {
|
||||
err = models.SharedNodeLogDAO.UpdateNodeLogsRead(tx, req.Role, req.NodeId)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
return this.Success()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user