xrecord

package
v0.3.13 Latest Latest
Warning

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

Go to latest
Published: May 16, 2024 License: BSD-3-Clause-Clear Imports: 1 Imported by: 0

Documentation

Overview

基础数据统计模块

用于统计个人/家庭等的基础数据记录,用于明细分析

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Regedit

func Regedit(c *Config)

注入配置项

c	程序中需要使用的配置项信息

Types

type Config

type Config struct {
	DB                    *gorm.DB // 数据库连接
	RecordTable           string   // 基础数据记录表
	RecordTypeTable       string   // 基础数据分类配置表
	RecordStatisticsTable string   // 基础数据统计配置表
}

type Record

type Record struct {
	Id        uint    `gorm:"column:id;primaryKey;autoIncrement;not null" form:"id" json:"id"`
	UserId    uint    `gorm:"column:user_id;comment:所属用户ID" form:"user_id" json:"user_id"`                      //所属用户ID
	Value     float64 `gorm:"column:value;type:decimal(12,4);comment:数据值记录" form:"value" json:"value"`          //数据值记录
	Type      uint    `gorm:"column:type;comment:所属数据类型" form:"type" json:"type"`                               //所属数据类型
	Relevance uint    `gorm:"column:relevance;comment:关联ID" form:"relevance" json:"relevance"`                  //关联ID
	CreatedAt string  `gorm:"column:created_at;type:datetime;comment:添加时间" form:"created_at" json:"created_at"` //添加时间
}

基础数据记录表

func (*Record) TableName

func (c *Record) TableName() string

返回所属表名信息

type RecordStatistics

type RecordStatistics struct {
	Id         uint    `gorm:"column:id;primaryKey;autoIncrement;not null" form:"id" json:"id"`
	RecordDate string  `gorm:"column:record_date;type:date;comment:统计时间" form:"record_date" json:"record_date"`          //统计时间
	RecordType uint    `gorm:"column:record_type;comment:统计数据类型" form:"record_type" json:"record_type"`                  //统计数据类型
	Type       uint8   `gorm:"column:type;type:tinyint unsigned;comment:数据类型 1-最大值 2-最小值 3-平均值" form:"type" json:"type"` //数据类型 1-最大值 2-最小值 3-平均值
	Value      float64 `gorm:"column:value;type:decimal(12,4);comment:数据值" form:"value" json:"value"`                    //数据值
	CreatedAt  string  `gorm:"column:created_at;type:datetime;comment:计算时间" form:"created_at" json:"created_at"`         //计算时间
}

基础数据统计表

func (*RecordStatistics) TableName

func (c *RecordStatistics) TableName() string

返回所属表名信息

type RecordType

type RecordType struct {
	Id         uint   `gorm:"column:id;primaryKey;autoIncrement;not null" form:"id" json:"id"`
	UserId     uint   `gorm:"column:user_id;comment:创建人ID" form:"user_id" json:"user_id"`                                         //创建人ID
	Name       string `gorm:"column:name;type:varchar(200);comment:分类名称" form:"name" json:"name"`                                 //分类名称
	NameDy     string `gorm:"column:name_dy;type:varchar(100);comment:分类数据单位" form:"name_dy" json:"name_dy"`                      //分类数据单位
	HasMax     uint8  `gorm:"column:has_max;type:tinyint unsigned;comment:是否统计最大值(每天)" form:"has_max" json:"has_max"`             //是否统计最大值(每天)
	HasMin     uint8  `gorm:"column:has_min;type:tinyint unsigned;comment:是否统计最小值(每天)" form:"has_min" json:"has_min"`             //是否统计最小值(每天)
	HasAverage uint8  `gorm:"column:has_average;type:tinyint unsigned;comment:是否统计平均值(每天)" form:"has_average" json:"has_average"` //是否统计平均值(每天)
	NextZero   uint8  ``                                                                                                          //是否空数据归零(当天无数据时方案 0-使用前一天数据 1-使用0值)
	/* 172-byte string literal not displayed */
	CreatedAt string `gorm:"column:created_at;type:datetime;comment:创建时间" form:"created_at" json:"created_at"` //创建时间
}

基础数据类型配置表

func (*RecordType) TableName

func (c *RecordType) TableName() string

返回所属表名信息

Jump to

Keyboard shortcuts

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