40 lines
1.2 KiB
Go
40 lines
1.2 KiB
Go
package adapters
|
|
|
|
import (
|
|
"context"
|
|
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
|
|
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/types"
|
|
|
|
"github.com/zeromicro/go-zero/core/logx"
|
|
)
|
|
|
|
type GetAdapterInfoLogic struct {
|
|
logx.Logger
|
|
ctx context.Context
|
|
svcCtx *svc.ServiceContext
|
|
}
|
|
|
|
func NewGetAdapterInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetAdapterInfoLogic {
|
|
return &GetAdapterInfoLogic{
|
|
Logger: logx.WithContext(ctx),
|
|
ctx: ctx,
|
|
svcCtx: svcCtx,
|
|
}
|
|
}
|
|
|
|
func (l *GetAdapterInfoLogic) GetAdapterInfo(req *types.AdapterInfoNameReq) (resp *types.AdapterInfoNameReqResp, err error) {
|
|
// todo: add your logic here and delete this line
|
|
resp = &types.AdapterInfoNameReqResp{}
|
|
var infoNameReqResp types.AdapterInfoNameReqResp
|
|
sql := `SELECT ta.type AS Type,ta.resource_type AS ResourceType,ta.name AS TName,tai.info_name AS InfoName FROM t_adapter ta LEFT JOIN t_adapter_info tai ON ta.id = tai.adapter_id WHERE ta.id = ?`
|
|
tx := l.svcCtx.DbEngin.Raw(sql, req.AdapterId).Scan(&infoNameReqResp.InfoList)
|
|
if tx.Error != nil {
|
|
logx.Error(err)
|
|
return nil, tx.Error
|
|
}
|
|
resp.Code = 200
|
|
resp.Msg = "success"
|
|
resp.InfoList = infoNameReqResp.InfoList
|
|
return resp, nil
|
|
}
|