-
Notifications
You must be signed in to change notification settings - Fork 0
/
fields_sheet.go
72 lines (61 loc) · 1.59 KB
/
fields_sheet.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
package OrgShareSpaceFileExcel
import (
"database/sql/driver"
"encoding/json"
"errors"
)
type FieldsSheetList []FieldsSheet
// Value sql底层处理器
func (t FieldsSheetList) Value() (driver.Value, error) {
return json.Marshal(t)
}
func (t *FieldsSheetList) Scan(value interface{}) error {
b, ok := value.([]byte)
if !ok {
return errors.New("type assertion to []byte failed")
}
return json.Unmarshal(b, &t)
}
type FieldsSheet struct {
//表名称
SheetName string `db:"sheet_name" json:"sheetName"`
//单元格内容列
Data FieldsSheetDataList `db:"data" json:"data"`
}
type FieldsSheetDataList []FieldsSheetData
// Value sql底层处理器
func (t FieldsSheetDataList) Value() (driver.Value, error) {
return json.Marshal(t)
}
func (t *FieldsSheetDataList) Scan(value interface{}) error {
b, ok := value.([]byte)
if !ok {
return errors.New("type assertion to []byte failed")
}
return json.Unmarshal(b, &t)
}
type FieldsSheetData struct {
//位置
Key string `db:"key" json:"key"`
//值
Val string `db:"val" json:"val"`
//合并附近单元格
// 当前单元格为原点,向右下侧开始衍生,如果为0则不合并
// 行
MargeRow int `db:"marge_row" json:"margeRow"`
// 列
MargeCel int `db:"marge_cel" json:"margeCel"`
//样式约定
Style string `db:"style" json:"style"`
}
// Value sql底层处理器
func (t FieldsSheetData) Value() (driver.Value, error) {
return json.Marshal(t)
}
func (t *FieldsSheetData) Scan(value interface{}) error {
b, ok := value.([]byte)
if !ok {
return errors.New("type assertion to []byte failed")
}
return json.Unmarshal(b, &t)
}