libService

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2023 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

* @Descripttion: 字段默认值填充函数 * @version: * @Author: lfzxs@qq.com * @Date: 2023-11-15 14:01:17 * @LastEditors: lfzxs@qq.com * @LastEditTime: 2023-12-01 17:11:34

* @Descripttion: * @version: * @Author: lfzxs@qq.com * @Date: 2023-11-09 15:44:29 * @LastEditors: lfzxs@qq.com * @LastEditTime: 2023-12-01 17:11:45

* @Descripttion: * @version: * @Author: lfzxs@qq.com * @Date: 2023-11-09 15:44:29 * @LastEditors: lfzxs@qq.com * @LastEditTime: 2023-12-01 15:38:48

Index

Constants

This section is empty.

Variables

View Source
var ConditionStrToEnum map[string]Condition = map[string]Condition{
	"eq":         Condition_EQ,
	"ne":         Condition_NE,
	"gt":         Condition_GT,
	"ge":         Condition_GE,
	"lt":         Condition_LT,
	"le":         Condition_LE,
	"like":       Condition_LIKE,
	"like_left":  Condition_LIKE_LEFT,
	"like_right": Condition_LIKE_RIGHT,
	"in":         Condition_IN,
}
View Source
var FunMap = map[string]FildFillFunc{
	"uuid":        Uuid,
	"snowflakeId": SnowflakeId,
	"uid":         Uid,
}
View Source
var ServiceUtil = serviceUtil{DefPageSize: 20, DefCurrent: 0}

Functions

func SnowflakeId

func SnowflakeId() string

func Uid

func Uid() string

func Uuid

func Uuid() string

Types

type AddWrapper

type AddWrapper struct {
	DataWrapper
}

type BaseDao

type BaseDao[T any] struct {
	//表名
	Table string
}

func (*BaseDao[T]) Add

func (obj *BaseDao[T]) Add(ctx context.Context, object any) (err error)

func (*BaseDao[T]) Edit

func (obj *BaseDao[T]) Edit(ctx context.Context, condition any, object any) (err error)

func (*BaseDao[T]) List

func (obj *BaseDao[T]) List(ctx context.Context, pageQuery *PageInp) (res *PageModel, err error)

func (*BaseDao[T]) Search

func (obj *BaseDao[T]) Search(ctx context.Context, querObject any) (res *PageModel, err error)

type Condition

type Condition int
const (
	//等于
	Condition_EQ Condition = 0
	//不等于
	Condition_NE Condition = 1
	//大于
	Condition_GT Condition = 2
	//大于等于
	Condition_GE Condition = 3
	//小于
	Condition_LT Condition = 4
	//小于等于
	Condition_LE Condition = 5
	//like '%值%'
	Condition_LIKE Condition = 20
	//like '%值'
	Condition_LIKE_LEFT Condition = 21
	//like '值%'
	Condition_LIKE_RIGHT Condition = 22
	//in
	Condition_IN Condition = 30

	//分页页码字段名
	Page_Filed_PgNum_NAME = "PageNum"
	//分页每页条数字段名
	Page_Filed_SIZE_NAME = "PageSize"
)

条件枚举

type DataWrapper

type DataWrapper struct {
	Model map[string]interface{}
}

type EditWrapper

type EditWrapper struct {
	Model map[string]interface{}
	QueryWrapper
}

更新

type FildFillFunc

type FildFillFunc func() string

type IDao

type IDao interface {
	List(ctx context.Context, pageQuery *PageInp) (res *PageModel, err error)
	Search(ctx context.Context, querObject any) (res *PageModel, err error)
}

type OrderItem

type OrderItem struct {
	Column string
	Asc    bool
}

排序对象

type PageInp

type PageInp struct {
	PageQuery
	QueryWrapper
}

分页查询输入对象

type PageModel

type PageModel struct {
	// 当前页码
	Current int `json:"current" dc:"当前页码"`
	// 记录数
	Size int `json:"size" dc:"每页记录数"`
	// 总记录数
	Total int `json:"total" dc:"总记录数"`
	// 数据记录
	List interface{}
}

type PageQuery

type PageQuery struct {
	// 每页记录数
	Size uint32
	// 当前页码
	Current uint32
	// 排序
	Orders []*OrderItem
}

分页查询对象

type QueryItem

type QueryItem struct {
	//字段名
	Field string
	//条件
	Cond Condition
	//值
	Value interface{}
}

查询项

type QueryWrapper

type QueryWrapper struct {
	Quserys []*QueryItem
}

条件构造器

Jump to

Keyboard shortcuts

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