|
- /*
-
- Copyright (c) [2023] [pcm]
- [pcm-coordinator] is licensed under Mulan PSL v2.
- You can use this software according to the terms and conditions of the Mulan PSL v2.
- You may obtain a copy of Mulan PSL v2 at:
- http://license.coscl.org.cn/MulanPSL2
- THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
- EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
- MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
- See the Mulan PSL v2 for more details.
-
- */
-
- package hpc
-
- import (
- "context"
- "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc"
- "gitlink.org.cn/JointCloud/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
- }
|