Documentation ¶
Index ¶
- Constants
- Variables
- func BalanceSheetStruct() *sqlbuilder.Struct
- func CashFlowStruct() *sqlbuilder.Struct
- func Count(m Model, wheres KV) (int, error)
- func GetAll(ms Models) error
- func GetMany(ms Models, wheres KV, p Pagination, orderBys ...OrderBy) error
- func GetOne(m Model, wheres KV, orderBys ...OrderBy) error
- func HolderStruct() *sqlbuilder.Struct
- func HoldingStruct() *sqlbuilder.Struct
- func IndustryStruct() *sqlbuilder.Struct
- func InitDB(cfg *config.Config)
- func Insert(m Model) (sql.Result, error)
- func MarketStruct() *sqlbuilder.Struct
- func ProfitStatementStruct() *sqlbuilder.Struct
- func StockStruct() *sqlbuilder.Struct
- func Update(m Model, updates KV, wheres KV) (sql.Result, error)
- type BalanceSheet
- func (m BalanceSheet) Columns() []string
- func (m BalanceSheet) DeleteBuilder() *sqlbuilder.DeleteBuilder
- func (m BalanceSheet) InsertBuilder() *sqlbuilder.InsertBuilder
- func (m BalanceSheet) SelectBuilder() *sqlbuilder.SelectBuilder
- func (m BalanceSheet) TableName() string
- func (m BalanceSheet) UpdateBuilder() *sqlbuilder.UpdateBuilder
- type BalanceSheets
- type CashFlow
- func (m CashFlow) Columns() []string
- func (m CashFlow) DeleteBuilder() *sqlbuilder.DeleteBuilder
- func (m CashFlow) InsertBuilder() *sqlbuilder.InsertBuilder
- func (m CashFlow) SelectBuilder() *sqlbuilder.SelectBuilder
- func (m CashFlow) TableName() string
- func (m CashFlow) UpdateBuilder() *sqlbuilder.UpdateBuilder
- type CashFlows
- type Holder
- func (m Holder) Columns() []string
- func (m Holder) DeleteBuilder() *sqlbuilder.DeleteBuilder
- func (m Holder) InsertBuilder() *sqlbuilder.InsertBuilder
- func (m Holder) SelectBuilder() *sqlbuilder.SelectBuilder
- func (m Holder) TableName() string
- func (m Holder) UpdateBuilder() *sqlbuilder.UpdateBuilder
- type Holders
- type Holding
- func (m Holding) Columns() []string
- func (m Holding) DeleteBuilder() *sqlbuilder.DeleteBuilder
- func (m Holding) InsertBuilder() *sqlbuilder.InsertBuilder
- func (m Holding) SelectBuilder() *sqlbuilder.SelectBuilder
- func (m Holding) TableName() string
- func (m Holding) UpdateBuilder() *sqlbuilder.UpdateBuilder
- type Holdings
- type Industries
- type Industry
- func (m Industry) Columns() []string
- func (m Industry) DeleteBuilder() *sqlbuilder.DeleteBuilder
- func (m Industry) InsertBuilder() *sqlbuilder.InsertBuilder
- func (m Industry) SelectBuilder() *sqlbuilder.SelectBuilder
- func (m Industry) TableName() string
- func (m Industry) UpdateBuilder() *sqlbuilder.UpdateBuilder
- type KV
- type Market
- func (m Market) Columns() []string
- func (m Market) DeleteBuilder() *sqlbuilder.DeleteBuilder
- func (m Market) InsertBuilder() *sqlbuilder.InsertBuilder
- func (m Market) SelectBuilder() *sqlbuilder.SelectBuilder
- func (m Market) TableName() string
- func (m Market) UpdateBuilder() *sqlbuilder.UpdateBuilder
- type Markets
- type Model
- type Models
- type OrderBy
- type Pagination
- type ProfitStatement
- func (m ProfitStatement) Columns() []string
- func (m ProfitStatement) DeleteBuilder() *sqlbuilder.DeleteBuilder
- func (m ProfitStatement) InsertBuilder() *sqlbuilder.InsertBuilder
- func (m ProfitStatement) SelectBuilder() *sqlbuilder.SelectBuilder
- func (m ProfitStatement) TableName() string
- func (m ProfitStatement) UpdateBuilder() *sqlbuilder.UpdateBuilder
- type ProfitStatements
- type Result
- type Stock
- func (m Stock) Columns() []string
- func (m Stock) DeleteBuilder() *sqlbuilder.DeleteBuilder
- func (m Stock) GetIndustryName() string
- func (m Stock) InsertBuilder() *sqlbuilder.InsertBuilder
- func (m Stock) SelectBuilder() *sqlbuilder.SelectBuilder
- func (m Stock) TableName() string
- func (m Stock) UpdateBuilder() *sqlbuilder.UpdateBuilder
- type Stocks
Constants ¶
const DefaultLimit int = 100
DefaultLimit is default limit
Variables ¶
var DB *sqlx.DB
DB is db connection
Functions ¶
func BalanceSheetStruct ¶
func BalanceSheetStruct() *sqlbuilder.Struct
BalanceSheetStruct returns the BalanceSheet struct
func CashFlowStruct ¶
func CashFlowStruct() *sqlbuilder.Struct
CashFlowStruct returns the CashFlow struct
func GetMany ¶
func GetMany(ms Models, wheres KV, p Pagination, orderBys ...OrderBy) error
GetMany gets many records from db
func HoldingStruct ¶
func HoldingStruct() *sqlbuilder.Struct
HoldingStruct returns the Holding struct
func IndustryStruct ¶
func IndustryStruct() *sqlbuilder.Struct
IndustryStruct returns the Industry struct
func ProfitStatementStruct ¶
func ProfitStatementStruct() *sqlbuilder.Struct
ProfitStatementStruct returns the ProfitStatement struct
Types ¶
type BalanceSheet ¶
type BalanceSheet struct { Code string `db:"code"` Date time.Time `db:"date"` TotalAsset float64 `db:"total_asset"` TotalLiability float64 `db:"total_liability"` CurrentAsset float64 `db:"current_asset"` NonCurrentAsset float64 `db:"non_current_asset"` CurrentLiability float64 `db:"current_liability"` NonCurrentLiability float64 `db:"non_current_liability"` OwnersEquity float64 `db:"owners_equity"` Cash float64 `db:"cash"` Receivable float64 `db:"receivable"` Inventory float64 `db:"inventory"` OtherCurrentAsset float64 `db:"other_current_asset"` Goodwill float64 `db:"goodwill"` Payable float64 `db:"payable"` CreatedAt time.Time `db:"created_at"` UpdatedAt time.Time `db:"updated_at"` }
BalanceSheet maps balance_sheet table
func (BalanceSheet) DeleteBuilder ¶
func (m BalanceSheet) DeleteBuilder() *sqlbuilder.DeleteBuilder
DeleteBuilder returns a delete builder
func (BalanceSheet) InsertBuilder ¶
func (m BalanceSheet) InsertBuilder() *sqlbuilder.InsertBuilder
InsertBuilder returns an insert builder
func (BalanceSheet) SelectBuilder ¶
func (m BalanceSheet) SelectBuilder() *sqlbuilder.SelectBuilder
SelectBuilder returns a select builder
func (BalanceSheet) TableName ¶
func (m BalanceSheet) TableName() string
TableName returns the table name
func (BalanceSheet) UpdateBuilder ¶
func (m BalanceSheet) UpdateBuilder() *sqlbuilder.UpdateBuilder
UpdateBuilder returns an update builder
type BalanceSheets ¶
type BalanceSheets []BalanceSheet
BalanceSheets is BalanceSheet list
func (BalanceSheets) SelectBuilder ¶
func (ms BalanceSheets) SelectBuilder() *sqlbuilder.SelectBuilder
SelectBuilder returns a select builder
type CashFlow ¶
type CashFlow struct { Code string `db:"code"` Date time.Time `db:"date"` OperatingInflow float64 `db:"operating_inflow"` OperatingOutflow float64 `db:"operating_outflow"` OperatingNet float64 `db:"operating_net"` InvestmentInflow float64 `db:"investment_inflow"` InvestmentOutflow float64 `db:"investment_outflow"` InvestmentNet float64 `db:"investment_net"` FinancingInflow float64 `db:"financing_inflow"` FinancingOutflow float64 `db:"financing_outflow"` FinancingNet float64 `db:"financing_net"` InitialBalance float64 `db:"initial_balance"` EndingBalance float64 `db:"ending_balance"` CreatedAt time.Time `db:"created_at"` UpdatedAt time.Time `db:"updated_at"` }
CashFlow maps cash_flow table
func (CashFlow) DeleteBuilder ¶
func (m CashFlow) DeleteBuilder() *sqlbuilder.DeleteBuilder
DeleteBuilder returns a delete builder
func (CashFlow) InsertBuilder ¶
func (m CashFlow) InsertBuilder() *sqlbuilder.InsertBuilder
InsertBuilder returns an insert builder
func (CashFlow) SelectBuilder ¶
func (m CashFlow) SelectBuilder() *sqlbuilder.SelectBuilder
SelectBuilder returns a select builder
func (CashFlow) UpdateBuilder ¶
func (m CashFlow) UpdateBuilder() *sqlbuilder.UpdateBuilder
UpdateBuilder returns an update builder
type CashFlows ¶
type CashFlows []CashFlow
CashFlows is CashFlow list
func (CashFlows) SelectBuilder ¶
func (ms CashFlows) SelectBuilder() *sqlbuilder.SelectBuilder
SelectBuilder returns a select builder
type Holder ¶
type Holder struct { Code string `db:"code"` Name string `db:"name"` CreatedAt time.Time `db:"created_at"` }
Holder maps Holder table
func (Holder) DeleteBuilder ¶
func (m Holder) DeleteBuilder() *sqlbuilder.DeleteBuilder
DeleteBuilder returns a delete builder
func (Holder) InsertBuilder ¶
func (m Holder) InsertBuilder() *sqlbuilder.InsertBuilder
InsertBuilder returns an insert builder
func (Holder) SelectBuilder ¶
func (m Holder) SelectBuilder() *sqlbuilder.SelectBuilder
SelectBuilder returns a select builder
func (Holder) UpdateBuilder ¶
func (m Holder) UpdateBuilder() *sqlbuilder.UpdateBuilder
UpdateBuilder returns an update builder
type Holders ¶
type Holders []Holder
Holders is Holder list
func (Holders) SelectBuilder ¶
func (ms Holders) SelectBuilder() *sqlbuilder.SelectBuilder
SelectBuilder returns a select builder
type Holding ¶
type Holding struct { HolderCode string `db:"holder_code"` StockCode string `db:"stock_code"` Date time.Time `db:"date"` Quantity int64 `db:"quantity"` Ratio float64 `db:"ratio"` CreatedAt time.Time `db:"created_at"` UpdatedAt time.Time `db:"updated_at"` }
Holding maps Holding table
func (Holding) DeleteBuilder ¶
func (m Holding) DeleteBuilder() *sqlbuilder.DeleteBuilder
DeleteBuilder returns a delete builder
func (Holding) InsertBuilder ¶
func (m Holding) InsertBuilder() *sqlbuilder.InsertBuilder
InsertBuilder returns an insert builder
func (Holding) SelectBuilder ¶
func (m Holding) SelectBuilder() *sqlbuilder.SelectBuilder
SelectBuilder returns a select builder
func (Holding) UpdateBuilder ¶
func (m Holding) UpdateBuilder() *sqlbuilder.UpdateBuilder
UpdateBuilder returns an update builder
type Holdings ¶
type Holdings []Holding
Holdings is Holding list
func (Holdings) SelectBuilder ¶
func (ms Holdings) SelectBuilder() *sqlbuilder.SelectBuilder
SelectBuilder returns a select builder
type Industries ¶
type Industries []Industry
Industries is industry list
func (Industries) SelectBuilder ¶
func (ms Industries) SelectBuilder() *sqlbuilder.SelectBuilder
SelectBuilder returns a select builder
type Industry ¶
Industry maps industry table
func (Industry) DeleteBuilder ¶
func (m Industry) DeleteBuilder() *sqlbuilder.DeleteBuilder
DeleteBuilder returns a delete builder
func (Industry) InsertBuilder ¶
func (m Industry) InsertBuilder() *sqlbuilder.InsertBuilder
InsertBuilder returns an insert builder
func (Industry) SelectBuilder ¶
func (m Industry) SelectBuilder() *sqlbuilder.SelectBuilder
SelectBuilder returns a select builder
func (Industry) UpdateBuilder ¶
func (m Industry) UpdateBuilder() *sqlbuilder.UpdateBuilder
UpdateBuilder returns an update builder
type Market ¶
type Market struct { Code string `db:"code"` Date time.Time `db:"date"` IssueVolume int32 `db:"issue_volume"` MarketValue float64 `db:"market_value"` NegotiableValue float64 `db:"negotiable_value"` TradeAmount float64 `db:"amount"` PE float64 `db:"pe"` TurnoverRate float64 `db:"ex"` CreatedAt time.Time `db:"created_at"` UpdatedAt time.Time `db:"updated_at"` }
Market maps market table
func (Market) DeleteBuilder ¶
func (m Market) DeleteBuilder() *sqlbuilder.DeleteBuilder
DeleteBuilder returns a delete builder
func (Market) InsertBuilder ¶
func (m Market) InsertBuilder() *sqlbuilder.InsertBuilder
InsertBuilder returns an insert builder
func (Market) SelectBuilder ¶
func (m Market) SelectBuilder() *sqlbuilder.SelectBuilder
SelectBuilder returns a select builder
func (Market) UpdateBuilder ¶
func (m Market) UpdateBuilder() *sqlbuilder.UpdateBuilder
UpdateBuilder returns an update builder
type Markets ¶
type Markets []Market
Markets is Market list
func (*Markets) LastFiveYears ¶
func (ms *Markets) LastFiveYears(wheres KV, p Pagination, orderBys ...OrderBy) error
LastFiveYears gets data in last five years
func (Markets) SelectBuilder ¶
func (ms Markets) SelectBuilder() *sqlbuilder.SelectBuilder
SelectBuilder returns a select builder
type Model ¶
type Model interface { TableName() string Columns() []string InsertBuilder() *sqlbuilder.InsertBuilder SelectBuilder() *sqlbuilder.SelectBuilder UpdateBuilder() *sqlbuilder.UpdateBuilder DeleteBuilder() *sqlbuilder.DeleteBuilder }
Model is the interface of db model
type Models ¶
type Models interface {
SelectBuilder() *sqlbuilder.SelectBuilder
}
Models is the interface of a set of Model
type Pagination ¶
Pagination is LIMIT and OFFSET in sql
func (*Pagination) GetOffset ¶
func (p *Pagination) GetOffset() int
GetOffset returns a valid offset
type ProfitStatement ¶
type ProfitStatement struct { Code string `db:"code"` Date time.Time `db:"date"` Income float64 `db:"income"` Cost float64 `db:"cost"` OperatingCost float64 `db:"operating_cost"` SellingExpense float64 `db:"selling_expense"` AdminExpense float64 `db:"admin_expense"` FinancialExpense float64 `db:"financial_expense"` OperatingProfit float64 `db:"operating_profit"` TotalProfit float64 `db:"total_profit"` NetProfit float64 `db:"net_profit"` OtherConsolidatedIncome float64 `db:"other_consolidated_income"` TotalConsolidatedIncome float64 `db:"total_consolidated_income"` CreatedAt time.Time `db:"created_at"` UpdatedAt time.Time `db:"updated_at"` }
ProfitStatement maps profit_statement table
func (ProfitStatement) Columns ¶
func (m ProfitStatement) Columns() []string
Columns returns the columns
func (ProfitStatement) DeleteBuilder ¶
func (m ProfitStatement) DeleteBuilder() *sqlbuilder.DeleteBuilder
DeleteBuilder returns a delete builder
func (ProfitStatement) InsertBuilder ¶
func (m ProfitStatement) InsertBuilder() *sqlbuilder.InsertBuilder
InsertBuilder returns an insert builder
func (ProfitStatement) SelectBuilder ¶
func (m ProfitStatement) SelectBuilder() *sqlbuilder.SelectBuilder
SelectBuilder returns a select builder
func (ProfitStatement) TableName ¶
func (m ProfitStatement) TableName() string
TableName returns the table name
func (ProfitStatement) UpdateBuilder ¶
func (m ProfitStatement) UpdateBuilder() *sqlbuilder.UpdateBuilder
UpdateBuilder returns an update builder
type ProfitStatements ¶
type ProfitStatements []ProfitStatement
ProfitStatements is ProfitStatement list
func (ProfitStatements) SelectBuilder ¶
func (ms ProfitStatements) SelectBuilder() *sqlbuilder.SelectBuilder
SelectBuilder returns a select builder
type Stock ¶
type Stock struct { Code string `db:"code"` Name string `db:"name"` MarketValue float64 `db:"market_value"` NegotiableValue float64 `db:"negotiable_value"` OpeningPrice float64 `db:"open"` ClosingPrice float64 `db:"close"` BottomPrice float64 `db:"low"` TopPrice float64 `db:"high"` LastPrice float64 `db:"last"` ChangeRate float64 `db:"rate"` TurnoverRate float64 `db:"ex"` TradeAmount float64 `db:"amount"` TradeVolume int64 `db:"volume"` PB float64 `db:"pb"` PE float64 `db:"pe"` IndustryCode string `db:"industry_code"` CreatedAt time.Time `db:"created_at"` UpdatedAt time.Time `db:"updated_at"` }
Stock maps stock table
func (Stock) DeleteBuilder ¶
func (m Stock) DeleteBuilder() *sqlbuilder.DeleteBuilder
DeleteBuilder returns a delete builder
func (Stock) GetIndustryName ¶
GetIndustryName gets industry name
func (Stock) InsertBuilder ¶
func (m Stock) InsertBuilder() *sqlbuilder.InsertBuilder
InsertBuilder returns an insert builder
func (Stock) SelectBuilder ¶
func (m Stock) SelectBuilder() *sqlbuilder.SelectBuilder
SelectBuilder returns a select builder
func (Stock) UpdateBuilder ¶
func (m Stock) UpdateBuilder() *sqlbuilder.UpdateBuilder
UpdateBuilder returns an update builder
type Stocks ¶
type Stocks []Stock
Stocks is stock list
func (Stocks) SelectBuilder ¶
func (ms Stocks) SelectBuilder() *sqlbuilder.SelectBuilder
SelectBuilder returns a select builder