get_configuration_by_id_logic.go 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. package configuration
  2. import (
  3. "context"
  4. "github.com/suyuan32/simple-admin-core/api/internal/svc"
  5. "github.com/suyuan32/simple-admin-core/api/internal/types"
  6. "github.com/suyuan32/simple-admin-core/rpc/types/core"
  7. "github.com/suyuan32/simple-admin-common/i18n"
  8. "github.com/zeromicro/go-zero/core/logx"
  9. )
  10. type GetConfigurationByIdLogic struct {
  11. logx.Logger
  12. ctx context.Context
  13. svcCtx *svc.ServiceContext
  14. }
  15. func NewGetConfigurationByIdLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetConfigurationByIdLogic {
  16. return &GetConfigurationByIdLogic{
  17. Logger: logx.WithContext(ctx),
  18. ctx: ctx,
  19. svcCtx: svcCtx,
  20. }
  21. }
  22. func (l *GetConfigurationByIdLogic) GetConfigurationById(req *types.IDReq) (resp *types.ConfigurationInfoResp, err error) {
  23. data, err := l.svcCtx.CoreRpc.GetConfigurationById(l.ctx, &core.IDReq{Id: req.Id})
  24. if err != nil {
  25. return nil, err
  26. }
  27. return &types.ConfigurationInfoResp{
  28. BaseDataInfo: types.BaseDataInfo{
  29. Code: 0,
  30. Msg: l.svcCtx.Trans.Trans(l.ctx, i18n.Success),
  31. },
  32. Data: types.ConfigurationInfo{
  33. BaseIDInfo: types.BaseIDInfo{
  34. Id: data.Id,
  35. CreatedAt: data.CreatedAt,
  36. UpdatedAt: data.UpdatedAt,
  37. },
  38. Sort: data.Sort,
  39. State: data.State,
  40. Name: data.Name,
  41. Key: data.Key,
  42. Value: data.Value,
  43. Category: data.Category,
  44. Remark: data.Remark,
  45. },
  46. }, nil
  47. }