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.

detailresourcespeclogic.go 1.4 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. package core
  2. import (
  3. "context"
  4. "github.com/pkg/errors"
  5. "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
  6. "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types"
  7. "github.com/zeromicro/go-zero/core/logx"
  8. )
  9. type DetailResourceSpecLogic struct {
  10. logx.Logger
  11. ctx context.Context
  12. svcCtx *svc.ServiceContext
  13. }
  14. func NewDetailResourceSpecLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DetailResourceSpecLogic {
  15. return &DetailResourceSpecLogic{
  16. Logger: logx.WithContext(ctx),
  17. ctx: ctx,
  18. svcCtx: svcCtx,
  19. }
  20. }
  21. func (l *DetailResourceSpecLogic) DetailResourceSpec(req *types.IdReq) (resp *types.ResourceSpec, err error) {
  22. resp = &types.ResourceSpec{}
  23. db := l.svcCtx.DbEngin.Model(&types.ResourceSpec{}).Table("t_resource_spec")
  24. err = db.Where("id = ? and deleted_at is null", req.Id).Scan(&resp).Error
  25. if err != nil {
  26. return nil, err
  27. }
  28. if resp.Id == 0 {
  29. logx.Errorf("resource spec not found , id:%s not found", req.Id)
  30. return resp, errors.New("resource spec not found")
  31. }
  32. var baseSpecs []types.BaseResourceSpec
  33. baseDb := l.svcCtx.DbEngin.Model(&types.BaseResourceSpec{}).Table("t_base_resource_spec")
  34. baseDb = baseDb.Where("t_base_resource_spec.deleted_at is null and t_base_resource_spec.resource_spec_id = ?", resp.Id)
  35. err = baseDb.Scan(&baseSpecs).Error
  36. if err != nil {
  37. return resp, err
  38. }
  39. resp.BaseResourceSpecs = baseSpecs
  40. return
  41. }

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.