| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- // Code scaffolded by goctl. Safe to edit.
- // goctl 1.10.2
- package application
- import (
- "context"
- "udeServer/internal/apierr"
- "udeServer/internal/log"
- "udeServer/internal/svc"
- "udeServer/internal/types"
- "github.com/zeromicro/go-zero/core/logx"
- )
- type ApplicationListLogic struct {
- logx.Logger
- ctx context.Context
- svcCtx *svc.ServiceContext
- }
- // 应用凭证列表
- func NewApplicationListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ApplicationListLogic {
- return &ApplicationListLogic{
- Logger: logx.WithContext(ctx),
- ctx: ctx,
- svcCtx: svcCtx,
- }
- }
- func (l *ApplicationListLogic) ApplicationList(req *types.ApplicationListReq) (*types.ApplicationListResp, error) {
- page, pageSize := normalizePage(req.Page, req.PageSize)
- // 状态筛选仅接受 1(启用)/2(禁用);其余取值(含 0)视为不过滤,与 sdf 行为一致
- var filterStatus int64
- switch req.Status {
- case 1, 2:
- filterStatus = req.Status
- }
- rows, total, err := l.svcCtx.ApplicationCredModel.FindPage(l.ctx, page, pageSize, filterStatus, req.CredIden, req.Name)
- if err != nil {
- log.RecordError(l.ctx, err)
- return nil, apierr.New(500, "查询应用凭证列表失败")
- }
- lists := make([]types.ApplicationCredentials, len(rows))
- for i := range rows {
- lists[i] = toApplicationCredentials(&rows[i])
- }
- return &types.ApplicationListResp{
- Total: total,
- ApplicationLists: lists,
- }, nil
- }
|