正在显示
21 个修改的文件
包含
451 行增加
和
116 行删除
@@ -2,19 +2,30 @@ package command | @@ -2,19 +2,30 @@ package command | ||
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | "fmt" | 4 | "fmt" |
5 | + "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/domain" | ||
5 | 6 | ||
6 | "github.com/astaxie/beego/validation" | 7 | "github.com/astaxie/beego/validation" |
7 | ) | 8 | ) |
8 | 9 | ||
9 | type CreateColumnSettingCommand struct { | 10 | type CreateColumnSettingCommand struct { |
11 | + // 公司id | ||
12 | + CompanyId int `json:"companyId"` | ||
13 | + // 用户uid | ||
14 | + Uid int64 `json:"uid"` | ||
10 | // 栏目设置描述 | 15 | // 栏目设置描述 |
11 | Description string `json:"description" valid:"Required"` | 16 | Description string `json:"description" valid:"Required"` |
12 | // 栏目设置关联用户名称 | 17 | // 栏目设置关联用户名称 |
13 | UserName string `json:"userName" valid:"Required"` | 18 | UserName string `json:"userName" valid:"Required"` |
19 | + // 默认栏目设置 | ||
20 | + Value []domain.Column `json:"value"` | ||
21 | + // 无效栏目设置爱 | ||
22 | + InvalidValue []domain.Column `json:"invalidValue"` | ||
23 | + // 模块键值 | ||
24 | + Key string `json:"key"` | ||
14 | } | 25 | } |
15 | 26 | ||
16 | func (createColumnSettingCommand *CreateColumnSettingCommand) Valid(validation *validation.Validation) { | 27 | func (createColumnSettingCommand *CreateColumnSettingCommand) Valid(validation *validation.Validation) { |
17 | - validation.SetError("CustomValid", "未实现的自定义认证") | 28 | + _ = validation.SetError("CustomValid", "未实现的自定义认证") |
18 | } | 29 | } |
19 | 30 | ||
20 | func (createColumnSettingCommand *CreateColumnSettingCommand) ValidateCommand() error { | 31 | func (createColumnSettingCommand *CreateColumnSettingCommand) ValidateCommand() error { |
@@ -9,6 +9,10 @@ import ( | @@ -9,6 +9,10 @@ import ( | ||
9 | type RemoveColumnSettingCommand struct { | 9 | type RemoveColumnSettingCommand struct { |
10 | // 栏目设置id | 10 | // 栏目设置id |
11 | ColumnSettingId int64 `json:"columnSettingId" valid:"Required"` | 11 | ColumnSettingId int64 `json:"columnSettingId" valid:"Required"` |
12 | + // 用户uid | ||
13 | + Uid int64 `json:"uid"` | ||
14 | + // 公司id | ||
15 | + CompanyId int `json:"companyId"` | ||
12 | } | 16 | } |
13 | 17 | ||
14 | func (removeColumnSettingCommand *RemoveColumnSettingCommand) Valid(validation *validation.Validation) { | 18 | func (removeColumnSettingCommand *RemoveColumnSettingCommand) Valid(validation *validation.Validation) { |
@@ -2,15 +2,24 @@ package command | @@ -2,15 +2,24 @@ package command | ||
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | "fmt" | 4 | "fmt" |
5 | + "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/domain" | ||
5 | 6 | ||
6 | "github.com/astaxie/beego/validation" | 7 | "github.com/astaxie/beego/validation" |
7 | ) | 8 | ) |
8 | 9 | ||
9 | type ResetColumnCommand struct { | 10 | type ResetColumnCommand struct { |
11 | + // 公司id | ||
12 | + CompanyId int `json:"companyId"` | ||
13 | + // 用户uid | ||
14 | + Uid int64 `json:"uid"` | ||
15 | + // 默认栏目 | ||
16 | + Value []domain.Column `json:"value"` | ||
17 | + // 默认无效栏目 | ||
18 | + InvalidValue []domain.Column `json:"invalidValue"` | ||
10 | } | 19 | } |
11 | 20 | ||
12 | func (resetColumnCommand *ResetColumnCommand) Valid(validation *validation.Validation) { | 21 | func (resetColumnCommand *ResetColumnCommand) Valid(validation *validation.Validation) { |
13 | - validation.SetError("CustomValid", "未实现的自定义认证") | 22 | + _ = validation.SetError("CustomValid", "未实现的自定义认证") |
14 | } | 23 | } |
15 | 24 | ||
16 | func (resetColumnCommand *ResetColumnCommand) ValidateCommand() error { | 25 | func (resetColumnCommand *ResetColumnCommand) ValidateCommand() error { |
@@ -2,17 +2,30 @@ package command | @@ -2,17 +2,30 @@ package command | ||
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | "fmt" | 4 | "fmt" |
5 | + "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/domain" | ||
5 | 6 | ||
6 | "github.com/astaxie/beego/validation" | 7 | "github.com/astaxie/beego/validation" |
7 | ) | 8 | ) |
8 | 9 | ||
9 | type UpdateColumnSettingCommand struct { | 10 | type UpdateColumnSettingCommand struct { |
10 | // 栏目设置id | 11 | // 栏目设置id |
11 | - ColumnSettingId int64 `json:"columnSettingId" valid:"Required"` | 12 | + ColumnSettingId int64 `json:"columnSettingId"` |
13 | + // 公司id | ||
14 | + CompanyId int `json:"companyId"` | ||
15 | + // 用户uid | ||
16 | + Uid int64 `json:"uid"` | ||
17 | + // 选中的栏目 | ||
18 | + Selected []domain.Column `json:"selected"` | ||
19 | + // 未选中的栏目 | ||
20 | + UnSelected []domain.Column `json:"unselected"` | ||
21 | + // 栏目设置 | ||
22 | + Value []domain.Column `json:"value"` | ||
23 | + // 无效栏目设置 | ||
24 | + InvalidValue []domain.Column `json:"invalidValue"` | ||
12 | } | 25 | } |
13 | 26 | ||
14 | func (updateColumnSettingCommand *UpdateColumnSettingCommand) Valid(validation *validation.Validation) { | 27 | func (updateColumnSettingCommand *UpdateColumnSettingCommand) Valid(validation *validation.Validation) { |
15 | - validation.SetError("CustomValid", "未实现的自定义认证") | 28 | + _ = validation.SetError("CustomValid", "未实现的自定义认证") |
16 | } | 29 | } |
17 | 30 | ||
18 | func (updateColumnSettingCommand *UpdateColumnSettingCommand) ValidateCommand() error { | 31 | func (updateColumnSettingCommand *UpdateColumnSettingCommand) ValidateCommand() error { |
@@ -8,7 +8,11 @@ import ( | @@ -8,7 +8,11 @@ import ( | ||
8 | 8 | ||
9 | type GetColumnSettingQuery struct { | 9 | type GetColumnSettingQuery struct { |
10 | // 栏目设置id | 10 | // 栏目设置id |
11 | - ColumnSettingId int64 `json:"columnSettingId" valid:"Required"` | 11 | + ColumnSettingId int64 `json:"columnSettingId"` |
12 | + // 公司id | ||
13 | + CompanyId int `json:"companyId"` | ||
14 | + // 用户uid | ||
15 | + Uid int64 `json:"uid"` | ||
12 | } | 16 | } |
13 | 17 | ||
14 | func (getColumnSettingQuery *GetColumnSettingQuery) Valid(validation *validation.Validation) { | 18 | func (getColumnSettingQuery *GetColumnSettingQuery) Valid(validation *validation.Validation) { |
@@ -14,7 +14,7 @@ type ListColumnSettingQuery struct { | @@ -14,7 +14,7 @@ type ListColumnSettingQuery struct { | ||
14 | } | 14 | } |
15 | 15 | ||
16 | func (listColumnSettingQuery *ListColumnSettingQuery) Valid(validation *validation.Validation) { | 16 | func (listColumnSettingQuery *ListColumnSettingQuery) Valid(validation *validation.Validation) { |
17 | - validation.SetError("CustomValid", "未实现的自定义认证") | 17 | + _ = validation.SetError("CustomValid", "未实现的自定义认证") |
18 | } | 18 | } |
19 | 19 | ||
20 | func (listColumnSettingQuery *ListColumnSettingQuery) ValidateQuery() error { | 20 | func (listColumnSettingQuery *ListColumnSettingQuery) ValidateQuery() error { |
@@ -7,14 +7,23 @@ import ( | @@ -7,14 +7,23 @@ import ( | ||
7 | "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/application/columnSetting/command" | 7 | "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/application/columnSetting/command" |
8 | "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/application/columnSetting/query" | 8 | "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/application/columnSetting/query" |
9 | "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/application/factory" | 9 | "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/application/factory" |
10 | + "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/constant" | ||
10 | "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/domain" | 11 | "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/domain" |
12 | + "strconv" | ||
13 | + "time" | ||
11 | ) | 14 | ) |
12 | 15 | ||
13 | // 栏目设置 | 16 | // 栏目设置 |
14 | type ColumnSettingService struct { | 17 | type ColumnSettingService struct { |
15 | } | 18 | } |
16 | 19 | ||
17 | -// 创建栏目设置增删改查 | 20 | +/** |
21 | + * @Author SteveChan | ||
22 | + * @Description //TODO 新增用户时,初始化栏目设置 | ||
23 | + * @Date 23:13 2021/1/26 | ||
24 | + * @Param | ||
25 | + * @return | ||
26 | + **/ | ||
18 | func (columnSettingService *ColumnSettingService) CreateColumnSetting(createColumnSettingCommand *command.CreateColumnSettingCommand) (interface{}, error) { | 27 | func (columnSettingService *ColumnSettingService) CreateColumnSetting(createColumnSettingCommand *command.CreateColumnSettingCommand) (interface{}, error) { |
19 | if err := createColumnSettingCommand.ValidateCommand(); err != nil { | 28 | if err := createColumnSettingCommand.ValidateCommand(); err != nil { |
20 | return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | 29 | return nil, application.ThrowError(application.ARG_ERROR, err.Error()) |
@@ -23,35 +32,48 @@ func (columnSettingService *ColumnSettingService) CreateColumnSetting(createColu | @@ -23,35 +32,48 @@ func (columnSettingService *ColumnSettingService) CreateColumnSetting(createColu | ||
23 | if err != nil { | 32 | if err != nil { |
24 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 33 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
25 | } | 34 | } |
26 | - if err := transactionContext.StartTransaction(); err != nil { | ||
27 | - return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 35 | + if errStart := transactionContext.StartTransaction(); errStart != nil { |
36 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, errStart.Error()) | ||
28 | } | 37 | } |
29 | defer func() { | 38 | defer func() { |
30 | - transactionContext.RollbackTransaction() | 39 | + _ = transactionContext.RollbackTransaction() |
31 | }() | 40 | }() |
32 | newColumnSetting := &domain.ColumnSetting{ | 41 | newColumnSetting := &domain.ColumnSetting{ |
33 | - Description: createColumnSettingCommand.Description, | ||
34 | - UserName: createColumnSettingCommand.UserName, | 42 | + Description: createColumnSettingCommand.Description, |
43 | + UserName: createColumnSettingCommand.UserName, | ||
44 | + CompanyId: createColumnSettingCommand.CompanyId, | ||
45 | + Uid: createColumnSettingCommand.Uid, | ||
46 | + Key: constant.ORDER_BASE, // 订单栏目模块名称 | ||
47 | + Value: domain.DefaultColumns, // 栏目值数组,创建用户时使用默认栏目设置 | ||
48 | + InvalidValue: domain.DefaultInvalidColumns, // 初始化无效栏目数组 | ||
49 | + CreatedAt: time.Now(), | ||
50 | + UpdatedAt: time.Now(), | ||
35 | } | 51 | } |
36 | var columnSettingRepository domain.ColumnSettingRepository | 52 | var columnSettingRepository domain.ColumnSettingRepository |
37 | - if value, err := factory.CreateColumnSettingRepository(map[string]interface{}{ | 53 | + if value, errFac := factory.CreateColumnSettingRepository(map[string]interface{}{ |
38 | "transactionContext": transactionContext, | 54 | "transactionContext": transactionContext, |
39 | - }); err != nil { | ||
40 | - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 55 | + }); errFac != nil { |
56 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, errFac.Error()) | ||
41 | } else { | 57 | } else { |
42 | columnSettingRepository = value | 58 | columnSettingRepository = value |
43 | } | 59 | } |
44 | - if columnSetting, err := columnSettingRepository.Save(newColumnSetting); err != nil { | ||
45 | - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 60 | + if columnSetting, errSaved := columnSettingRepository.Save(newColumnSetting); errSaved != nil { |
61 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, errSaved.Error()) | ||
46 | } else { | 62 | } else { |
47 | - if err := transactionContext.CommitTransaction(); err != nil { | ||
48 | - return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 63 | + if errCommit := transactionContext.CommitTransaction(); errCommit != nil { |
64 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, errCommit.Error()) | ||
49 | } | 65 | } |
50 | return columnSetting, nil | 66 | return columnSetting, nil |
51 | } | 67 | } |
52 | } | 68 | } |
53 | 69 | ||
54 | -// 返回栏目设置增删改查 | 70 | +/** |
71 | + * @Author SteveChan | ||
72 | + * @Description //TODO 返回栏目设置 | ||
73 | + * @Date 23:14 2021/1/26 | ||
74 | + * @Param | ||
75 | + * @return | ||
76 | + **/ | ||
55 | func (columnSettingService *ColumnSettingService) GetColumnSetting(getColumnSettingQuery *query.GetColumnSettingQuery) (interface{}, error) { | 77 | func (columnSettingService *ColumnSettingService) GetColumnSetting(getColumnSettingQuery *query.GetColumnSettingQuery) (interface{}, error) { |
56 | if err := getColumnSettingQuery.ValidateQuery(); err != nil { | 78 | if err := getColumnSettingQuery.ValidateQuery(); err != nil { |
57 | return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | 79 | return nil, application.ThrowError(application.ARG_ERROR, err.Error()) |
@@ -64,27 +86,27 @@ func (columnSettingService *ColumnSettingService) GetColumnSetting(getColumnSett | @@ -64,27 +86,27 @@ func (columnSettingService *ColumnSettingService) GetColumnSetting(getColumnSett | ||
64 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 86 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
65 | } | 87 | } |
66 | defer func() { | 88 | defer func() { |
67 | - transactionContext.RollbackTransaction() | 89 | + _ = transactionContext.RollbackTransaction() |
68 | }() | 90 | }() |
69 | var columnSettingRepository domain.ColumnSettingRepository | 91 | var columnSettingRepository domain.ColumnSettingRepository |
70 | - if value, err := factory.CreateColumnSettingRepository(map[string]interface{}{ | 92 | + if value, errFact := factory.CreateColumnSettingRepository(map[string]interface{}{ |
71 | "transactionContext": transactionContext, | 93 | "transactionContext": transactionContext, |
72 | - }); err != nil { | ||
73 | - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 94 | + }); errFact != nil { |
95 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, errFact.Error()) | ||
74 | } else { | 96 | } else { |
75 | columnSettingRepository = value | 97 | columnSettingRepository = value |
76 | } | 98 | } |
77 | - columnSetting, err := columnSettingRepository.FindOne(map[string]interface{}{"column_settingId": getColumnSettingQuery.ColumnSettingId}) | 99 | + columnSettingFound, err := columnSettingRepository.FindOne(map[string]interface{}{"uid": getColumnSettingQuery.Uid, "companyId": getColumnSettingQuery.CompanyId}) |
78 | if err != nil { | 100 | if err != nil { |
79 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 101 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
80 | } | 102 | } |
81 | - if columnSetting == nil { | ||
82 | - return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(getColumnSettingQuery.ColumnSettingId))) | 103 | + if columnSettingFound == nil { |
104 | + return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", strconv.FormatInt(getColumnSettingQuery.Uid, 10))) | ||
83 | } else { | 105 | } else { |
84 | - if err := transactionContext.CommitTransaction(); err != nil { | ||
85 | - return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 106 | + if errCommit := transactionContext.CommitTransaction(); errCommit != nil { |
107 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, errCommit.Error()) | ||
86 | } | 108 | } |
87 | - return columnSetting, nil | 109 | + return columnSettingFound, nil |
88 | } | 110 | } |
89 | } | 111 | } |
90 | 112 | ||
@@ -124,7 +146,13 @@ func (columnSettingService *ColumnSettingService) ListColumnSetting(listColumnSe | @@ -124,7 +146,13 @@ func (columnSettingService *ColumnSettingService) ListColumnSetting(listColumnSe | ||
124 | } | 146 | } |
125 | } | 147 | } |
126 | 148 | ||
127 | -// 移除栏目设置增删改查 | 149 | +/** |
150 | + * @Author SteveChan | ||
151 | + * @Description //TODO 删除用户时移除栏目设置 | ||
152 | + * @Date 23:14 2021/1/26 | ||
153 | + * @Param | ||
154 | + * @return | ||
155 | + **/ | ||
128 | func (columnSettingService *ColumnSettingService) RemoveColumnSetting(removeColumnSettingCommand *command.RemoveColumnSettingCommand) (interface{}, error) { | 156 | func (columnSettingService *ColumnSettingService) RemoveColumnSetting(removeColumnSettingCommand *command.RemoveColumnSettingCommand) (interface{}, error) { |
129 | if err := removeColumnSettingCommand.ValidateCommand(); err != nil { | 157 | if err := removeColumnSettingCommand.ValidateCommand(); err != nil { |
130 | return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | 158 | return nil, application.ThrowError(application.ARG_ERROR, err.Error()) |
@@ -137,7 +165,7 @@ func (columnSettingService *ColumnSettingService) RemoveColumnSetting(removeColu | @@ -137,7 +165,7 @@ func (columnSettingService *ColumnSettingService) RemoveColumnSetting(removeColu | ||
137 | return nil, application.ThrowError(application.TRANSACTION_ERROR, errSt.Error()) | 165 | return nil, application.ThrowError(application.TRANSACTION_ERROR, errSt.Error()) |
138 | } | 166 | } |
139 | defer func() { | 167 | defer func() { |
140 | - transactionContext.RollbackTransaction() | 168 | + _ = transactionContext.RollbackTransaction() |
141 | }() | 169 | }() |
142 | var columnSettingRepository domain.ColumnSettingRepository | 170 | var columnSettingRepository domain.ColumnSettingRepository |
143 | if value, errFac := factory.CreateColumnSettingRepository(map[string]interface{}{ | 171 | if value, errFac := factory.CreateColumnSettingRepository(map[string]interface{}{ |
@@ -147,14 +175,14 @@ func (columnSettingService *ColumnSettingService) RemoveColumnSetting(removeColu | @@ -147,14 +175,14 @@ func (columnSettingService *ColumnSettingService) RemoveColumnSetting(removeColu | ||
147 | } else { | 175 | } else { |
148 | columnSettingRepository = value | 176 | columnSettingRepository = value |
149 | } | 177 | } |
150 | - columnSetting, err := columnSettingRepository.FindOne(map[string]interface{}{"column_settingId": removeColumnSettingCommand.ColumnSettingId}) | 178 | + columnSettingFound, err := columnSettingRepository.FindOne(map[string]interface{}{"uid": removeColumnSettingCommand.Uid, "companyId": removeColumnSettingCommand.CompanyId}) |
151 | if err != nil { | 179 | if err != nil { |
152 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 180 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
153 | } | 181 | } |
154 | - if columnSetting == nil { | ||
155 | - return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(removeColumnSettingCommand.ColumnSettingId))) | 182 | + if columnSettingFound == nil { |
183 | + return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", strconv.FormatInt(removeColumnSettingCommand.Uid, 10))) | ||
156 | } | 184 | } |
157 | - if columnSettingRemoved, errRm := columnSettingRepository.Remove(columnSetting); errRm != nil { | 185 | + if columnSettingRemoved, _, errRm := columnSettingRepository.Remove(columnSettingFound, nil); errRm != nil { |
158 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, errRm.Error()) | 186 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, errRm.Error()) |
159 | } else { | 187 | } else { |
160 | if errTr := transactionContext.CommitTransaction(); errTr != nil { | 188 | if errTr := transactionContext.CommitTransaction(); errTr != nil { |
@@ -164,7 +192,13 @@ func (columnSettingService *ColumnSettingService) RemoveColumnSetting(removeColu | @@ -164,7 +192,13 @@ func (columnSettingService *ColumnSettingService) RemoveColumnSetting(removeColu | ||
164 | } | 192 | } |
165 | } | 193 | } |
166 | 194 | ||
167 | -// 重置栏目设置 | 195 | +/** |
196 | + * @Author SteveChan | ||
197 | + * @Description //TODO 重置栏目设置 | ||
198 | + * @Date 23:15 2021/1/26 | ||
199 | + * @Param | ||
200 | + * @return | ||
201 | + **/ | ||
168 | func (columnSettingService *ColumnSettingService) ResetColumn(resetColumnCommand *command.ResetColumnCommand) (interface{}, error) { | 202 | func (columnSettingService *ColumnSettingService) ResetColumn(resetColumnCommand *command.ResetColumnCommand) (interface{}, error) { |
169 | if err := resetColumnCommand.ValidateCommand(); err != nil { | 203 | if err := resetColumnCommand.ValidateCommand(); err != nil { |
170 | return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | 204 | return nil, application.ThrowError(application.ARG_ERROR, err.Error()) |
@@ -173,19 +207,48 @@ func (columnSettingService *ColumnSettingService) ResetColumn(resetColumnCommand | @@ -173,19 +207,48 @@ func (columnSettingService *ColumnSettingService) ResetColumn(resetColumnCommand | ||
173 | if err != nil { | 207 | if err != nil { |
174 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 208 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
175 | } | 209 | } |
176 | - if err := transactionContext.StartTransaction(); err != nil { | ||
177 | - return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 210 | + if errStart := transactionContext.StartTransaction(); errStart != nil { |
211 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, errStart.Error()) | ||
178 | } | 212 | } |
179 | defer func() { | 213 | defer func() { |
180 | - transactionContext.RollbackTransaction() | 214 | + _ = transactionContext.RollbackTransaction() |
181 | }() | 215 | }() |
182 | - if err := transactionContext.CommitTransaction(); err != nil { | ||
183 | - return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 216 | + |
217 | + var columnSettingRepository domain.ColumnSettingRepository | ||
218 | + if value, errFact := factory.CreateColumnSettingRepository(map[string]interface{}{ | ||
219 | + "transactionContext": transactionContext, | ||
220 | + }); errFact != nil { | ||
221 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, errFact.Error()) | ||
222 | + } else { | ||
223 | + columnSettingRepository = value | ||
224 | + } | ||
225 | + columnSettingFound, err := columnSettingRepository.FindOne(map[string]interface{}{"uid": resetColumnCommand.Uid, "companyId": resetColumnCommand.CompanyId}) | ||
226 | + if err != nil { | ||
227 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
228 | + } | ||
229 | + if columnSettingFound == nil { | ||
230 | + return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", strconv.FormatInt(resetColumnCommand.Uid, 10))) | ||
231 | + } | ||
232 | + if errUpdated := columnSettingFound.Update(tool_funs.SimpleStructToMap(resetColumnCommand)); errUpdated != nil { | ||
233 | + return nil, application.ThrowError(application.BUSINESS_ERROR, errUpdated.Error()) | ||
234 | + } | ||
235 | + if columnSettingSaved, errSaved := columnSettingRepository.Save(columnSettingFound); errSaved != nil { | ||
236 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, errSaved.Error()) | ||
237 | + } else { | ||
238 | + if errCommit := transactionContext.CommitTransaction(); errCommit != nil { | ||
239 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, errCommit.Error()) | ||
240 | + } | ||
241 | + return columnSettingSaved, nil | ||
184 | } | 242 | } |
185 | - return nil, nil | ||
186 | } | 243 | } |
187 | 244 | ||
188 | -// 更新栏目设置增删改查 | 245 | +/** |
246 | + * @Author SteveChan | ||
247 | + * @Description //TODO 更新栏目设置 | ||
248 | + * @Date 23:15 2021/1/26 | ||
249 | + * @Param | ||
250 | + * @return | ||
251 | + **/ | ||
189 | func (columnSettingService *ColumnSettingService) UpdateColumnSetting(updateColumnSettingCommand *command.UpdateColumnSettingCommand) (interface{}, error) { | 252 | func (columnSettingService *ColumnSettingService) UpdateColumnSetting(updateColumnSettingCommand *command.UpdateColumnSettingCommand) (interface{}, error) { |
190 | if err := updateColumnSettingCommand.ValidateCommand(); err != nil { | 253 | if err := updateColumnSettingCommand.ValidateCommand(); err != nil { |
191 | return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | 254 | return nil, application.ThrowError(application.ARG_ERROR, err.Error()) |
@@ -194,35 +257,37 @@ func (columnSettingService *ColumnSettingService) UpdateColumnSetting(updateColu | @@ -194,35 +257,37 @@ func (columnSettingService *ColumnSettingService) UpdateColumnSetting(updateColu | ||
194 | if err != nil { | 257 | if err != nil { |
195 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 258 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
196 | } | 259 | } |
197 | - if err := transactionContext.StartTransaction(); err != nil { | ||
198 | - return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 260 | + if errStart := transactionContext.StartTransaction(); errStart != nil { |
261 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, errStart.Error()) | ||
199 | } | 262 | } |
200 | defer func() { | 263 | defer func() { |
201 | - transactionContext.RollbackTransaction() | 264 | + _ = transactionContext.RollbackTransaction() |
202 | }() | 265 | }() |
203 | var columnSettingRepository domain.ColumnSettingRepository | 266 | var columnSettingRepository domain.ColumnSettingRepository |
204 | - if value, err := factory.CreateColumnSettingRepository(map[string]interface{}{ | 267 | + if value, errFact := factory.CreateColumnSettingRepository(map[string]interface{}{ |
205 | "transactionContext": transactionContext, | 268 | "transactionContext": transactionContext, |
206 | - }); err != nil { | ||
207 | - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 269 | + }); errFact != nil { |
270 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, errFact.Error()) | ||
208 | } else { | 271 | } else { |
209 | columnSettingRepository = value | 272 | columnSettingRepository = value |
210 | } | 273 | } |
211 | - columnSetting, err := columnSettingRepository.FindOne(map[string]interface{}{"column_settingId": updateColumnSettingCommand.ColumnSettingId}) | 274 | + updateColumnSettingCommand.Value = updateColumnSettingCommand.Selected |
275 | + updateColumnSettingCommand.InvalidValue = updateColumnSettingCommand.UnSelected | ||
276 | + columnSetting, err := columnSettingRepository.FindOne(map[string]interface{}{"uid": updateColumnSettingCommand.Uid, "companyId": updateColumnSettingCommand.CompanyId}) | ||
212 | if err != nil { | 277 | if err != nil { |
213 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 278 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
214 | } | 279 | } |
215 | if columnSetting == nil { | 280 | if columnSetting == nil { |
216 | - return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(updateColumnSettingCommand.ColumnSettingId))) | 281 | + return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", strconv.FormatInt(updateColumnSettingCommand.Uid, 10))) |
217 | } | 282 | } |
218 | - if err := columnSetting.Update(tool_funs.SimpleStructToMap(updateColumnSettingCommand)); err != nil { | ||
219 | - return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) | 283 | + if errUpdated := columnSetting.Update(tool_funs.SimpleStructToMap(updateColumnSettingCommand)); errUpdated != nil { |
284 | + return nil, application.ThrowError(application.BUSINESS_ERROR, errUpdated.Error()) | ||
220 | } | 285 | } |
221 | - if columnSettingSaved, err := columnSettingRepository.Save(columnSetting); err != nil { | ||
222 | - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 286 | + if columnSettingSaved, errSaved := columnSettingRepository.Save(columnSetting); errSaved != nil { |
287 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, errSaved.Error()) | ||
223 | } else { | 288 | } else { |
224 | - if err := transactionContext.CommitTransaction(); err != nil { | ||
225 | - return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 289 | + if errCommit := transactionContext.CommitTransaction(); errCommit != nil { |
290 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, errCommit.Error()) | ||
226 | } | 291 | } |
227 | return columnSettingSaved, nil | 292 | return columnSettingSaved, nil |
228 | } | 293 | } |
@@ -894,7 +894,7 @@ func (service OrderInfoService) ListOrderBonusForExcel(listOrderQuery query.List | @@ -894,7 +894,7 @@ func (service OrderInfoService) ListOrderBonusForExcel(listOrderQuery query.List | ||
894 | 894 | ||
895 | /** | 895 | /** |
896 | * @Author SteveChan | 896 | * @Author SteveChan |
897 | - * @Description // 导出订单数据 | 897 | + * @Description //TODO 根据栏目设置,导出订单数据 |
898 | * @Date 22:05 2021/1/10 | 898 | * @Date 22:05 2021/1/10 |
899 | * @Param | 899 | * @Param |
900 | * @return | 900 | * @return |
@@ -927,6 +927,7 @@ func (service OrderInfoService) ListOrderForExcel(listOrderQuery query.ListOrder | @@ -927,6 +927,7 @@ func (service OrderInfoService) ListOrderForExcel(listOrderQuery query.ListOrder | ||
927 | listOrderQuery.DeliveryCode, // 发货单号 | 927 | listOrderQuery.DeliveryCode, // 发货单号 |
928 | [2]string{listOrderQuery.UpdateTimeBegin, listOrderQuery.UpdateTimeEnd}, | 928 | [2]string{listOrderQuery.UpdateTimeBegin, listOrderQuery.UpdateTimeEnd}, |
929 | [2]string{listOrderQuery.CreateTimeBegin, listOrderQuery.CreateTimeEnd}, | 929 | [2]string{listOrderQuery.CreateTimeBegin, listOrderQuery.CreateTimeEnd}, |
930 | + [2]string{listOrderQuery.SaleDateStart, listOrderQuery.SaleDateEnd}, | ||
930 | listOrderQuery.PartnerCategory, | 931 | listOrderQuery.PartnerCategory, |
931 | ) | 932 | ) |
932 | if err != nil { | 933 | if err != nil { |
@@ -85,6 +85,13 @@ func (s SyncOrderService) SyncOrderFromBestshop(cmd command.CreateOrderFromBests | @@ -85,6 +85,13 @@ func (s SyncOrderService) SyncOrderFromBestshop(cmd command.CreateOrderFromBests | ||
85 | return err | 85 | return err |
86 | } | 86 | } |
87 | 87 | ||
88 | +/** | ||
89 | + * @Author SteveChan | ||
90 | + * @Description //TODO 同步小程序订单,增加销售时间 | ||
91 | + * @Date 23:53 2021/1/26 | ||
92 | + * @Param | ||
93 | + * @return | ||
94 | + **/ | ||
88 | func (s SyncOrderService) CreateOrderFromBestshop(cmd command.CreateOrderFromBestshop) error { | 95 | func (s SyncOrderService) CreateOrderFromBestshop(cmd command.CreateOrderFromBestshop) error { |
89 | var ( | 96 | var ( |
90 | transactionContext, _ = factory.CreateTransactionContext(nil) | 97 | transactionContext, _ = factory.CreateTransactionContext(nil) |
@@ -4,6 +4,7 @@ import ( | @@ -4,6 +4,7 @@ import ( | ||
4 | "encoding/json" | 4 | "encoding/json" |
5 | "errors" | 5 | "errors" |
6 | "fmt" | 6 | "fmt" |
7 | + "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/constant" | ||
7 | "time" | 8 | "time" |
8 | 9 | ||
9 | "github.com/astaxie/beego/logs" | 10 | "github.com/astaxie/beego/logs" |
@@ -85,6 +86,13 @@ func NewSyncEmployeeService(option map[string]interface{}) *SyncEmployeeService | @@ -85,6 +86,13 @@ func NewSyncEmployeeService(option map[string]interface{}) *SyncEmployeeService | ||
85 | 86 | ||
86 | var _ SyncAction = (*SyncEmployeeService)(nil) | 87 | var _ SyncAction = (*SyncEmployeeService)(nil) |
87 | 88 | ||
89 | +/** | ||
90 | + * @Author SteveChan | ||
91 | + * @Description //TODO 新增、导入用户初始化栏目设置 | ||
92 | + * @Date 23:54 2021/1/26 | ||
93 | + * @Param | ||
94 | + * @return | ||
95 | + **/ | ||
88 | func (service SyncEmployeeService) DoAction(action string, byteData []byte) error { | 96 | func (service SyncEmployeeService) DoAction(action string, byteData []byte) error { |
89 | switch action { | 97 | switch action { |
90 | case "add": | 98 | case "add": |
@@ -157,6 +165,13 @@ func (service SyncEmployeeService) DoAction(action string, byteData []byte) erro | @@ -157,6 +165,13 @@ func (service SyncEmployeeService) DoAction(action string, byteData []byte) erro | ||
157 | } | 165 | } |
158 | } | 166 | } |
159 | 167 | ||
168 | +/** | ||
169 | + * @Author SteveChan | ||
170 | + * @Description //TODO 初始化栏目设置 | ||
171 | + * @Date 00:07 2021/1/27 | ||
172 | + * @Param | ||
173 | + * @return | ||
174 | + **/ | ||
160 | //addEmployeeData 添加用户 | 175 | //addEmployeeData 添加用户 |
161 | func (service SyncEmployeeService) addEmployeeData(datas []EmployeeData) error { | 176 | func (service SyncEmployeeService) addEmployeeData(datas []EmployeeData) error { |
162 | var ( | 177 | var ( |
@@ -167,7 +182,7 @@ func (service SyncEmployeeService) addEmployeeData(datas []EmployeeData) error { | @@ -167,7 +182,7 @@ func (service SyncEmployeeService) addEmployeeData(datas []EmployeeData) error { | ||
167 | return err | 182 | return err |
168 | } | 183 | } |
169 | defer func() { | 184 | defer func() { |
170 | - transactionContext.RollbackTransaction() | 185 | + _ = transactionContext.RollbackTransaction() |
171 | }() | 186 | }() |
172 | var usersRepository domain.UsersRepository | 187 | var usersRepository domain.UsersRepository |
173 | if usersRepository, err = factory.CreateUsersRepository(map[string]interface{}{ | 188 | if usersRepository, err = factory.CreateUsersRepository(map[string]interface{}{ |
@@ -175,6 +190,12 @@ func (service SyncEmployeeService) addEmployeeData(datas []EmployeeData) error { | @@ -175,6 +190,12 @@ func (service SyncEmployeeService) addEmployeeData(datas []EmployeeData) error { | ||
175 | }); err != nil { | 190 | }); err != nil { |
176 | return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) | 191 | return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) |
177 | } | 192 | } |
193 | + var columnSettingRepository domain.ColumnSettingRepository | ||
194 | + if columnSettingRepository, err = factory.CreateColumnSettingRepository(map[string]interface{}{ | ||
195 | + "transactionContext": transactionContext, | ||
196 | + }); err != nil { | ||
197 | + return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) | ||
198 | + } | ||
178 | for i := range datas { | 199 | for i := range datas { |
179 | data := datas[i] | 200 | data := datas[i] |
180 | newUser := domain.Users{ | 201 | newUser := domain.Users{ |
@@ -202,7 +223,24 @@ func (service SyncEmployeeService) addEmployeeData(datas []EmployeeData) error { | @@ -202,7 +223,24 @@ func (service SyncEmployeeService) addEmployeeData(datas []EmployeeData) error { | ||
202 | if err = usersRepository.Add(&newUser); err != nil { | 223 | if err = usersRepository.Add(&newUser); err != nil { |
203 | return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) | 224 | return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) |
204 | } | 225 | } |
226 | + | ||
227 | + // 初始化栏目设置 | ||
228 | + newColumnSetting := &domain.ColumnSetting{ | ||
229 | + Description: "订单管理栏目设置", | ||
230 | + UserName: data.Name, | ||
231 | + CompanyId: int(data.CompanyId), | ||
232 | + Uid: data.Id, | ||
233 | + Key: constant.ORDER_BASE, // 订单栏目模块名称 | ||
234 | + Value: domain.DefaultColumns, // 栏目值数组,创建用户时使用默认栏目设置 | ||
235 | + InvalidValue: domain.DefaultInvalidColumns, // 初始化无效栏目数组 | ||
236 | + CreatedAt: time.Now(), | ||
237 | + UpdatedAt: time.Now(), | ||
238 | + } | ||
239 | + if _, err = columnSettingRepository.Save(newColumnSetting); err != nil { | ||
240 | + return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) | ||
241 | + } | ||
205 | } | 242 | } |
243 | + | ||
206 | err = transactionContext.CommitTransaction() | 244 | err = transactionContext.CommitTransaction() |
207 | return err | 245 | return err |
208 | } | 246 | } |
@@ -270,7 +308,7 @@ func (service SyncEmployeeService) deleteEmployeeData(data DeleteUserData) error | @@ -270,7 +308,7 @@ func (service SyncEmployeeService) deleteEmployeeData(data DeleteUserData) error | ||
270 | return err | 308 | return err |
271 | } | 309 | } |
272 | defer func() { | 310 | defer func() { |
273 | - transactionContext.RollbackTransaction() | 311 | + _ = transactionContext.RollbackTransaction() |
274 | }() | 312 | }() |
275 | var usersRepository domain.UsersRepository | 313 | var usersRepository domain.UsersRepository |
276 | if usersRepository, err = factory.CreateUsersRepository(map[string]interface{}{ | 314 | if usersRepository, err = factory.CreateUsersRepository(map[string]interface{}{ |
@@ -281,6 +319,25 @@ func (service SyncEmployeeService) deleteEmployeeData(data DeleteUserData) error | @@ -281,6 +319,25 @@ func (service SyncEmployeeService) deleteEmployeeData(data DeleteUserData) error | ||
281 | if err = usersRepository.Remove(data.Ids); err != nil { | 319 | if err = usersRepository.Remove(data.Ids); err != nil { |
282 | return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) | 320 | return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) |
283 | } | 321 | } |
322 | + // TODO 删除栏目设置 | ||
323 | + var columnSettingRepository domain.ColumnSettingRepository | ||
324 | + if value, errFac := factory.CreateColumnSettingRepository(map[string]interface{}{ | ||
325 | + "transactionContext": transactionContext, | ||
326 | + }); errFac != nil { | ||
327 | + return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) | ||
328 | + } else { | ||
329 | + columnSettingRepository = value | ||
330 | + } | ||
331 | + _, columnSettingsFound, err := columnSettingRepository.Find(map[string]interface{}{"ids": data.Ids, "companyId": data.CompanyId}) | ||
332 | + if err != nil { | ||
333 | + return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) | ||
334 | + } | ||
335 | + if len(columnSettingsFound) == 0 { | ||
336 | + return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) | ||
337 | + } | ||
338 | + if _, _, errRm := columnSettingRepository.Remove(nil, columnSettingsFound); errRm != nil { | ||
339 | + return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, errRm.Error()) | ||
340 | + } | ||
284 | err = transactionContext.CommitTransaction() | 341 | err = transactionContext.CommitTransaction() |
285 | return err | 342 | return err |
286 | } | 343 | } |
@@ -295,7 +352,7 @@ func (service SyncEmployeeService) updateUsersStatus(data ForbidAllowUserData) e | @@ -295,7 +352,7 @@ func (service SyncEmployeeService) updateUsersStatus(data ForbidAllowUserData) e | ||
295 | return err | 352 | return err |
296 | } | 353 | } |
297 | defer func() { | 354 | defer func() { |
298 | - transactionContext.RollbackTransaction() | 355 | + _ = transactionContext.RollbackTransaction() |
299 | }() | 356 | }() |
300 | var uDao *dao.UsersDao | 357 | var uDao *dao.UsersDao |
301 | if uDao, err = factory.CreateUsersDao(map[string]interface{}{ | 358 | if uDao, err = factory.CreateUsersDao(map[string]interface{}{ |
@@ -16,6 +16,9 @@ var ( | @@ -16,6 +16,9 @@ var ( | ||
16 | UCENTER_CHECK_ALT = "rsF0pL!6DwjBO735" | 16 | UCENTER_CHECK_ALT = "rsF0pL!6DwjBO735" |
17 | ) | 17 | ) |
18 | 18 | ||
19 | +// 栏目常量设置 | ||
20 | +var ORDER_BASE = "order_base" // 订单管理栏目 | ||
21 | + | ||
19 | var ( | 22 | var ( |
20 | BUSINESS_ADMIN_HOST = "http://suplus-business-admin-test.fjmaimaimai.com" //企业平台的地址 | 23 | BUSINESS_ADMIN_HOST = "http://suplus-business-admin-test.fjmaimaimai.com" //企业平台的地址 |
21 | ) | 24 | ) |
@@ -9,7 +9,7 @@ package domain | @@ -9,7 +9,7 @@ package domain | ||
9 | // 栏目项值对象 | 9 | // 栏目项值对象 |
10 | type Column struct { | 10 | type Column struct { |
11 | // 列标记 | 11 | // 列标记 |
12 | - ColumnId string `json:"columnId"` | 12 | + Id string `json:"id"` |
13 | // 列标记中文 | 13 | // 列标记中文 |
14 | ParamCn string `json:"paramCn"` | 14 | ParamCn string `json:"paramCn"` |
15 | // 列标记是否固定,1:固定,2:不固定 | 15 | // 列标记是否固定,1:固定,2:不固定 |
@@ -2,12 +2,78 @@ package domain | @@ -2,12 +2,78 @@ package domain | ||
2 | 2 | ||
3 | import "time" | 3 | import "time" |
4 | 4 | ||
5 | +// 默认选中栏目 | ||
6 | +var DefaultColumns = []Column{ | ||
7 | + { | ||
8 | + Id: "index", | ||
9 | + ParamCn: "序号", | ||
10 | + ParamFix: 1, | ||
11 | + }, { | ||
12 | + Id: "orderId", | ||
13 | + ParamCn: "订单号", | ||
14 | + ParamFix: 2, | ||
15 | + }, { | ||
16 | + Id: "shipmentsId", | ||
17 | + ParamCn: "发货单号", | ||
18 | + ParamFix: 2, | ||
19 | + }, { | ||
20 | + Id: "saleDate", | ||
21 | + ParamCn: "销售日期", | ||
22 | + ParamFix: 2, | ||
23 | + }, { | ||
24 | + Id: "orderNum", | ||
25 | + ParamCn: "订单数量", | ||
26 | + ParamFix: 2, | ||
27 | + }, { | ||
28 | + Id: "quantityControl", | ||
29 | + ParamCn: "数量调整", | ||
30 | + ParamFix: 2, | ||
31 | + }, { | ||
32 | + Id: "orderPrice", | ||
33 | + ParamCn: "订单金额", | ||
34 | + ParamFix: 2, | ||
35 | + }, { | ||
36 | + Id: "priceControl", | ||
37 | + ParamCn: "金额调整", | ||
38 | + ParamFix: 2, | ||
39 | + }, { | ||
40 | + Id: "orderDist", | ||
41 | + ParamCn: "订单区域", | ||
42 | + ParamFix: 2, | ||
43 | + }, { | ||
44 | + Id: "partnerCategory", | ||
45 | + ParamCn: "合伙人类型", | ||
46 | + ParamFix: 2, | ||
47 | + }, { | ||
48 | + Id: "buyer", | ||
49 | + ParamCn: "客户", | ||
50 | + ParamFix: 2, | ||
51 | + }, { | ||
52 | + Id: "partner", | ||
53 | + ParamCn: "合伙人", | ||
54 | + ParamFix: 2, | ||
55 | + }, | ||
56 | +} | ||
57 | + | ||
58 | +// 默认未选中栏目 | ||
59 | +var DefaultInvalidColumns = []Column{ | ||
60 | + { | ||
61 | + Id: "update_time", | ||
62 | + ParamCn: "更新时间", | ||
63 | + ParamFix: 2, | ||
64 | + }, { | ||
65 | + Id: "create_time", | ||
66 | + ParamCn: "创建时间", | ||
67 | + ParamFix: 2, | ||
68 | + }, | ||
69 | +} | ||
70 | + | ||
5 | // 栏目设置 | 71 | // 栏目设置 |
6 | type ColumnSetting struct { | 72 | type ColumnSetting struct { |
7 | // 栏目设置id | 73 | // 栏目设置id |
8 | Id int64 `json:"id"` | 74 | Id int64 `json:"id"` |
9 | // 栏目设置关联用户公司id | 75 | // 栏目设置关联用户公司id |
10 | - CompanyId int32 `json:"companyId"` | 76 | + CompanyId int `json:"companyId"` |
11 | // 栏目设置创建时间 | 77 | // 栏目设置创建时间 |
12 | CreatedAt time.Time `json:"createdAt"` | 78 | CreatedAt time.Time `json:"createdAt"` |
13 | // 栏目设置描述 | 79 | // 栏目设置描述 |
@@ -20,13 +86,15 @@ type ColumnSetting struct { | @@ -20,13 +86,15 @@ type ColumnSetting struct { | ||
20 | UpdatedAt time.Time `json:"updatedAt"` | 86 | UpdatedAt time.Time `json:"updatedAt"` |
21 | // 栏目设置关联用户名称 | 87 | // 栏目设置关联用户名称 |
22 | UserName string `json:"userName"` | 88 | UserName string `json:"userName"` |
23 | - // 栏目数组 | 89 | + // 有效栏目数组 |
24 | Value []Column `json:"value"` | 90 | Value []Column `json:"value"` |
91 | + // 无效栏目数组 | ||
92 | + InvalidValue []Column `json:"invalidValue"` | ||
25 | } | 93 | } |
26 | 94 | ||
27 | type ColumnSettingRepository interface { | 95 | type ColumnSettingRepository interface { |
28 | Save(columnSetting *ColumnSetting) (*ColumnSetting, error) | 96 | Save(columnSetting *ColumnSetting) (*ColumnSetting, error) |
29 | - Remove(columnSetting *ColumnSetting) (*ColumnSetting, error) | 97 | + Remove(columnSetting *ColumnSetting, columnSettings []*ColumnSetting) (*ColumnSetting, []*ColumnSetting, error) |
30 | FindOne(queryOptions map[string]interface{}) (*ColumnSetting, error) | 98 | FindOne(queryOptions map[string]interface{}) (*ColumnSetting, error) |
31 | Find(queryOptions map[string]interface{}) (int64, []*ColumnSetting, error) | 99 | Find(queryOptions map[string]interface{}) (int64, []*ColumnSetting, error) |
32 | } | 100 | } |
@@ -39,11 +107,8 @@ func (columnSetting *ColumnSetting) Identify() interface{} { | @@ -39,11 +107,8 @@ func (columnSetting *ColumnSetting) Identify() interface{} { | ||
39 | } | 107 | } |
40 | 108 | ||
41 | func (columnSetting *ColumnSetting) Update(data map[string]interface{}) error { | 109 | func (columnSetting *ColumnSetting) Update(data map[string]interface{}) error { |
42 | - if columnSettingId, ok := data["columnSettingId"]; ok { | ||
43 | - columnSetting.Id = columnSettingId.(int64) | ||
44 | - } | ||
45 | if companyId, ok := data["companyId"]; ok { | 110 | if companyId, ok := data["companyId"]; ok { |
46 | - columnSetting.CompanyId = companyId.(int32) | 111 | + columnSetting.CompanyId = companyId.(int) |
47 | } | 112 | } |
48 | if createdAt, ok := data["createdAt"]; ok { | 113 | if createdAt, ok := data["createdAt"]; ok { |
49 | columnSetting.CreatedAt = createdAt.(time.Time) | 114 | columnSetting.CreatedAt = createdAt.(time.Time) |
@@ -66,5 +131,8 @@ func (columnSetting *ColumnSetting) Update(data map[string]interface{}) error { | @@ -66,5 +131,8 @@ func (columnSetting *ColumnSetting) Update(data map[string]interface{}) error { | ||
66 | if value, ok := data["value"]; ok { | 131 | if value, ok := data["value"]; ok { |
67 | columnSetting.Value = value.([]Column) | 132 | columnSetting.Value = value.([]Column) |
68 | } | 133 | } |
134 | + if invalidValue, ok := data["invalidValue"]; ok { | ||
135 | + columnSetting.InvalidValue = invalidValue.([]Column) | ||
136 | + } | ||
69 | return nil | 137 | return nil |
70 | } | 138 | } |
@@ -259,6 +259,13 @@ type CustomOrderListForExcel struct { | @@ -259,6 +259,13 @@ type CustomOrderListForExcel struct { | ||
259 | PartnerName string //合伙人 | 259 | PartnerName string //合伙人 |
260 | } | 260 | } |
261 | 261 | ||
262 | +/** | ||
263 | + * @Author SteveChan | ||
264 | + * @Description //TODO 导出到excel,增加栏目设置 | ||
265 | + * @Date 23:45 2021/1/26 | ||
266 | + * @Param | ||
267 | + * @return | ||
268 | + **/ | ||
262 | //OrderListForExcel 获取实际订单列表用于excel导出 | 269 | //OrderListForExcel 获取实际订单列表用于excel导出 |
263 | //@param companyId 公司id | 270 | //@param companyId 公司id |
264 | //@param orderType 订单类型 | 271 | //@param orderType 订单类型 |
@@ -267,7 +274,7 @@ type CustomOrderListForExcel struct { | @@ -267,7 +274,7 @@ type CustomOrderListForExcel struct { | ||
267 | //@param updateTime 订单更新时间范围"[开始时间,结束时间]",时间格式"2006-01-02 15:04:05+07" | 274 | //@param updateTime 订单更新时间范围"[开始时间,结束时间]",时间格式"2006-01-02 15:04:05+07" |
268 | //@param createTime 订单的创建时间范围"[开始时间,结束时间]" 时间格式"2006-01-02 15:04:05+07" | 275 | //@param createTime 订单的创建时间范围"[开始时间,结束时间]" 时间格式"2006-01-02 15:04:05+07" |
269 | func (dao OrderBaseDao) OrderListForExcel(companyId int64, partnerName string, orderCode string, deliveryCode string, | 276 | func (dao OrderBaseDao) OrderListForExcel(companyId int64, partnerName string, orderCode string, deliveryCode string, |
270 | - updateTime [2]string, createTime [2]string, partnerCategory int) ( | 277 | + updateTime [2]string, createTime [2]string, saleDate [2]string, partnerCategory int) ( |
271 | result []CustomOrderListForExcel, err error) { | 278 | result []CustomOrderListForExcel, err error) { |
272 | sqlstr := ` | 279 | sqlstr := ` |
273 | SELECT t1.order_code,t1.delivery_code | 280 | SELECT t1.order_code,t1.delivery_code |
@@ -306,17 +313,14 @@ func (dao OrderBaseDao) OrderListForExcel(companyId int64, partnerName string, o | @@ -306,17 +313,14 @@ func (dao OrderBaseDao) OrderListForExcel(companyId int64, partnerName string, o | ||
306 | params = append(params, partnerCategory) | 313 | params = append(params, partnerCategory) |
307 | sqlstr += ` AND t1.partner_category@>'{"id":?}' ` | 314 | sqlstr += ` AND t1.partner_category@>'{"id":?}' ` |
308 | } | 315 | } |
309 | - | ||
310 | if len(updateTime[0]) > 0 { | 316 | if len(updateTime[0]) > 0 { |
311 | params = append(params, updateTime[0]) | 317 | params = append(params, updateTime[0]) |
312 | sqlstr += ` AND t1.update_time>=? ` | 318 | sqlstr += ` AND t1.update_time>=? ` |
313 | } | 319 | } |
314 | - | ||
315 | if len(updateTime[1]) > 0 { | 320 | if len(updateTime[1]) > 0 { |
316 | params = append(params, updateTime[1]) | 321 | params = append(params, updateTime[1]) |
317 | sqlstr += ` AND t1.update_time<=? ` | 322 | sqlstr += ` AND t1.update_time<=? ` |
318 | } | 323 | } |
319 | - | ||
320 | if len(createTime[0]) > 0 { | 324 | if len(createTime[0]) > 0 { |
321 | params = append(params, createTime[0]) | 325 | params = append(params, createTime[0]) |
322 | sqlstr += ` AND t1.create_time>=? ` | 326 | sqlstr += ` AND t1.create_time>=? ` |
@@ -325,6 +329,14 @@ func (dao OrderBaseDao) OrderListForExcel(companyId int64, partnerName string, o | @@ -325,6 +329,14 @@ func (dao OrderBaseDao) OrderListForExcel(companyId int64, partnerName string, o | ||
325 | params = append(params, createTime[1]) | 329 | params = append(params, createTime[1]) |
326 | sqlstr += ` AND t1.create_time<=? ` | 330 | sqlstr += ` AND t1.create_time<=? ` |
327 | } | 331 | } |
332 | + if len(saleDate[0]) > 0 { | ||
333 | + params = append(params, saleDate[0]) | ||
334 | + sqlstr += ` AND t1.sale_date>=? ` | ||
335 | + } | ||
336 | + if len(saleDate[1]) > 0 { | ||
337 | + params = append(params, saleDate[1]) | ||
338 | + sqlstr += ` AND t1.sale_date<=? ` | ||
339 | + } | ||
328 | sqlstr += ` ORDER BY t1.create_time DESC limit 10000 ` | 340 | sqlstr += ` ORDER BY t1.create_time DESC limit 10000 ` |
329 | tx := dao.transactionContext.GetDB() | 341 | tx := dao.transactionContext.GetDB() |
330 | _, err = tx.Query(&result, sqlstr, params...) | 342 | _, err = tx.Query(&result, sqlstr, params...) |
@@ -9,7 +9,7 @@ type ColumnSetting struct { | @@ -9,7 +9,7 @@ type ColumnSetting struct { | ||
9 | // 栏目设置id | 9 | // 栏目设置id |
10 | Id int64 | 10 | Id int64 |
11 | // 栏目设置关联用户公司id | 11 | // 栏目设置关联用户公司id |
12 | - CompanyId int32 | 12 | + CompanyId int |
13 | // 栏目设置创建时间 | 13 | // 栏目设置创建时间 |
14 | CreatedAt time.Time | 14 | CreatedAt time.Time |
15 | // 栏目设置描述 | 15 | // 栏目设置描述 |
@@ -24,4 +24,6 @@ type ColumnSetting struct { | @@ -24,4 +24,6 @@ type ColumnSetting struct { | ||
24 | UserName string | 24 | UserName string |
25 | // 栏目数组 | 25 | // 栏目数组 |
26 | Value []domain.Column `pg:",array"` | 26 | Value []domain.Column `pg:",array"` |
27 | + // 无效栏目数组 | ||
28 | + InvalidValue []domain.Column `pg:",array"` | ||
27 | } | 29 | } |
@@ -16,6 +16,7 @@ type ColumnSettingRepository struct { | @@ -16,6 +16,7 @@ type ColumnSettingRepository struct { | ||
16 | func (repository *ColumnSettingRepository) nextIdentify() (int64, error) { | 16 | func (repository *ColumnSettingRepository) nextIdentify() (int64, error) { |
17 | return 0, nil | 17 | return 0, nil |
18 | } | 18 | } |
19 | + | ||
19 | func (repository *ColumnSettingRepository) Save(columnSetting *domain.ColumnSetting) (*domain.ColumnSetting, error) { | 20 | func (repository *ColumnSettingRepository) Save(columnSetting *domain.ColumnSetting) (*domain.ColumnSetting, error) { |
20 | tx := repository.transactionContext.PgTx | 21 | tx := repository.transactionContext.PgTx |
21 | if columnSetting.Identify() == nil { | 22 | if columnSetting.Identify() == nil { |
@@ -23,31 +24,46 @@ func (repository *ColumnSettingRepository) Save(columnSetting *domain.ColumnSett | @@ -23,31 +24,46 @@ func (repository *ColumnSettingRepository) Save(columnSetting *domain.ColumnSett | ||
23 | if err != nil { | 24 | if err != nil { |
24 | return columnSetting, err | 25 | return columnSetting, err |
25 | } | 26 | } |
26 | - if _, err := tx.QueryOne( | ||
27 | - pg.Scan(&columnSetting.Id, &columnSetting.CompanyId, &columnSetting.CreatedAt, &columnSetting.Description, &columnSetting.Key, &columnSetting.Uid, &columnSetting.UpdatedAt, &columnSetting.UserName, pg.Array(&columnSetting.Value)), | ||
28 | - "INSERT INTO column_settings (column_setting_id, company_id, created_at, description, key, uid, updated_at, user_name, value) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING column_setting_id, company_id, created_at, description, key, uid, updated_at, user_name, value", | ||
29 | - columnSetting.Id, columnSetting.CompanyId, columnSetting.CreatedAt, columnSetting.Description, columnSetting.Key, columnSetting.Uid, columnSetting.UpdatedAt, columnSetting.UserName, pg.Array(columnSetting.Value)); err != nil { | ||
30 | - return columnSetting, err | 27 | + if _, errInsert := tx.QueryOne( |
28 | + pg.Scan(&columnSetting.Id, &columnSetting.CompanyId, &columnSetting.CreatedAt, &columnSetting.Description, &columnSetting.Key, &columnSetting.Uid, &columnSetting.UpdatedAt, &columnSetting.UserName, pg.Array(&columnSetting.Value), pg.Array(&columnSetting.InvalidValue)), | ||
29 | + "INSERT INTO column_settings (column_setting_id, company_id, created_at, description, key, uid, updated_at, user_name, value, invalid_value) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING column_setting_id, company_id, created_at, description, key, uid, updated_at, user_name, value, invalid_value", | ||
30 | + columnSetting.Id, columnSetting.CompanyId, columnSetting.CreatedAt, columnSetting.Description, columnSetting.Key, columnSetting.Uid, columnSetting.UpdatedAt, columnSetting.UserName, pg.Array(columnSetting.Value), pg.Array(columnSetting.InvalidValue)); errInsert != nil { | ||
31 | + return columnSetting, errInsert | ||
31 | } | 32 | } |
32 | } else { | 33 | } else { |
33 | - if _, err := tx.QueryOne( | ||
34 | - pg.Scan(&columnSetting.Id, &columnSetting.CompanyId, &columnSetting.CreatedAt, &columnSetting.Description, &columnSetting.Key, &columnSetting.Uid, &columnSetting.UpdatedAt, &columnSetting.UserName, pg.Array(&columnSetting.Value)), | ||
35 | - "UPDATE column_settings SET column_setting_id=?, company_id=?, created_at=?, description=?, key=?, uid=?, updated_at=?, user_name=?, value=? WHERE id=? RETURNING column_setting_id, company_id, created_at, description, key, uid, updated_at, user_name, value", | ||
36 | - columnSetting.Id, columnSetting.CompanyId, columnSetting.CreatedAt, columnSetting.Description, columnSetting.Key, columnSetting.Uid, columnSetting.UpdatedAt, columnSetting.UserName, pg.Array(columnSetting.Value), columnSetting.Identify()); err != nil { | ||
37 | - return columnSetting, err | 34 | + if _, errUpdate := tx.QueryOne( |
35 | + pg.Scan(&columnSetting.Id, &columnSetting.CompanyId, &columnSetting.CreatedAt, &columnSetting.Description, &columnSetting.Key, &columnSetting.Uid, &columnSetting.UpdatedAt, &columnSetting.UserName, pg.Array(&columnSetting.Value), pg.Array(&columnSetting.InvalidValue)), | ||
36 | + "UPDATE column_settings SET column_setting_id=?, company_id=?, created_at=?, description=?, key=?, uid=?, updated_at=?, user_name=?, value=?, invalid_value=? WHERE id=? RETURNING column_setting_id, company_id, created_at, description, key, uid, updated_at, user_name, value, invalid_value", | ||
37 | + columnSetting.Id, columnSetting.CompanyId, columnSetting.CreatedAt, columnSetting.Description, columnSetting.Key, columnSetting.Uid, columnSetting.UpdatedAt, columnSetting.UserName, pg.Array(columnSetting.Value), pg.Array(columnSetting.InvalidValue), columnSetting.Identify()); errUpdate != nil { | ||
38 | + return columnSetting, errUpdate | ||
38 | } | 39 | } |
39 | } | 40 | } |
40 | return columnSetting, nil | 41 | return columnSetting, nil |
41 | } | 42 | } |
42 | -func (repository *ColumnSettingRepository) Remove(columnSetting *domain.ColumnSetting) (*domain.ColumnSetting, error) { | 43 | + |
44 | +func (repository *ColumnSettingRepository) Remove(columnSetting *domain.ColumnSetting, columnSettings []*domain.ColumnSetting) (*domain.ColumnSetting, []*domain.ColumnSetting, error) { | ||
43 | tx := repository.transactionContext.PgTx | 45 | tx := repository.transactionContext.PgTx |
46 | + | ||
47 | + // 单个删除 | ||
44 | columnSettingModel := new(models.ColumnSetting) | 48 | columnSettingModel := new(models.ColumnSetting) |
45 | columnSettingModel.Id = columnSetting.Identify().(int64) | 49 | columnSettingModel.Id = columnSetting.Identify().(int64) |
46 | if _, err := tx.Model(columnSettingModel).WherePK().Delete(); err != nil { | 50 | if _, err := tx.Model(columnSettingModel).WherePK().Delete(); err != nil { |
47 | - return columnSetting, err | 51 | + return columnSetting, nil, err |
48 | } | 52 | } |
49 | - return columnSetting, nil | 53 | + |
54 | + // 批量删除 | ||
55 | + var columnSettingModels []*models.ColumnSetting | ||
56 | + for _, setting := range columnSettings { | ||
57 | + columnSettingModels = append(columnSettingModels, &models.ColumnSetting{ | ||
58 | + Id: setting.Identify().(int64), | ||
59 | + }) | ||
60 | + } | ||
61 | + if _, err := tx.Model(columnSettingModels).WherePK().Delete(); err != nil { | ||
62 | + return nil, columnSettings, err | ||
63 | + } | ||
64 | + return columnSetting, columnSettings, nil | ||
50 | } | 65 | } |
66 | + | ||
51 | func (repository *ColumnSettingRepository) FindOne(queryOptions map[string]interface{}) (*domain.ColumnSetting, error) { | 67 | func (repository *ColumnSettingRepository) FindOne(queryOptions map[string]interface{}) (*domain.ColumnSetting, error) { |
52 | tx := repository.transactionContext.PgTx | 68 | tx := repository.transactionContext.PgTx |
53 | columnSettingModel := new(models.ColumnSetting) | 69 | columnSettingModel := new(models.ColumnSetting) |
@@ -55,6 +71,12 @@ func (repository *ColumnSettingRepository) FindOne(queryOptions map[string]inter | @@ -55,6 +71,12 @@ func (repository *ColumnSettingRepository) FindOne(queryOptions map[string]inter | ||
55 | if columnSettingId, ok := queryOptions["column_settingId"]; ok { | 71 | if columnSettingId, ok := queryOptions["column_settingId"]; ok { |
56 | query = query.Where("column_setting.id = ?", columnSettingId) | 72 | query = query.Where("column_setting.id = ?", columnSettingId) |
57 | } | 73 | } |
74 | + if uid, ok := queryOptions["uid"]; ok { | ||
75 | + query = query.Where("column_setting.uid = ?", uid) | ||
76 | + } | ||
77 | + if companyId, ok := queryOptions["companyId"]; ok { | ||
78 | + query = query.Where("column_setting.company_id = ?", companyId) | ||
79 | + } | ||
58 | if err := query.First(); err != nil { | 80 | if err := query.First(); err != nil { |
59 | if err.Error() == "pg: no rows in result set" { | 81 | if err.Error() == "pg: no rows in result set" { |
60 | return nil, fmt.Errorf("没有此资源") | 82 | return nil, fmt.Errorf("没有此资源") |
@@ -68,23 +90,33 @@ func (repository *ColumnSettingRepository) FindOne(queryOptions map[string]inter | @@ -68,23 +90,33 @@ func (repository *ColumnSettingRepository) FindOne(queryOptions map[string]inter | ||
68 | return repository.transformPgModelToDomainModel(columnSettingModel) | 90 | return repository.transformPgModelToDomainModel(columnSettingModel) |
69 | } | 91 | } |
70 | } | 92 | } |
93 | + | ||
71 | func (repository *ColumnSettingRepository) Find(queryOptions map[string]interface{}) (int64, []*domain.ColumnSetting, error) { | 94 | func (repository *ColumnSettingRepository) Find(queryOptions map[string]interface{}) (int64, []*domain.ColumnSetting, error) { |
72 | tx := repository.transactionContext.PgTx | 95 | tx := repository.transactionContext.PgTx |
73 | var columnSettingModels []*models.ColumnSetting | 96 | var columnSettingModels []*models.ColumnSetting |
74 | columnSettings := make([]*domain.ColumnSetting, 0) | 97 | columnSettings := make([]*domain.ColumnSetting, 0) |
75 | query := tx.Model(&columnSettingModels) | 98 | query := tx.Model(&columnSettingModels) |
99 | + if ids, ok := queryOptions["ids"]; ok { | ||
100 | + query = query.Where("column_setting.uid IN (?)", pg.In(ids.(int))) | ||
101 | + } | ||
102 | + if uid, ok := queryOptions["uid"]; ok { | ||
103 | + query = query.Where("column_setting.uid = ?", uid) | ||
104 | + } | ||
105 | + if companyId, ok := queryOptions["companyId"]; ok { | ||
106 | + query = query.Where("column_setting.company_id = ?", companyId) | ||
107 | + } | ||
76 | if offset, ok := queryOptions["offset"]; ok { | 108 | if offset, ok := queryOptions["offset"]; ok { |
77 | - offset := offset.(int) | ||
78 | - if offset > -1 { | ||
79 | - query = query.Offset(offset) | 109 | + queryOffset := offset.(int) |
110 | + if queryOffset > -1 { | ||
111 | + query = query.Offset(queryOffset) | ||
80 | } | 112 | } |
81 | } else { | 113 | } else { |
82 | query = query.Offset(0) | 114 | query = query.Offset(0) |
83 | } | 115 | } |
84 | if limit, ok := queryOptions["limit"]; ok { | 116 | if limit, ok := queryOptions["limit"]; ok { |
85 | - limit := limit.(int) | ||
86 | - if limit > -1 { | ||
87 | - query = query.Limit(limit) | 117 | + queryLimit := limit.(int) |
118 | + if queryLimit > -1 { | ||
119 | + query = query.Limit(queryLimit) | ||
88 | } | 120 | } |
89 | } else { | 121 | } else { |
90 | query = query.Limit(20) | 122 | query = query.Limit(20) |
@@ -93,8 +125,8 @@ func (repository *ColumnSettingRepository) Find(queryOptions map[string]interfac | @@ -93,8 +125,8 @@ func (repository *ColumnSettingRepository) Find(queryOptions map[string]interfac | ||
93 | return 0, columnSettings, err | 125 | return 0, columnSettings, err |
94 | } else { | 126 | } else { |
95 | for _, columnSettingModel := range columnSettingModels { | 127 | for _, columnSettingModel := range columnSettingModels { |
96 | - if columnSetting, err := repository.transformPgModelToDomainModel(columnSettingModel); err != nil { | ||
97 | - return 0, columnSettings, err | 128 | + if columnSetting, errTrans := repository.transformPgModelToDomainModel(columnSettingModel); errTrans != nil { |
129 | + return 0, columnSettings, errTrans | ||
98 | } else { | 130 | } else { |
99 | columnSettings = append(columnSettings, columnSetting) | 131 | columnSettings = append(columnSettings, columnSetting) |
100 | } | 132 | } |
@@ -102,19 +134,22 @@ func (repository *ColumnSettingRepository) Find(queryOptions map[string]interfac | @@ -102,19 +134,22 @@ func (repository *ColumnSettingRepository) Find(queryOptions map[string]interfac | ||
102 | return int64(count), columnSettings, nil | 134 | return int64(count), columnSettings, nil |
103 | } | 135 | } |
104 | } | 136 | } |
137 | + | ||
105 | func (repository *ColumnSettingRepository) transformPgModelToDomainModel(columnSettingModel *models.ColumnSetting) (*domain.ColumnSetting, error) { | 138 | func (repository *ColumnSettingRepository) transformPgModelToDomainModel(columnSettingModel *models.ColumnSetting) (*domain.ColumnSetting, error) { |
106 | return &domain.ColumnSetting{ | 139 | return &domain.ColumnSetting{ |
107 | - Id: columnSettingModel.Id, | ||
108 | - CompanyId: columnSettingModel.CompanyId, | ||
109 | - CreatedAt: columnSettingModel.CreatedAt, | ||
110 | - Description: columnSettingModel.Description, | ||
111 | - Key: columnSettingModel.Key, | ||
112 | - Uid: columnSettingModel.Uid, | ||
113 | - UpdatedAt: columnSettingModel.UpdatedAt, | ||
114 | - UserName: columnSettingModel.UserName, | ||
115 | - Value: columnSettingModel.Value, | 140 | + Id: columnSettingModel.Id, |
141 | + CompanyId: columnSettingModel.CompanyId, | ||
142 | + CreatedAt: columnSettingModel.CreatedAt, | ||
143 | + Description: columnSettingModel.Description, | ||
144 | + Key: columnSettingModel.Key, | ||
145 | + Uid: columnSettingModel.Uid, | ||
146 | + UpdatedAt: columnSettingModel.UpdatedAt, | ||
147 | + UserName: columnSettingModel.UserName, | ||
148 | + Value: columnSettingModel.Value, // 有效栏目设置 | ||
149 | + InvalidValue: columnSettingModel.InvalidValue, // 无效栏目设置 | ||
116 | }, nil | 150 | }, nil |
117 | } | 151 | } |
152 | + | ||
118 | func NewColumnSettingRepository(transactionContext *pgTransaction.TransactionContext) (*ColumnSettingRepository, error) { | 153 | func NewColumnSettingRepository(transactionContext *pgTransaction.TransactionContext) (*ColumnSettingRepository, error) { |
119 | if transactionContext == nil { | 154 | if transactionContext == nil { |
120 | return nil, fmt.Errorf("transactionContext参数不能为nil") | 155 | return nil, fmt.Errorf("transactionContext参数不能为nil") |
@@ -2,8 +2,8 @@ package controllers | @@ -2,8 +2,8 @@ package controllers | ||
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | "encoding/json" | 4 | "encoding/json" |
5 | + "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/domain" | ||
5 | 6 | ||
6 | - "github.com/astaxie/beego" | ||
7 | "github.com/linmadan/egglib-go/web/beego/utils" | 7 | "github.com/linmadan/egglib-go/web/beego/utils" |
8 | "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/application/columnSetting/command" | 8 | "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/application/columnSetting/command" |
9 | "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/application/columnSetting/query" | 9 | "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/application/columnSetting/query" |
@@ -11,7 +11,7 @@ import ( | @@ -11,7 +11,7 @@ import ( | ||
11 | ) | 11 | ) |
12 | 12 | ||
13 | type ColumnSettingController struct { | 13 | type ColumnSettingController struct { |
14 | - beego.Controller | 14 | + BaseController |
15 | } | 15 | } |
16 | 16 | ||
17 | func (controller *ColumnSettingController) CreateColumnSetting() { | 17 | func (controller *ColumnSettingController) CreateColumnSetting() { |
@@ -29,12 +29,23 @@ func (controller *ColumnSettingController) CreateColumnSetting() { | @@ -29,12 +29,23 @@ func (controller *ColumnSettingController) CreateColumnSetting() { | ||
29 | controller.ServeJSON() | 29 | controller.ServeJSON() |
30 | } | 30 | } |
31 | 31 | ||
32 | +/** | ||
33 | + * @Author SteveChan | ||
34 | + * @Description //TODO 更新栏目设置 | ||
35 | + * @Date 22:52 2021/1/26 | ||
36 | + * @Param | ||
37 | + * @return | ||
38 | + **/ | ||
32 | func (controller *ColumnSettingController) UpdateColumnSetting() { | 39 | func (controller *ColumnSettingController) UpdateColumnSetting() { |
33 | columnSettingService := service.NewColumnSettingService(nil) | 40 | columnSettingService := service.NewColumnSettingService(nil) |
34 | updateColumnSettingCommand := &command.UpdateColumnSettingCommand{} | 41 | updateColumnSettingCommand := &command.UpdateColumnSettingCommand{} |
35 | - json.Unmarshal(controller.Ctx.Input.GetData("requestBody").([]byte), updateColumnSettingCommand) | ||
36 | - columnSettingId, _ := controller.GetInt64(":columnSettingId") | ||
37 | - updateColumnSettingCommand.ColumnSettingId = columnSettingId | 42 | + _ = json.Unmarshal(controller.Ctx.Input.GetData("requestBody").([]byte), updateColumnSettingCommand) |
43 | + //columnSettingId, _ := controller.GetInt64(":columnSettingId") | ||
44 | + companyId := controller.GetUserCompany() | ||
45 | + uid := controller.GetUserId() | ||
46 | + //updateColumnSettingCommand.ColumnSettingId = columnSettingId | ||
47 | + updateColumnSettingCommand.CompanyId = int(companyId) | ||
48 | + updateColumnSettingCommand.Uid = uid | ||
38 | data, err := columnSettingService.UpdateColumnSetting(updateColumnSettingCommand) | 49 | data, err := columnSettingService.UpdateColumnSetting(updateColumnSettingCommand) |
39 | var response utils.JsonResponse | 50 | var response utils.JsonResponse |
40 | if err != nil { | 51 | if err != nil { |
@@ -46,11 +57,22 @@ func (controller *ColumnSettingController) UpdateColumnSetting() { | @@ -46,11 +57,22 @@ func (controller *ColumnSettingController) UpdateColumnSetting() { | ||
46 | controller.ServeJSON() | 57 | controller.ServeJSON() |
47 | } | 58 | } |
48 | 59 | ||
60 | +/** | ||
61 | + * @Author SteveChan | ||
62 | + * @Description //TODO 获取栏目设置 | ||
63 | + * @Date 22:53 2021/1/26 | ||
64 | + * @Param | ||
65 | + * @return | ||
66 | + **/ | ||
49 | func (controller *ColumnSettingController) GetColumnSetting() { | 67 | func (controller *ColumnSettingController) GetColumnSetting() { |
50 | columnSettingService := service.NewColumnSettingService(nil) | 68 | columnSettingService := service.NewColumnSettingService(nil) |
51 | getColumnSettingQuery := &query.GetColumnSettingQuery{} | 69 | getColumnSettingQuery := &query.GetColumnSettingQuery{} |
52 | - columnSettingId, _ := controller.GetInt64(":columnSettingId") | ||
53 | - getColumnSettingQuery.ColumnSettingId = columnSettingId | 70 | + //columnSettingId, _ := controller.GetInt64(":columnSettingId") |
71 | + companyId := controller.GetUserCompany() // 公司id | ||
72 | + uid := controller.GetUserId() // 用户id | ||
73 | + //getColumnSettingQuery.ColumnSettingId = columnSettingId | ||
74 | + getColumnSettingQuery.CompanyId = int(companyId) | ||
75 | + getColumnSettingQuery.Uid = uid | ||
54 | data, err := columnSettingService.GetColumnSetting(getColumnSettingQuery) | 76 | data, err := columnSettingService.GetColumnSetting(getColumnSettingQuery) |
55 | var response utils.JsonResponse | 77 | var response utils.JsonResponse |
56 | if err != nil { | 78 | if err != nil { |
@@ -65,7 +87,7 @@ func (controller *ColumnSettingController) GetColumnSetting() { | @@ -65,7 +87,7 @@ func (controller *ColumnSettingController) GetColumnSetting() { | ||
65 | func (controller *ColumnSettingController) RemoveColumnSetting() { | 87 | func (controller *ColumnSettingController) RemoveColumnSetting() { |
66 | columnSettingService := service.NewColumnSettingService(nil) | 88 | columnSettingService := service.NewColumnSettingService(nil) |
67 | removeColumnSettingCommand := &command.RemoveColumnSettingCommand{} | 89 | removeColumnSettingCommand := &command.RemoveColumnSettingCommand{} |
68 | - json.Unmarshal(controller.Ctx.Input.GetData("requestBody").([]byte), removeColumnSettingCommand) | 90 | + _ = json.Unmarshal(controller.Ctx.Input.GetData("requestBody").([]byte), removeColumnSettingCommand) |
69 | columnSettingId, _ := controller.GetInt64(":columnSettingId") | 91 | columnSettingId, _ := controller.GetInt64(":columnSettingId") |
70 | removeColumnSettingCommand.ColumnSettingId = columnSettingId | 92 | removeColumnSettingCommand.ColumnSettingId = columnSettingId |
71 | data, err := columnSettingService.RemoveColumnSetting(removeColumnSettingCommand) | 93 | data, err := columnSettingService.RemoveColumnSetting(removeColumnSettingCommand) |
@@ -79,10 +101,22 @@ func (controller *ColumnSettingController) RemoveColumnSetting() { | @@ -79,10 +101,22 @@ func (controller *ColumnSettingController) RemoveColumnSetting() { | ||
79 | controller.ServeJSON() | 101 | controller.ServeJSON() |
80 | } | 102 | } |
81 | 103 | ||
104 | +/** | ||
105 | + * @Author SteveChan | ||
106 | + * @Description //TODO 重置栏目设置 | ||
107 | + * @Date 22:52 2021/1/26 | ||
108 | + * @Param | ||
109 | + * @return | ||
110 | + **/ | ||
82 | func (controller *ColumnSettingController) ResetColumn() { | 111 | func (controller *ColumnSettingController) ResetColumn() { |
83 | columnSettingService := service.NewColumnSettingService(nil) | 112 | columnSettingService := service.NewColumnSettingService(nil) |
84 | resetColumnCommand := &command.ResetColumnCommand{} | 113 | resetColumnCommand := &command.ResetColumnCommand{} |
85 | - json.Unmarshal(controller.Ctx.Input.GetData("requestBody").([]byte), resetColumnCommand) | 114 | + companyId := controller.GetUserCompany() |
115 | + uid := controller.GetUserId() | ||
116 | + //_ = json.Unmarshal(controller.Ctx.Input.GetData("requestBody").([]byte), resetColumnCommand) | ||
117 | + resetColumnCommand.CompanyId = int(companyId) | ||
118 | + resetColumnCommand.Uid = uid | ||
119 | + resetColumnCommand.Value = domain.DefaultColumns // 还原默认栏目设置 | ||
86 | data, err := columnSettingService.ResetColumn(resetColumnCommand) | 120 | data, err := columnSettingService.ResetColumn(resetColumnCommand) |
87 | var response utils.JsonResponse | 121 | var response utils.JsonResponse |
88 | if err != nil { | 122 | if err != nil { |
@@ -893,7 +893,6 @@ func (c *OrderInfoController) ImportOrderFromExcel() { | @@ -893,7 +893,6 @@ func (c *OrderInfoController) ImportOrderFromExcel() { | ||
893 | case 4: // TODO 销售日期格式和有效性校验 | 893 | case 4: // TODO 销售日期格式和有效性校验 |
894 | { | 894 | { |
895 | regexpStr := `(\d{4})/(\d{2})/(\d{2})` | 895 | regexpStr := `(\d{4})/(\d{2})/(\d{2})` |
896 | - //cellStr := strings.TrimSpace(cell) | ||
897 | ok := regexp.MustCompile(regexpStr).MatchString(cell) | 896 | ok := regexp.MustCompile(regexpStr).MatchString(cell) |
898 | if !ok { | 897 | if !ok { |
899 | var tmpRow []string | 898 | var tmpRow []string |
@@ -43,7 +43,7 @@ func init() { | @@ -43,7 +43,7 @@ func init() { | ||
43 | beego.NSRouter("/actual/close", &controllers.OrderInfoController{}, "POST:OrderDisable"), | 43 | beego.NSRouter("/actual/close", &controllers.OrderInfoController{}, "POST:OrderDisable"), |
44 | beego.NSRouter("/fileImportTemplate", &controllers.OrderInfoController{}, "POST:DownloadTemplate"), // 下载导入模板 | 44 | beego.NSRouter("/fileImportTemplate", &controllers.OrderInfoController{}, "POST:DownloadTemplate"), // 下载导入模板 |
45 | beego.NSRouter("/fileImport", &controllers.OrderInfoController{}, "POST:ImportOrderFromExcel"), // 导入订单数据 | 45 | beego.NSRouter("/fileImport", &controllers.OrderInfoController{}, "POST:ImportOrderFromExcel"), // 导入订单数据 |
46 | - beego.NSRouter("/actual/listColumn", &controllers.ColumnSettingController{}, "POST:ListColumnSetting"), // 返回栏目设置列表 | 46 | + beego.NSRouter("/actual/listColumn", &controllers.ColumnSettingController{}, "POST:GetColumnSetting"), // 返回栏目设置列表 |
47 | beego.NSRouter("/actual/updateColumn", &controllers.ColumnSettingController{}, "POST:UpdateColumnSetting"), // 更新栏目设置 | 47 | beego.NSRouter("/actual/updateColumn", &controllers.ColumnSettingController{}, "POST:UpdateColumnSetting"), // 更新栏目设置 |
48 | beego.NSRouter("/actual/resetColumn", &controllers.ColumnSettingController{}, "Post:ResetColumn"), // 重置栏目设置 | 48 | beego.NSRouter("/actual/resetColumn", &controllers.ColumnSettingController{}, "Post:ResetColumn"), // 重置栏目设置 |
49 | ), | 49 | ), |
-
请 注册 或 登录 后发表评论