Merge pull request 'fix bugs' (#31) from devad/pcm-coordinator:master into master

Former-commit-id: 6739241de1
This commit is contained in:
devad 2024-02-29 17:13:27 +08:00
commit 26c5e59e1a
5 changed files with 25 additions and 6 deletions

View File

@ -684,6 +684,14 @@ type (
Version string `json:"version,optional"`
Server string `json:"server,optional"`
}
AdapterCreateReq {
Id string `json:"id,optional" db:"id"`
Name string `json:"name"`
Type string `json:"type"`
Nickname string `json:"nickname"`
Version string `json:"version"`
Server string `json:"server"`
}
AdapterDelReq {
Id string `form:"id,optional" db:"id"`
}

View File

@ -585,7 +585,7 @@ service pcm {
get /adapter/list (AdapterQueryReq) returns (AdapterListResp)
@handler CreateAdapterHandler
post /adapter/create (AdapterReq) returns (AdapterResp)
post /adapter/create (AdapterCreateReq) returns (AdapterResp)
@handler UpdateAdapterHandler
put /adapter/update (AdapterReq) returns (AdapterResp)

View File

@ -11,7 +11,7 @@ import (
func CreateAdapterHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.AdapterReq
var req types.AdapterCreateReq
if err := httpx.Parse(r, &req); err != nil {
result.ParamErrorResult(r, w, err)
return

View File

@ -2,7 +2,6 @@ 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"
@ -24,12 +23,15 @@ func NewCreateAdapterLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Cre
}
}
func (l *CreateAdapterLogic) CreateAdapter(req *types.AdapterReq) (resp *types.AdapterResp, err error) {
func (l *CreateAdapterLogic) CreateAdapter(req *types.AdapterCreateReq) (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)
result := l.svcCtx.DbEngin.Table("t_adapter").Create(&adapter)
if result.Error != nil {
return nil, result.Error
}
return
}

View File

@ -647,6 +647,15 @@ type AdapterReq struct {
Server string `json:"server,optional"`
}
type AdapterCreateReq struct {
Id string `json:"id,optional" db:"id"`
Name string `json:"name"`
Type string `json:"type"`
Nickname string `json:"nickname"`
Version string `json:"version"`
Server string `json:"server"`
}
type AdapterDelReq struct {
Id string `form:"id,optional" db:"id"`
}