36 lines
934 B
Go
36 lines
934 B
Go
package adapters
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"github.com/zeromicro/go-zero/core/logx"
|
|
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/svc"
|
|
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/types"
|
|
"gitlink.org.cn/jcce-pcm/pcm-coordinator/pkg/utils"
|
|
"time"
|
|
)
|
|
|
|
type CreateAdapterLogic struct {
|
|
logx.Logger
|
|
ctx context.Context
|
|
svcCtx *svc.ServiceContext
|
|
}
|
|
|
|
func NewCreateAdapterLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateAdapterLogic {
|
|
return &CreateAdapterLogic{
|
|
Logger: logx.WithContext(ctx),
|
|
ctx: ctx,
|
|
svcCtx: svcCtx,
|
|
}
|
|
}
|
|
|
|
func (l *CreateAdapterLogic) CreateAdapter(req *types.AdapterReq) (resp *types.AdapterResp, err error) {
|
|
adapter := types.AdapterInfo{}
|
|
utils.Convert(req, &adapter)
|
|
adapter.Id = utils.GenSnowflakeIDStr()
|
|
adapter.CreateTime = time.Now().Format("2006-01-02 15:04:05")
|
|
tx := l.svcCtx.DbEngin.Table("t_adapter").Create(&adapter)
|
|
fmt.Print(tx.Error)
|
|
return
|
|
}
|