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.

adddictlogic.go 1.1 kB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. package dictionary
  2. import (
  3. "context"
  4. "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils"
  5. "time"
  6. "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
  7. "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types"
  8. "github.com/zeromicro/go-zero/core/logx"
  9. )
  10. type AddDictLogic struct {
  11. logx.Logger
  12. ctx context.Context
  13. svcCtx *svc.ServiceContext
  14. }
  15. func NewAddDictLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AddDictLogic {
  16. return &AddDictLogic{
  17. Logger: logx.WithContext(ctx),
  18. ctx: ctx,
  19. svcCtx: svcCtx,
  20. }
  21. }
  22. func (l *AddDictLogic) AddDict(req *types.DictEditReq) (resp *types.DictResp, err error) {
  23. dict := &types.DictInfo{}
  24. dict.DictName = req.DictName
  25. dict.DictCode = req.DictCode
  26. dict.Type = req.Type
  27. dict.Description = req.Description
  28. dict.Id = utils.GenSnowflakeIDStr()
  29. dict.CreateTime = time.Now().Format("2006-01-02 15:04:05")
  30. dict.Status = req.Status
  31. result := l.svcCtx.DbEngin.Table("t_dict").Create(&dict)
  32. if result.Error != nil {
  33. logx.Errorf("Failed to create dictionary , errors: %s", result.Error)
  34. return nil, result.Error
  35. }
  36. return
  37. }

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.