common

package
v0.0.0-...-2946602 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2022 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	JSON = "application/json"
	FORM = "application/x-www-form-urlencoded"
)

Variables

This section is empty.

Functions

func CreateOneMongoDBRecordTemplate

func CreateOneMongoDBRecordTemplate(ctx *gin.Context, op CreateMongoDBTemplateOptions)

CreateOneMongoDBRecordTemplate MongoDB 创建模板

此处的 data 需为指针,不然没法触发 mongo hook

func DeleteOneMongoDBRecordByIDTemplate

func DeleteOneMongoDBRecordByIDTemplate(ctx *gin.Context, op MongoDBTemplateOptions)

DeleteOneMongoDBRecordByIDTemplate MongoDB 按REC_ID更新模板

func GinPaginate

func GinPaginate(ctx *gin.Context, data []interface{})

GinPaginate 在service层面分页

func HarvestClientFromContext

func HarvestClientFromContext(ctx context.Context) (*client.BookName, string)

HarvestClientFromContext 从Context里读取账套信息

func HarvestClientFromGinContext

func HarvestClientFromGinContext(ctx *gin.Context) *client.BookName

HarvestClientFromGinContext 从请求体里读取账套信息

func HarvestEmailFromHeader

func HarvestEmailFromHeader(ctx *gin.Context) string

func InternalDataBaseErrorTemplate

func InternalDataBaseErrorTemplate(ctx *gin.Context, message PredefinedMessage, table _interface.ChineseTabler)

InternalDataBaseErrorTemplate 数据库异常

func RequestParamErrorTemplate

func RequestParamErrorTemplate(ctx *gin.Context, message PredefinedMessage)

RequestParamErrorTemplate 入参异常

func SelectESTableContentWithCountTemplate

func SelectESTableContentWithCountTemplate(ctx *gin.Context, op SelectESTemplateOptions)

func SelectMongoDBTableContentWithCountTemplate

func SelectMongoDBTableContentWithCountTemplate(ctx *gin.Context, op SelectMongoDBTemplateOptions, conditionList ...MongoCondition)

SelectMongoDBTableContentWithCountTemplate MongoDB 搜索模板

func SelectMysqlTableContentWithCountTemplate

func SelectMysqlTableContentWithCountTemplate(ctx *gin.Context, op SelectMysqlTemplateOptions, conditionList ...MysqlCondition) interface{}

SelectMysqlTableContentWithCountTemplate Mysql 搜索模板

func SelectSuccessTemplate

func SelectSuccessTemplate(ctx *gin.Context, count int64, dataList interface{})

SelectSuccessTemplate 普适的列表查询返回

func UpdateOneMongoDBRecordByIDTemplate

func UpdateOneMongoDBRecordByIDTemplate(ctx *gin.Context, op MongoDBTemplateOptions)

UpdateOneMongoDBRecordByIDTemplate MongoDB 通用更新

按REC_ID更新模板

Types

type Auto

type Auto struct {
	Auto bool `json:"auto" form:"auto"`
}

Auto 临时结构

是否自动创建/删除/更新应收?

func (Auto) WithContext

func (auto Auto) WithContext(ctx context.Context) context.Context

type CreateMongoDBTemplateOptions

type CreateMongoDBTemplateOptions struct {
	DB         *qmgo.Database
	Context    context.Context
	TableModel _interface.ChineseTabler
	PreFunc    func(_interface.ChineseTabler) _interface.ChineseTabler
	NotSyncES  bool
}

type CreateMysqlTemplateOptions

type CreateMysqlTemplateOptions struct {
	DB         *gorm.DB
	TableModel _interface.ChineseTabler
	PreFunc    func(_interface.ChineseTabler) _interface.ChineseTabler
}

CreateMysqlTemplateOptions MySQL 创建模板配置

type MongoCondition

type MongoCondition struct {
	Symbol      myMongo.OperatorSymbol
	ColumnName  string
	ColumnValue interface{}
}

MongoCondition MongoDB 搜索条件

type MongoDBTemplateOptions

type MongoDBTemplateOptions struct {
	DB         *qmgo.Database
	Context    context.Context
	TableModel _interface.ChineseTabler
	PreFunc    func(_interface.ChineseTabler) _interface.ChineseTabler
	RecID      int
	OmitList   []string
	NotSyncES  bool
}

MongoDBTemplateOptions MongoDB 更新/删除配置项

DB 			Mongo数据库连接
Context 	上下文传递参数或状态
TableModel	要操作的对象
PreFunc		操作前执行的函数
RecID		对象ID
OmitList	对象里忽略的字段

type MysqlCondition

type MysqlCondition struct {
	Symbol      mysql.OperatorSymbol // 操作符
	ColumnName  string               // 相关字段
	ColumnValue string               // 字段值
}

MysqlCondition MySQL 搜索条件

type PredefinedMessage

type PredefinedMessage string
const (
	REQUEST_PARM_ERROR    PredefinedMessage = "您的输入有误!"
	BOOK_NAME_LACK_ERROR  PredefinedMessage = "请先选择账套!"
	DATABASE_DELETE_ERROR PredefinedMessage = "删除%s失败!"
	DATABASE_UPDATE_ERROR PredefinedMessage = "更新%s失败!"
	DATABASE_INSERT_ERROR PredefinedMessage = "添加%s失败!"
	DATABASE_SELECT_ERROR PredefinedMessage = "查询%s内容失败!"
	DATABASE_COUNT_ERROR  PredefinedMessage = "查询%s总数失败!"
	OTHER_ERROR           PredefinedMessage = "其他问题导致操作%s失败"
)

type SelectESTemplateOptions

type SelectESTemplateOptions struct {
	TableModel  _interface.EsTabler
	Query       elastic.Query
	Scripts     string
	ResHookFunc func(data []interface{}) []interface{}
}

SelectESTemplateOptions ElasticSearch 搜索模板配置

type SelectMongoDBTemplateOptions

type SelectMongoDBTemplateOptions struct {
	DB            *qmgo.Database
	TableModel    _interface.ChineseTabler
	OrderByColumn string
	ResHookFunc   func(data []interface{}) []interface{}
}

SelectMongoDBTemplateOptions MongoDB 搜索模板配置

type SelectMysqlTemplateOptions

type SelectMysqlTemplateOptions struct {
	DB            *gorm.DB                               // db
	TableModel    _interface.ChineseTabler               // 表
	OrderByColumn string                                 // order by 字段
	ResHookFunc   func(data []interface{}) []interface{} // 返回前预处理函数
	NotReturn     bool                                   // 不自动返回
	NotPaginate   bool                                   // 不自动分页
}

SelectMysqlTemplateOptions MySQL 搜索模板配置

type UpdateMysqlTemplateOptions

type UpdateMysqlTemplateOptions struct {
	CreateMysqlTemplateOptions
	RecID      int
	OmitColumn []string
}

UpdateMysqlTemplateOptions Mysql 更新模板配置

Jump to

Keyboard shortcuts

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