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.

editdictitemlogic.go 1.1 kB

123456789101112131415161718192021222324252627282930313233343536373839
  1. package dictionary
  2. import (
  3. "context"
  4. "github.com/pkg/errors"
  5. "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils"
  6. "gorm.io/gorm"
  7. "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc"
  8. "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types"
  9. "github.com/zeromicro/go-zero/core/logx"
  10. )
  11. type EditDictItemLogic struct {
  12. logx.Logger
  13. ctx context.Context
  14. svcCtx *svc.ServiceContext
  15. }
  16. func NewEditDictItemLogic(ctx context.Context, svcCtx *svc.ServiceContext) *EditDictItemLogic {
  17. return &EditDictItemLogic{
  18. Logger: logx.WithContext(ctx),
  19. ctx: ctx,
  20. svcCtx: svcCtx,
  21. }
  22. }
  23. func (l *EditDictItemLogic) EditDictItem(req *types.DictItemEditReq) (resp *types.DictItemResp, err error) {
  24. dictItem := &types.DictItemInfo{}
  25. result := l.svcCtx.DbEngin.Table("t_dict_item").First(&dictItem, req.Id)
  26. if errors.Is(result.Error, gorm.ErrRecordNotFound) {
  27. logx.Errorf("Dictionary data editing failure. errors: %s", result.Error)
  28. return nil, errors.New("DictItem does not exist")
  29. }
  30. utils.Convert(req, &dictItem)
  31. l.svcCtx.DbEngin.Table("t_dict_item").Model(&dictItem).Updates(&dictItem)
  32. return
  33. }

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.