model

package
v0.0.0-...-0090c64 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (

	/**
	 * 数据库表主键名称(字符串形式)
	 */
	TableMajorKeyString = "sId"

	/**
	 * 数据库表主键名称(自增长形式)
	 */
	TableMajorKeyAutoInt = "iId"

	/**
	 * 数据库表主键名称(UUID形式)
	 */
	TableMajorKeyUuId = "uId"

	/**
	 * 数据库表字段名称-上级字段名
	 */
	TablePidKey = "sPid"

	/**
	 * 数据库表字段名称-主键路径名
	 */
	TablePathKey = "sPath"

	/**
	 * 数据库表字段名称-树形节点名
	 */
	TableTreeNodeName = "sName"

	/**
	 * 数据库表字段名称-创建人
	 */
	TableCreatorName = "sCreator"

	/**
	 * 数据库表字段名称-创建时间
	 */
	TableCreateDateName = "dCreateDate"

	/**
	 * 数据库表字段名称-修改人
	 */
	TableModifiederName = "sModifieder"

	/**
	 * 数据库表字段名称-修改时间
	 */
	TableModifiedDateName = "dModifiedDate"

	/**
	 * 数据库表字段名称-状态值
	 */
	TableStateName = "iState"

	/**
	 * 数据库表字段名称-排序值
	 */
	TableIndexName = "iIndex"

	/**
	 * 数据库表字段名称-版本号
	 */
	TableVersionName = "iVersion"

	/**
	 * 数据库表字段名称-逻辑删除标识
	 */
	TableDelSignName = "iDelSign"

	/**
	 * 数据库表字段名称-步骤值
	 */
	TableSetpName = "iSetp"

	/**
	 * 数据库表字段名称-唯一标识
	 */
	TableOnlyignName = "sOnlyign"

	/**
	 * 基本数据库库名
	 */
	BaseSystemName = "BaseSystem"

	/**
	 * 字典表表名
	 */
	TableNameDictionary = "Dictionary"

	/**
	 * 字典表值字段名
	 */
	TableDictionaryValueName = "sValue"

	/**
	 * 记录验证串字段名
	 */
	TableRecordKeyName = "sRecordKey"

	/**
	 * 标识字段名
	 */
	TablesSign = "sSign"

	/**
	* 备注字段名
	 */
	TablesMemo = "sMemo"

	/**
	 * 数据库树型表根节点默认值
	 */
	TableTreeRootValue = "00"

	/**
	 * 属性对应数据库表主键名称(字符串形式)
	 */
	GtableMajorKeyString = "GsId"

	/**
	 * 属性对应数据库表主键名称(自增长形式)
	 */
	GtableMajorKeyAutoInt = "GiId"

	/**
	 * 属性对应数据库表主键名称(UUID形式)
	 */
	GtableMajorKeyUuId = "GuId"

	/**
	 * 属性对应数据库表字段名称-上级字段名
	 */
	GtablePidKey = "GsPid"

	/**
	 * 属性对应数据库表字段名称-主键路径名
	 */
	GtablePathKey = "GsPath"

	/**
	 * 属性对应数据库表字段名称-树形节点名
	 */
	GtableTreeNodeName = "GsName"

	/**
	 * 属性对应数据库表字段名称-创建人
	 */
	GtableCreatorName = "GsCreator"

	/**
	 * 属性对应数据库表字段名称-创建时间
	 */
	GtableCreateDateName = "GdCreateDate"

	/**
	 * 属性对应数据库表字段名称-修改人
	 */
	GtableModifiederName = "GsModifieder"

	/**
	 * 属性对应数据库表字段名称-修改时间
	 */
	GtableModifiedDateName = "GdModifiedDate"

	/**
	 * 属性对应数据库表字段名称-状态值
	 */
	GtableStateName = "GiState"

	/**
	 * 属性对应数据库表字段名称-排序值
	 */
	GtableIndexName = "GiIndex"

	/**
	 * 属性对应数据库表字段名称-版本号
	 */
	GtableVersionName = "GiVersion"

	/**
	 * 属性对应数据库表字段名称-逻辑删除标识
	 */
	GtableDelSignName = "GiDelSign"

	/**
	 * 属性对应数据库表字段名称-步骤值
	 */
	GtableSetpName = "GiSetp"

	/**
	 * 属性对应数据库表字段名称-唯一标识
	 */
	GtableOnlyignName = "GsOnlyign"

	/**
	 * 属性对应数据库树型表根节点默认值
	 */
	GtableTreeRootValue = "00"

	/**
	 * 属性对应基本数据库库名
	 */
	GBaseSystemName = "BaseSystem"

	/**
	 * 属性对应字典表表名
	 */
	GtableNameDictionary = "Dictionary"

	/**
	 * 属性对应字典表值字段名
	 */
	GtableDictionaryValueName = "GsValue"

	/**
	 * 属性对应记录验证串字段名
	 */
	GtableRecordKeyName = "GsRecordKey"

	/**
	 * 属性对应标识字段名
	 */
	GtablesSign = "GsSign"

	/**
	* 属性对应备注字段名
	 */
	GtablesMemo = "GsMemo"
)
View Source
const SPECIAL_STR = "/INTEGER/STRING/INT/NULL/LONG/FLOAT/DOUBLE/FUNCTION/" // /Integer/string/int/null/long/float/double/function/

要被过滤的特殊字符串,用'/'分隔

Variables

This section is empty.

Functions

func SetupLogger

func SetupLogger()

Types

type CacheInfo

type CacheInfo struct {
	GsId     string      `json:"sId"`     //编号,作为关键字存在
	Gdata    interface{} `json:"data"`    //缓存的数据对象
	GdCreate time.Time   `json:"dCreate"` //创建时间
	GdLast   time.Time   `json:"dLast"`   //最后访问时间
}

用于定义缓存信息的类

func (CacheInfo) New

func (this CacheInfo) New(sId string, data interface{}) CacheInfo

*

  • 新建缓存信息结构体
  • @param sId 编号,作为关键字存在
  • @param data 缓存的数据对象
  • @return 返回新创建的结构体

type DataInfo

type DataInfo struct {
	GbDbField        bool   `json:"bDbField"`        //是否数据库字段
	GsName           string `json:"sName"`           //名称
	GsDbName         string `json:"sDbName"`         //所在数据库名称
	GsTableName      string `json:"sTableName"`      //所在数据库表表名称
	GsKeyName        string `json:"sKeyName"`        //表主键名称
	GiIndex          int    `json:"iIndex"`          //序号
	GiMaxLength      int    `json:"iMaxLength"`      //最大长度
	GbNull           bool   `json:"bNull"`           //是否允许为空
	Gbkey            bool   `json:"bkey"`            //是否主键
	GbExtra          bool   `json:"bExtra"`          //是否自增
	GsDefaultData    string `json:"sDefaultData"`    //默认值
	GsComment        string `json:"sComment"`        //字段备注
	GbDecimal        bool   `json:"bDecimal"`        //类型是否有小数
	GiIntegralLength int    `json:"iIntegralLength"` //整数位的长度
	GiDecimalLength  int    `json:"iDecimalLength"`  //小数位的长度
	GsDbFileType     string `json:"sDbFileType"`     //字段在数据库中的类型
	GsRelTitle       string `json:"sRelTitle"`       //关联后显示的名称
	GsRelName        string `json:"sRelName"`        //关联关系中被动关联的字段名,如 (LEFT JOIN RelTable ON RelTable.A = MainTable.B )中的A
	GsRelMainName    string `json:"sRelMainName"`    //关联关系中被关联的字段名,如 (LEFT JOIN RelTable ON RelTable.A = MainTable.B )中的B
}

数据信息注解

func (DataInfo) GetAnonyTagInfo

func (d DataInfo) GetAnonyTagInfo(sf reflect.StructField) map[string]string

取匿名属性Tag信息

func (DataInfo) GetDataInfoByName

func (d DataInfo) GetDataInfoByName(entry interface{}, name string) *DataInfo

取结构体指定属性的tag中的dataInfo信息

func (DataInfo) MapToEntity

func (d DataInfo) MapToEntity(data map[string]interface{}, entity interface{}) *MsgEmity

*

  • 用反射将map转成实体
  • data 数据
  • entity 数据结构

func (*DataInfo) Now

func (d *DataInfo) Now() *DataInfo

创建结构体,并设置默认值

func (DataInfo) SetDataInfoDefault

func (d DataInfo) SetDataInfoDefault(entity interface{}) interface{}

对对象中添加了dataInfo注解的属性添加默认值

func (DataInfo) TrimAttribute

func (d DataInfo) TrimAttribute(entity interface{}) interface{}

清除对象各个属性的值的前后空格

func (DataInfo) ValidAttr

func (d DataInfo) ValidAttr(data map[string]interface{}, entity interface{}, ignoreNames []string) *MsgEmity

*

  • 对对象中添加了DataInfo注解的不为null的属性检查限制
  • data 数据
  • entity 检查用数据结构
  • ignoreNames 待忽略的字段

func (DataInfo) ValidAttrByAdd

func (d DataInfo) ValidAttrByAdd(entity interface{}, ignoreNames []string) *MsgEmity

*

  • 对'新增'对象中添加了DataInfo注解的属性检查限制
  • entity 检查用数据结构
  • ignoreNames 待忽略的字段

func (DataInfo) ValidAttrByEdit

func (d DataInfo) ValidAttrByEdit(data map[string]interface{}, entity interface{}, ignoreNames []string) *MsgEmity

*

  • 对'编辑'对象中添加了DataInfo注解的不为null的属性检查限制
  • data 数据
  • entity 检查用数据结构
  • ignoreNames 待忽略的字段

type FileEmity

type FileEmity struct {
	Gsuccess     bool        `json:"success"`
	Gmsg         string      `json:"msg"`
	Gdata        interface{} `json:"data"` //[]byte
	Gdisposition string      `json:"disposition"`
	Gtype        string      `json:"type"`
	Glength      int         `json:"length"`
	GsLength     string      `json:"sLength"`
}

文件结构体,用于http返回传递消息

func (*FileEmity) AppendMsg

func (fm *FileEmity) AppendMsg(msg ...interface{}) *FileEmity

*

  • 在描述信息后面累加'描述信息'
  • msg 描述信息
  • @return 返回原结构体 m

func (FileEmity) Err

func (fm FileEmity) Err(data int, msg ...interface{}) *FileEmity

*

  • 构造消息结构体,返回包含'错误信息'的结构体
  • @param data 码值
  • @param msg 描述信息
  • @return 返回新创建的结构体

func (FileEmity) ErrString

func (fm FileEmity) ErrString(data int, msg ...interface{}) string

*

  • 返回包含'错误信息'的结构体Json字符串
  • @param data 码值
  • @param msg 描述信息
  • @return 返回Json字符串

func (*FileEmity) IncCode

func (fm *FileEmity) IncCode(iCode int) *FileEmity

*

  • 累加'码值'
  • iCode 被累加值
  • @return 返回原结构体 m

func (*FileEmity) IncData

func (fm *FileEmity) IncData(iCode int) int

*

  • 累加'码值'
  • iCode 被累加值
  • @return 返回原结构体 m

func (*FileEmity) InsertMsg

func (fm *FileEmity) InsertMsg(msg ...interface{}) *FileEmity

*

  • 在描述信息前面插入'描述信息'
  • msg 描述信息
  • @return 返回原结构体 m

func (*FileEmity) SetData

func (fm *FileEmity) SetData(data interface{}) *FileEmity

*

  • 重设'返回数据'
  • data 码值|数据
  • @return 返回原结构体 m

func (*FileEmity) SetMsg

func (fm *FileEmity) SetMsg(msg ...interface{}) *FileEmity

*

  • 重设'描述信息'
  • msg 描述信息
  • @return 返回原结构体 m

func (FileEmity) Success

func (fm FileEmity) Success(data interface{}, disposition, sType string, msg ...interface{}) *FileEmity

*

  • 构造消息结构体,返回包含'正确信息'的结构体
  • @param data 码值|数据
  • @param msg 描述信息
  • @return 返回新创建的结构体

func (*FileEmity) ToStr

func (fm *FileEmity) ToStr() string

*

  • 将结构体转换成json字符串输出
  • @return 返回json结构字符串

type FindByPageParam

type FindByPageParam struct {
	Gpage        Page        `json:"page"`        //分页信息对象
	Gorders      []OrderInfo `json:"orders"`      //排序信息对象集合
	GsLikeStr    string      `json:"sLikeStr"`    //全文检索条件
	GsLikeDateSt string      `json:"sLikeDateSt"` //全文检索查询记录修改时间范围条件-开始
	GsLikeDateEd string      `json:"sLikeDateEd"` //全文检索查询记录修改时间范围条件-结束
	Gcondition   interface{} `json:"condition"`   //常规查询条件对象(根据定义的类型转换)
}

分页查询条件组合类

type GlobalConstant

type GlobalConstant struct{}

type GlobalFunc

type GlobalFunc struct{}

type GlobalVariable

type GlobalVariable struct{}

func (GlobalVariable) Del

func (gv GlobalVariable) Del(name string) bool

删除指定全局变量

func (GlobalVariable) Get

func (gv GlobalVariable) Get(name string) interface{}

取指定全局变量

func (GlobalVariable) RegisterVariable

func (gv GlobalVariable) RegisterVariable(name string, data interface{}) interface{}

注册全局变量

type MsgEmity

type MsgEmity struct {
	Gsuccess bool        `json:"success"`
	Gmsg     string      `json:"msg"`
	Gdata    interface{} `json:"data"`
}

消息结构体,用于方法间传递消息

func (*MsgEmity) AppendMsg

func (m *MsgEmity) AppendMsg(msg ...interface{}) *MsgEmity

*

  • 在描述信息后面累加'描述信息'
  • msg 描述信息
  • @return 返回原结构体 m

func (MsgEmity) Err

func (m MsgEmity) Err(data int, msg ...interface{}) *MsgEmity

*

  • 构造消息结构体,返回包含'错误信息'的结构体
  • @param data 码值
  • @param msg 描述信息
  • @return 返回新创建的结构体

func (MsgEmity) ErrString

func (m MsgEmity) ErrString(data int, msg ...interface{}) string

*

  • 返回包含'错误信息'的结构体Json字符串
  • @param data 码值
  • @param msg 描述信息
  • @return 返回Json字符串

func (*MsgEmity) IncCode

func (m *MsgEmity) IncCode(iCode int) *MsgEmity

*

  • 累加'码值'
  • iCode 被累加值
  • @return 返回原结构体 m

func (*MsgEmity) IncData

func (m *MsgEmity) IncData(iCode int) int

*

  • 累加'码值'
  • iCode 被累加值
  • @return 返回原结构体 m

func (*MsgEmity) InsertMsg

func (m *MsgEmity) InsertMsg(msg ...interface{}) *MsgEmity

*

  • 在描述信息前面插入'描述信息'
  • msg 描述信息
  • @return 返回原结构体 m

func (*MsgEmity) SetData

func (m *MsgEmity) SetData(data interface{}) *MsgEmity

*

  • 重设'返回数据'
  • data 码值|数据
  • @return 返回原结构体 m

func (*MsgEmity) SetMsg

func (m *MsgEmity) SetMsg(msg ...interface{}) *MsgEmity

*

  • 重设'描述信息'
  • msg 描述信息
  • @return 返回原结构体 m

func (MsgEmity) Success

func (m MsgEmity) Success(data interface{}, msg ...interface{}) *MsgEmity

*

  • 构造消息结构体,返回包含'正确信息'的结构体
  • @param data 码值|数据
  • @param msg 描述信息
  • @return 返回新创建的结构体

func (MsgEmity) SuccessString

func (m MsgEmity) SuccessString(data interface{}, msg ...interface{}) string

*

  • 返回包含'正确信息'的结构体Json字符串
  • @param data 码值|数据
  • @param msg 描述信息
  • @return 返回Json字符串

func (*MsgEmity) ToStr

func (m *MsgEmity) ToStr() string

*

  • 将结构体转换成json字符串输出
  • @return 返回json结构字符串

type OrderInfo

type OrderInfo struct {
	GsOrderDbName string `json:"sOrderDbName"` //排序字段名所属库名
	GsOrderTable  string `json:"sOrderTable"`  //排序字段名所属表
	GsOrderField  string `json:"sOrderField"`  //排序字段名
	GsDirection   string `json:"sDirection"`   //排序方式(升序ASC 降序DESC)
	GiIndex       int    `json:"iIndex"`       //排序顺序
}

排序信息

func (*OrderInfo) SetsDirection

func (o *OrderInfo) SetsDirection(sDirection string)

*

  • 设置 排序方式(升序ASC 降序DESC)
  • @param sDirection 排序方式(升序ASC 降序DESC)

func (*OrderInfo) SetsOrderDbName

func (o *OrderInfo) SetsOrderDbName(sOrderDbName string)

*

  • 设置 排序字段名所属库名
  • @param sOrderDbName 排序字段名所属库名

func (*OrderInfo) SetsOrderField

func (o *OrderInfo) SetsOrderField(sOrderField string)

*

  • 设置 排序字段名
  • @param sOrderField 排序字段名

func (*OrderInfo) SetsOrderTable

func (o *OrderInfo) SetsOrderTable(sOrderTable string)

*

  • 设置 排序字段名所属表
  • @param sOrderTable 排序字段名所属表

func (*OrderInfo) String

func (o *OrderInfo) String() string

*

  • 输出排序字符串

type Page

type Page struct {
	GiCurrent   int                      `json:"iCurrent"`   //当前页
	GiSize      int                      `json:"iSize"`      //每页显示记录
	GiCountRow  int                      `json:"iCountRow"`  //总记录数
	GiCountPage int                      `json:"iCountPage"` //总页数
	Record      []map[string]interface{} `json:"Record"`     //本页的数据列表
}

分页数据信息对象,常用于前端与后台列表数据交互

func (*Page) New

func (p *Page) New() *Page

创建分页信息

func (*Page) Set

func (p *Page) Set(start, size, countRow int, record []map[string]interface{}) *Page

设置分页信息

func (*Page) SetRecord

func (p *Page) SetRecord(record []map[string]interface{}) *Page

设置数据列表

type Set

type Set struct {
	Key   string
	Value interface{}
}

键值对结构体

type TableInfo

type TableInfo struct {
	GsDbName          string `json:"sDbName"`          //所在数据库名称
	GsTableName       string `json:"sTableName"`       //所在数据库表表名称
	GsKeyName         string `json:"sKeyName"`         //表主键名称
	GiKeyLen          int    `json:"iKeyLen"`          //主键长度
	GbAutoKey         bool   `json:"bAutoKey"`         //是否自增主键
	GbHasPid          bool   `json:"bHasPid"`          //是否存在sPid
	GbHasPath         bool   `json:"bHasPath"`         //是否存在sPath
	GbHasRecordKey    bool   `json:"bHasRecordKey"`    //是否存在sRecordKey
	GbHasMemo         bool   `json:"bHasMemo"`         //是否存在sMemo
	GbHasCreator      bool   `json:"bHasCreator"`      //是否存在sCreator
	GbHasCreateDate   bool   `json:"bHasCreateDate"`   //是否存在dCreateDate
	GbHasModifieder   bool   `json:"bHasModifieder"`   //是否存在sModifieder
	GbHasModifiedDate bool   `json:"bHasModifiedDate"` //是否存在dModifiedDate
	GbHasState        bool   `json:"bHasState"`        //是否存在iState
	GbHasIndex        bool   `json:"bHasIndex"`        //是否存在iIndex
	GbHasVersion      bool   `json:"bHasVersion"`      //是否存在iVersion
	GbHasPassword     bool   `json:"bHasPassword"`     //是否存在sPassword
	GbHasSign         bool   `json:"bHasSign"`         //是否存在sSign
	GbHasOnlyign      bool   `json:"bHasOnlyign"`      //是否存在sOnlyign
	GbHasDelSign      bool   `json:"bHasDelSign"`      //是否存在iDelSign
}

数据信息注解

func (TableInfo) GetByEntity

func (t TableInfo) GetByEntity(entity interface{}) *TableInfo

取指定数据库表信息

func (TableInfo) GetColumnNames

func (t TableInfo) GetColumnNames(entity interface{}) []string

取指定数据库表的字段名集合

func (TableInfo) GetEntity

func (t TableInfo) GetEntity(name string) interface{}

取指定数据库实体类信息

func (TableInfo) GetTableInfo

func (t TableInfo) GetTableInfo(name string) *TableInfo

取指定数据库表信息

func (TableInfo) RegisterEntity

func (t TableInfo) RegisterEntity(name string, entity interface{})

注册数据库实体类结构体

func (TableInfo) RegisterTableInfo

func (t TableInfo) RegisterTableInfo(name string, tableInfo *TableInfo)

注册数据库表信息

Jump to

Keyboard shortcuts

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