chat_dataset_document_mapping.api 5.4 KB

syntax = "v1"

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

@server(
    prefix: v1
    group: chat_dataset_document_mapping
    jwt: JwtAuth
)
service Core {
	@doc  "详情"
    @handler chat_dataset_document_mappingGet
    get /chat_dataset_document_mapping/:id (ChatDatasetDocumentMappingGetRequest) returns (ChatDatasetDocumentMappingGetResponse)
    @doc  "保存"
	@handler chat_dataset_document_mappingSave
    post /chat_dataset_document_mapping (ChatDatasetDocumentMappingSaveRequest) returns (ChatDatasetDocumentMappingSaveResponse)
    @doc  "删除"
	@handler chat_dataset_document_mappingDelete
    delete /chat_dataset_document_mapping/:id (ChatDatasetDocumentMappingDeleteRequest) returns (ChatDatasetDocumentMappingDeleteResponse)
    @doc  "更新"
	@handler chat_dataset_document_mappingUpdate
    put /chat_dataset_document_mapping/:id (ChatDatasetDocumentMappingUpdateRequest) returns (ChatDatasetDocumentMappingUpdateResponse)
    @doc  "搜索"
	@handler chat_dataset_document_mappingSearch
    post /chat_dataset_document_mapping/search (ChatDatasetDocumentMappingSearchRequest) returns (ChatDatasetDocumentMappingSearchResponse)
}

type (
    ChatDatasetDocumentMappingGetRequest {
		Id int64 `path:"id"`
	}
    ChatDatasetDocumentMappingGetResponse {
		ChatDatasetDocumentMapping ChatDatasetDocumentMappingItem `json:"chat_dataset_document_mapping"`
    }

	ChatDatasetDocumentMappingSaveRequest {
		ChatDatasetDocumentMapping ChatDatasetDocumentMappingItem `json:"chat_dataset_document_mapping"`
    }
    ChatDatasetDocumentMappingSaveResponse {}

	ChatDatasetDocumentMappingDeleteRequest {
        Id int64 `path:"id"`
    }
    ChatDatasetDocumentMappingDeleteResponse {}

	ChatDatasetDocumentMappingUpdateRequest {
		Id int64 `path:"id"`
        ChatDatasetDocumentMapping ChatDatasetDocumentMappingItem `json:"chat_dataset_document_mapping"`
    }
    ChatDatasetDocumentMappingUpdateResponse {}

 	ChatDatasetDocumentMappingSearchRequest {
         Page int  `json:"page"`
         Size int  `json:"size"`
    }
    ChatDatasetDocumentMappingSearchResponse{
        List []ChatDatasetDocumentMappingItem  `json:"list"`
        Total int64 `json:"total"`
    }
	ChatDatasetDocumentMappingItem {
	
	}
)

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

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

//func NewDomainChatDatasetDocumentMapping(item types.ChatDatasetDocumentMappingItem) *domain.ChatDatasetDocumentMapping {
//	return &domain.ChatDatasetDocumentMapping{

//	}
//}
//
//func NewTypesChatDatasetDocumentMapping(item *domain.ChatDatasetDocumentMapping) types.ChatDatasetDocumentMappingItem {
//	return types.ChatDatasetDocumentMappingItem{
//		Id:     item.Id,
//	}
//}

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

// Delete
	//var (
	//	conn = l.svcCtx.DefaultDBConn()
	//	dm   *domain.ChatDatasetDocumentMapping
	//)
	//if dm, err = l.svcCtx.ChatDatasetDocumentMappingRepository.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.ChatDatasetDocumentMappingRepository.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.ChatDatasetDocumentMapping
	//	total int64
	//)
	//
	//queryOptions := domain.NewQueryOptions().WithOffsetLimit(req.Page, req.Size).
	//	WithKV("", "")

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

// Update
	//var (
	//	conn = l.svcCtx.DefaultDBConn()
	//	dm   *domain.ChatDatasetDocumentMapping
	//)
	//if dm, err = l.svcCtx.ChatDatasetDocumentMappingRepository.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.ChatDatasetDocumentMappingRepository.UpdateWithVersion(l.ctx, conn, dm)
	//	return err
	//}, true); err != nil {
	//	return nil, xerr.NewErrMsg("更新失败")
	//}
	//resp = &types.ChatDatasetDocumentMappingUpdateResponse{}
	//return