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.

listdictitemlogic.go 1.6 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. package dictionary
  2. import (
  3. "context"
  4. "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc"
  5. "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types"
  6. "github.com/zeromicro/go-zero/core/logx"
  7. )
  8. type ListDictItemLogic struct {
  9. logx.Logger
  10. ctx context.Context
  11. svcCtx *svc.ServiceContext
  12. }
  13. func NewListDictItemLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListDictItemLogic {
  14. return &ListDictItemLogic{
  15. Logger: logx.WithContext(ctx),
  16. ctx: ctx,
  17. svcCtx: svcCtx,
  18. }
  19. }
  20. func (l *ListDictItemLogic) ListDictItem(req *types.DictItemReq) (resp *types.PageResult, err error) {
  21. limit := req.PageSize
  22. offset := req.PageSize * (req.PageNum - 1)
  23. resp = &types.PageResult{}
  24. var dictList []types.DictItemInfo
  25. db := l.svcCtx.DbEngin.Model(&types.DictItemInfo{}).Table("t_dict_item")
  26. if req.ItemText != "" {
  27. db = db.Where("item_text LIKE ?", "%"+req.ItemText+"%")
  28. }
  29. if req.ItemValue != "" {
  30. db = db.Where("item_value LIKE ?", "%"+req.ItemValue+"%")
  31. }
  32. if req.Type != "" {
  33. db = db.Where("type = ?", req.Type)
  34. }
  35. if req.ParentId != "" {
  36. db = db.Where("parent_id = ?", req.ParentId)
  37. }
  38. if req.Status != "" {
  39. db = db.Where("status = ?", req.Status)
  40. }
  41. if req.DictId != "" {
  42. db = db.Where("dict_id = ?", req.DictId)
  43. }
  44. var total int64
  45. err = db.Count(&total).Error
  46. if err != nil {
  47. return resp, err
  48. }
  49. db = db.Limit(limit).Offset(offset)
  50. err = db.Order("create_time desc").Find(&dictList).Error
  51. resp.List = dictList
  52. resp.PageSize = req.PageSize
  53. resp.PageNum = req.PageNum
  54. resp.Total = total
  55. return resp, nil
  56. }

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.