右键删除节点列表,好像实现了,还需要实现右键删除地图节点

This commit is contained in:
2026-06-04 01:16:33 +08:00
parent 7c1b30b3a0
commit e945222519
10 changed files with 272 additions and 5 deletions
+28
View File
@@ -83,6 +83,23 @@ func (s *store) GetMapReport(nodeID string) (*mapReportRecord, error) {
return &row, nil
}
func (s *store) DeleteNode(nodeID string) error {
return s.db.Transaction(func(tx *gorm.DB) error {
nodeResult := tx.Where("node_id = ?", nodeID).Delete(&nodeInfoRecord{})
if nodeResult.Error != nil {
return nodeResult.Error
}
reportResult := tx.Where("node_id = ?", nodeID).Delete(&mapReportRecord{})
if reportResult.Error != nil {
return reportResult.Error
}
if nodeResult.RowsAffected+reportResult.RowsAffected == 0 {
return gorm.ErrRecordNotFound
}
return nil
})
}
func applyNodeFilters(q *gorm.DB, opts listOptions) *gorm.DB {
if opts.NodeID != "" {
q = q.Where("node_id = ?", opts.NodeID)
@@ -101,6 +118,17 @@ func (s *store) ListTextMessages(opts listOptions) ([]textMessageRecord, error)
return rows, s.listAppendRows(opts, &rows).Error
}
func (s *store) DeleteTextMessage(id uint64) error {
result := s.db.Where("id = ?", id).Delete(&textMessageRecord{})
if result.Error != nil {
return result.Error
}
if result.RowsAffected == 0 {
return gorm.ErrRecordNotFound
}
return nil
}
func (s *store) ListPositions(opts listOptions) ([]positionRecord, error) {
var rows []positionRecord
return rows, s.listAppendRows(opts, &rows).Error