| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- package product
- import (
- "context"
- "perms-system-server/internal/svc"
- "perms-system-server/internal/types"
- "perms-system-server/internal/util"
- "github.com/zeromicro/go-zero/core/logx"
- )
- type ProductListLogic struct {
- logx.Logger
- ctx context.Context
- svcCtx *svc.ServiceContext
- }
- func NewProductListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ProductListLogic {
- return &ProductListLogic{
- Logger: logx.WithContext(ctx),
- ctx: ctx,
- svcCtx: svcCtx,
- }
- }
- func (l *ProductListLogic) ProductList(req *types.ProductListReq) (resp *types.PageResp, err error) {
- page, pageSize := util.NormalizePage(req.Page, req.PageSize)
- list, total, err := l.svcCtx.SysProductModel.FindList(l.ctx, page, pageSize)
- if err != nil {
- return nil, err
- }
- items := make([]types.ProductItem, 0, len(list))
- for _, p := range list {
- items = append(items, types.ProductItem{
- Id: p.Id,
- Code: p.Code,
- Name: p.Name,
- AppKey: p.AppKey,
- Remark: p.Remark,
- Status: p.Status,
- CreateTime: p.CreateTime,
- })
- }
- return &types.PageResp{
- Total: total,
- List: items,
- }, nil
- }
|