Browse Source

修改sql注入风险

yjp 10 months ago
parent
commit
51ccc2c6f4
22 changed files with 146 additions and 1961 deletions
  1. 0 1
      baize.go
  2. 1 1
      framework/core/api/api.go
  3. 0 127
      framework/core/infrastructure/database/data_service/client/client.go
  4. 0 43
      framework/core/infrastructure/database/data_service/client/data_source.go
  5. 0 17
      framework/core/infrastructure/database/data_service/client/infos.go
  6. 0 41
      framework/core/infrastructure/database/data_service/client/namespace.go
  7. 0 71
      framework/core/infrastructure/database/data_service/client/sql.go
  8. 0 188
      framework/core/infrastructure/database/data_service/data_service.go
  9. 0 46
      framework/core/infrastructure/database/data_service/grpc_client/grpc_client.go
  10. 0 525
      framework/core/infrastructure/database/data_service/grpc_client/v1/request/sql.pb.go
  11. 0 76
      framework/core/infrastructure/database/data_service/grpc_client/v1/request/sql.validator.pb.go
  12. 0 163
      framework/core/infrastructure/database/data_service/grpc_client/v1/response/sql.pb.go
  13. 0 78
      framework/core/infrastructure/database/data_service/grpc_client/v1/sql.pb.go
  14. 0 139
      framework/core/infrastructure/database/data_service/grpc_client/v1/sql_grpc.pb.go
  15. 0 132
      framework/core/infrastructure/database/data_service/transaction.go
  16. 58 35
      framework/core/infrastructure/database/database.go
  17. 3 3
      framework/core/infrastructure/database/operations/operations.go
  18. 38 76
      framework/core/infrastructure/database/sql/condition.go
  19. 30 93
      framework/core/infrastructure/database/sql/sql_template.go
  20. 15 18
      framework/core/infrastructure/database/sql/table_row.go
  21. 0 73
      framework/core/infrastructure/database/sql/value.go
  22. 1 15
      framework/core/infrastructure/infrastructure.go

+ 0 - 1
baize.go

@@ -16,7 +16,6 @@ func NewApplication(conf application.Config) *application.App {
 	// 创建基础设施
 	infrastructureConfig := new(infrastructure.Config)
 	infrastructureConfig.DatabaseConfig.Operations = conf.InfrastructureConfig.Database.Operations
-	infrastructureConfig.DatabaseConfig.DataService = conf.InfrastructureConfig.Database.DataService
 	infrastructureConfig.CacheConfig = conf.InfrastructureConfig.Cache
 
 	infrastructureInstance := infrastructure.NewInfrastructure(*infrastructureConfig)

+ 1 - 1
framework/core/api/api.go

@@ -46,7 +46,7 @@ func New(opts ...Option) *Api {
 			c.Next()
 
 			path := c.FullPath()
-			if slices.Contains(options.skipPaths, path) {
+			if slices.Contains(options.logSkipPaths, path) {
 				return
 			}
 

+ 0 - 127
framework/core/infrastructure/database/data_service/client/client.go

@@ -1,127 +0,0 @@
-package client
-
-import (
-	"git.sxidc.com/go-tools/utils/http_client"
-	"github.com/pkg/errors"
-	"time"
-)
-
-const (
-	defaultTimeoutSec = 30
-)
-
-var instance *Client
-
-func InitInstance(timeout time.Duration) {
-	if instance == nil {
-		if timeout == 0 {
-			timeout = defaultTimeoutSec * time.Second
-		}
-
-		instance = New(timeout)
-	}
-}
-
-func GetInstance() *Client {
-	if instance == nil {
-		panic("还没有调用InitInstance")
-	}
-
-	return instance
-}
-
-type Client struct {
-	client  *http_client.Client
-	timeout time.Duration
-}
-
-func New(timeout time.Duration) *Client {
-	client := http_client.New()
-
-	return &Client{
-		client:  client,
-		timeout: timeout,
-	}
-}
-
-func (c *Client) post(token string, url string, request interface{}, result interface{}) error {
-	req := c.client.NewRequest(http_client.WithNewRequestTimeout(c.timeout))
-
-	resp, err := req.Post(url, request,
-		http_client.WithRequestHeaders(map[string]string{
-			"Content-Type":  "application/json",
-			"Authorization": token,
-		}))
-	if err != nil {
-		return errors.New(err.Error())
-	}
-
-	err = resp.Json(result)
-	if err != nil {
-		return errors.New(err.Error())
-	}
-
-	return nil
-}
-
-func (c *Client) delete(token string, url string, queryMap map[string]string, result interface{}) error {
-	req := c.client.NewRequest(http_client.WithNewRequestTimeout(c.timeout))
-
-	resp, err := req.Delete(url,
-		http_client.WithRequestHeaders(map[string]string{
-			"Content-Type":  "application/json",
-			"Authorization": token,
-		}),
-		http_client.WithRequestQueryParams(queryMap))
-	if err != nil {
-		return errors.New(err.Error())
-	}
-
-	err = resp.Json(result)
-	if err != nil {
-		return errors.New(err.Error())
-	}
-
-	return nil
-}
-
-func (c *Client) put(token string, url string, request interface{}, result interface{}) error {
-	req := c.client.NewRequest(http_client.WithNewRequestTimeout(c.timeout))
-
-	resp, err := req.Put(url, request,
-		http_client.WithRequestHeaders(map[string]string{
-			"Content-Type":  "application/json",
-			"Authorization": token,
-		}))
-	if err != nil {
-		return errors.New(err.Error())
-	}
-
-	err = resp.Json(result)
-	if err != nil {
-		return errors.New(err.Error())
-	}
-
-	return nil
-}
-
-func (c *Client) get(token string, url string, queryMap map[string]string, result interface{}) error {
-	req := c.client.NewRequest(http_client.WithNewRequestTimeout(c.timeout))
-
-	resp, err := req.Get(url,
-		http_client.WithRequestHeaders(map[string]string{
-			"Content-Type":  "application/json",
-			"Authorization": token,
-		}),
-		http_client.WithRequestQueryParams(queryMap))
-	if err != nil {
-		return errors.New(err.Error())
-	}
-
-	err = resp.Json(result)
-	if err != nil {
-		return errors.New(err.Error())
-	}
-
-	return nil
-}

+ 0 - 43
framework/core/infrastructure/database/data_service/client/data_source.go

@@ -1,43 +0,0 @@
-package client
-
-import (
-	"github.com/pkg/errors"
-	"net/url"
-	"strconv"
-)
-
-const (
-	getDataSourcesUrl = "/ds/api/v1/dataSource/query"
-)
-
-func (c *Client) GetDataSources(token string, baseUrl string, namespace string, name string, typeStr string, pageNo int, pageSize int) ([]DataSourceInfo, error) {
-	fullUrl, err := url.JoinPath(baseUrl, getDataSourcesUrl)
-	if err != nil {
-		return nil, errors.New(err.Error())
-	}
-
-	resp := new(struct {
-		Success    bool             `json:"success"`
-		Msg        string           `json:"msg"`
-		Infos      []DataSourceInfo `json:"infos"`
-		TotalCount int64            `json:"totalCount"`
-		PageNo     int64            `json:"pageNo"`
-	})
-
-	err = c.get(token, fullUrl, map[string]string{
-		"namespace": namespace,
-		"name":      name,
-		"type":      typeStr,
-		"pageNo":    strconv.Itoa(pageNo),
-		"pageSize":  strconv.Itoa(pageSize),
-	}, resp)
-	if err != nil {
-		return nil, err
-	}
-
-	if !resp.Success {
-		return nil, errors.New(resp.Msg)
-	}
-
-	return resp.Infos, nil
-}

+ 0 - 17
framework/core/infrastructure/database/data_service/client/infos.go

@@ -1,17 +0,0 @@
-package client
-
-type NamespaceInfo struct {
-	ID          string `json:"id"`
-	Name        string `json:"name"`
-	Creator     string `json:"creator"`
-	CreatedTime string `json:"createdTime"`
-}
-
-type DataSourceInfo struct {
-	Namespace   string `json:"namespace"`
-	Name        string `json:"name"`
-	Type        string `json:"type"`
-	Spec        string `json:"spec"`
-	Creator     string `json:"creator"`
-	CreatedTime string `json:"createdTime"`
-}

+ 0 - 41
framework/core/infrastructure/database/data_service/client/namespace.go

@@ -1,41 +0,0 @@
-package client
-
-import (
-	"github.com/pkg/errors"
-	"net/url"
-	"strconv"
-)
-
-const (
-	getNamespacesUrl = "/ds/api/v1/namespace/query"
-)
-
-func (c *Client) GetNamespaces(token string, baseUrl string, name string, pageNo int, pageSize int) ([]NamespaceInfo, error) {
-	fullUrl, err := url.JoinPath(baseUrl, getNamespacesUrl)
-	if err != nil {
-		return nil, errors.New(err.Error())
-	}
-
-	resp := new(struct {
-		Success    bool            `json:"success"`
-		Msg        string          `json:"msg"`
-		Infos      []NamespaceInfo `json:"infos"`
-		TotalCount int64           `json:"totalCount"`
-		PageNo     int64           `json:"pageNo"`
-	})
-
-	err = c.get(token, fullUrl, map[string]string{
-		"name":     name,
-		"pageNo":   strconv.Itoa(pageNo),
-		"pageSize": strconv.Itoa(pageSize),
-	}, resp)
-	if err != nil {
-		return nil, err
-	}
-
-	if !resp.Success {
-		return nil, errors.New(resp.Msg)
-	}
-
-	return resp.Infos, nil
-}

+ 0 - 71
framework/core/infrastructure/database/data_service/client/sql.go

@@ -1,71 +0,0 @@
-package client
-
-import (
-	"github.com/pkg/errors"
-	"net/url"
-)
-
-const (
-	executeRawSqlUrl = "/ds/api/v1/sql/rawSql/execute"
-	executeSqlUrl    = "/ds/api/v1/sql/execute"
-)
-
-func (c *Client) ExecuteRawSql(token string, baseUrl string,
-	namespace string, dataSource string, sql string, executeParams map[string]any) ([]map[string]any, error) {
-	fullUrl, err := url.JoinPath(baseUrl, executeRawSqlUrl)
-	if err != nil {
-		return nil, errors.New(err.Error())
-	}
-
-	resp := new(struct {
-		Success bool             `json:"success"`
-		Msg     string           `json:"msg"`
-		Results []map[string]any `json:"results"`
-	})
-
-	err = c.post(token, fullUrl, map[string]any{
-		"namespace":     namespace,
-		"dataSource":    dataSource,
-		"sql":           sql,
-		"executeParams": executeParams,
-	}, resp)
-	if err != nil {
-		return nil, err
-	}
-
-	if !resp.Success {
-		return nil, errors.New(resp.Msg)
-	}
-
-	return resp.Results, nil
-}
-
-func (c *Client) ExecuteSql(token string, baseUrl string,
-	namespace string, dataSource string, name string, executeParams map[string]any) ([]map[string]any, error) {
-	fullUrl, err := url.JoinPath(baseUrl, executeSqlUrl)
-	if err != nil {
-		return nil, errors.New(err.Error())
-	}
-
-	resp := new(struct {
-		Success bool             `json:"success"`
-		Msg     string           `json:"msg"`
-		Results []map[string]any `json:"results"`
-	})
-
-	err = c.post(token, fullUrl, map[string]any{
-		"namespace":     namespace,
-		"dataSource":    dataSource,
-		"name":          name,
-		"executeParams": executeParams,
-	}, resp)
-	if err != nil {
-		return nil, err
-	}
-
-	if !resp.Success {
-		return nil, errors.New(resp.Msg)
-	}
-
-	return resp.Results, nil
-}

+ 0 - 188
framework/core/infrastructure/database/data_service/data_service.go

@@ -1,188 +0,0 @@
-package data_service
-
-import (
-	"git.sxidc.com/go-framework/baize/framework/core/infrastructure/database/data_service/client"
-	"git.sxidc.com/go-framework/baize/framework/core/infrastructure/database/data_service/grpc_client"
-	"git.sxidc.com/go-framework/baize/framework/core/infrastructure/database/data_service/grpc_client/v1/request"
-	"git.sxidc.com/go-framework/baize/framework/core/infrastructure/database/sql"
-	"git.sxidc.com/go-framework/baize/framework/core/infrastructure/logger"
-	"git.sxidc.com/go-tools/utils/strutils"
-	"github.com/pkg/errors"
-	"io"
-	"time"
-)
-
-type Config struct {
-	Token      string `json:"token" yaml:"token"`
-	Address    string `json:"address" yaml:"address"`
-	HttpPort   string `json:"http_port" yaml:"http_port"`
-	GrpcPort   string `json:"grpc_port" yaml:"grpc_port"`
-	Namespace  string `json:"namespace" yaml:"namespace"`
-	DataSource string `json:"data_source" yaml:"data_source"`
-	TimeoutSec int64  `json:"timeout_sec" yaml:"timeout_sec"`
-}
-
-type DataService struct {
-	config     Config
-	client     *client.Client
-	grpcClient *grpc_client.Client
-}
-
-func NewDataService(config *Config) (*DataService, error) {
-	baseUrl := "http://" + config.Address + ":" + config.HttpPort
-	grpcAddress := config.Address + ":" + config.GrpcPort
-
-	if config.TimeoutSec == 0 {
-		config.TimeoutSec = 30
-	}
-
-	c := client.New(time.Duration(config.TimeoutSec) * time.Second)
-
-	namespaceInfos, err := c.GetNamespaces(config.Token, baseUrl,
-		config.Namespace, 1, 1)
-	if err != nil {
-		return nil, err
-	}
-
-	if namespaceInfos == nil || len(namespaceInfos) == 0 {
-		return nil, errors.New("命名空间不存在")
-	}
-
-	dataSourceInfos, err := c.GetDataSources(
-		config.Token, baseUrl, config.Namespace, config.DataSource, "", 1, 1)
-	if err != nil {
-		return nil, err
-	}
-
-	if dataSourceInfos == nil || len(dataSourceInfos) == 0 {
-		return nil, errors.New("数据源不存在")
-	}
-
-	grpcClient, err := grpc_client.NewClient(grpcAddress)
-	if err != nil {
-		return nil, errors.New(err.Error())
-	}
-
-	return &DataService{
-		config:     *config,
-		client:     c,
-		grpcClient: grpcClient,
-	}, nil
-}
-
-func DestroyDataService(ds *DataService) error {
-	if ds == nil {
-		return nil
-	}
-
-	err := grpc_client.Destroy(ds.grpcClient)
-	if err != nil {
-		return errors.New(err.Error())
-	}
-
-	ds = nil
-
-	return nil
-}
-
-func (ds *DataService) ExecuteRawSql(sqlStr string, executeParams map[string]any) ([]sql.Result, error) {
-	if strutils.IsStringEmpty(sqlStr) {
-		return make([]sql.Result, 0), nil
-	}
-
-	config := ds.config
-	baseUrl := "http://" + config.Address + ":" + config.HttpPort
-
-	tableRows, err := ds.client.ExecuteRawSql(config.Token, baseUrl,
-		config.Namespace, config.DataSource, sqlStr, executeParams)
-	if err != nil {
-		return nil, err
-	}
-
-	results := make([]sql.Result, len(tableRows))
-	for i, row := range tableRows {
-		results[i] = row
-	}
-
-	return results, nil
-}
-
-func (ds *DataService) ExecuteSql(name string, executeParams map[string]any) ([]sql.Result, error) {
-	if strutils.IsStringEmpty(name) {
-		return nil, errors.New("没有传递SQL资源名称")
-	}
-
-	config := ds.config
-	baseUrl := "http://" + config.Address + ":" + config.HttpPort
-
-	tableRows, err := ds.client.ExecuteSql(config.Token, baseUrl,
-		config.Namespace, config.DataSource, name, executeParams)
-	if err != nil {
-		return nil, err
-	}
-
-	results := make([]sql.Result, len(tableRows))
-	for i, row := range tableRows {
-		results[i] = row
-	}
-
-	return results, nil
-}
-
-func (ds *DataService) Transaction(txFunc TxFunc) error {
-	stream, err := ds.grpcClient.Transaction()
-	if err != nil {
-		return errors.New(err.Error())
-	}
-
-	defer func() {
-		innerErr := stream.CloseSend()
-		if innerErr != nil {
-			logger.GetInstance().Error(errors.New(innerErr.Error()))
-			return
-		}
-	}()
-
-	err = stream.Send(&request.TransactionOperation{
-		Request: &request.TransactionOperation_TransactionBeginRequest{
-			TransactionBeginRequest: &request.TransactionBeginRequest{
-				Token:      ds.config.Token,
-				Namespace:  ds.config.Namespace,
-				DataSource: ds.config.DataSource,
-			},
-		}})
-	if err != nil {
-		return errors.New(err.Error())
-	}
-
-	resp, err := stream.Recv()
-	if err != nil {
-		return errors.New(err.Error())
-	}
-
-	if !resp.Success {
-		return errors.New(resp.Msg)
-	}
-
-	err = txFunc(&Transaction{
-		stream: stream,
-	})
-	if err != nil {
-		return err
-	}
-
-	err = stream.Send(&request.TransactionOperation{
-		Request: &request.TransactionOperation_TransactionEndRequest{
-			TransactionEndRequest: &request.TransactionEndRequest{},
-		}})
-	if err != nil {
-		return errors.New(err.Error())
-	}
-
-	_, err = stream.Recv()
-	if err != nil && err != io.EOF {
-		return errors.New(err.Error())
-	}
-
-	return nil
-}

+ 0 - 46
framework/core/infrastructure/database/data_service/grpc_client/grpc_client.go

@@ -1,46 +0,0 @@
-package grpc_client
-
-import (
-	"context"
-	"git.sxidc.com/go-framework/baize/framework/core/infrastructure/database/data_service/grpc_client/v1"
-	"google.golang.org/grpc"
-	"google.golang.org/grpc/credentials/insecure"
-)
-
-type Client struct {
-	conn         *grpc.ClientConn
-	sqlServiceV1 v1.SqlServiceClient
-}
-
-func NewClient(address string) (*Client, error) {
-	conn, err := grpc.NewClient(address, grpc.WithTransportCredentials(insecure.NewCredentials()))
-	if err != nil {
-		return nil, err
-	}
-
-	return &Client{
-		conn:         conn,
-		sqlServiceV1: v1.NewSqlServiceClient(conn),
-	}, nil
-}
-
-func Destroy(c *Client) error {
-	if c == nil {
-		return nil
-	}
-
-	err := c.conn.Close()
-	if err != nil {
-		return err
-	}
-
-	c.sqlServiceV1 = nil
-	c.conn = nil
-	c = nil
-
-	return nil
-}
-
-func (c *Client) Transaction() (v1.SqlService_TransactionClient, error) {
-	return c.sqlServiceV1.Transaction(context.Background())
-}

+ 0 - 525
framework/core/infrastructure/database/data_service/grpc_client/v1/request/sql.pb.go

@@ -1,525 +0,0 @@
-// Code generated by protoc-gen-go. DO NOT EDIT.
-// versions:
-// 	protoc-gen-go v1.28.1
-// 	protoc        v3.12.4
-// source: v1/request/sql.proto
-
-package request
-
-import (
-	_ "github.com/mwitkow/go-proto-validators"
-	protoreflect "google.golang.org/protobuf/reflect/protoreflect"
-	protoimpl "google.golang.org/protobuf/runtime/protoimpl"
-	reflect "reflect"
-	sync "sync"
-)
-
-const (
-	// Verify that this generated code is sufficiently up-to-date.
-	_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
-	// Verify that runtime/protoimpl is sufficiently up-to-date.
-	_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
-)
-
-type TransactionBeginRequest struct {
-	state         protoimpl.MessageState
-	sizeCache     protoimpl.SizeCache
-	unknownFields protoimpl.UnknownFields
-
-	Token      string `protobuf:"bytes,1,opt,name=Token,proto3" json:"Token,omitempty"`
-	Namespace  string `protobuf:"bytes,2,opt,name=Namespace,proto3" json:"Namespace,omitempty"`
-	DataSource string `protobuf:"bytes,3,opt,name=DataSource,proto3" json:"DataSource,omitempty"`
-}
-
-func (x *TransactionBeginRequest) Reset() {
-	*x = TransactionBeginRequest{}
-	if protoimpl.UnsafeEnabled {
-		mi := &file_v1_request_sql_proto_msgTypes[0]
-		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
-		ms.StoreMessageInfo(mi)
-	}
-}
-
-func (x *TransactionBeginRequest) String() string {
-	return protoimpl.X.MessageStringOf(x)
-}
-
-func (*TransactionBeginRequest) ProtoMessage() {}
-
-func (x *TransactionBeginRequest) ProtoReflect() protoreflect.Message {
-	mi := &file_v1_request_sql_proto_msgTypes[0]
-	if protoimpl.UnsafeEnabled && x != nil {
-		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
-		if ms.LoadMessageInfo() == nil {
-			ms.StoreMessageInfo(mi)
-		}
-		return ms
-	}
-	return mi.MessageOf(x)
-}
-
-// Deprecated: Use TransactionBeginRequest.ProtoReflect.Descriptor instead.
-func (*TransactionBeginRequest) Descriptor() ([]byte, []int) {
-	return file_v1_request_sql_proto_rawDescGZIP(), []int{0}
-}
-
-func (x *TransactionBeginRequest) GetToken() string {
-	if x != nil {
-		return x.Token
-	}
-	return ""
-}
-
-func (x *TransactionBeginRequest) GetNamespace() string {
-	if x != nil {
-		return x.Namespace
-	}
-	return ""
-}
-
-func (x *TransactionBeginRequest) GetDataSource() string {
-	if x != nil {
-		return x.DataSource
-	}
-	return ""
-}
-
-type TransactionEndRequest struct {
-	state         protoimpl.MessageState
-	sizeCache     protoimpl.SizeCache
-	unknownFields protoimpl.UnknownFields
-}
-
-func (x *TransactionEndRequest) Reset() {
-	*x = TransactionEndRequest{}
-	if protoimpl.UnsafeEnabled {
-		mi := &file_v1_request_sql_proto_msgTypes[1]
-		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
-		ms.StoreMessageInfo(mi)
-	}
-}
-
-func (x *TransactionEndRequest) String() string {
-	return protoimpl.X.MessageStringOf(x)
-}
-
-func (*TransactionEndRequest) ProtoMessage() {}
-
-func (x *TransactionEndRequest) ProtoReflect() protoreflect.Message {
-	mi := &file_v1_request_sql_proto_msgTypes[1]
-	if protoimpl.UnsafeEnabled && x != nil {
-		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
-		if ms.LoadMessageInfo() == nil {
-			ms.StoreMessageInfo(mi)
-		}
-		return ms
-	}
-	return mi.MessageOf(x)
-}
-
-// Deprecated: Use TransactionEndRequest.ProtoReflect.Descriptor instead.
-func (*TransactionEndRequest) Descriptor() ([]byte, []int) {
-	return file_v1_request_sql_proto_rawDescGZIP(), []int{1}
-}
-
-type ExecuteRawSqlRequest struct {
-	state         protoimpl.MessageState
-	sizeCache     protoimpl.SizeCache
-	unknownFields protoimpl.UnknownFields
-
-	SQL           string `protobuf:"bytes,1,opt,name=SQL,proto3" json:"SQL,omitempty"`
-	ExecuteParams string `protobuf:"bytes,2,opt,name=ExecuteParams,proto3" json:"ExecuteParams,omitempty"`
-}
-
-func (x *ExecuteRawSqlRequest) Reset() {
-	*x = ExecuteRawSqlRequest{}
-	if protoimpl.UnsafeEnabled {
-		mi := &file_v1_request_sql_proto_msgTypes[2]
-		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
-		ms.StoreMessageInfo(mi)
-	}
-}
-
-func (x *ExecuteRawSqlRequest) String() string {
-	return protoimpl.X.MessageStringOf(x)
-}
-
-func (*ExecuteRawSqlRequest) ProtoMessage() {}
-
-func (x *ExecuteRawSqlRequest) ProtoReflect() protoreflect.Message {
-	mi := &file_v1_request_sql_proto_msgTypes[2]
-	if protoimpl.UnsafeEnabled && x != nil {
-		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
-		if ms.LoadMessageInfo() == nil {
-			ms.StoreMessageInfo(mi)
-		}
-		return ms
-	}
-	return mi.MessageOf(x)
-}
-
-// Deprecated: Use ExecuteRawSqlRequest.ProtoReflect.Descriptor instead.
-func (*ExecuteRawSqlRequest) Descriptor() ([]byte, []int) {
-	return file_v1_request_sql_proto_rawDescGZIP(), []int{2}
-}
-
-func (x *ExecuteRawSqlRequest) GetSQL() string {
-	if x != nil {
-		return x.SQL
-	}
-	return ""
-}
-
-func (x *ExecuteRawSqlRequest) GetExecuteParams() string {
-	if x != nil {
-		return x.ExecuteParams
-	}
-	return ""
-}
-
-type ExecuteSqlRequest struct {
-	state         protoimpl.MessageState
-	sizeCache     protoimpl.SizeCache
-	unknownFields protoimpl.UnknownFields
-
-	Name          string `protobuf:"bytes,1,opt,name=Name,proto3" json:"Name,omitempty"`
-	ExecuteParams string `protobuf:"bytes,2,opt,name=ExecuteParams,proto3" json:"ExecuteParams,omitempty"`
-}
-
-func (x *ExecuteSqlRequest) Reset() {
-	*x = ExecuteSqlRequest{}
-	if protoimpl.UnsafeEnabled {
-		mi := &file_v1_request_sql_proto_msgTypes[3]
-		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
-		ms.StoreMessageInfo(mi)
-	}
-}
-
-func (x *ExecuteSqlRequest) String() string {
-	return protoimpl.X.MessageStringOf(x)
-}
-
-func (*ExecuteSqlRequest) ProtoMessage() {}
-
-func (x *ExecuteSqlRequest) ProtoReflect() protoreflect.Message {
-	mi := &file_v1_request_sql_proto_msgTypes[3]
-	if protoimpl.UnsafeEnabled && x != nil {
-		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
-		if ms.LoadMessageInfo() == nil {
-			ms.StoreMessageInfo(mi)
-		}
-		return ms
-	}
-	return mi.MessageOf(x)
-}
-
-// Deprecated: Use ExecuteSqlRequest.ProtoReflect.Descriptor instead.
-func (*ExecuteSqlRequest) Descriptor() ([]byte, []int) {
-	return file_v1_request_sql_proto_rawDescGZIP(), []int{3}
-}
-
-func (x *ExecuteSqlRequest) GetName() string {
-	if x != nil {
-		return x.Name
-	}
-	return ""
-}
-
-func (x *ExecuteSqlRequest) GetExecuteParams() string {
-	if x != nil {
-		return x.ExecuteParams
-	}
-	return ""
-}
-
-type TransactionOperation struct {
-	state         protoimpl.MessageState
-	sizeCache     protoimpl.SizeCache
-	unknownFields protoimpl.UnknownFields
-
-	// Types that are assignable to Request:
-	//
-	//	*TransactionOperation_TransactionBeginRequest
-	//	*TransactionOperation_TransactionEndRequest
-	//	*TransactionOperation_ExecuteRawSqlRequest
-	//	*TransactionOperation_ExecuteSqlRequest
-	Request isTransactionOperation_Request `protobuf_oneof:"Request"`
-}
-
-func (x *TransactionOperation) Reset() {
-	*x = TransactionOperation{}
-	if protoimpl.UnsafeEnabled {
-		mi := &file_v1_request_sql_proto_msgTypes[4]
-		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
-		ms.StoreMessageInfo(mi)
-	}
-}
-
-func (x *TransactionOperation) String() string {
-	return protoimpl.X.MessageStringOf(x)
-}
-
-func (*TransactionOperation) ProtoMessage() {}
-
-func (x *TransactionOperation) ProtoReflect() protoreflect.Message {
-	mi := &file_v1_request_sql_proto_msgTypes[4]
-	if protoimpl.UnsafeEnabled && x != nil {
-		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
-		if ms.LoadMessageInfo() == nil {
-			ms.StoreMessageInfo(mi)
-		}
-		return ms
-	}
-	return mi.MessageOf(x)
-}
-
-// Deprecated: Use TransactionOperation.ProtoReflect.Descriptor instead.
-func (*TransactionOperation) Descriptor() ([]byte, []int) {
-	return file_v1_request_sql_proto_rawDescGZIP(), []int{4}
-}
-
-func (m *TransactionOperation) GetRequest() isTransactionOperation_Request {
-	if m != nil {
-		return m.Request
-	}
-	return nil
-}
-
-func (x *TransactionOperation) GetTransactionBeginRequest() *TransactionBeginRequest {
-	if x, ok := x.GetRequest().(*TransactionOperation_TransactionBeginRequest); ok {
-		return x.TransactionBeginRequest
-	}
-	return nil
-}
-
-func (x *TransactionOperation) GetTransactionEndRequest() *TransactionEndRequest {
-	if x, ok := x.GetRequest().(*TransactionOperation_TransactionEndRequest); ok {
-		return x.TransactionEndRequest
-	}
-	return nil
-}
-
-func (x *TransactionOperation) GetExecuteRawSqlRequest() *ExecuteRawSqlRequest {
-	if x, ok := x.GetRequest().(*TransactionOperation_ExecuteRawSqlRequest); ok {
-		return x.ExecuteRawSqlRequest
-	}
-	return nil
-}
-
-func (x *TransactionOperation) GetExecuteSqlRequest() *ExecuteSqlRequest {
-	if x, ok := x.GetRequest().(*TransactionOperation_ExecuteSqlRequest); ok {
-		return x.ExecuteSqlRequest
-	}
-	return nil
-}
-
-type isTransactionOperation_Request interface {
-	isTransactionOperation_Request()
-}
-
-type TransactionOperation_TransactionBeginRequest struct {
-	TransactionBeginRequest *TransactionBeginRequest `protobuf:"bytes,1,opt,name=TransactionBeginRequest,proto3,oneof"`
-}
-
-type TransactionOperation_TransactionEndRequest struct {
-	TransactionEndRequest *TransactionEndRequest `protobuf:"bytes,2,opt,name=TransactionEndRequest,proto3,oneof"`
-}
-
-type TransactionOperation_ExecuteRawSqlRequest struct {
-	ExecuteRawSqlRequest *ExecuteRawSqlRequest `protobuf:"bytes,3,opt,name=ExecuteRawSqlRequest,proto3,oneof"`
-}
-
-type TransactionOperation_ExecuteSqlRequest struct {
-	ExecuteSqlRequest *ExecuteSqlRequest `protobuf:"bytes,4,opt,name=ExecuteSqlRequest,proto3,oneof"`
-}
-
-func (*TransactionOperation_TransactionBeginRequest) isTransactionOperation_Request() {}
-
-func (*TransactionOperation_TransactionEndRequest) isTransactionOperation_Request() {}
-
-func (*TransactionOperation_ExecuteRawSqlRequest) isTransactionOperation_Request() {}
-
-func (*TransactionOperation_ExecuteSqlRequest) isTransactionOperation_Request() {}
-
-var File_v1_request_sql_proto protoreflect.FileDescriptor
-
-var file_v1_request_sql_proto_rawDesc = []byte{
-	0x0a, 0x14, 0x76, 0x31, 0x2f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x2f, 0x73, 0x71, 0x6c,
-	0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x07, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a,
-	0x36, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6d, 0x77, 0x69, 0x74,
-	0x6b, 0x6f, 0x77, 0x2f, 0x67, 0x6f, 0x2d, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2d, 0x76, 0x61, 0x6c,
-	0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x73, 0x2f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f,
-	0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x85, 0x01, 0x0a, 0x17, 0x54, 0x72, 0x61, 0x6e,
-	0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x42, 0x65, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x71, 0x75,
-	0x65, 0x73, 0x74, 0x12, 0x1c, 0x0a, 0x05, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x01, 0x20, 0x01,
-	0x28, 0x09, 0x42, 0x06, 0xe2, 0xdf, 0x1f, 0x02, 0x58, 0x01, 0x52, 0x05, 0x54, 0x6f, 0x6b, 0x65,
-	0x6e, 0x12, 0x24, 0x0a, 0x09, 0x4e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x18, 0x02,
-	0x20, 0x01, 0x28, 0x09, 0x42, 0x06, 0xe2, 0xdf, 0x1f, 0x02, 0x58, 0x01, 0x52, 0x09, 0x4e, 0x61,
-	0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x12, 0x26, 0x0a, 0x0a, 0x44, 0x61, 0x74, 0x61, 0x53,
-	0x6f, 0x75, 0x72, 0x63, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x42, 0x06, 0xe2, 0xdf, 0x1f,
-	0x02, 0x58, 0x01, 0x52, 0x0a, 0x44, 0x61, 0x74, 0x61, 0x53, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x22,
-	0x17, 0x0a, 0x15, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x45, 0x6e,
-	0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x56, 0x0a, 0x14, 0x45, 0x78, 0x65, 0x63,
-	0x75, 0x74, 0x65, 0x52, 0x61, 0x77, 0x53, 0x71, 0x6c, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74,
-	0x12, 0x18, 0x0a, 0x03, 0x53, 0x51, 0x4c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x06, 0xe2,
-	0xdf, 0x1f, 0x02, 0x58, 0x01, 0x52, 0x03, 0x53, 0x51, 0x4c, 0x12, 0x24, 0x0a, 0x0d, 0x45, 0x78,
-	0x65, 0x63, 0x75, 0x74, 0x65, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28,
-	0x09, 0x52, 0x0d, 0x45, 0x78, 0x65, 0x63, 0x75, 0x74, 0x65, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73,
-	0x22, 0x55, 0x0a, 0x11, 0x45, 0x78, 0x65, 0x63, 0x75, 0x74, 0x65, 0x53, 0x71, 0x6c, 0x52, 0x65,
-	0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1a, 0x0a, 0x04, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20,
-	0x01, 0x28, 0x09, 0x42, 0x06, 0xe2, 0xdf, 0x1f, 0x02, 0x58, 0x01, 0x52, 0x04, 0x4e, 0x61, 0x6d,
-	0x65, 0x12, 0x24, 0x0a, 0x0d, 0x45, 0x78, 0x65, 0x63, 0x75, 0x74, 0x65, 0x50, 0x61, 0x72, 0x61,
-	0x6d, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x45, 0x78, 0x65, 0x63, 0x75, 0x74,
-	0x65, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x22, 0xf8, 0x02, 0x0a, 0x14, 0x54, 0x72, 0x61, 0x6e,
-	0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e,
-	0x12, 0x5c, 0x0a, 0x17, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x42,
-	0x65, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28,
-	0x0b, 0x32, 0x20, 0x2e, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x2e, 0x54, 0x72, 0x61, 0x6e,
-	0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x42, 0x65, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x71, 0x75,
-	0x65, 0x73, 0x74, 0x48, 0x00, 0x52, 0x17, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69,
-	0x6f, 0x6e, 0x42, 0x65, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x56,
-	0x0a, 0x15, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x45, 0x6e, 0x64,
-	0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1e, 0x2e,
-	0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x2e, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74,
-	0x69, 0x6f, 0x6e, 0x45, 0x6e, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x48, 0x00, 0x52,
-	0x15, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x45, 0x6e, 0x64, 0x52,
-	0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x53, 0x0a, 0x14, 0x45, 0x78, 0x65, 0x63, 0x75, 0x74,
-	0x65, 0x52, 0x61, 0x77, 0x53, 0x71, 0x6c, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x18, 0x03,
-	0x20, 0x01, 0x28, 0x0b, 0x32, 0x1d, 0x2e, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x2e, 0x45,
-	0x78, 0x65, 0x63, 0x75, 0x74, 0x65, 0x52, 0x61, 0x77, 0x53, 0x71, 0x6c, 0x52, 0x65, 0x71, 0x75,
-	0x65, 0x73, 0x74, 0x48, 0x00, 0x52, 0x14, 0x45, 0x78, 0x65, 0x63, 0x75, 0x74, 0x65, 0x52, 0x61,
-	0x77, 0x53, 0x71, 0x6c, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x4a, 0x0a, 0x11, 0x45,
-	0x78, 0x65, 0x63, 0x75, 0x74, 0x65, 0x53, 0x71, 0x6c, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74,
-	0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74,
-	0x2e, 0x45, 0x78, 0x65, 0x63, 0x75, 0x74, 0x65, 0x53, 0x71, 0x6c, 0x52, 0x65, 0x71, 0x75, 0x65,
-	0x73, 0x74, 0x48, 0x00, 0x52, 0x11, 0x45, 0x78, 0x65, 0x63, 0x75, 0x74, 0x65, 0x53, 0x71, 0x6c,
-	0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x42, 0x09, 0x0a, 0x07, 0x52, 0x65, 0x71, 0x75, 0x65,
-	0x73, 0x74, 0x42, 0x1f, 0x5a, 0x1d, 0x64, 0x73, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x67, 0x72, 0x70,
-	0x63, 0x5f, 0x61, 0x70, 0x69, 0x2f, 0x70, 0x62, 0x2f, 0x76, 0x31, 0x2f, 0x72, 0x65, 0x71, 0x75,
-	0x65, 0x73, 0x74, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
-}
-
-var (
-	file_v1_request_sql_proto_rawDescOnce sync.Once
-	file_v1_request_sql_proto_rawDescData = file_v1_request_sql_proto_rawDesc
-)
-
-func file_v1_request_sql_proto_rawDescGZIP() []byte {
-	file_v1_request_sql_proto_rawDescOnce.Do(func() {
-		file_v1_request_sql_proto_rawDescData = protoimpl.X.CompressGZIP(file_v1_request_sql_proto_rawDescData)
-	})
-	return file_v1_request_sql_proto_rawDescData
-}
-
-var file_v1_request_sql_proto_msgTypes = make([]protoimpl.MessageInfo, 5)
-var file_v1_request_sql_proto_goTypes = []interface{}{
-	(*TransactionBeginRequest)(nil), // 0: request.TransactionBeginRequest
-	(*TransactionEndRequest)(nil),   // 1: request.TransactionEndRequest
-	(*ExecuteRawSqlRequest)(nil),    // 2: request.ExecuteRawSqlRequest
-	(*ExecuteSqlRequest)(nil),       // 3: request.ExecuteSqlRequest
-	(*TransactionOperation)(nil),    // 4: request.TransactionOperation
-}
-var file_v1_request_sql_proto_depIdxs = []int32{
-	0, // 0: request.TransactionOperation.TransactionBeginRequest:type_name -> request.TransactionBeginRequest
-	1, // 1: request.TransactionOperation.TransactionEndRequest:type_name -> request.TransactionEndRequest
-	2, // 2: request.TransactionOperation.ExecuteRawSqlRequest:type_name -> request.ExecuteRawSqlRequest
-	3, // 3: request.TransactionOperation.ExecuteSqlRequest:type_name -> request.ExecuteSqlRequest
-	4, // [4:4] is the sub-list for method output_type
-	4, // [4:4] is the sub-list for method input_type
-	4, // [4:4] is the sub-list for extension type_name
-	4, // [4:4] is the sub-list for extension extendee
-	0, // [0:4] is the sub-list for field type_name
-}
-
-func init() { file_v1_request_sql_proto_init() }
-func file_v1_request_sql_proto_init() {
-	if File_v1_request_sql_proto != nil {
-		return
-	}
-	if !protoimpl.UnsafeEnabled {
-		file_v1_request_sql_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
-			switch v := v.(*TransactionBeginRequest); i {
-			case 0:
-				return &v.state
-			case 1:
-				return &v.sizeCache
-			case 2:
-				return &v.unknownFields
-			default:
-				return nil
-			}
-		}
-		file_v1_request_sql_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
-			switch v := v.(*TransactionEndRequest); i {
-			case 0:
-				return &v.state
-			case 1:
-				return &v.sizeCache
-			case 2:
-				return &v.unknownFields
-			default:
-				return nil
-			}
-		}
-		file_v1_request_sql_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
-			switch v := v.(*ExecuteRawSqlRequest); i {
-			case 0:
-				return &v.state
-			case 1:
-				return &v.sizeCache
-			case 2:
-				return &v.unknownFields
-			default:
-				return nil
-			}
-		}
-		file_v1_request_sql_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
-			switch v := v.(*ExecuteSqlRequest); i {
-			case 0:
-				return &v.state
-			case 1:
-				return &v.sizeCache
-			case 2:
-				return &v.unknownFields
-			default:
-				return nil
-			}
-		}
-		file_v1_request_sql_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
-			switch v := v.(*TransactionOperation); i {
-			case 0:
-				return &v.state
-			case 1:
-				return &v.sizeCache
-			case 2:
-				return &v.unknownFields
-			default:
-				return nil
-			}
-		}
-	}
-	file_v1_request_sql_proto_msgTypes[4].OneofWrappers = []interface{}{
-		(*TransactionOperation_TransactionBeginRequest)(nil),
-		(*TransactionOperation_TransactionEndRequest)(nil),
-		(*TransactionOperation_ExecuteRawSqlRequest)(nil),
-		(*TransactionOperation_ExecuteSqlRequest)(nil),
-	}
-	type x struct{}
-	out := protoimpl.TypeBuilder{
-		File: protoimpl.DescBuilder{
-			GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
-			RawDescriptor: file_v1_request_sql_proto_rawDesc,
-			NumEnums:      0,
-			NumMessages:   5,
-			NumExtensions: 0,
-			NumServices:   0,
-		},
-		GoTypes:           file_v1_request_sql_proto_goTypes,
-		DependencyIndexes: file_v1_request_sql_proto_depIdxs,
-		MessageInfos:      file_v1_request_sql_proto_msgTypes,
-	}.Build()
-	File_v1_request_sql_proto = out.File
-	file_v1_request_sql_proto_rawDesc = nil
-	file_v1_request_sql_proto_goTypes = nil
-	file_v1_request_sql_proto_depIdxs = nil
-}

+ 0 - 76
framework/core/infrastructure/database/data_service/grpc_client/v1/request/sql.validator.pb.go

@@ -1,76 +0,0 @@
-// Code generated by protoc-gen-gogo. DO NOT EDIT.
-// source: v1/request/sql.proto
-
-package request
-
-import (
-	fmt "fmt"
-	math "math"
-	proto "github.com/golang/protobuf/proto"
-	_ "github.com/mwitkow/go-proto-validators"
-	github_com_mwitkow_go_proto_validators "github.com/mwitkow/go-proto-validators"
-)
-
-// Reference imports to suppress errors if they are not otherwise used.
-var _ = proto.Marshal
-var _ = fmt.Errorf
-var _ = math.Inf
-
-func (this *TransactionBeginRequest) Validate() error {
-	if this.Token == "" {
-		return github_com_mwitkow_go_proto_validators.FieldError("Token", fmt.Errorf(`value '%v' must not be an empty string`, this.Token))
-	}
-	if this.Namespace == "" {
-		return github_com_mwitkow_go_proto_validators.FieldError("Namespace", fmt.Errorf(`value '%v' must not be an empty string`, this.Namespace))
-	}
-	if this.DataSource == "" {
-		return github_com_mwitkow_go_proto_validators.FieldError("DataSource", fmt.Errorf(`value '%v' must not be an empty string`, this.DataSource))
-	}
-	return nil
-}
-func (this *TransactionEndRequest) Validate() error {
-	return nil
-}
-func (this *ExecuteRawSqlRequest) Validate() error {
-	if this.SQL == "" {
-		return github_com_mwitkow_go_proto_validators.FieldError("SQL", fmt.Errorf(`value '%v' must not be an empty string`, this.SQL))
-	}
-	return nil
-}
-func (this *ExecuteSqlRequest) Validate() error {
-	if this.Name == "" {
-		return github_com_mwitkow_go_proto_validators.FieldError("Name", fmt.Errorf(`value '%v' must not be an empty string`, this.Name))
-	}
-	return nil
-}
-func (this *TransactionOperation) Validate() error {
-	if oneOfNester, ok := this.GetRequest().(*TransactionOperation_TransactionBeginRequest); ok {
-		if oneOfNester.TransactionBeginRequest != nil {
-			if err := github_com_mwitkow_go_proto_validators.CallValidatorIfExists(oneOfNester.TransactionBeginRequest); err != nil {
-				return github_com_mwitkow_go_proto_validators.FieldError("TransactionBeginRequest", err)
-			}
-		}
-	}
-	if oneOfNester, ok := this.GetRequest().(*TransactionOperation_TransactionEndRequest); ok {
-		if oneOfNester.TransactionEndRequest != nil {
-			if err := github_com_mwitkow_go_proto_validators.CallValidatorIfExists(oneOfNester.TransactionEndRequest); err != nil {
-				return github_com_mwitkow_go_proto_validators.FieldError("TransactionEndRequest", err)
-			}
-		}
-	}
-	if oneOfNester, ok := this.GetRequest().(*TransactionOperation_ExecuteRawSqlRequest); ok {
-		if oneOfNester.ExecuteRawSqlRequest != nil {
-			if err := github_com_mwitkow_go_proto_validators.CallValidatorIfExists(oneOfNester.ExecuteRawSqlRequest); err != nil {
-				return github_com_mwitkow_go_proto_validators.FieldError("ExecuteRawSqlRequest", err)
-			}
-		}
-	}
-	if oneOfNester, ok := this.GetRequest().(*TransactionOperation_ExecuteSqlRequest); ok {
-		if oneOfNester.ExecuteSqlRequest != nil {
-			if err := github_com_mwitkow_go_proto_validators.CallValidatorIfExists(oneOfNester.ExecuteSqlRequest); err != nil {
-				return github_com_mwitkow_go_proto_validators.FieldError("ExecuteSqlRequest", err)
-			}
-		}
-	}
-	return nil
-}

+ 0 - 163
framework/core/infrastructure/database/data_service/grpc_client/v1/response/sql.pb.go

@@ -1,163 +0,0 @@
-// Code generated by protoc-gen-go. DO NOT EDIT.
-// versions:
-// 	protoc-gen-go v1.28.1
-// 	protoc        v3.12.4
-// source: v1/response/sql.proto
-
-package response
-
-import (
-	protoreflect "google.golang.org/protobuf/reflect/protoreflect"
-	protoimpl "google.golang.org/protobuf/runtime/protoimpl"
-	reflect "reflect"
-	sync "sync"
-)
-
-const (
-	// Verify that this generated code is sufficiently up-to-date.
-	_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
-	// Verify that runtime/protoimpl is sufficiently up-to-date.
-	_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
-)
-
-type TransactionResponse struct {
-	state         protoimpl.MessageState
-	sizeCache     protoimpl.SizeCache
-	unknownFields protoimpl.UnknownFields
-
-	Success bool   `protobuf:"varint,1,opt,name=Success,proto3" json:"Success,omitempty"`
-	Msg     string `protobuf:"bytes,2,opt,name=Msg,proto3" json:"Msg,omitempty"`
-	Results string `protobuf:"bytes,3,opt,name=Results,proto3" json:"Results,omitempty"`
-}
-
-func (x *TransactionResponse) Reset() {
-	*x = TransactionResponse{}
-	if protoimpl.UnsafeEnabled {
-		mi := &file_v1_response_sql_proto_msgTypes[0]
-		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
-		ms.StoreMessageInfo(mi)
-	}
-}
-
-func (x *TransactionResponse) String() string {
-	return protoimpl.X.MessageStringOf(x)
-}
-
-func (*TransactionResponse) ProtoMessage() {}
-
-func (x *TransactionResponse) ProtoReflect() protoreflect.Message {
-	mi := &file_v1_response_sql_proto_msgTypes[0]
-	if protoimpl.UnsafeEnabled && x != nil {
-		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
-		if ms.LoadMessageInfo() == nil {
-			ms.StoreMessageInfo(mi)
-		}
-		return ms
-	}
-	return mi.MessageOf(x)
-}
-
-// Deprecated: Use TransactionResponse.ProtoReflect.Descriptor instead.
-func (*TransactionResponse) Descriptor() ([]byte, []int) {
-	return file_v1_response_sql_proto_rawDescGZIP(), []int{0}
-}
-
-func (x *TransactionResponse) GetSuccess() bool {
-	if x != nil {
-		return x.Success
-	}
-	return false
-}
-
-func (x *TransactionResponse) GetMsg() string {
-	if x != nil {
-		return x.Msg
-	}
-	return ""
-}
-
-func (x *TransactionResponse) GetResults() string {
-	if x != nil {
-		return x.Results
-	}
-	return ""
-}
-
-var File_v1_response_sql_proto protoreflect.FileDescriptor
-
-var file_v1_response_sql_proto_rawDesc = []byte{
-	0x0a, 0x15, 0x76, 0x31, 0x2f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x2f, 0x73, 0x71,
-	0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x08, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73,
-	0x65, 0x22, 0x5b, 0x0a, 0x13, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e,
-	0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x53, 0x75, 0x63, 0x63,
-	0x65, 0x73, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x53, 0x75, 0x63, 0x63, 0x65,
-	0x73, 0x73, 0x12, 0x10, 0x0a, 0x03, 0x4d, 0x73, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52,
-	0x03, 0x4d, 0x73, 0x67, 0x12, 0x18, 0x0a, 0x07, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x73, 0x18,
-	0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x73, 0x42, 0x20,
-	0x5a, 0x1e, 0x64, 0x73, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x5f, 0x61, 0x70,
-	0x69, 0x2f, 0x70, 0x62, 0x2f, 0x76, 0x31, 0x2f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65,
-	0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
-}
-
-var (
-	file_v1_response_sql_proto_rawDescOnce sync.Once
-	file_v1_response_sql_proto_rawDescData = file_v1_response_sql_proto_rawDesc
-)
-
-func file_v1_response_sql_proto_rawDescGZIP() []byte {
-	file_v1_response_sql_proto_rawDescOnce.Do(func() {
-		file_v1_response_sql_proto_rawDescData = protoimpl.X.CompressGZIP(file_v1_response_sql_proto_rawDescData)
-	})
-	return file_v1_response_sql_proto_rawDescData
-}
-
-var file_v1_response_sql_proto_msgTypes = make([]protoimpl.MessageInfo, 1)
-var file_v1_response_sql_proto_goTypes = []interface{}{
-	(*TransactionResponse)(nil), // 0: response.TransactionResponse
-}
-var file_v1_response_sql_proto_depIdxs = []int32{
-	0, // [0:0] is the sub-list for method output_type
-	0, // [0:0] is the sub-list for method input_type
-	0, // [0:0] is the sub-list for extension type_name
-	0, // [0:0] is the sub-list for extension extendee
-	0, // [0:0] is the sub-list for field type_name
-}
-
-func init() { file_v1_response_sql_proto_init() }
-func file_v1_response_sql_proto_init() {
-	if File_v1_response_sql_proto != nil {
-		return
-	}
-	if !protoimpl.UnsafeEnabled {
-		file_v1_response_sql_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
-			switch v := v.(*TransactionResponse); i {
-			case 0:
-				return &v.state
-			case 1:
-				return &v.sizeCache
-			case 2:
-				return &v.unknownFields
-			default:
-				return nil
-			}
-		}
-	}
-	type x struct{}
-	out := protoimpl.TypeBuilder{
-		File: protoimpl.DescBuilder{
-			GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
-			RawDescriptor: file_v1_response_sql_proto_rawDesc,
-			NumEnums:      0,
-			NumMessages:   1,
-			NumExtensions: 0,
-			NumServices:   0,
-		},
-		GoTypes:           file_v1_response_sql_proto_goTypes,
-		DependencyIndexes: file_v1_response_sql_proto_depIdxs,
-		MessageInfos:      file_v1_response_sql_proto_msgTypes,
-	}.Build()
-	File_v1_response_sql_proto = out.File
-	file_v1_response_sql_proto_rawDesc = nil
-	file_v1_response_sql_proto_goTypes = nil
-	file_v1_response_sql_proto_depIdxs = nil
-}

+ 0 - 78
framework/core/infrastructure/database/data_service/grpc_client/v1/sql.pb.go

@@ -1,78 +0,0 @@
-// Code generated by protoc-gen-go. DO NOT EDIT.
-// versions:
-// 	protoc-gen-go v1.28.1
-// 	protoc        v3.12.4
-// source: v1/sql.proto
-
-package v1
-
-import (
-	request "git.sxidc.com/go-framework/baize/framework/core/infrastructure/database/data_service/grpc_client/v1/request"
-	response "git.sxidc.com/go-framework/baize/framework/core/infrastructure/database/data_service/grpc_client/v1/response"
-	protoreflect "google.golang.org/protobuf/reflect/protoreflect"
-	protoimpl "google.golang.org/protobuf/runtime/protoimpl"
-	reflect "reflect"
-)
-
-const (
-	// Verify that this generated code is sufficiently up-to-date.
-	_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
-	// Verify that runtime/protoimpl is sufficiently up-to-date.
-	_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
-)
-
-var File_v1_sql_proto protoreflect.FileDescriptor
-
-var file_v1_sql_proto_rawDesc = []byte{
-	0x0a, 0x0c, 0x76, 0x31, 0x2f, 0x73, 0x71, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x02,
-	0x76, 0x31, 0x1a, 0x14, 0x76, 0x31, 0x2f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x2f, 0x73,
-	0x71, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x15, 0x76, 0x31, 0x2f, 0x72, 0x65, 0x73,
-	0x70, 0x6f, 0x6e, 0x73, 0x65, 0x2f, 0x73, 0x71, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x32,
-	0x5f, 0x0a, 0x0a, 0x53, 0x71, 0x6c, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x51, 0x0a,
-	0x0b, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1d, 0x2e, 0x72,
-	0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x2e, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69,
-	0x6f, 0x6e, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x1a, 0x1d, 0x2e, 0x72, 0x65,
-	0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x2e, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69,
-	0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x28, 0x01, 0x30, 0x01,
-	0x42, 0x17, 0x5a, 0x15, 0x64, 0x73, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x5f,
-	0x61, 0x70, 0x69, 0x2f, 0x70, 0x62, 0x2f, 0x76, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f,
-	0x33,
-}
-
-var file_v1_sql_proto_goTypes = []interface{}{
-	(*request.TransactionOperation)(nil), // 0: request.TransactionOperation
-	(*response.TransactionResponse)(nil), // 1: response.TransactionResponse
-}
-var file_v1_sql_proto_depIdxs = []int32{
-	0, // 0: v1.SqlService.Transaction:input_type -> request.TransactionOperation
-	1, // 1: v1.SqlService.Transaction:output_type -> response.TransactionResponse
-	1, // [1:2] is the sub-list for method output_type
-	0, // [0:1] is the sub-list for method input_type
-	0, // [0:0] is the sub-list for extension type_name
-	0, // [0:0] is the sub-list for extension extendee
-	0, // [0:0] is the sub-list for field type_name
-}
-
-func init() { file_v1_sql_proto_init() }
-func file_v1_sql_proto_init() {
-	if File_v1_sql_proto != nil {
-		return
-	}
-	type x struct{}
-	out := protoimpl.TypeBuilder{
-		File: protoimpl.DescBuilder{
-			GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
-			RawDescriptor: file_v1_sql_proto_rawDesc,
-			NumEnums:      0,
-			NumMessages:   0,
-			NumExtensions: 0,
-			NumServices:   1,
-		},
-		GoTypes:           file_v1_sql_proto_goTypes,
-		DependencyIndexes: file_v1_sql_proto_depIdxs,
-	}.Build()
-	File_v1_sql_proto = out.File
-	file_v1_sql_proto_rawDesc = nil
-	file_v1_sql_proto_goTypes = nil
-	file_v1_sql_proto_depIdxs = nil
-}

+ 0 - 139
framework/core/infrastructure/database/data_service/grpc_client/v1/sql_grpc.pb.go

@@ -1,139 +0,0 @@
-// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
-// versions:
-// - protoc-gen-go-grpc v1.2.0
-// - protoc             v3.12.4
-// source: v1/sql.proto
-
-package v1
-
-import (
-	context "context"
-	request "git.sxidc.com/go-framework/baize/framework/core/infrastructure/database/data_service/grpc_client/v1/request"
-	response "git.sxidc.com/go-framework/baize/framework/core/infrastructure/database/data_service/grpc_client/v1/response"
-	grpc "google.golang.org/grpc"
-	codes "google.golang.org/grpc/codes"
-	status "google.golang.org/grpc/status"
-)
-
-// This is a compile-time assertion to ensure that this generated file
-// is compatible with the grpc package it is being compiled against.
-// Requires gRPC-Go v1.32.0 or later.
-const _ = grpc.SupportPackageIsVersion7
-
-// SqlServiceClient is the client API for SqlService service.
-//
-// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
-type SqlServiceClient interface {
-	Transaction(ctx context.Context, opts ...grpc.CallOption) (SqlService_TransactionClient, error)
-}
-
-type sqlServiceClient struct {
-	cc grpc.ClientConnInterface
-}
-
-func NewSqlServiceClient(cc grpc.ClientConnInterface) SqlServiceClient {
-	return &sqlServiceClient{cc}
-}
-
-func (c *sqlServiceClient) Transaction(ctx context.Context, opts ...grpc.CallOption) (SqlService_TransactionClient, error) {
-	stream, err := c.cc.NewStream(ctx, &SqlService_ServiceDesc.Streams[0], "/v1.SqlService/Transaction", opts...)
-	if err != nil {
-		return nil, err
-	}
-	x := &sqlServiceTransactionClient{stream}
-	return x, nil
-}
-
-type SqlService_TransactionClient interface {
-	Send(*request.TransactionOperation) error
-	Recv() (*response.TransactionResponse, error)
-	grpc.ClientStream
-}
-
-type sqlServiceTransactionClient struct {
-	grpc.ClientStream
-}
-
-func (x *sqlServiceTransactionClient) Send(m *request.TransactionOperation) error {
-	return x.ClientStream.SendMsg(m)
-}
-
-func (x *sqlServiceTransactionClient) Recv() (*response.TransactionResponse, error) {
-	m := new(response.TransactionResponse)
-	if err := x.ClientStream.RecvMsg(m); err != nil {
-		return nil, err
-	}
-	return m, nil
-}
-
-// SqlServiceServer is the server API for SqlService service.
-// All implementations must embed UnimplementedSqlServiceServer
-// for forward compatibility
-type SqlServiceServer interface {
-	Transaction(SqlService_TransactionServer) error
-	mustEmbedUnimplementedSqlServiceServer()
-}
-
-// UnimplementedSqlServiceServer must be embedded to have forward compatible implementations.
-type UnimplementedSqlServiceServer struct {
-}
-
-func (UnimplementedSqlServiceServer) Transaction(SqlService_TransactionServer) error {
-	return status.Errorf(codes.Unimplemented, "method Transaction not implemented")
-}
-func (UnimplementedSqlServiceServer) mustEmbedUnimplementedSqlServiceServer() {}
-
-// UnsafeSqlServiceServer may be embedded to opt out of forward compatibility for this service.
-// Use of this interface is not recommended, as added methods to SqlServiceServer will
-// result in compilation errors.
-type UnsafeSqlServiceServer interface {
-	mustEmbedUnimplementedSqlServiceServer()
-}
-
-func RegisterSqlServiceServer(s grpc.ServiceRegistrar, srv SqlServiceServer) {
-	s.RegisterService(&SqlService_ServiceDesc, srv)
-}
-
-func _SqlService_Transaction_Handler(srv interface{}, stream grpc.ServerStream) error {
-	return srv.(SqlServiceServer).Transaction(&sqlServiceTransactionServer{stream})
-}
-
-type SqlService_TransactionServer interface {
-	Send(*response.TransactionResponse) error
-	Recv() (*request.TransactionOperation, error)
-	grpc.ServerStream
-}
-
-type sqlServiceTransactionServer struct {
-	grpc.ServerStream
-}
-
-func (x *sqlServiceTransactionServer) Send(m *response.TransactionResponse) error {
-	return x.ServerStream.SendMsg(m)
-}
-
-func (x *sqlServiceTransactionServer) Recv() (*request.TransactionOperation, error) {
-	m := new(request.TransactionOperation)
-	if err := x.ServerStream.RecvMsg(m); err != nil {
-		return nil, err
-	}
-	return m, nil
-}
-
-// SqlService_ServiceDesc is the grpc.ServiceDesc for SqlService service.
-// It's only intended for direct use with grpc.RegisterService,
-// and not to be introspected or modified (even as a copy)
-var SqlService_ServiceDesc = grpc.ServiceDesc{
-	ServiceName: "v1.SqlService",
-	HandlerType: (*SqlServiceServer)(nil),
-	Methods:     []grpc.MethodDesc{},
-	Streams: []grpc.StreamDesc{
-		{
-			StreamName:    "Transaction",
-			Handler:       _SqlService_Transaction_Handler,
-			ServerStreams: true,
-			ClientStreams: true,
-		},
-	},
-	Metadata: "v1/sql.proto",
-}

+ 0 - 132
framework/core/infrastructure/database/data_service/transaction.go

@@ -1,132 +0,0 @@
-package data_service
-
-import (
-	"encoding/json"
-	"git.sxidc.com/go-framework/baize/framework/core/infrastructure/database/data_service/grpc_client/v1"
-	"git.sxidc.com/go-framework/baize/framework/core/infrastructure/database/data_service/grpc_client/v1/request"
-	"git.sxidc.com/go-framework/baize/framework/core/infrastructure/database/sql"
-	"git.sxidc.com/go-framework/baize/framework/core/infrastructure/logger"
-	"github.com/pkg/errors"
-)
-
-type TxFunc func(tx *Transaction) error
-
-type Transaction struct {
-	stream v1.SqlService_TransactionClient
-}
-
-func (tx *Transaction) ExecuteRawSql(sqlStr string, executeParams map[string]any) ([]sql.Result, error) {
-	var retErr error
-
-	defer func() {
-		if retErr != nil {
-			innerErr := tx.stream.CloseSend()
-			if innerErr != nil {
-				logger.GetInstance().Error(errors.New(innerErr.Error()))
-				return
-			}
-		}
-	}()
-
-	executeParamsJsonBytes, err := json.Marshal(executeParams)
-	if err != nil {
-		retErr = errors.New(err.Error())
-		return nil, retErr
-	}
-
-	err = tx.stream.SendMsg(&request.TransactionOperation{
-		Request: &request.TransactionOperation_ExecuteRawSqlRequest{
-			ExecuteRawSqlRequest: &request.ExecuteRawSqlRequest{
-				SQL:           sqlStr,
-				ExecuteParams: string(executeParamsJsonBytes),
-			},
-		},
-	})
-	if err != nil {
-		retErr = errors.New(err.Error())
-		return nil, retErr
-	}
-
-	resp, err := tx.stream.Recv()
-	if err != nil {
-		retErr = errors.New(err.Error())
-		return nil, retErr
-	}
-
-	if !resp.Success {
-		retErr = errors.New(resp.Msg)
-		return nil, retErr
-	}
-
-	tableRows := make([]map[string]any, 0)
-	err = json.Unmarshal([]byte(resp.Results), &tableRows)
-	if err != nil {
-		retErr = errors.New(err.Error())
-		return nil, retErr
-	}
-
-	results := make([]sql.Result, len(tableRows))
-	for i, row := range tableRows {
-		results[i] = row
-	}
-
-	return results, nil
-}
-
-func (tx *Transaction) ExecuteSql(name string, executeParams map[string]any) ([]sql.Result, error) {
-	var retErr error
-
-	defer func() {
-		if retErr != nil {
-			innerErr := tx.stream.CloseSend()
-			if innerErr != nil {
-				logger.GetInstance().Error(errors.New(innerErr.Error()))
-				return
-			}
-		}
-	}()
-
-	executeParamsJsonBytes, err := json.Marshal(executeParams)
-	if err != nil {
-		retErr = errors.New(err.Error())
-		return nil, retErr
-	}
-
-	err = tx.stream.Send(&request.TransactionOperation{
-		Request: &request.TransactionOperation_ExecuteSqlRequest{
-			ExecuteSqlRequest: &request.ExecuteSqlRequest{
-				Name:          name,
-				ExecuteParams: string(executeParamsJsonBytes),
-			},
-		},
-	})
-	if err != nil {
-		retErr = errors.New(err.Error())
-		return nil, retErr
-	}
-
-	resp, err := tx.stream.Recv()
-	if err != nil {
-		retErr = errors.New(err.Error())
-		return nil, retErr
-	}
-
-	if !resp.Success {
-		retErr = errors.New(resp.Msg)
-		return nil, retErr
-	}
-
-	tableRows := make([]map[string]any, 0)
-	err = json.Unmarshal([]byte(resp.Results), &tableRows)
-	if err != nil {
-		retErr = errors.New(err.Error())
-		return nil, retErr
-	}
-
-	results := make([]sql.Result, len(tableRows))
-	for i, row := range tableRows {
-		results[i] = row
-	}
-
-	return results, nil
-}

+ 58 - 35
framework/core/infrastructure/database/database.go

@@ -1,7 +1,6 @@
 package database
 
 import (
-	"git.sxidc.com/go-framework/baize/framework/core/infrastructure/database/data_service"
 	"git.sxidc.com/go-framework/baize/framework/core/infrastructure/database/operations"
 	"git.sxidc.com/go-framework/baize/framework/core/infrastructure/database/sql"
 	"git.sxidc.com/go-framework/baize/framework/core/tag/sql/sql_mapping"
@@ -14,8 +13,8 @@ import (
 )
 
 type Executor interface {
-	ExecuteRawSql(sql string, executeParams map[string]any) ([]sql.Result, error)
-	ExecuteSql(name string, executeParams map[string]any) ([]sql.Result, error)
+	ExecuteRawSql(sql string, executeParams map[string]any, values ...any) ([]sql.Result, error)
+	ExecuteSql(name string, executeParams map[string]any, values ...any) ([]sql.Result, error)
 }
 
 const (
@@ -41,10 +40,6 @@ func Transaction(executor Executor, txFunc func(tx Executor) error) error {
 			return err
 		}
 		tx.CommitTransaction()
-	case *data_service.DataService:
-		return e.Transaction(func(tx *data_service.Transaction) error {
-			return txFunc(tx)
-		})
 	default:
 		return nil
 	}
@@ -83,15 +78,17 @@ func insertEntitySingle(executor Executor, tableName string, e any) error {
 		return err
 	}
 
-	executeParamsMap, err := sql.InsertExecuteParams{
+	executeParams := sql.InsertExecuteParams{
 		TableName: tableName,
 		TableRow:  formInsertTableRow(fields, time.Now().Local()),
-	}.Map()
+	}
+
+	executeParamsMap, err := executeParams.Map()
 	if err != nil {
 		return err
 	}
 
-	_, err = executor.ExecuteRawSql(sql.InsertTpl, executeParamsMap)
+	_, err = executor.ExecuteRawSql(sql.InsertTpl, executeParamsMap, executeParams.TableRow.Values()...)
 	if err != nil {
 		if strings.Contains(err.Error(), "SQLSTATE 23505") {
 			return ErrDBRecordHasExist
@@ -129,15 +126,22 @@ func insertEntityBatch(executor Executor, tableName string, es any) error {
 		tableRowBatch = append(tableRowBatch, *formInsertTableRow(fields, now))
 	}
 
-	executeParamsMap, err := sql.InsertBatchExecuteParams{
+	executeParams := sql.InsertBatchExecuteParams{
 		TableName:     tableName,
 		TableRowBatch: tableRowBatch,
-	}.Map()
+	}
+
+	executeParamsMap, err := executeParams.Map()
 	if err != nil {
 		return err
 	}
 
-	_, err = executor.ExecuteRawSql(sql.InsertTpl, executeParamsMap)
+	values := make([]any, 0)
+	for _, tableRow := range executeParams.TableRowBatch {
+		values = append(values, tableRow.Values()...)
+	}
+
+	_, err = executor.ExecuteRawSql(sql.InsertTpl, executeParamsMap, values...)
 	if err != nil {
 		if strings.Contains(err.Error(), "SQLSTATE 23505") {
 			return ErrDBRecordHasExist
@@ -198,15 +202,17 @@ func DeleteEntity(executor Executor, tableName string, e any) error {
 		conditions.Equal(field.ColumnName, field.Value)
 	}
 
-	executeParamsMap, err := sql.DeleteExecuteParams{
+	executeParams := sql.DeleteExecuteParams{
 		TableName:  tableName,
 		Conditions: conditions,
-	}.Map()
+	}
+
+	executeParamsMap, err := executeParams.Map()
 	if err != nil {
 		return err
 	}
 
-	_, err = executor.ExecuteRawSql(sql.DeleteTpl, executeParamsMap)
+	_, err = executor.ExecuteRawSql(sql.DeleteTpl, executeParamsMap, executeParams.Conditions.Args()...)
 	if err != nil {
 		return err
 	}
@@ -267,16 +273,22 @@ func UpdateEntity(executor Executor, tableName string, e any) error {
 		}
 	}
 
-	executeParamsMap, err := sql.UpdateExecuteParams{
+	executeParams := sql.UpdateExecuteParams{
 		TableName:  tableName,
 		TableRow:   tableRow,
 		Conditions: conditions,
-	}.Map()
+	}
+
+	executeParamsMap, err := executeParams.Map()
 	if err != nil {
 		return err
 	}
 
-	_, err = executor.ExecuteRawSql(sql.UpdateTpl, executeParamsMap)
+	args := make([]any, 0)
+	args = append(args, executeParams.TableRow.Values()...)
+	args = append(args, executeParams.Conditions.Args()...)
+
+	_, err = executor.ExecuteRawSql(sql.UpdateTpl, executeParamsMap, args...)
 	if err != nil {
 		return err
 	}
@@ -298,7 +310,7 @@ func Insert(executor Executor, executeParams *sql.InsertExecuteParams) error {
 		return err
 	}
 
-	_, err = executor.ExecuteRawSql(sql.InsertTpl, executeParamsMap)
+	_, err = executor.ExecuteRawSql(sql.InsertTpl, executeParamsMap, executeParams.TableRow.Values()...)
 	if err != nil {
 		return err
 	}
@@ -320,7 +332,12 @@ func InsertBatch(executor Executor, executeParams *sql.InsertBatchExecuteParams)
 		return err
 	}
 
-	_, err = executor.ExecuteRawSql(sql.InsertTpl, executeParamsMap)
+	values := make([][]any, 0)
+	for _, tableRow := range executeParams.TableRowBatch {
+		values = append(values, tableRow.Values())
+	}
+
+	_, err = executor.ExecuteRawSql(sql.InsertTpl, executeParamsMap, values)
 	if err != nil {
 		return err
 	}
@@ -342,7 +359,7 @@ func Delete(executor Executor, executeParams *sql.DeleteExecuteParams) error {
 		return err
 	}
 
-	_, err = executor.ExecuteRawSql(sql.DeleteTpl, executeParamsMap)
+	_, err = executor.ExecuteRawSql(sql.DeleteTpl, executeParamsMap, executeParams.Conditions.Args()...)
 	if err != nil {
 		return err
 	}
@@ -364,7 +381,11 @@ func Update(executor Executor, executeParams *sql.UpdateExecuteParams) error {
 		return err
 	}
 
-	_, err = executor.ExecuteRawSql(sql.UpdateTpl, executeParamsMap)
+	args := make([]any, 0)
+	args = append(args, executeParams.TableRow.Values()...)
+	args = append(args, executeParams.Conditions.Args()...)
+
+	_, err = executor.ExecuteRawSql(sql.UpdateTpl, executeParamsMap, args...)
 	if err != nil {
 		return err
 	}
@@ -386,20 +407,22 @@ func Query(executor Executor, executeParams *sql.QueryExecuteParams) ([]sql.Resu
 		return nil, 0, err
 	}
 
-	countExecuteParamsMap, err := sql.CountExecuteParams{
+	countExecuteParams := sql.CountExecuteParams{
 		TableName:  executeParams.TableName,
 		Conditions: executeParams.Conditions,
-	}.Map()
+	}
+
+	countExecuteParamsMap, err := countExecuteParams.Map()
 	if err != nil {
 		return nil, 0, err
 	}
 
-	tableRows, err := executor.ExecuteRawSql(sql.QueryTpl, queryExecuteParamsMap)
+	tableRows, err := executor.ExecuteRawSql(sql.QueryTpl, queryExecuteParamsMap, executeParams.Conditions.Args()...)
 	if err != nil {
 		return nil, 0, err
 	}
 
-	countTableRow, err := executor.ExecuteRawSql(sql.CountTpl, countExecuteParamsMap)
+	countTableRow, err := executor.ExecuteRawSql(sql.CountTpl, countExecuteParamsMap, countExecuteParams.Conditions.Args()...)
 	if err != nil {
 		return nil, 0, err
 	}
@@ -426,7 +449,7 @@ func QueryOne(executor Executor, executeParams *sql.QueryOneExecuteParams) (sql.
 		return nil, err
 	}
 
-	tableRows, err := executor.ExecuteRawSql(sql.QueryTpl, executeParamsMap)
+	tableRows, err := executor.ExecuteRawSql(sql.QueryTpl, executeParamsMap, executeParams.Conditions.Args()...)
 	if err != nil {
 		return nil, err
 	}
@@ -452,7 +475,7 @@ func Count(executor Executor, executeParams *sql.CountExecuteParams) (int64, err
 		return 0, err
 	}
 
-	tableRows, err := executor.ExecuteRawSql(sql.CountTpl, executeParamsMap)
+	tableRows, err := executor.ExecuteRawSql(sql.CountTpl, executeParamsMap, executeParams.Conditions.Args()...)
 	if err != nil {
 		return 0, err
 	}
@@ -474,7 +497,7 @@ func CheckExist(executor Executor, executeParams *sql.CheckExistExecuteParams) (
 		return false, err
 	}
 
-	tableRows, err := executor.ExecuteRawSql(sql.CountTpl, executeParamsMap)
+	tableRows, err := executor.ExecuteRawSql(sql.CountTpl, executeParamsMap, executeParams.Conditions.Args()...)
 	if err != nil {
 		return false, err
 	}
@@ -496,7 +519,7 @@ func CheckHasOnlyOne(executor Executor, executeParams *sql.CheckHasOnlyOneExecut
 		return false, err
 	}
 
-	tableRows, err := executor.ExecuteRawSql(sql.CountTpl, executeParamsMap)
+	tableRows, err := executor.ExecuteRawSql(sql.CountTpl, executeParamsMap, executeParams.Conditions.Args()...)
 	if err != nil {
 		return false, err
 	}
@@ -504,7 +527,7 @@ func CheckHasOnlyOne(executor Executor, executeParams *sql.CheckHasOnlyOneExecut
 	return int64(tableRows[0]["count"].(float64)) == 1, nil
 }
 
-func ExecuteRawSql(executor Executor, sql string, executeParams map[string]any) ([]sql.Result, error) {
+func ExecuteRawSql(executor Executor, sql string, executeParams map[string]any, args ...any) ([]sql.Result, error) {
 	if executor == nil {
 		return nil, errors.New("没有传递执行器")
 	}
@@ -513,7 +536,7 @@ func ExecuteRawSql(executor Executor, sql string, executeParams map[string]any)
 		return nil, errors.New("没有sql")
 	}
 
-	tableRows, err := executor.ExecuteRawSql(sql, executeParams)
+	tableRows, err := executor.ExecuteRawSql(sql, executeParams, args...)
 	if err != nil {
 		return nil, err
 	}
@@ -521,7 +544,7 @@ func ExecuteRawSql(executor Executor, sql string, executeParams map[string]any)
 	return tableRows, nil
 }
 
-func ExecuteSql(executor Executor, name string, executeParams map[string]any) ([]sql.Result, error) {
+func ExecuteSql(executor Executor, name string, executeParams map[string]any, args ...any) ([]sql.Result, error) {
 	if executor == nil {
 		return nil, errors.New("没有传递执行器")
 	}
@@ -530,7 +553,7 @@ func ExecuteSql(executor Executor, name string, executeParams map[string]any) ([
 		return nil, errors.New("没有sql资源名称")
 	}
 
-	tableRows, err := executor.ExecuteSql(name, executeParams)
+	tableRows, err := executor.ExecuteSql(name, executeParams, args...)
 	if err != nil {
 		return nil, err
 	}

+ 3 - 3
framework/core/infrastructure/database/operations/operations.go

@@ -144,14 +144,14 @@ func (op *Operations) AutoMigrate(tables ...Table) error {
 	return nil
 }
 
-func (op *Operations) ExecuteRawSql(sqlStr string, executeParams map[string]any) ([]sql.Result, error) {
+func (op *Operations) ExecuteRawSql(sqlStr string, executeParams map[string]any, values ...any) ([]sql.Result, error) {
 	parsedSql, err := template.ParseTemplateStringToString(sqlStr, executeParams)
 	if err != nil {
 		return nil, errors.New(err.Error())
 	}
 
 	tableRows := make([]map[string]any, 0)
-	err = op.db.Raw(parsedSql).Scan(&tableRows).Error
+	err = op.db.Raw(parsedSql, values...).Scan(&tableRows).Error
 	if err != nil {
 		return nil, errors.New(err.Error())
 	}
@@ -175,6 +175,6 @@ func (op *Operations) ExecuteRawSql(sqlStr string, executeParams map[string]any)
 	return results, nil
 }
 
-func (op *Operations) ExecuteSql(_ string, _ map[string]any) ([]sql.Result, error) {
+func (op *Operations) ExecuteSql(_ string, _ map[string]any, _ ...any) ([]sql.Result, error) {
 	return make([]sql.Result, 0), nil
 }

+ 38 - 76
framework/core/infrastructure/database/sql/condition.go

@@ -1,18 +1,21 @@
 package sql
 
 type Conditions struct {
-	Conditions []string
-	err        error
+	queries []string
+	args    [][]any
+	err     error
 }
 
 func NewConditions() *Conditions {
 	return &Conditions{
-		Conditions: make([]string, 0),
+		queries: make([]string, 0),
+		args:    make([][]any, 0),
 	}
 }
 
-func (conditions *Conditions) AddCondition(condition string) *Conditions {
-	conditions.Conditions = append(conditions.Conditions, condition)
+func (conditions *Conditions) AddCondition(query string, values ...any) *Conditions {
+	conditions.queries = append(conditions.queries, query)
+	conditions.args = append(conditions.args, values)
 	return conditions
 }
 
@@ -21,14 +24,8 @@ func (conditions *Conditions) Equal(columnName string, value any) *Conditions {
 		return conditions
 	}
 
-	parsedValue, err := toSqlValue(value)
-	if err != nil {
-		conditions.err = err
-		return conditions
-	}
-
-	conditions.Conditions = append(conditions.Conditions, "\""+columnName+"\" = "+parsedValue)
-
+	conditions.queries = append(conditions.queries, "\""+columnName+"\" = ?")
+	conditions.args = append(conditions.args, []any{value})
 	return conditions
 }
 
@@ -37,14 +34,8 @@ func (conditions *Conditions) Like(columnName string, value string) *Conditions
 		return conditions
 	}
 
-	parsedValue, err := toSqlValue(value)
-	if err != nil {
-		conditions.err = err
-		return conditions
-	}
-
-	conditions.Conditions = append(conditions.Conditions, "\""+columnName+"\" LIKE "+parsedValue)
-
+	conditions.queries = append(conditions.queries, "\""+columnName+"\" LIKE ?")
+	conditions.args = append(conditions.args, []any{value})
 	return conditions
 }
 
@@ -53,14 +44,8 @@ func (conditions *Conditions) In(columnName string, value any) *Conditions {
 		return conditions
 	}
 
-	parsedValue, err := toSqlValues(value)
-	if err != nil {
-		conditions.err = err
-		return conditions
-	}
-
-	conditions.Conditions = append(conditions.Conditions, "\""+columnName+"\" IN "+parsedValue)
-
+	conditions.queries = append(conditions.queries, "\""+columnName+"\" IN ?")
+	conditions.args = append(conditions.args, []any{value})
 	return conditions
 }
 
@@ -69,14 +54,8 @@ func (conditions *Conditions) NotIn(columnName string, value any) *Conditions {
 		return conditions
 	}
 
-	parsedValue, err := toSqlValues(value)
-	if err != nil {
-		conditions.err = err
-		return conditions
-	}
-
-	conditions.Conditions = append(conditions.Conditions, "\""+columnName+"\" NOT IN "+parsedValue)
-
+	conditions.queries = append(conditions.queries, "\""+columnName+"\" NOT IN ?")
+	conditions.args = append(conditions.args, []any{value})
 	return conditions
 }
 
@@ -85,14 +64,8 @@ func (conditions *Conditions) Not(columnName string, value any) *Conditions {
 		return conditions
 	}
 
-	parsedValue, err := toSqlValue(value)
-	if err != nil {
-		conditions.err = err
-		return conditions
-	}
-
-	conditions.Conditions = append(conditions.Conditions, "\""+columnName+"\" != "+parsedValue)
-
+	conditions.queries = append(conditions.queries, "\""+columnName+"\" != ?")
+	conditions.args = append(conditions.args, []any{value})
 	return conditions
 }
 
@@ -101,14 +74,8 @@ func (conditions *Conditions) LessThan(columnName string, value any) *Conditions
 		return conditions
 	}
 
-	parsedValue, err := toSqlValue(value)
-	if err != nil {
-		conditions.err = err
-		return conditions
-	}
-
-	conditions.Conditions = append(conditions.Conditions, "\""+columnName+"\" < "+parsedValue)
-
+	conditions.queries = append(conditions.queries, "\""+columnName+"\" < ?")
+	conditions.args = append(conditions.args, []any{value})
 	return conditions
 }
 
@@ -117,14 +84,8 @@ func (conditions *Conditions) LessThanAndEqual(columnName string, value any) *Co
 		return conditions
 	}
 
-	parsedValue, err := toSqlValue(value)
-	if err != nil {
-		conditions.err = err
-		return conditions
-	}
-
-	conditions.Conditions = append(conditions.Conditions, "\""+columnName+"\" <= "+parsedValue)
-
+	conditions.queries = append(conditions.queries, "\""+columnName+"\" <= ?")
+	conditions.args = append(conditions.args, []any{value})
 	return conditions
 }
 
@@ -133,14 +94,8 @@ func (conditions *Conditions) GreaterThan(columnName string, value any) *Conditi
 		return conditions
 	}
 
-	parsedValue, err := toSqlValue(value)
-	if err != nil {
-		conditions.err = err
-		return conditions
-	}
-
-	conditions.Conditions = append(conditions.Conditions, "\""+columnName+"\" > "+parsedValue)
-
+	conditions.queries = append(conditions.queries, "\""+columnName+"\" > ?")
+	conditions.args = append(conditions.args, []any{value})
 	return conditions
 }
 
@@ -149,13 +104,20 @@ func (conditions *Conditions) GreaterThanAndEqual(columnName string, value any)
 		return conditions
 	}
 
-	parsedValue, err := toSqlValue(value)
-	if err != nil {
-		conditions.err = err
-		return conditions
-	}
+	conditions.queries = append(conditions.queries, "\""+columnName+"\" >= ?")
+	conditions.args = append(conditions.args, []any{value})
+	return conditions
+}
 
-	conditions.Conditions = append(conditions.Conditions, "\""+columnName+"\" >= "+parsedValue)
+func (conditions *Conditions) Queries() []string {
+	return conditions.queries
+}
 
-	return conditions
+func (conditions *Conditions) Args() []any {
+	args := make([]any, 0)
+	for _, conditionArgs := range conditions.args {
+		args = append(args, conditionArgs...)
+	}
+
+	return args
 }

+ 30 - 93
framework/core/infrastructure/database/sql/sql_template.go

@@ -10,7 +10,7 @@ INSERT INTO
 VALUES
 {{- $valuesClauses := list }}
 {{- range .values_list }}
-{{- $valuesClause := printf "(%s)" ( . | join "," ) }}
+{{- $valuesClause := printf "(%s)" ( . | join ", " ) }}
 {{- $valuesClauses = append $valuesClauses $valuesClause }}
 {{- end }}
     {{ $valuesClauses | join "," }}
@@ -30,17 +30,19 @@ func (params InsertExecuteParams) Map() (map[string]any, error) {
 		return nil, params.TableRow.err
 	}
 
-	columns := make([]string, 0)
-	values := make([]any, 0)
+	if (params.TableRow.columns == nil || len(params.TableRow.columns) == 0) ||
+		(params.TableRow.values == nil || len(params.TableRow.values) == 0) {
+		return nil, errors.New("没有传递列和值")
+	}
 
-	for _, cv := range params.TableRow.columnValues {
-		columns = append(columns, cv.column)
-		values = append(values, cv.value)
+	values := make([]any, 0)
+	for i := 0; i < len(params.TableRow.values); i++ {
+		values = append(values, "?")
 	}
 
 	return map[string]any{
 		"table_name":  params.TableName,
-		"columns":     columns,
+		"columns":     params.TableRow.columns,
 		"values_list": []any{values},
 	}, nil
 }
@@ -55,39 +57,27 @@ func (params InsertBatchExecuteParams) Map() (map[string]any, error) {
 		return nil, nil
 	}
 
-	columns := make([]string, 0)
-	for _, cv := range params.TableRowBatch[0].columnValues {
-		columns = append(columns, cv.column)
+	values := make([]any, 0)
+	for i := 0; i < len(params.TableRowBatch[0].values); i++ {
+		values = append(values, "?")
 	}
 
 	valuesList := make([]any, 0)
-
 	for _, tableRow := range params.TableRowBatch {
 		if tableRow.err != nil {
 			return nil, tableRow.err
 		}
 
-		if len(columns) != len(tableRow.columnValues) {
+		if len(values) != len(tableRow.values) {
 			return nil, errors.New("列数不匹配,保证每个TableRow的Add数量一致")
 		}
 
-		columnAndValueMap := make(map[string]any)
-
-		for _, cv := range tableRow.columnValues {
-			columnAndValueMap[cv.column] = cv.value
-		}
-
-		values := make([]any, len(columnAndValueMap))
-		for i, column := range columns {
-			values[i] = columnAndValueMap[column]
-		}
-
 		valuesList = append(valuesList, values)
 	}
 
 	return map[string]any{
 		"table_name":  params.TableName,
-		"columns":     columns,
+		"columns":     params.TableRowBatch[0].columns,
 		"values_list": valuesList,
 	}, nil
 }
@@ -96,7 +86,7 @@ const DeleteTpl = `
 DELETE FROM
     {{ .table_name }}
 WHERE
-    {{ range .conditions }} {{ . }} AND {{ end }} 1 = 1
+    {{ range .queries }} {{ . }} AND {{ end }} 1 = 1
 `
 
 type DeleteExecuteParams struct {
@@ -115,7 +105,7 @@ func (params DeleteExecuteParams) Map() (map[string]any, error) {
 
 	return map[string]any{
 		"table_name": params.TableName,
-		"conditions": params.Conditions.Conditions,
+		"queries":    params.queries,
 	}, nil
 }
 
@@ -123,9 +113,9 @@ const UpdateTpl = `
 UPDATE
     {{ .table_name }}
 SET
-    {{ .set_list | join "," }}
+    {{ .set_list | join ", " }}
 WHERE
-    {{ range .conditions }} {{ . }} AND {{ end }} 1 = 1
+    {{ range .queries }} {{ . }} AND {{ end }} 1 = 1
 `
 
 type UpdateExecuteParams struct {
@@ -144,33 +134,24 @@ func (params UpdateExecuteParams) Map() (map[string]any, error) {
 	}
 
 	setList := make([]string, 0)
-	for _, cv := range params.TableRow.columnValues {
-		setList = append(setList, cv.column+" = "+cv.value)
-	}
-
-	conditions := make([]string, 0)
-	if params.Conditions != nil {
-		if params.Conditions.err != nil {
-			return nil, params.Conditions.err
-		}
-
-		conditions = params.Conditions.Conditions
+	for _, column := range params.TableRow.columns {
+		setList = append(setList, column+" = ?")
 	}
 
 	return map[string]any{
 		"table_name": params.TableName,
 		"set_list":   setList,
-		"conditions": conditions,
+		"queries":    params.Conditions.queries,
 	}, nil
 }
 
 const QueryTpl = `
 SELECT
-    {{ if .select_columns }}{{ .select_columns | join "," }}{{ else }}*{{ end }} 
+    {{ if .select_columns }}{{ .select_columns | join ", " }}{{ else }}*{{ end }} 
 FROM
     {{ .table_name }}
 WHERE
-    {{ range .conditions }} {{ . }} AND {{ end }} 1 = 1
+    {{ range .queries }} {{ . }} AND {{ end }} 1 = 1
 {{ if .order_by }}ORDER BY {{ .order_by }}{{ end }}
 {{ if .limit }}LIMIT {{ .limit }}{{ end }}
 {{ if .offset }}OFFSET {{ .offset }}{{ end }}
@@ -194,19 +175,10 @@ func (params QueryExecuteParams) Map() (map[string]any, error) {
 		offset = (params.PageNo - 1) * params.PageSize
 	}
 
-	conditions := make([]string, 0)
-	if params.Conditions != nil {
-		if params.Conditions.err != nil {
-			return nil, params.Conditions.err
-		}
-
-		conditions = params.Conditions.Conditions
-	}
-
 	return map[string]any{
 		"table_name":     params.TableName,
 		"select_columns": params.SelectClauses,
-		"conditions":     conditions,
+		"queries":        params.Conditions.queries,
 		"limit":          limit,
 		"offset":         offset,
 		"order_by":       params.OrderBy,
@@ -220,19 +192,10 @@ type QueryOneExecuteParams struct {
 }
 
 func (params QueryOneExecuteParams) Map() (map[string]any, error) {
-	conditions := make([]string, 0)
-	if params.Conditions != nil {
-		if params.Conditions.err != nil {
-			return nil, params.Conditions.err
-		}
-
-		conditions = params.Conditions.Conditions
-	}
-
 	return map[string]any{
 		"table_name":     params.TableName,
 		"select_columns": params.SelectClauses,
-		"conditions":     conditions,
+		"queries":        params.Conditions.queries,
 	}, nil
 }
 
@@ -242,7 +205,7 @@ SELECT
 FROM
     {{ .table_name }}
 WHERE
-    {{ range .conditions }} {{ . }} AND {{ end }} 1 = 1
+    {{ range .queries }} {{ . }} AND {{ end }} 1 = 1
 `
 
 type CountExecuteParams struct {
@@ -251,39 +214,22 @@ type CountExecuteParams struct {
 }
 
 func (params CountExecuteParams) Map() (map[string]any, error) {
-	conditions := make([]string, 0)
-	if params.Conditions != nil {
-		if params.Conditions.err != nil {
-			return nil, params.Conditions.err
-		}
-
-		conditions = params.Conditions.Conditions
-	}
-
 	return map[string]any{
 		"table_name": params.TableName,
-		"conditions": conditions,
+		"queries":    params.Conditions.queries,
 	}, nil
 }
 
 type CheckExistExecuteParams struct {
 	TableName string
 	*Conditions
+	Values []any
 }
 
 func (params CheckExistExecuteParams) Map() (map[string]any, error) {
-	conditions := make([]string, 0)
-	if params.Conditions != nil {
-		if params.Conditions.err != nil {
-			return nil, params.Conditions.err
-		}
-
-		conditions = params.Conditions.Conditions
-	}
-
 	return map[string]any{
 		"table_name": params.TableName,
-		"conditions": conditions,
+		"queries":    params.Conditions.queries,
 	}, nil
 }
 
@@ -293,17 +239,8 @@ type CheckHasOnlyOneExecuteParams struct {
 }
 
 func (params CheckHasOnlyOneExecuteParams) Map() (map[string]any, error) {
-	conditions := make([]string, 0)
-	if params.Conditions != nil {
-		if params.Conditions.err != nil {
-			return nil, params.Conditions.err
-		}
-
-		conditions = params.Conditions.Conditions
-	}
-
 	return map[string]any{
 		"table_name": params.TableName,
-		"conditions": conditions,
+		"queries":    params.Conditions.queries,
 	}, nil
 }

+ 15 - 18
framework/core/infrastructure/database/sql/table_row.go

@@ -1,18 +1,15 @@
 package sql
 
 type TableRow struct {
-	columnValues []columnValue
-	err          error
-}
-
-type columnValue struct {
-	column string
-	value  string
+	columns []string
+	values  []any
+	err     error
 }
 
 func NewTableRow() *TableRow {
 	return &TableRow{
-		columnValues: make([]columnValue, 0),
+		columns: make([]string, 0),
+		values:  make([]any, 0),
 	}
 }
 
@@ -21,16 +18,16 @@ func (tableRow *TableRow) Add(column string, value any) *TableRow {
 		return tableRow
 	}
 
-	parsedValue, err := toSqlValue(value)
-	if err != nil {
-		tableRow.err = err
-		return tableRow
-	}
-
-	tableRow.columnValues = append(tableRow.columnValues, columnValue{
-		column: "\"" + column + "\"",
-		value:  parsedValue,
-	})
+	tableRow.columns = append(tableRow.columns, "\""+column+"\"")
+	tableRow.values = append(tableRow.values, value)
 
 	return tableRow
 }
+
+func (tableRow *TableRow) Columns() []string {
+	return tableRow.columns
+}
+
+func (tableRow *TableRow) Values() []any {
+	return tableRow.values
+}

+ 0 - 73
framework/core/infrastructure/database/sql/value.go

@@ -1,73 +0,0 @@
-package sql
-
-import (
-	"git.sxidc.com/go-tools/utils/reflectutils"
-	"github.com/pkg/errors"
-	"reflect"
-	"strings"
-	"time"
-)
-
-const (
-	timeWriteFormat = time.DateTime + ".000000+08"
-)
-
-func toSqlValue(value any) (string, error) {
-	if value == nil {
-		return "", nil
-	}
-
-	valueValue := reflect.ValueOf(value)
-
-	if valueValue.Kind() == reflect.Slice {
-		return "", errors.New("请使用toSqlValues处理slice类型")
-	}
-
-	switch v := reflectutils.PointerValueElem(valueValue).Interface().(type) {
-	case string:
-		return "'" + v + "'", nil
-	case time.Time:
-		return "'" + v.Format(timeWriteFormat) + "'", nil
-	default:
-		retStr := new(string)
-		err := reflectutils.AssignStringValue(v, reflect.ValueOf(retStr).Elem())
-		if err != nil {
-			return "", errors.New(err.Error())
-		}
-
-		return *retStr, nil
-	}
-}
-
-func toSqlValues(values any) (string, error) {
-	if values == nil {
-		return "()", nil
-	}
-
-	sliceValue := reflect.ValueOf(values)
-
-	if sliceValue.IsZero() {
-		return "()", nil
-	}
-
-	if sliceValue.Kind() != reflect.Slice {
-		return "", errors.New("传递的不是slice")
-	}
-
-	parsedValues := make([]string, 0)
-	for i := 0; i < sliceValue.Len(); i++ {
-		value := sliceValue.Index(i).Interface()
-		parsedValue, err := toSqlValue(value)
-		if err != nil {
-			return "", err
-		}
-
-		parsedValues = append(parsedValues, parsedValue)
-	}
-
-	if len(parsedValues) == 0 {
-		return "()", nil
-	}
-
-	return "(" + strings.Join(parsedValues, ",") + ")", nil
-}

+ 1 - 15
framework/core/infrastructure/infrastructure.go

@@ -5,7 +5,6 @@ import (
 	"git.sxidc.com/go-framework/baize/framework/core/infrastructure/cache/local"
 	"git.sxidc.com/go-framework/baize/framework/core/infrastructure/cache/redis"
 	"git.sxidc.com/go-framework/baize/framework/core/infrastructure/database"
-	"git.sxidc.com/go-framework/baize/framework/core/infrastructure/database/data_service"
 	"git.sxidc.com/go-framework/baize/framework/core/infrastructure/database/operations"
 	"git.sxidc.com/go-tools/utils/strutils"
 )
@@ -16,8 +15,7 @@ type Config struct {
 }
 
 type DatabaseConfig struct {
-	Operations  *operations.Config   `json:"operations" yaml:"operations"`
-	DataService *data_service.Config `json:"data_service" yaml:"data_service"`
+	Operations *operations.Config `json:"operations" yaml:"operations"`
 }
 
 type CacheConfig struct {
@@ -47,13 +45,6 @@ func NewInfrastructure(config Config) *Infrastructure {
 		}
 
 		i.dbExecutor = op
-	} else if config.DatabaseConfig.DataService != nil {
-		dataService, err := data_service.NewDataService(config.DatabaseConfig.DataService)
-		if err != nil {
-			panic("创建数据服务失败: " + err.Error())
-		}
-
-		i.dbExecutor = dataService
 	}
 
 	// 初始化缓存
@@ -100,11 +91,6 @@ func DestroyInfrastructure(i *Infrastructure) {
 			if err != nil {
 				panic("销毁数据库操作失败: " + err.Error())
 			}
-		case *data_service.DataService:
-			err := data_service.DestroyDataService(dbExecutor)
-			if err != nil {
-				panic("销毁数据服务失败: " + err.Error())
-			}
 		default:
 			panic("不支持的数据库执行器类型")
 		}