Skip to content

Commit efdbe9d

Browse files
go fmt
1 parent 49951ec commit efdbe9d

11 files changed

Lines changed: 50 additions & 49 deletions

File tree

account_book.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ type AccountBook struct {
88
Projects []IdName
99
}
1010

11-
//根据科目名获取科目ID为索引的Map
11+
// 根据科目名获取科目ID为索引的Map
1212
func (accountBook AccountBook) CategoryIdMap() map[int]Category {
1313
m := make(map[int]Category)
1414
for _, category := range accountBook.Categories {
@@ -18,7 +18,7 @@ func (accountBook AccountBook) CategoryIdMap() map[int]Category {
1818
return m
1919
}
2020

21-
//根据科目名获取科目ID
21+
// 根据科目名获取科目ID
2222
func (accountBook AccountBook) CategoryIdByName(name string) int {
2323
for _, item := range accountBook.Categories {
2424
if item.Name == name {
@@ -29,7 +29,7 @@ func (accountBook AccountBook) CategoryIdByName(name string) int {
2929
return 0
3030
}
3131

32-
//根据商户名获取商户ID
32+
// 根据商户名获取商户ID
3333
func (accountBook AccountBook) StoreIdByName(name string) int {
3434
for _, item := range accountBook.Stores {
3535
if item.Name == name {
@@ -40,7 +40,7 @@ func (accountBook AccountBook) StoreIdByName(name string) int {
4040
return 0
4141
}
4242

43-
//根据成员名获取成员ID
43+
// 根据成员名获取成员ID
4444
func (accountBook AccountBook) MemberIdByName(name string) int {
4545
for _, item := range accountBook.Members {
4646
if item.Name == name {
@@ -51,7 +51,7 @@ func (accountBook AccountBook) MemberIdByName(name string) int {
5151
return 0
5252
}
5353

54-
//根据账户名获取账户ID
54+
// 根据账户名获取账户ID
5555
func (accountBook AccountBook) AccountIdByName(name string) int {
5656
for _, item := range accountBook.Accounts {
5757
if item.Name == name {
@@ -62,7 +62,7 @@ func (accountBook AccountBook) AccountIdByName(name string) int {
6262
return 0
6363
}
6464

65-
//根据项目名获取项目ID
65+
// 根据项目名获取项目ID
6666
func (accountBook AccountBook) ProjectIdByName(name string) int {
6767
for _, item := range accountBook.Projects {
6868
if item.Name == name {

account_book_api.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
"github.com/PuerkitoBio/goquery"
1010
)
1111

12-
//刷新账本列表
12+
// 刷新账本列表
1313
func (cli *Client) SyncAccountBookList() error {
1414
resp, err := cli.Get(BaseUrl + "/report_index.do")
1515
if err != nil {
@@ -43,7 +43,7 @@ func (cli *Client) SyncAccountBookList() error {
4343
return nil
4444
}
4545

46-
//切换账本
46+
// 切换账本
4747
func (cli *Client) SwitchAccountBook(name string) error {
4848
var accountBookId int
4949
for _, accountBook := range cli.AccountBookList {

bill.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
"io/ioutil"
1111
)
1212

13-
//周期账手动入账
13+
// 周期账手动入账
1414
func (cli *Client) BillEntry(id int, day time.Time, money float64) (string, error) {
1515
data := url.Values{}
1616
data.Set("opt", "entry")

category.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ import (
88
"github.com/PuerkitoBio/goquery"
99
)
1010

11-
//账单科目
11+
// 账单科目
1212
type Category struct {
1313
IdName
1414
Type int //科目类别:支出或收入,参见TranTypeXXX常量
1515
IsSub bool //是否是子科目
1616
SubIds []int
1717
}
1818

19-
//初始化账本、分类、账户、商家、项目、成员等信息
19+
// 初始化账本、分类、账户、商家、项目、成员等信息
2020
func (cli *Client) SyncMetaInfo() error {
2121
resp, err := cli.Get(BaseUrl + "/tally/new.do")
2222
if err != nil {
@@ -45,7 +45,7 @@ func (cli *Client) SyncMetaInfo() error {
4545
return nil
4646
}
4747

48-
//解析HTML文档生成科目s
48+
// 解析HTML文档生成科目s
4949
func parseCategories(doc *goquery.Selection) []Category {
5050
categories := []Category{}
5151
anchors := doc.Find("div#panel-category a")
@@ -83,7 +83,7 @@ func parseCategories(doc *goquery.Selection) []Category {
8383
return categories
8484
}
8585

86-
//解析HTML文档生成类别s
86+
// 解析HTML文档生成类别s
8787
func parseIdNames(doc *goquery.Selection, zone string) []IdName {
8888
prefix := "c" + strings.Title(zone[:3]) + "-"
8989

@@ -107,7 +107,7 @@ func parseIdNames(doc *goquery.Selection, zone string) []IdName {
107107
return idNames
108108
}
109109

110-
//从cCat-???-??????-a格式的字符串中提取科目ID和类型
110+
// 从cCat-???-??????-a格式的字符串中提取科目ID和类型
111111
func categoryIdTypeSplit(idStr string) (int, int) {
112112
idStr = strings.TrimSuffix(idStr, "-a")
113113

client.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,26 @@ import (
66
"os"
77
)
88

9-
//请求的基础链接地址
9+
// 请求的基础链接地址
1010
const (
1111
BaseUrl = "https://www.sui.com"
1212
LoginUrl = "https://login.sui.com"
1313
)
1414

15-
//交易类型
15+
// 交易类型
1616
const (
1717
TranTypePayout = 1 //支出
1818
TranTypeTransfer = 2 //转账
1919
TranTypeIncome = 5 //收入
2020
)
2121

22-
//多个响应使用的分页结构
22+
// 多个响应使用的分页结构
2323
type PageInfo struct {
2424
PageCount int
2525
PageNo int
2626
}
2727

28-
//多个响应使用的日期结构
28+
// 多个响应使用的日期结构
2929
type DateInfo struct {
3030
Year int //从1900算起第N年
3131
Month int //从0开始的月份
@@ -38,19 +38,19 @@ type DateInfo struct {
3838
TimezoneOffset int //与UTC时间的相差的小时数
3939
}
4040

41-
//包含ID、Name两个属性的结构
41+
// 包含ID、Name两个属性的结构
4242
type IdName struct {
4343
Id int
4444
Name string
4545
}
4646

47-
//包含收入、支出两个属性的结构
47+
// 包含收入、支出两个属性的结构
4848
type IncomeAndPayout struct {
4949
Income float32
5050
Payout float32
5151
}
5252

53-
//执行操作的Feidee客户端
53+
// 执行操作的Feidee客户端
5454
type Client struct {
5555
httpClient *http.Client
5656
Verbose bool

data.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
"github.com/PuerkitoBio/goquery"
99
)
1010

11-
//数据导出到文件(随手记WEB版格式的xls文件)
11+
// 数据导出到文件(随手记WEB版格式的xls文件)
1212
func (cli *Client) ExportToFile(filename string) error {
1313
b, err := cli.ExportToBuffer()
1414
if err != nil {
@@ -34,7 +34,7 @@ func (cli *Client) ExportToBuffer() ([]byte, error) {
3434
return ioutil.ReadAll(resp.Body)
3535
}
3636

37-
//获取数据导出的链接(导出为随手记WEB版格式的xls文件)
37+
// 获取数据导出的链接(导出为随手记WEB版格式的xls文件)
3838
func (cli *Client) GetExportLink() (string, error) {
3939
addr := BaseUrl + "/data/index.jsp"
4040
resp, err := cli.Get(addr)

example/exporter/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//随手记导出工具
1+
// 随手记导出工具
22
package main
33

44
import (

login.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ import (
1212
"github.com/PuerkitoBio/goquery"
1313
)
1414

15-
//自动跳转以刷新认证信息时,最大的递归调用次数
15+
// 自动跳转以刷新认证信息时,最大的递归调用次数
1616
const MaxAuthRedirectCount = 5
1717

18-
//登录
18+
// 登录
1919
func (cli *Client) login(email, password string) error {
2020
vccodeInfo, err := cli.getVccode()
2121
if err != nil {
@@ -44,7 +44,7 @@ type VCCodeInfo struct {
4444
Uid string
4545
}
4646

47-
//获取VCCode
47+
// 获取VCCode
4848
func (cli *Client) getVccode() (VCCodeInfo, error) {
4949
resp, err := cli.Get(LoginUrl + "/login.do?opt=vccode")
5050
if err != nil {
@@ -69,7 +69,7 @@ func (cli *Client) getVccode() (VCCodeInfo, error) {
6969
return respInfo, nil
7070
}
7171

72-
//鉴定用户
72+
// 鉴定用户
7373
func (cli *Client) verifyUser(vccodeInfo VCCodeInfo, email, password string) error {
7474
//密码加密处理
7575
password = hexSha1(password)
@@ -108,7 +108,7 @@ func (cli *Client) verifyUser(vccodeInfo VCCodeInfo, email, password string) err
108108
}
109109
}
110110

111-
//自动跟踪认证跳转,完成验证信息刷新
111+
// 自动跟踪认证跳转,完成验证信息刷新
112112
func (cli *Client) authRedirect(method, address string, data url.Values, jumpCount int) error {
113113
if cli.Verbose {
114114
log.Println("第", jumpCount, "次认证跳转", method, address, "参数", data)
@@ -163,7 +163,7 @@ func (cli *Client) authRedirect(method, address string, data url.Values, jumpCou
163163
return cli.authRedirect(formMethod, formAction, formData, jumpCount+1)
164164
}
165165

166-
//密码加密,算法来自于: https://www.feidee.com/sso/js/fdLogin.js中的hex_sha1
166+
// 密码加密,算法来自于: https://www.feidee.com/sso/js/fdLogin.js中的hex_sha1
167167
func hexSha1(input string) string {
168168
sha1Sum := sha1.Sum([]byte(input))
169169
return hex.EncodeToString(sha1Sum[:])

report.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
"time"
99
)
1010

11-
//对账报表
11+
// 对账报表
1212
type CompareInfo struct {
1313
Balance float32 //当前余额
1414
DayBalance float32 //当日余额(当日收入-当日支出)
@@ -23,13 +23,13 @@ type CompareInfo struct {
2323
Date DateInfo
2424
}
2525

26-
//报表页响应
26+
// 报表页响应
2727
type CompareReportResponse struct {
2828
PageInfo
2929
List []CompareInfo
3030
}
3131

32-
//获取所有对账报表
32+
// 获取所有对账报表
3333
func (cli *Client) CompareReport(accountId int, begin, end time.Time) ([]CompareInfo, error) {
3434
pageCount := 1
3535
list := []CompareInfo{}
@@ -45,7 +45,7 @@ func (cli *Client) CompareReport(accountId int, begin, end time.Time) ([]Compare
4545
return list, nil
4646
}
4747

48-
//获取单页对账报表
48+
// 获取单页对账报表
4949
func (cli *Client) CompareReportByPage(accountId int, begin, end time.Time, page int) (CompareReportResponse, error) {
5050
data := url.Values{}
5151
data.Set("m", "compare")
@@ -69,7 +69,7 @@ func (cli *Client) CompareReportByPage(accountId int, begin, end time.Time, page
6969
return respInfo, nil
7070
}
7171

72-
//日常收支报表
72+
// 日常收支报表
7373
type DailyReportList []struct {
7474
IdName
7575
Total float32
@@ -91,7 +91,7 @@ type DailyReport struct {
9191
OutList DailyReportList `json:"outlst"`
9292
}
9393

94-
//日常收支报表
94+
// 日常收支报表
9595
func (cli *Client) DailyReport(begin, end time.Time, params url.Values) (DailyReport, error) {
9696
if params == nil {
9797
params = url.Values{}

tally.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66
"strconv"
77
)
88

9-
//流水信息
9+
// 流水信息
1010
type Tally struct {
1111
Account int
1212
BuyerAcount string //支出、收入时为交易账户,转账时为转出账户
@@ -37,7 +37,7 @@ type Tally struct {
3737
Date DateInfo
3838
}
3939

40-
//生成用于更新的url.Values参数
40+
// 生成用于更新的url.Values参数
4141
func (t Tally) ToUpdateParams() url.Values {
4242
data := url.Values{}
4343

0 commit comments

Comments
 (0)