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.

aiStorage.go 1.4 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. package database
  2. import (
  3. "github.com/zeromicro/go-zero/core/logx"
  4. "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types"
  5. "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/constants"
  6. "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models"
  7. "gorm.io/gorm"
  8. "time"
  9. )
  10. type AiStorage struct {
  11. DbEngin *gorm.DB
  12. }
  13. func (s *AiStorage) GetParticipants() (*types.ClusterListResp, error) {
  14. var resp types.ClusterListResp
  15. tx := s.DbEngin.Raw("select * from t_cluster where `deleted_at` IS NULL ORDER BY create_time Desc").Scan(&resp.List)
  16. if tx.Error != nil {
  17. logx.Errorf(tx.Error.Error())
  18. return nil, tx.Error
  19. }
  20. return &resp, nil
  21. }
  22. func (s *AiStorage) GetClustersByAdapterId(id string) (*types.ClusterListResp, error) {
  23. var resp types.ClusterListResp
  24. tx := s.DbEngin.Raw("select * from t_cluster where `deleted_at` IS NULL and `adapter_id` = ? ORDER BY create_time Desc", id).Scan(&resp.List)
  25. if tx.Error != nil {
  26. logx.Errorf(tx.Error.Error())
  27. return nil, tx.Error
  28. }
  29. return &resp, nil
  30. }
  31. func (s *AiStorage) SaveTask(name string) error {
  32. // 构建主任务结构体
  33. taskModel := models.Task{
  34. Status: constants.Saved,
  35. Description: "ai task",
  36. Name: name,
  37. CommitTime: time.Now(),
  38. }
  39. // 保存任务数据到数据库
  40. tx := s.DbEngin.Create(&taskModel)
  41. if tx.Error != nil {
  42. return tx.Error
  43. }
  44. return nil
  45. }
  46. func (s *AiStorage) UpdateTask() error {
  47. return nil
  48. }

PCM is positioned as Software stack over Cloud, aiming to build the standards and ecology of heterogeneous cloud collaboration for JCC in a non intrusive and autonomous peer-to-peer manner.