1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- package logic
- import (
- "GtDataStore/app/cmd/organization/internal/svc"
- "GtDataStore/app/cmd/organization/pb"
- "context"
- "github.com/zeromicro/go-zero/core/logx"
- )
- type FindAppListLogic struct {
- ctx context.Context
- svcCtx *svc.ServiceContext
- logx.Logger
- }
- func NewFindAppListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *FindAppListLogic {
- return &FindAppListLogic{
- ctx: ctx,
- svcCtx: svcCtx,
- Logger: logx.WithContext(ctx),
- }
- }
- func (l *FindAppListLogic) FindAppList(in *pb.FindAppListReq) (*pb.FindAppListResp, error) {
- if in.Page <= 1 {
- in.Page = 1
- }
- offset, limit := (in.Page-1)*in.PageSize, in.PageSize
- appInfos, total, err := l.svcCtx.AppInfo.Find(l.ctx, offset, limit, "`id` DESC")
- if err != nil {
- return nil, err
- }
- res := make([]*pb.AppInfo, len(appInfos))
- for i, info := range appInfos {
- res[i] = &pb.AppInfo{
- Id: info.Id,
- AppName: info.AppName,
- ProjectIds: info.ProjectIds,
- Secret: info.Secret,
- Status: info.Status,
- ExpireAt: info.ExpireAt.Format("2006-01-02 15:04:05"),
- CTime: info.MTime.Format("2006-01-02 15:04:05"),
- }
- }
- return &pb.FindAppListResp{List: res, Pagination: &pb.Pagination{
- Current: uint32(in.Page),
- PageSize: uint32(in.PageSize),
- Total: uint32(total),
- }}, nil
- }
|