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.

deleteappbyappnamelogic.go 1.6 kB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. package apps
  2. import (
  3. "context"
  4. "github.com/zeromicro/go-zero/core/logx"
  5. "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc"
  6. "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types"
  7. "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/constants"
  8. "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models"
  9. )
  10. type DeleteAppByAppNameLogic struct {
  11. logx.Logger
  12. ctx context.Context
  13. svcCtx *svc.ServiceContext
  14. }
  15. func NewDeleteAppByAppNameLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteAppByAppNameLogic {
  16. return &DeleteAppByAppNameLogic{
  17. Logger: logx.WithContext(ctx),
  18. ctx: ctx,
  19. svcCtx: svcCtx,
  20. }
  21. }
  22. func (l *DeleteAppByAppNameLogic) DeleteAppByAppName(req *types.DeleteAppReq) (resp *types.DeleteAppResp, err error) {
  23. resp = &types.DeleteAppResp{}
  24. var task = &Task{}
  25. //查询应用的yamlString
  26. l.svcCtx.DbEngin.Raw(`select * from task where ns_id= ? and name= ? AND deleted_at IS NULL`, req.NsID, req.Name).Scan(&task)
  27. if task.Id == 0 {
  28. resp.Code = 500
  29. resp.Msg = "App not fount"
  30. return resp, err
  31. }
  32. //删除主任务信息
  33. l.svcCtx.DbEngin.Model(&models.Task{}).Where("id", task.Id).Update("status", constants.Deleted)
  34. tx := l.svcCtx.DbEngin.Delete(&models.Task{}, task.Id)
  35. if tx.Error != nil {
  36. return nil, tx.Error
  37. }
  38. // 将子任务状态修改为待删除
  39. tx = l.svcCtx.DbEngin.Model(&models.Cloud{}).Where("task_id", task.Id).Update("status", constants.WaitDelete)
  40. l.svcCtx.DbEngin.Where("task_id = ?", task.Id).Delete(&models.Cloud{})
  41. if tx.Error != nil {
  42. return nil, tx.Error
  43. }
  44. return
  45. }

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.