35 lines
1.1 KiB
Go
35 lines
1.1 KiB
Go
package hpc
|
|
|
|
import (
|
|
"context"
|
|
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/svc"
|
|
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/types"
|
|
|
|
"github.com/zeromicro/go-zero/core/logx"
|
|
)
|
|
|
|
type QueueAssetsLogic struct {
|
|
logx.Logger
|
|
ctx context.Context
|
|
svcCtx *svc.ServiceContext
|
|
}
|
|
|
|
func NewQueueAssetsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *QueueAssetsLogic {
|
|
return &QueueAssetsLogic{
|
|
Logger: logx.WithContext(ctx),
|
|
ctx: ctx,
|
|
svcCtx: svcCtx,
|
|
}
|
|
}
|
|
|
|
func (l *QueueAssetsLogic) QueueAssets() (resp *types.QueueAssetsResp, err error) {
|
|
// 查询数据库队列资源信息
|
|
var queueAssetsResp types.QueueAssetsResp
|
|
tx := l.svcCtx.DbEngin.Raw("SELECT qpi.*,ti.tenant_name FROM sc_queue_phy_info qpi left join sc_participant_phy_info ppi on ppi.id = qpi.participant_id left JOIN sc_tenant_info ti on ti.id = ppi.tenant_id WHERE qpi.created_time IN ( SELECT MAX( created_time ) FROM sc_queue_phy_info WHERE deleted_flag = 0 GROUP BY participant_id, queue_name ) ").Scan(&queueAssetsResp.QueueAssets)
|
|
if tx.Error != nil {
|
|
logx.Error(err)
|
|
return nil, tx.Error
|
|
}
|
|
return &queueAssetsResp, nil
|
|
}
|