networkStruct

package
v1.5.15 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 6, 2025 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ContentType

type ContentType int8
const (
	Query    ContentType = 1
	BodyJson ContentType = 2
	BodyForm ContentType = 3
	BodyXML  ContentType = 4
	XWWWForm ContentType = 5
)

func (ContentType) GetContentTypeStr

func (contentType ContentType) GetContentTypeStr() string

type Method

type Method int8
const (
	Get     Method = 1
	Post    Method = 2
	Put     Method = 3
	Delete  Method = 4
	Options Method = 5
)

func (Method) String

func (p Method) String() string

type MyRequestParams

type MyRequestParams struct {
	Method      Method // 请求方法
	URL         string // 请求地址
	ContentType ContentType
	Headers     map[string]string      // 请求头参数
	Params      map[string]interface{} // 请求参数
	ResStruct   interface{}            // 要被解析成的结构体
}

MyRequestParams 自己定义的请求体 method networkStruct.Method, contentType networkStruct.ContentType, targetURL string, params map[string]interface{}, headers map[string]string, iStruct interface{}

type MyRequestResp

type MyRequestResp struct {
	StatusCode      int
	Headers         http.Header // 返回的请求头
	ResStruct       interface{} // 解析后的结构体
	IsParsedSuccess bool        // 是否解析成功
	ResStr          string      // 返回数据字符串化
}

MyRequestResp 自己定义的请求返回 interface{}, *http.Header, int, error

type Params

type Params struct {

	// 前端参数
	PageNow  int    `json:"page_now" belong:"etc" default:"1"`    // [read]
	PageSize int    `json:"page_size" belong:"etc" default:"10"`  // [read]
	Order    string `json:"order" belong:"etc" default:"ids asc"` // [read]

	// 根据前端参数处理后的数据
	Condition map[string]interface{} // [read、update、delete] 条件
	Value     map[string]interface{} // [update、insert] - 数据
	Etc       map[string]interface{} // 其他
	RawMap    map[string]interface{}

	// 内部补充参数
	Single    bool     // [read] - 附加条件
	Preloads  []string // [read] - 附加
	TableName string   // [update、delete] - 指定表名

	// 操作结果
	NewID        uint64      // [insert] - 新主键
	Rows         interface{} // [read] - 结构切片
	Row          interface{} // [read、update、delete、insert] - 结构
	Count        int64       // [read] - 统计行数
	RowsAffected int64       // [update、delete] - 影响行数
	Error        error       // 错误
}

Params 参数结构体

func (*Params) GetCondition

func (params *Params) GetCondition() map[string]interface{}

GetCondition 条件

func (*Params) GetCount

func (params *Params) GetCount() int64

func (*Params) GetError

func (params *Params) GetError() error

Error 错误

func (*Params) GetEtc

func (params *Params) GetEtc() map[string]interface{}

Etc 其他

func (*Params) GetLimit

func (params *Params) GetLimit() int

func (*Params) GetNewID

func (params *Params) GetNewID() uint64

NewID 新主键

func (*Params) GetOffset

func (params *Params) GetOffset() int

func (*Params) GetOrder

func (params *Params) GetOrder() string

Order 顺序

func (*Params) GetPageNow

func (params *Params) GetPageNow() int

GetPageNow 页码

func (*Params) GetPageSize

func (params *Params) GetPageSize() int

func (*Params) GetPreloads

func (params *Params) GetPreloads() []string

Preloads 预加载

func (*Params) GetRawMap

func (params *Params) GetRawMap() map[string]interface{}

RawMap 原始数据

func (*Params) GetRow

func (params *Params) GetRow() interface{}

func (*Params) GetRows

func (params *Params) GetRows() interface{}

func (*Params) GetRowsAffected

func (params *Params) GetRowsAffected() int64

RowsAffected 影响行数

func (*Params) GetTableName

func (params *Params) GetTableName() string

GetTableName 表名

func (*Params) GetValue

func (params *Params) GetValue() map[string]interface{}

GetValue Value 操作值

func (*Params) SetCondition

func (params *Params) SetCondition(condition map[string]interface{})

func (*Params) SetCount

func (params *Params) SetCount(count int64)

Count 结果数目

func (*Params) SetError

func (params *Params) SetError(err error)

func (*Params) SetEtc

func (params *Params) SetEtc(data map[string]interface{})

func (*Params) SetNewID

func (params *Params) SetNewID(newID uint64)

func (*Params) SetOrder

func (params *Params) SetOrder(order string)

func (*Params) SetPageNow

func (params *Params) SetPageNow(pageNow int)

func (*Params) SetPageSize

func (params *Params) SetPageSize(pageSize int)

func (*Params) SetPreloads

func (params *Params) SetPreloads(preloads []string)

func (*Params) SetRawMap

func (params *Params) SetRawMap(RawMap map[string]interface{})

func (*Params) SetRow

func (params *Params) SetRow(rows interface{})

Row 查询结果

func (*Params) SetRows

func (params *Params) SetRows(rows interface{})

Rows 查询结果

func (*Params) SetRowsAffected

func (params *Params) SetRowsAffected(rowsAffected int64)

func (*Params) SetTableName

func (params *Params) SetTableName(tableName string)

func (*Params) SetValue

func (params *Params) SetValue(value map[string]interface{})

type ParamsInterface

type ParamsInterface interface {

	// order 顺序
	GetOrder() string
	SetOrder(string)

	// page 页码
	GetPageSize() int
	SetPageSize(int)
	GetPageNow() int
	SetPageNow(int)
	GetLimit() int
	GetOffset() int

	// [read] - prelaoad 附加
	GetPreloads() []string
	SetPreloads([]string)

	// [read、update、post、delete] - 原始数据
	GetRawMap() map[string]interface{}
	SetRawMap(map[string]interface{})

	// [read、update、delete] - condition 条件
	GetCondition() map[string]interface{}
	SetCondition(map[string]interface{})

	// [read] - rows 查询记录
	GetRows() interface{}
	SetRows(interface{})

	// [read、insert、update、delete] - row
	GetRow() interface{}
	SetRow(interface{})

	// [read] -  count 查询数目
	GetCount() int64
	SetCount(int64)

	// error 错误
	GetError() error
	SetError(error)

	// [update、delete] - rows affected 影响行数
	GetRowsAffected() int64
	SetRowsAffected(int64)

	// [update、insert] - value 数据
	GetValue() map[string]interface{}
	SetValue(map[string]interface{})

	// [update、delete] - 表名
	GetTableName() string
	SetTableName(string)

	// [insert] - 新的主键
	GetNewID() uint64
	SetNewID(newID uint64)

	// 其他
	GetEtc() map[string]interface{}
	SetEtc(data map[string]interface{})
}

ParamsInterface 参数接口

type ReadCommonStruct

type ReadCommonStruct struct {
	PageNow  int    `json:"page_now" belong:"etc" default:"1"`
	PageSize int    `json:"page_size" belong:"etc" default:"10"`
	Order    string `json:"order" belong:"etc" default:"id asc"`
}

ReadCommonStruct 读取列表公用的参数

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL