server

package
v0.0.0-...-441fd9a Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2023 License: MIT Imports: 32 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CodeErrorStart = iota + 100
	CodeProtocol
	CodeMissArgs
	CodeInvalidArgs
	CodeInternalError
	CodeVerifyFailed
	CodeInvalidToken
	CodeNeedAuth
	CodeDisabled
)
View Source
const (
	MsgNoRecordID = "缺失记录ID"
)

Variables

This section is empty.

Functions

func CodeToMessage

func CodeToMessage(code Code, msg string) string

func JSONMiddleware

func JSONMiddleware() gin.HandlerFunc

func RebuildBills

func RebuildBills() (err error)

Types

type BatchRecordRequest

type BatchRecordRequest struct {
	Records []RecordRequest `json:"records"`
}

func (*BatchRecordRequest) Valid

func (req *BatchRecordRequest) Valid() bool

type Bill

type Bill struct {
	ID                string        `json:"id"`
	FromSubWalletID   string        `json:"fromSubWalletID"`
	FromSubWalletName string        `json:"fromSubWalletName"`
	ToSubWalletID     string        `json:"toSubWalletID"`
	ToSubWalletName   string        `json:"toSubWalletName"`
	CostDir           model.CostDir `json:"costDir"`
	Amount            int           `json:"amount"`
	LabelIDs          []string      `json:"labelIDs"`
	LabelIDNames      []string      `json:"labelIDNames"`
	Remark            string        `json:"remark"`
	LossAmount        int           `json:"lossAmount"`
	LossWalletID      string        `json:"lossWalletID"`
	LossWalletName    string        `json:"lossWalletName"`
	At                int64         `json:"at"`
	AtS               string        `json:"atS"`

	FromPersonName string `json:"fromPersonName"`
	ToPersonName   string `json:"toPersonName"`
	OperationID    string `json:"operationID"`
	OperationName  string `json:"operationName"`
}

type Code

type Code int
const (
	CodeSuccess Code = iota
	CodeGroupNameExists
	CodeWalletNameExists
)

func (Code) String

func (c Code) String() string

type DeleteRecordRequest

type DeleteRecordRequest struct {
	RequestStat  bool     `json:"requestStat"`
	StatLabelIDs []string `json:"statLabelIDs"` // empty: all; [] 0: no label record; labelID: label id record

	DStatLabelIDs []uint64 `json:"-"`
}

func (*DeleteRecordRequest) Valid

func (req *DeleteRecordRequest) Valid() bool

type DeleteRecordResponse

type DeleteRecordResponse struct {
	DayStatistics    Statistics `json:"dayStatistics"`
	WeekStatistics   Statistics `json:"weekStatistics"`
	MonthStatistics  Statistics `json:"monthStatistics"`
	SeasonStatistics Statistics `json:"seasonStatistics"`
	YearStatistics   Statistics `json:"yearStatistics"`
}

type DeletedBill

type DeletedBill struct {
	Bill      `json:",inline"`
	DeletedAt string `json:"deletedAt"`
}

type GetBaseInfosResponse

type GetBaseInfosResponse struct {
	MerchantWallets []MerchantWallets `json:"merchantWallets"`
	SelfWallets     MerchantWallets   `json:"selfWallets"`
	Labels          []IDName          `json:"labels"`
	Groups          []IDName          `json:"groups"`
}

type GetDayRecordsRequest

type GetDayRecordsRequest struct {
	Year  int `json:"year"`
	Month int `json:"month"`
	Day   int `json:"day"`
}

func (*GetDayRecordsRequest) Valid

func (req *GetDayRecordsRequest) Valid() bool

type GetDayRecordsResponse

type GetDayRecordsResponse struct {
	Bills []Bill `json:"bills"`
}

type GetDeletedRecordsResponse

type GetDeletedRecordsResponse struct {
	Bills []DeletedBill `json:"bills"`
}

type GetRecordsRequest

type GetRecordsRequest struct {
	RecordID   string `json:"recordID"`
	PageCount  int    `json:"pageCount"`
	GroupID    string `json:"groupID"`
	NewForward bool   `json:"newForward"`

	RequestStat  bool     `json:"requestStat"`
	StatLabelIDs []string `json:"statLabelIDs"` // empty: all; [] 0: no label record; labelID: label id record

	DStatLabelIDs []uint64 `json:"-"`
}

func (*GetRecordsRequest) Valid

func (req *GetRecordsRequest) Valid() bool

type GetRecordsResponse

type GetRecordsResponse struct {
	Bills            []Bill     `json:"bills"`
	HasMore          bool       `json:"hasMore"`
	DayStatistics    Statistics `json:"dayStatistics"`
	WeekStatistics   Statistics `json:"weekStatistics"`
	MonthStatistics  Statistics `json:"monthStatistics"`
	SeasonStatistics Statistics `json:"seasonStatistics"`
	YearStatistics   Statistics `json:"yearStatistics"`
}

type GroupEnterCodesRequest

type GroupEnterCodesRequest struct {
	GroupID string `json:"groupID"`
	Count   int    `json:"count"`
}

func (*GroupEnterCodesRequest) Valid

func (req *GroupEnterCodesRequest) Valid() bool

type GroupEnterCodesResponse

type GroupEnterCodesResponse struct {
	EnterCodes []string `json:"enterCodes"`
	ExpireAt   int64    `json:"expireAt"`
	ExpireAtS  string   `json:"expireAtS"`
}

type GroupNewRequest

type GroupNewRequest struct {
	Name string
}

func (*GroupNewRequest) Valid

func (req *GroupNewRequest) Valid() bool

type GroupNewResponse

type GroupNewResponse struct {
	ID string `json:"id"`
}

type IDName

type IDName struct {
	ID   string `json:"id"`
	Name string `json:"name"`
}

type LoginRequest

type LoginRequest struct {
	UserName string `json:"userName"`
	Password string `json:"password"`
}

func (*LoginRequest) Valid

func (req *LoginRequest) Valid() bool

type LoginResponse

type LoginResponse struct {
	ID    string `json:"id"`
	Token string `json:"token"`
}

type MerchantWallets

type MerchantWallets struct {
	PersonID   string            `json:"personID"`
	PersonName string            `json:"personName"`
	CostDir    model.CostDir     `json:"costDir"`
	Wallets    []*WalletWithInfo `json:"wallets"`
}

type PersonWallets

type PersonWallets struct {
	PersonID   string            `json:"personID"`
	PersonName string            `json:"personName"`
	Wallets    []*WalletWithInfo `json:"wallets"`
}

type RecordRequest

type RecordRequest struct {
	FromSubWalletID string   `json:"fromSubWalletID"`
	ToSubWalletID   string   `json:"toSubWalletID"`
	Amount          int      `json:"amount"`
	LabelIDs        []string `json:"labelIDs"`
	Remark          string   `json:"remark"`
	LossAmount      int      `json:"lossAmount"`
	LossWalletID    string   `json:"lossWalletID"`
	At              int64    `json:"at"`

	DFromSubWalletID uint64   `json:"-"`
	DToSubWalletID   uint64   `json:"-"`
	DLabelIDs        []uint64 `json:"-"`
	DLossWalletID    uint64   `json:"-"`
}

func (*RecordRequest) Valid

func (req *RecordRequest) Valid() (ok bool)

type RegisterRequest

type RegisterRequest struct {
	UserName string `json:"userName"`
	Password string `json:"password"`
}

func (*RegisterRequest) Valid

func (req *RegisterRequest) Valid() bool

type RegisterResponse

type RegisterResponse struct {
	ID    string `json:"id"`
	Token string `json:"token"`
}

type ResponseWrapper

type ResponseWrapper struct {
	Code    Code        `json:"code"`
	Message string      `json:"message"`
	Resp    interface{} `json:"resp,omitempty"`
}

func (*ResponseWrapper) Apply

func (wr *ResponseWrapper) Apply(code Code, msg string)

type Server

type Server struct {
	// contains filtered or unexported fields
}

func NewServer

func NewServer(ctx context.Context, routineMan routineman.RoutineMan, cfg *config.Config, logger l.Wrapper) *Server

func (*Server) Wait

func (s *Server) Wait()

type StatAllResponse

type StatAllResponse struct {
	Years []StatYear `json:"years"`
}

type StatMonth

type StatMonth struct {
	Month int                  `json:"month"`
	Stat  ex.LifeCostTotalData `json:"stat"`
	Weeks []StatWeek           `json:"weeks"`
}

type StatSeason

type StatSeason struct {
	Season int                  `json:"season"`
	Stat   ex.LifeCostTotalData `json:"stat"`
	Months []StatMonth          `json:"months"`
}

type StatWeek

type StatWeek struct {
	Week int                  `json:"week"`
	Stat ex.LifeCostTotalData `json:"stat"`
	Days []StatWeekDay        `json:"days"`
}

type StatWeekDay

type StatWeekDay struct {
	WeekDay  int                  `json:"weekDay"`
	MonthDay int                  `json:"monthDay"`
	Stat     ex.LifeCostTotalData `json:"stat"`
}

type StatYear

type StatYear struct {
	Year    int                  `json:"year"`
	Stat    ex.LifeCostTotalData `json:"stat"`
	Seasons []StatSeason         `json:"seasons"`
}

type Statistics

type Statistics struct {
	IncomingCount   int `json:"incomingCount"`
	OutgoingCount   int `json:"outgoingCount"`
	GroupTransCount int `json:"groupTransCount"`

	IncomingAmount int `json:"incomingAmount"`
	OutgoingAmount int `json:"outgoingAmount"`
}

type StatisticsResponse

type StatisticsResponse struct {
	DayStatistics    Statistics `json:"dayStatistics"`
	WeekStatistics   Statistics `json:"weekStatistics"`
	MonthStatistics  Statistics `json:"monthStatistics"`
	SeasonStatistics Statistics `json:"seasonStatistics"`
	YearStatistics   Statistics `json:"yearStatistics"`
}

type WalletNewByDirRequest

type WalletNewByDirRequest struct {
	GroupID       string        `json:"groupID"`
	NewWalletName string        `json:"newWalletName"`
	Dir           model.CostDir `json:"dir"`
}

func (*WalletNewByDirRequest) Valid

func (req *WalletNewByDirRequest) Valid() bool

type WalletNewRequest

type WalletNewRequest struct {
	Name string `json:"name"`
}

func (*WalletNewRequest) Valid

func (req *WalletNewRequest) Valid() bool

type WalletNewResponse

type WalletNewResponse struct {
	ID string `json:"id"`
}

type WalletWithInfo

type WalletWithInfo struct {
	ID   string `json:"id"`
	Name string `json:"name"`
}

Jump to

Keyboard shortcuts

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