chat_dataset.api 4.4 KB

syntax = "v1"

info(
    title: "xx实例"
    desc: "xx实例"
    author: "author"
    email: "email"
    version: "v1"
)

@server(
    prefix: v1
    group: chat_dataset
    jwt: JwtAuth
)
service Core {
	@doc  "详情"
    @handler chat_datasetGet
    get /chat_dataset/:id (ChatDatasetGetRequest) returns (ChatDatasetGetResponse)
    @doc  "保存"
	@handler chat_datasetSave
    post /chat_dataset (ChatDatasetSaveRequest) returns (ChatDatasetSaveResponse)
    @doc  "删除"
	@handler chat_datasetDelete
    delete /chat_dataset/:id (ChatDatasetDeleteRequest) returns (ChatDatasetDeleteResponse)
    @doc  "更新"
	@handler chat_datasetUpdate
    put /chat_dataset/:id (ChatDatasetUpdateRequest) returns (ChatDatasetUpdateResponse)
    @doc  "搜索"
	@handler chat_datasetSearch
    post /chat_dataset/search (ChatDatasetSearchRequest) returns (ChatDatasetSearchResponse)
}

type (
    ChatDatasetGetRequest {
		Id int64 `path:"id"`
	}
    ChatDatasetGetResponse {
		ChatDataset ChatDatasetItem `json:"chat_dataset"`
    }

	ChatDatasetSaveRequest {
		ChatDataset ChatDatasetItem `json:"chat_dataset"`
    }
    ChatDatasetSaveResponse {}

	ChatDatasetDeleteRequest {
        Id int64 `path:"id"`
    }
    ChatDatasetDeleteResponse {}

	ChatDatasetUpdateRequest {
		Id int64 `path:"id"`
        ChatDataset ChatDatasetItem `json:"chat_dataset"`
    }
    ChatDatasetUpdateResponse {}

 	ChatDatasetSearchRequest {
         Page int  `json:"page"`
         Size int  `json:"size"`
    }
    ChatDatasetSearchResponse{
        List []ChatDatasetItem  `json:"list"`
        Total int64 `json:"total"`
    }
	ChatDatasetItem {
	
	}
)

// logic CRUD
// Save
	//var (
	//	conn = l.svcCtx.DefaultDBConn()
	//	dm   *domain.ChatDataset
	//)
	//// 唯一判断

	//dm = NewDomainChatDataset(req.ChatDataset)
	//if err = transaction.UseTrans(l.ctx, l.svcCtx.DB, func(ctx context.Context, conn transaction.Conn) error {
	//	dm, err = l.svcCtx.ChatDatasetRepository.Insert(l.ctx, conn, dm)
	//	return err
	//}, true); err != nil {
	//	return nil, xerr.NewErrMsg("保存失败")
	//}
	////resp = &types.ChatDatasetSaveResponse{}
	//return

//func NewDomainChatDataset(item types.ChatDatasetItem) *domain.ChatDataset {
//	return &domain.ChatDataset{

//	}
//}
//
//func NewTypesChatDataset(item *domain.ChatDataset) types.ChatDatasetItem {
//	return types.ChatDatasetItem{
//		Id:     item.Id,
//	}
//}

// Get
	//var (
	//	conn = l.svcCtx.DefaultDBConn()
	//	dm   *domain.ChatDataset
	//)
	//// 货号唯一
	//if dm, err = l.svcCtx.ChatDatasetRepository.FindOne(l.ctx, conn, req.Id); err != nil {
	//	return nil, xerr.NewErrMsgErr("不存在", err)
	//}
	//resp = &types.ChatDatasetGetResponse{
	//	ChatDataset: NewTypesChatDataset(dm),
	//}
	//return

// Delete
	//var (
	//	conn = l.svcCtx.DefaultDBConn()
	//	dm   *domain.ChatDataset
	//)
	//if dm, err = l.svcCtx.ChatDatasetRepository.FindOne(l.ctx, conn, req.Id); err != nil {
	//	return nil, xerr.NewErrMsgErr("不存在", err)
	//}
	//if err = transaction.UseTrans(l.ctx, l.svcCtx.DB, func(ctx context.Context, conn transaction.Conn) error {
	//	if dm, err = l.svcCtx.ChatDatasetRepository.Delete(l.ctx, conn, dm); err != nil {
	//		return err
	//	}
	//	return nil
	//}, true); err != nil {
	//	return nil, xerr.NewErrMsgErr("移除失败", err)
	//}
	//return

// Search
	//var (
	//	conn  = l.svcCtx.DefaultDBConn()
	//	dms   []*domain.ChatDataset
	//	total int64
	//)
	//
	//queryOptions := domain.NewQueryOptions().WithOffsetLimit(req.Page, req.Size).
	//	WithKV("", "")

	//total, dms, err = l.svcCtx.ChatDatasetRepository.Find(l.ctx, conn, queryOptions)
	//list := make([]types.ChatDatasetItem, 0)
	//for i := range dms {
	//	list = append(list, NewTypesChatDataset(dms[i]))
	//}
	//resp = &types.ChatDatasetSearchResponse{
	//	List:  list,
	//	Total: total,
	//}
	//return

// Update
	//var (
	//	conn = l.svcCtx.DefaultDBConn()
	//	dm   *domain.ChatDataset
	//)
	//if dm, err = l.svcCtx.ChatDatasetRepository.FindOne(l.ctx, conn, req.Id); err != nil {
	//	return nil, xerr.NewErrMsgErr("不存在", err)
	//}
	//// 不可编辑判断
	
	//// 赋值

	//// 更新
	//if err = transaction.UseTrans(l.ctx, l.svcCtx.DB, func(ctx context.Context, conn transaction.Conn) error {
	//	dm, err = l.svcCtx.ChatDatasetRepository.UpdateWithVersion(l.ctx, conn, dm)
	//	return err
	//}, true); err != nil {
	//	return nil, xerr.NewErrMsg("更新失败")
	//}
	//resp = &types.ChatDatasetUpdateResponse{}
	//return