get_configuration_list_logic.go 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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 GetConfigurationListLogic struct {
  11. logx.Logger
  12. ctx context.Context
  13. svcCtx *svc.ServiceContext
  14. }
  15. func NewGetConfigurationListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetConfigurationListLogic {
  16. return &GetConfigurationListLogic{
  17. Logger: logx.WithContext(ctx),
  18. ctx: ctx,
  19. svcCtx: svcCtx,
  20. }
  21. }
  22. func (l *GetConfigurationListLogic) GetConfigurationList(req *types.ConfigurationListReq) (resp *types.ConfigurationListResp, err error) {
  23. data, err := l.svcCtx.CoreRpc.GetConfigurationList(l.ctx,
  24. &core.ConfigurationListReq{
  25. Page: req.Page,
  26. PageSize: req.PageSize,
  27. Name: req.Name,
  28. Key: req.Key,
  29. Category: req.Category,
  30. })
  31. if err != nil {
  32. return nil, err
  33. }
  34. resp = &types.ConfigurationListResp{}
  35. resp.Msg = l.svcCtx.Trans.Trans(l.ctx, i18n.Success)
  36. resp.Data.Total = data.GetTotal()
  37. for _, v := range data.Data {
  38. resp.Data.Data = append(resp.Data.Data,
  39. types.ConfigurationInfo{
  40. BaseIDInfo: types.BaseIDInfo{
  41. Id: v.Id,
  42. CreatedAt: v.CreatedAt,
  43. UpdatedAt: v.UpdatedAt,
  44. },
  45. Sort: v.Sort,
  46. State: v.State,
  47. Name: v.Name,
  48. Key: v.Key,
  49. Value: v.Value,
  50. Category: v.Category,
  51. Remark: v.Remark,
  52. })
  53. }
  54. return resp, nil
  55. }