You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

dataset.go 3.5 kB

2 years ago
3 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. // Copyright 2023 The casbin Authors. All Rights Reserved.
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. package object
  15. import (
  16. "github.com/casbin/casvisor/util"
  17. "xorm.io/core"
  18. )
  19. type TreeItem struct {
  20. Key string `xorm:"varchar(100)" json:"key"`
  21. Title string `xorm:"varchar(100)" json:"title"`
  22. Content string `xorm:"mediumtext" json:"content"`
  23. TitleEn string `xorm:"varchar(100)" json:"titleEn"`
  24. ContentEn string `xorm:"mediumtext" json:"contentEn"`
  25. Children []*TreeItem `xorm:"varchar(1000)" json:"children"`
  26. }
  27. type Dataset struct {
  28. Owner string `xorm:"varchar(100) notnull pk" json:"owner"`
  29. Name string `xorm:"varchar(100) notnull pk" json:"name"`
  30. CreatedTime string `xorm:"varchar(100)" json:"createdTime"`
  31. StartDate string `xorm:"varchar(100)" json:"startDate"`
  32. EndDate string `xorm:"varchar(100)" json:"endDate"`
  33. FullName string `xorm:"varchar(100)" json:"fullName"`
  34. Organizer string `xorm:"varchar(100)" json:"organizer"`
  35. Location string `xorm:"varchar(100)" json:"location"`
  36. Address string `xorm:"varchar(100)" json:"address"`
  37. Status string `xorm:"varchar(100)" json:"status"`
  38. Language string `xorm:"varchar(100)" json:"language"`
  39. Tags []string `xorm:"mediumtext" json:"tags"`
  40. Carousels []string `xorm:"mediumtext" json:"carousels"`
  41. IntroText string `xorm:"mediumtext" json:"introText"`
  42. DefaultItem string `xorm:"mediumtext" json:"defaultItem"`
  43. TreeItems []*TreeItem `xorm:"mediumtext" json:"treeItems"`
  44. }
  45. func GetGlobalDatasets() []*Dataset {
  46. datasets := []*Dataset{}
  47. err := adapter.engine.Asc("owner").Desc("created_time").Find(&datasets)
  48. if err != nil {
  49. panic(err)
  50. }
  51. return datasets
  52. }
  53. func GetDatasets(owner string) []*Dataset {
  54. datasets := []*Dataset{}
  55. err := adapter.engine.Desc("created_time").Find(&datasets, &Dataset{Owner: owner})
  56. if err != nil {
  57. panic(err)
  58. }
  59. return datasets
  60. }
  61. func getDataset(owner string, name string) *Dataset {
  62. dataset := Dataset{Owner: owner, Name: name}
  63. existed, err := adapter.engine.Get(&dataset)
  64. if err != nil {
  65. panic(err)
  66. }
  67. if existed {
  68. return &dataset
  69. } else {
  70. return nil
  71. }
  72. }
  73. func GetDataset(id string) *Dataset {
  74. owner, name := util.GetOwnerAndNameFromId(id)
  75. return getDataset(owner, name)
  76. }
  77. func UpdateDataset(id string, dataset *Dataset) bool {
  78. owner, name := util.GetOwnerAndNameFromId(id)
  79. if getDataset(owner, name) == nil {
  80. return false
  81. }
  82. _, err := adapter.engine.ID(core.PK{owner, name}).AllCols().Update(dataset)
  83. if err != nil {
  84. panic(err)
  85. }
  86. //return affected != 0
  87. return true
  88. }
  89. func AddDataset(dataset *Dataset) bool {
  90. affected, err := adapter.engine.Insert(dataset)
  91. if err != nil {
  92. panic(err)
  93. }
  94. return affected != 0
  95. }
  96. func DeleteDataset(dataset *Dataset) bool {
  97. affected, err := adapter.engine.ID(core.PK{dataset.Owner, dataset.Name}).Delete(&Dataset{})
  98. if err != nil {
  99. panic(err)
  100. }
  101. return affected != 0
  102. }

Caswire是一款基于人工智能技术的开源反病毒和入侵检测系统。该系统通过深度学习和模式识别技术,能够实时识别和防御各种网络威胁,包括病毒、恶意软件以及其他安全威胁。Caswire支持动态学习和适应网络环境的变化,确保持续的安全防护。我们期望在Caswire上:1)增强其机器学习模型,以提高恶意行为的检测准确率;2)优化系统的实时响应能力,提升在高威胁环境下的表现。