正在显示
7 个修改的文件
包含
187 行增加
和
73 行删除
@@ -180,6 +180,7 @@ func (employeeService *EmployeeService) ListEmployee(listEmployeeQuery *query.Li | @@ -180,6 +180,7 @@ func (employeeService *EmployeeService) ListEmployee(listEmployeeQuery *query.Li | ||
180 | if err := listEmployeeQuery.ValidateQuery(); err != nil { | 180 | if err := listEmployeeQuery.ValidateQuery(); err != nil { |
181 | return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | 181 | return nil, application.ThrowError(application.ARG_ERROR, err.Error()) |
182 | } | 182 | } |
183 | + | ||
183 | transactionContext, err := factory.CreateTransactionContext(nil) | 184 | transactionContext, err := factory.CreateTransactionContext(nil) |
184 | if err != nil { | 185 | if err != nil { |
185 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 186 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
@@ -35,4 +35,12 @@ func CreateCashPoolDao(options map[string]interface{}) (*dao.CashPoolDao, error) | @@ -35,4 +35,12 @@ func CreateCashPoolDao(options map[string]interface{}) (*dao.CashPoolDao, error) | ||
35 | transactionContext = value.(*pg.TransactionContext) | 35 | transactionContext = value.(*pg.TransactionContext) |
36 | } | 36 | } |
37 | return dao.NewCashPoolDao(transactionContext) | 37 | return dao.NewCashPoolDao(transactionContext) |
38 | +} | ||
39 | + | ||
40 | +func CreateListIntervalDao(options map[string]interface{}) (*dao.ListIntervalDao, error) { | ||
41 | + var transactionContext *pg.TransactionContext | ||
42 | + if value, ok := options["transactionContext"]; ok { | ||
43 | + transactionContext = value.(*pg.TransactionContext) | ||
44 | + } | ||
45 | + return dao.NewListIntervalDao(transactionContext) | ||
38 | } | 46 | } |
@@ -8,6 +8,7 @@ import ( | @@ -8,6 +8,7 @@ import ( | ||
8 | "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/listInterval/command" | 8 | "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/listInterval/command" |
9 | "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/listInterval/query" | 9 | "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/listInterval/query" |
10 | "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain" | 10 | "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain" |
11 | + "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/infrastructure/dao" | ||
11 | "time" | 12 | "time" |
12 | ) | 13 | ) |
13 | 14 | ||
@@ -40,6 +41,16 @@ func (listIntervalService *ListIntervalService) CreateListInterval(createListInt | @@ -40,6 +41,16 @@ func (listIntervalService *ListIntervalService) CreateListInterval(createListInt | ||
40 | listIntervalRepository = value | 41 | listIntervalRepository = value |
41 | } | 42 | } |
42 | 43 | ||
44 | + // 排行榜管理DAO初始化 | ||
45 | + var listIntervalDao *dao.ListIntervalDao | ||
46 | + if value, err := factory.CreateListIntervalDao(map[string]interface{}{ | ||
47 | + "transactionContext": transactionContext, | ||
48 | + }); err != nil { | ||
49 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
50 | + } else { | ||
51 | + listIntervalDao = value | ||
52 | + } | ||
53 | + | ||
43 | // 获取当前最新排行榜时间 | 54 | // 获取当前最新排行榜时间 |
44 | listListIntervalQuery := &query.ListListIntervalQuery { | 55 | listListIntervalQuery := &query.ListListIntervalQuery { |
45 | CompanyId: createListIntervalCommand.CompanyId, | 56 | CompanyId: createListIntervalCommand.CompanyId, |
@@ -56,6 +67,10 @@ func (listIntervalService *ListIntervalService) CreateListInterval(createListInt | @@ -56,6 +67,10 @@ func (listIntervalService *ListIntervalService) CreateListInterval(createListInt | ||
56 | startTime := time.Date(createListIntervalCommand.ListIntervalStartTime.Local().Year(), createListIntervalCommand.ListIntervalStartTime.Local().Month(), createListIntervalCommand.ListIntervalStartTime.Local().Day(), 0, 0, 0, 0, time.Local) | 67 | startTime := time.Date(createListIntervalCommand.ListIntervalStartTime.Local().Year(), createListIntervalCommand.ListIntervalStartTime.Local().Month(), createListIntervalCommand.ListIntervalStartTime.Local().Day(), 0, 0, 0, 0, time.Local) |
57 | endTime := time.Date(createListIntervalCommand.ListIntervalEndTime.Local().Year(), createListIntervalCommand.ListIntervalEndTime.Local().Month(), createListIntervalCommand.ListIntervalEndTime.Local().Day(), 23, 59, 59, 0, time.Local) | 68 | endTime := time.Date(createListIntervalCommand.ListIntervalEndTime.Local().Year(), createListIntervalCommand.ListIntervalEndTime.Local().Month(), createListIntervalCommand.ListIntervalEndTime.Local().Day(), 23, 59, 59, 0, time.Local) |
58 | 69 | ||
70 | + ok := listIntervalDao.RankPeriodCheckTime(startTime.UnixNano() / 1e6, endTime.UnixNano() / 1e6, 0) | ||
71 | + if !ok { | ||
72 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "年榜时间不能重叠") | ||
73 | + } | ||
59 | 74 | ||
60 | // 判断年榜时间是否和上个年榜重叠 | 75 | // 判断年榜时间是否和上个年榜重叠 |
61 | if len(listIntervals) > 0 { | 76 | if len(listIntervals) > 0 { |
@@ -193,6 +208,7 @@ func (listIntervalService *ListIntervalService) UpdateListInterval(updateListInt | @@ -193,6 +208,7 @@ func (listIntervalService *ListIntervalService) UpdateListInterval(updateListInt | ||
193 | transactionContext.RollbackTransaction() | 208 | transactionContext.RollbackTransaction() |
194 | }() | 209 | }() |
195 | 210 | ||
211 | + // 排行榜管理仓储初始化 | ||
196 | var listIntervalRepository domain.ListIntervalRepository | 212 | var listIntervalRepository domain.ListIntervalRepository |
197 | if value, err := factory.CreateListIntervalRepository(map[string]interface{}{ | 213 | if value, err := factory.CreateListIntervalRepository(map[string]interface{}{ |
198 | "transactionContext": transactionContext, | 214 | "transactionContext": transactionContext, |
@@ -202,6 +218,16 @@ func (listIntervalService *ListIntervalService) UpdateListInterval(updateListInt | @@ -202,6 +218,16 @@ func (listIntervalService *ListIntervalService) UpdateListInterval(updateListInt | ||
202 | listIntervalRepository = value | 218 | listIntervalRepository = value |
203 | } | 219 | } |
204 | 220 | ||
221 | + // 排行榜管理DAO初始化 | ||
222 | + var listIntervalDao *dao.ListIntervalDao | ||
223 | + if value, err := factory.CreateListIntervalDao(map[string]interface{}{ | ||
224 | + "transactionContext": transactionContext, | ||
225 | + }); err != nil { | ||
226 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
227 | + } else { | ||
228 | + listIntervalDao = value | ||
229 | + } | ||
230 | + | ||
205 | // 获取当前年榜 | 231 | // 获取当前年榜 |
206 | listIntervalFound, err := listIntervalRepository.FindOne(map[string]interface{}{"listId": updateListIntervalCommand.ListIntervalId}) | 232 | listIntervalFound, err := listIntervalRepository.FindOne(map[string]interface{}{"listId": updateListIntervalCommand.ListIntervalId}) |
207 | if err != nil { | 233 | if err != nil { |
@@ -211,89 +237,103 @@ func (listIntervalService *ListIntervalService) UpdateListInterval(updateListInt | @@ -211,89 +237,103 @@ func (listIntervalService *ListIntervalService) UpdateListInterval(updateListInt | ||
211 | return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(updateListIntervalCommand.ListIntervalId))) | 237 | return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(updateListIntervalCommand.ListIntervalId))) |
212 | } | 238 | } |
213 | 239 | ||
214 | - // 获取榜单命令 | ||
215 | - listListIntervalQuery := &query.ListListIntervalQuery { | ||
216 | - CompanyId: listIntervalFound.CompanyId, | ||
217 | - } | ||
218 | - | ||
219 | - //获取所有年榜 | ||
220 | - _, listIntervals, err := listIntervalRepository.Find(tool_funs.SimpleStructToMap(listListIntervalQuery)) | ||
221 | - if err != nil { | ||
222 | - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
223 | - } | ||
224 | - | ||
225 | - var currentListIntervalIndex int | 240 | + //// 获取所有年榜 |
241 | + //listListIntervalQuery := &query.ListListIntervalQuery { | ||
242 | + // CompanyId: listIntervalFound.CompanyId, | ||
243 | + //} | ||
244 | + ////获取所有年榜 | ||
245 | + //_, listIntervals, err := listIntervalRepository.Find(tool_funs.SimpleStructToMap(listListIntervalQuery)) | ||
246 | + //if err != nil { | ||
247 | + // return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
248 | + //} | ||
249 | + // | ||
250 | + //var currentListIntervalIndex int | ||
226 | 251 | ||
227 | // 当前更新的开始结束时间 | 252 | // 当前更新的开始结束时间 |
228 | startTime := time.Date(updateListIntervalCommand.ListIntervalStartTime.Local().Year(), updateListIntervalCommand.ListIntervalStartTime.Local().Month(), updateListIntervalCommand.ListIntervalStartTime.Local().Day(), 0, 0, 0, 0, time.Local) | 253 | startTime := time.Date(updateListIntervalCommand.ListIntervalStartTime.Local().Year(), updateListIntervalCommand.ListIntervalStartTime.Local().Month(), updateListIntervalCommand.ListIntervalStartTime.Local().Day(), 0, 0, 0, 0, time.Local) |
229 | endTime := time.Date(updateListIntervalCommand.ListIntervalEndTime.Local().Year(), updateListIntervalCommand.ListIntervalEndTime.Local().Month(), updateListIntervalCommand.ListIntervalEndTime.Local().Day(), 23, 59, 59, 0, time.Local) | 254 | endTime := time.Date(updateListIntervalCommand.ListIntervalEndTime.Local().Year(), updateListIntervalCommand.ListIntervalEndTime.Local().Month(), updateListIntervalCommand.ListIntervalEndTime.Local().Day(), 23, 59, 59, 0, time.Local) |
230 | - | ||
231 | updateListIntervalCommand.ListIntervalStartTime = startTime | 255 | updateListIntervalCommand.ListIntervalStartTime = startTime |
232 | updateListIntervalCommand.ListIntervalEndTime = endTime | 256 | updateListIntervalCommand.ListIntervalEndTime = endTime |
233 | 257 | ||
234 | - // 判断年榜时间是否和上个年榜重叠 | ||
235 | - if len(listIntervals) > 0 { | ||
236 | - | ||
237 | - // 找到当前排行榜所处位置 | ||
238 | - for i, listInterval := range listIntervals { | ||
239 | - if listInterval.ListIntervalId == listIntervalFound.ListIntervalId { | ||
240 | - currentListIntervalIndex = i | ||
241 | - } | ||
242 | - } | ||
243 | - | ||
244 | - if currentListIntervalIndex == 0 && len(listIntervals) > 1 { // 当前排行榜在首位,且不止一个活动 | ||
245 | - // 上一个活动开始结束时间 | ||
246 | - //lastIntervalStartTime := listIntervals[currentListIntervalIndex + 1].IntervalStartTime.Local() | ||
247 | - lastIntervalEndTime := listIntervals[currentListIntervalIndex + 1].IntervalEndTime.Local() | ||
248 | - | ||
249 | - if startTime.Before(lastIntervalEndTime) || startTime.Equal(lastIntervalEndTime) { // 开始时间重叠判断 | ||
250 | - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "年榜时间不能重叠") | ||
251 | - } | ||
252 | - } else if currentListIntervalIndex != 0 { // 当前排行榜不在首位 | ||
253 | - fmt.Print(currentListIntervalIndex, "\n") | ||
254 | - | ||
255 | - // 上一个年榜开始结束时间 | ||
256 | - lastIntervalStartTime := listIntervals[currentListIntervalIndex + 1].IntervalStartTime.Local() | ||
257 | - lastIntervalEndTime := listIntervals[currentListIntervalIndex + 1].IntervalEndTime.Local() | ||
258 | - fmt.Print(lastIntervalEndTime,"\n") | ||
259 | - | ||
260 | - // 下一个年榜开始结束时间 | ||
261 | - nextIntervalStartTime := listIntervals[currentListIntervalIndex - 1].IntervalStartTime.Local() | ||
262 | - fmt.Print(nextIntervalStartTime, "\n") | ||
263 | - nextIntervalEndTime := listIntervals[currentListIntervalIndex - 1].IntervalEndTime.Local() | ||
264 | - | ||
265 | - fmt.Print(startTime, "\n") | ||
266 | - fmt.Print(endTime, "\n") | ||
267 | - | ||
268 | - if startTime.After(lastIntervalStartTime) && startTime.Before(lastIntervalEndTime) || endTime.After(nextIntervalStartTime) && endTime.Before(nextIntervalEndTime) { | ||
269 | - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "年榜时间不能重叠") | ||
270 | - } | ||
271 | - } | 258 | + ok := listIntervalDao.RankPeriodCheckTime(startTime.UnixNano() / 1e6, endTime.UnixNano() / 1e6, listIntervalFound.ListIntervalId) |
259 | + if !ok { | ||
260 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "年榜时间不能重叠") | ||
261 | + } | ||
272 | 262 | ||
273 | - if err := listIntervalFound.Update(tool_funs.SimpleStructToMap(updateListIntervalCommand)); err != nil { | ||
274 | - return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) | ||
275 | - } | ||
276 | - if listIntervalUpdated, err := listIntervalRepository.Save(listIntervalFound); err != nil { | ||
277 | - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
278 | - } else { | ||
279 | - if err := transactionContext.CommitTransaction(); err != nil { | ||
280 | - return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
281 | - } | ||
282 | - return listIntervalUpdated, nil | ||
283 | - } | ||
284 | - } else { // 正常更新 | ||
285 | - if err := listIntervalFound.Update(tool_funs.SimpleStructToMap(updateListIntervalCommand)); err != nil { | ||
286 | - return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) | ||
287 | - } | ||
288 | - if listIntervalUpdated, err := listIntervalRepository.Save(listIntervalFound); err != nil { | ||
289 | - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
290 | - } else { | ||
291 | - if err := transactionContext.CommitTransaction(); err != nil { | ||
292 | - return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
293 | - } | ||
294 | - return listIntervalUpdated, nil | 263 | + if err := listIntervalFound.Update(tool_funs.SimpleStructToMap(updateListIntervalCommand)); err != nil { |
264 | + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) | ||
265 | + } | ||
266 | + if listIntervalUpdated, err := listIntervalRepository.Save(listIntervalFound); err != nil { | ||
267 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
268 | + } else { | ||
269 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
270 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
295 | } | 271 | } |
272 | + return listIntervalUpdated, nil | ||
296 | } | 273 | } |
274 | + | ||
275 | + // 判断年榜时间是否和上个年榜重叠 | ||
276 | + //if len(listIntervals) > 0 { | ||
277 | + // // 找到当前排行榜所处位置 | ||
278 | + // for i, listInterval := range listIntervals { | ||
279 | + // if listInterval.ListIntervalId == listIntervalFound.ListIntervalId { | ||
280 | + // currentListIntervalIndex = i | ||
281 | + // } | ||
282 | + // } | ||
283 | + // | ||
284 | + // if currentListIntervalIndex == 0 && len(listIntervals) > 1 { // 当前排行榜在首位,且不止一个活动 | ||
285 | + // // 上一个活动开始结束时间 | ||
286 | + // //lastIntervalStartTime := listIntervals[currentListIntervalIndex + 1].IntervalStartTime.Local() | ||
287 | + // lastIntervalEndTime := listIntervals[currentListIntervalIndex + 1].IntervalEndTime.Local() | ||
288 | + // | ||
289 | + // if startTime.Before(lastIntervalEndTime) || startTime.Equal(lastIntervalEndTime) { // 开始时间重叠判断 | ||
290 | + // return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "年榜时间不能重叠") | ||
291 | + // } | ||
292 | + // } else if currentListIntervalIndex != 0 { // 当前排行榜不在首位 | ||
293 | + // fmt.Print(currentListIntervalIndex, "\n") | ||
294 | + // | ||
295 | + // // 上一个年榜开始结束时间 | ||
296 | + // lastIntervalStartTime := listIntervals[currentListIntervalIndex + 1].IntervalStartTime.Local() | ||
297 | + // lastIntervalEndTime := listIntervals[currentListIntervalIndex + 1].IntervalEndTime.Local() | ||
298 | + // fmt.Print(lastIntervalEndTime,"\n") | ||
299 | + // | ||
300 | + // // 下一个年榜开始结束时间 | ||
301 | + // nextIntervalStartTime := listIntervals[currentListIntervalIndex - 1].IntervalStartTime.Local() | ||
302 | + // fmt.Print(nextIntervalStartTime, "\n") | ||
303 | + // nextIntervalEndTime := listIntervals[currentListIntervalIndex - 1].IntervalEndTime.Local() | ||
304 | + // | ||
305 | + // fmt.Print(startTime, "\n") | ||
306 | + // fmt.Print(endTime, "\n") | ||
307 | + // | ||
308 | + // if startTime.After(lastIntervalStartTime) && startTime.Before(lastIntervalEndTime) || endTime.After(nextIntervalStartTime) && endTime.Before(nextIntervalEndTime) { | ||
309 | + // return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "年榜时间不能重叠") | ||
310 | + // } | ||
311 | + // } | ||
312 | + // | ||
313 | + // if err := listIntervalFound.Update(tool_funs.SimpleStructToMap(updateListIntervalCommand)); err != nil { | ||
314 | + // return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) | ||
315 | + // } | ||
316 | + // if listIntervalUpdated, err := listIntervalRepository.Save(listIntervalFound); err != nil { | ||
317 | + // return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
318 | + // } else { | ||
319 | + // if err := transactionContext.CommitTransaction(); err != nil { | ||
320 | + // return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
321 | + // } | ||
322 | + // return listIntervalUpdated, nil | ||
323 | + // } | ||
324 | + //} else { // 正常更新 | ||
325 | + // if err := listIntervalFound.Update(tool_funs.SimpleStructToMap(updateListIntervalCommand)); err != nil { | ||
326 | + // return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) | ||
327 | + // } | ||
328 | + // if listIntervalUpdated, err := listIntervalRepository.Save(listIntervalFound); err != nil { | ||
329 | + // return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
330 | + // } else { | ||
331 | + // if err := transactionContext.CommitTransaction(); err != nil { | ||
332 | + // return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
333 | + // } | ||
334 | + // return listIntervalUpdated, nil | ||
335 | + // } | ||
336 | + //} | ||
297 | } | 337 | } |
298 | 338 | ||
299 | // 移除排行榜时间 | 339 | // 移除排行榜时间 |
@@ -23,6 +23,8 @@ type SearchTaskCommand struct { | @@ -23,6 +23,8 @@ type SearchTaskCommand struct { | ||
23 | TaskStatus int `json:"taskStatus,omitempty"` | 23 | TaskStatus int `json:"taskStatus,omitempty"` |
24 | // 任务状态ID列表 | 24 | // 任务状态ID列表 |
25 | TaskStates []int `json:"taskStates,omitempty"` | 25 | TaskStates []int `json:"taskStates,omitempty"` |
26 | + // 任务状态ID列表 | ||
27 | + TaskStatuss []int `json:"taskStatuss,omitempty"` | ||
26 | // 项目归属 | 28 | // 项目归属 |
27 | ProjectBelongs []int `json:"projectBelongs,omitempty"` | 29 | ProjectBelongs []int `json:"projectBelongs,omitempty"` |
28 | // 客户价值 | 30 | // 客户价值 |
@@ -134,6 +134,9 @@ func (unifiedUserCenterService *UnifiedUserCenterService) SyncEmployeeCallback(s | @@ -134,6 +134,9 @@ func (unifiedUserCenterService *UnifiedUserCenterService) SyncEmployeeCallback(s | ||
134 | if value, ok := addEmployee["status"]; ok { | 134 | if value, ok := addEmployee["status"]; ok { |
135 | status = int(value.(float64)) | 135 | status = int(value.(float64)) |
136 | } | 136 | } |
137 | + | ||
138 | + // TODO 增加员工判断 | ||
139 | + | ||
137 | employee := &domain.Employee{ | 140 | employee := &domain.Employee{ |
138 | CompanyId: companyId, | 141 | CompanyId: companyId, |
139 | EmployeeInfo: &domain.EmployeeInfo{ | 142 | EmployeeInfo: &domain.EmployeeInfo{ |
@@ -146,6 +149,7 @@ func (unifiedUserCenterService *UnifiedUserCenterService) SyncEmployeeCallback(s | @@ -146,6 +149,7 @@ func (unifiedUserCenterService *UnifiedUserCenterService) SyncEmployeeCallback(s | ||
146 | Status: status, | 149 | Status: status, |
147 | SuMoney: 0, | 150 | SuMoney: 0, |
148 | } | 151 | } |
152 | + | ||
149 | if _, err := employeeRepository.Save(employee); err != nil { | 153 | if _, err := employeeRepository.Save(employee); err != nil { |
150 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 154 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
151 | } | 155 | } |
1 | +package dao | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "github.com/go-pg/pg" | ||
6 | + pgTransaction "github.com/linmadan/egglib-go/transaction/pg" | ||
7 | +) | ||
8 | + | ||
9 | +type ListIntervalDao struct { | ||
10 | + transactionContext *pgTransaction.TransactionContext | ||
11 | +} | ||
12 | + | ||
13 | +// 榜单时间管理 | ||
14 | +func (dao *ListIntervalDao) RankPeriodCheckTime(startTime int64, endTime int64, idNot int) bool { | ||
15 | + tx := dao.transactionContext.PgTx | ||
16 | + cnt, err := tx.Query( | ||
17 | + pg.Scan(), | ||
18 | + `SELECT count(*) FROM list_interval | ||
19 | + WHERE id <> ? | ||
20 | + AND | ||
21 | + ( | ||
22 | + (UNIX_TIMESTAMP(start_time) BETWEEN ? AND ?) | ||
23 | + OR | ||
24 | + (UNIX_TIMESTAMP(end_time) BETWEEN ? AND ?) | ||
25 | + OR | ||
26 | + (? BETWEEN CAST(list_interval_start_time AS TIMESTAMP) AND CAST(list_interval_end_time AS TIMESTAMP)) | ||
27 | + OR | ||
28 | + (? BETWEEN CAST(list_interval_start_time AS TIMESTAMP) AND CAST(list_interval_end_time AS TIMESTAMP)) | ||
29 | + ) | ||
30 | + LIMIT 1 `, | ||
31 | + idNot, startTime, endTime, startTime, endTime, startTime, endTime) | ||
32 | + if err != nil { | ||
33 | + fmt.Errorf(err.Error()) | ||
34 | + return false | ||
35 | + } | ||
36 | + if cnt != nil { | ||
37 | + return false | ||
38 | + } | ||
39 | + return true | ||
40 | +} | ||
41 | + | ||
42 | +func NewListIntervalDao(transactionContext *pgTransaction.TransactionContext) (*ListIntervalDao, error) { | ||
43 | + if transactionContext == nil { | ||
44 | + return nil, fmt.Errorf("transactionContext参数不能为nil") | ||
45 | + } else { | ||
46 | + return &ListIntervalDao{ | ||
47 | + transactionContext: transactionContext, | ||
48 | + }, nil | ||
49 | + } | ||
50 | +} |
@@ -124,6 +124,15 @@ func (repository *TaskRepository) Find(queryOptions map[string]interface{}) (int | @@ -124,6 +124,15 @@ func (repository *TaskRepository) Find(queryOptions map[string]interface{}) (int | ||
124 | return q, nil | 124 | return q, nil |
125 | }) | 125 | }) |
126 | } | 126 | } |
127 | + if taskStatuss, ok := queryOptions["taskStatuss"]; ok && len(taskStatuss.([]int)) != 0 { | ||
128 | + //query = query.WhereGroup(func(q *orm.Query) (*orm.Query, error) { | ||
129 | + // for _, value := range taskStatuss.([]int) { | ||
130 | + // q = q.WhereOr("task.task_status = ?", value) | ||
131 | + // } | ||
132 | + // return q, nil | ||
133 | + //}) | ||
134 | + query = query.Where(`task.task_status IN (?)`, pg.In(taskStatuss.([]int64))) | ||
135 | + } | ||
127 | if taskType, ok := queryOptions["taskType"]; ok && (taskType != 0) { | 136 | if taskType, ok := queryOptions["taskType"]; ok && (taskType != 0) { |
128 | query = query.Where(`task.task_type = ?`, taskType) | 137 | query = query.Where(`task.task_type = ?`, taskType) |
129 | } | 138 | } |
-
请 注册 或 登录 后发表评论