|
@@ -40,7 +40,7 @@ func Favorite(header *protocol.RequestHeader, request *protocol.FavoriteRequest) |
|
@@ -40,7 +40,7 @@ func Favorite(header *protocol.RequestHeader, request *protocol.FavoriteRequest) |
|
40
|
Id: f.Id,
|
40
|
Id: f.Id,
|
|
41
|
}
|
41
|
}
|
|
42
|
switch f.SourceType {
|
42
|
switch f.SourceType {
|
|
43
|
- case protocol.SourceType_Chance:
|
43
|
+ case protocol.SourceTypeChance:
|
|
44
|
chance, err = agg.GetChance(f.SourceId, f.CompanyId)
|
44
|
chance, err = agg.GetChance(f.SourceId, f.CompanyId)
|
|
45
|
if err != nil {
|
45
|
if err != nil {
|
|
46
|
log.Error(err)
|
46
|
log.Error(err)
|
|
@@ -49,7 +49,7 @@ func Favorite(header *protocol.RequestHeader, request *protocol.FavoriteRequest) |
|
@@ -49,7 +49,7 @@ func Favorite(header *protocol.RequestHeader, request *protocol.FavoriteRequest) |
|
49
|
chance.IsZan = (f.MarkFlag & protocol.MarkFlag_Zan) == protocol.MarkFlag_Zan
|
49
|
chance.IsZan = (f.MarkFlag & protocol.MarkFlag_Zan) == protocol.MarkFlag_Zan
|
|
50
|
chance.IsCollect = (f.MarkFlag & protocol.MarkFlag_Collect) == protocol.MarkFlag_Collect
|
50
|
chance.IsCollect = (f.MarkFlag & protocol.MarkFlag_Collect) == protocol.MarkFlag_Collect
|
|
51
|
item.Favorite = chance
|
51
|
item.Favorite = chance
|
|
52
|
- case protocol.SourceType_Comment:
|
52
|
+ case protocol.SourceTypeComment:
|
|
53
|
}
|
53
|
}
|
|
54
|
rsp.Lists[i] = item
|
54
|
rsp.Lists[i] = item
|
|
55
|
}
|
55
|
}
|
|
@@ -71,7 +71,7 @@ func SympathyAction(header *protocol.RequestHeader, request *protocol.SympathyAc |
|
@@ -71,7 +71,7 @@ func SympathyAction(header *protocol.RequestHeader, request *protocol.SympathyAc |
|
71
|
log.Error(err)
|
71
|
log.Error(err)
|
|
72
|
return
|
72
|
return
|
|
73
|
}
|
73
|
}
|
|
74
|
- if request.SourceType == protocol.SourceType_Chance {
|
74
|
+ if request.SourceType == protocol.SourceTypeChance {
|
|
75
|
if chance, err = repository.Chance.GetChanceById(request.Id); err != nil {
|
75
|
if chance, err = repository.Chance.GetChanceById(request.Id); err != nil {
|
|
76
|
log.Error("机会不存在", err)
|
76
|
log.Error("机会不存在", err)
|
|
77
|
return
|
77
|
return
|
|
@@ -258,14 +258,14 @@ func ChanceSubmit(header *protocol.RequestHeader, request *protocol.ChanceSubmit |
|
@@ -258,14 +258,14 @@ func ChanceSubmit(header *protocol.RequestHeader, request *protocol.ChanceSubmit |
|
258
|
}
|
258
|
}
|
|
259
|
//6.文件
|
259
|
//6.文件
|
|
260
|
{
|
260
|
{
|
|
261
|
- data :=&models.ChanceData{
|
|
|
|
262
|
- Id:idgen.Next(),
|
|
|
|
263
|
- ChanceId:chance.Id,
|
|
|
|
264
|
- Speechs:common.AssertJson(request.Speechs),
|
|
|
|
265
|
- Images:common.AssertJson(request.Pictures),
|
|
|
|
266
|
- Videos:common.AssertJson(request.Videos),
|
|
|
|
267
|
- CreateAt:time.Now(),
|
|
|
|
268
|
- UpdateAt:time.Now(),
|
261
|
+ data := &models.ChanceData{
|
|
|
|
262
|
+ Id: idgen.Next(),
|
|
|
|
263
|
+ ChanceId: chance.Id,
|
|
|
|
264
|
+ Speechs: common.AssertJson(request.Speechs),
|
|
|
|
265
|
+ Images: common.AssertJson(request.Pictures),
|
|
|
|
266
|
+ Videos: common.AssertJson(request.Videos),
|
|
|
|
267
|
+ CreateAt: time.Now(),
|
|
|
|
268
|
+ UpdateAt: time.Now(),
|
|
269
|
}
|
269
|
}
|
|
270
|
if _, err = orm.Insert(data); err != nil {
|
270
|
if _, err = orm.Insert(data); err != nil {
|
|
271
|
log.Error(err)
|
271
|
log.Error(err)
|
|
@@ -288,16 +288,16 @@ func ChanceUpdate(header *protocol.RequestHeader, request *protocol.ChanceSubmit |
|
@@ -288,16 +288,16 @@ func ChanceUpdate(header *protocol.RequestHeader, request *protocol.ChanceSubmit |
|
288
|
auditConfig *protocol.AuditConfig
|
288
|
auditConfig *protocol.AuditConfig
|
|
289
|
chanceData *models.ChanceData
|
289
|
chanceData *models.ChanceData
|
|
290
|
//auditFlows []*models.AuditFlowProcess
|
290
|
//auditFlows []*models.AuditFlowProcess
|
|
291
|
- updateMap =make(map[string]interface{})
|
291
|
+ updateMap = make(map[string]interface{})
|
|
292
|
)
|
292
|
)
|
|
293
|
- if chance,err =models.GetChanceById(request.Id);err!=nil{
|
293
|
+ if chance, err = models.GetChanceById(request.Id); err != nil {
|
|
294
|
log.Error(err)
|
294
|
log.Error(err)
|
|
295
|
return
|
295
|
return
|
|
296
|
}
|
296
|
}
|
|
297
|
//TODO:非本人 1.需要验证角色权限,是否是审核人
|
297
|
//TODO:非本人 1.需要验证角色权限,是否是审核人
|
|
298
|
- if chance.UserId!=header.Uid{
|
298
|
+ if chance.UserId != header.Uid {
|
|
299
|
err = protocol.NewErrWithMessage(1)
|
299
|
err = protocol.NewErrWithMessage(1)
|
|
300
|
- log.Error(fmt.Sprintf("user:%v 无权限操作机会 chance:%v",header.Uid,chance.Id))
|
300
|
+ log.Error(fmt.Sprintf("user:%v 无权限操作机会 chance:%v", header.Uid, chance.Id))
|
|
301
|
return
|
301
|
return
|
|
302
|
}
|
302
|
}
|
|
303
|
//TODO:验证机会当前是否在审核中
|
303
|
//TODO:验证机会当前是否在审核中
|
|
@@ -315,14 +315,13 @@ func ChanceUpdate(header *protocol.RequestHeader, request *protocol.ChanceSubmit |
|
@@ -315,14 +315,13 @@ func ChanceUpdate(header *protocol.RequestHeader, request *protocol.ChanceSubmit |
|
315
|
updateMap["SourceContent"] = common.AssertJson(request.FormList)
|
315
|
updateMap["SourceContent"] = common.AssertJson(request.FormList)
|
|
316
|
updateMap["DepartmentId"] = request.RelatedDepartment
|
316
|
updateMap["DepartmentId"] = request.RelatedDepartment
|
|
317
|
|
317
|
|
|
318
|
- if err = utils.UpdateTableByMapWithOrmer(orm,&models.Chance{Id:chance.Id},updateMap); err != nil {
|
318
|
+ if err = utils.UpdateTableByMapWithOrmer(orm, &models.Chance{Id: chance.Id}, updateMap); err != nil {
|
|
319
|
log.Error(err)
|
319
|
log.Error(err)
|
|
320
|
orm.Rollback()
|
320
|
orm.Rollback()
|
|
321
|
return
|
321
|
return
|
|
322
|
}
|
322
|
}
|
|
323
|
}
|
323
|
}
|
|
324
|
|
324
|
|
|
325
|
-
|
|
|
|
326
|
//4.查询审核配置
|
325
|
//4.查询审核配置
|
|
327
|
//5.生成审核流 删除旧的 生成新的
|
326
|
//5.生成审核流 删除旧的 生成新的
|
|
328
|
//if auditFlows, err = GenAuditFlowProcess(header, chance.Id, template.Id, auditConfig); err != nil {
|
327
|
//if auditFlows, err = GenAuditFlowProcess(header, chance.Id, template.Id, auditConfig); err != nil {
|
|
@@ -340,26 +339,26 @@ func ChanceUpdate(header *protocol.RequestHeader, request *protocol.ChanceSubmit |
|
@@ -340,26 +339,26 @@ func ChanceUpdate(header *protocol.RequestHeader, request *protocol.ChanceSubmit |
|
340
|
|
339
|
|
|
341
|
//6.更新文件
|
340
|
//6.更新文件
|
|
342
|
{
|
341
|
{
|
|
343
|
- if chanceData,err = models.GetChanceDataByChanceId(chance.Id);err==nil{
|
|
|
|
344
|
- if err = utils.UpdateTableByMapWithOrmer(orm,chanceData,map[string]interface{}{
|
|
|
|
345
|
- "Speechs":common.AssertJson(request.Speechs),
|
|
|
|
346
|
- "Images":common.AssertJson(request.Pictures),
|
|
|
|
347
|
- "Videos":common.AssertJson(request.Videos),
|
|
|
|
348
|
- "UpdateAt":time.Now(),
|
|
|
|
349
|
- });err!=nil{
|
342
|
+ if chanceData, err = models.GetChanceDataByChanceId(chance.Id); err == nil {
|
|
|
|
343
|
+ if err = utils.UpdateTableByMapWithOrmer(orm, chanceData, map[string]interface{}{
|
|
|
|
344
|
+ "Speechs": common.AssertJson(request.Speechs),
|
|
|
|
345
|
+ "Images": common.AssertJson(request.Pictures),
|
|
|
|
346
|
+ "Videos": common.AssertJson(request.Videos),
|
|
|
|
347
|
+ "UpdateAt": time.Now(),
|
|
|
|
348
|
+ }); err != nil {
|
|
350
|
log.Error(err)
|
349
|
log.Error(err)
|
|
351
|
orm.Rollback()
|
350
|
orm.Rollback()
|
|
352
|
return
|
351
|
return
|
|
353
|
}
|
352
|
}
|
|
354
|
- }else{
|
|
|
|
355
|
- data :=&models.ChanceData{
|
|
|
|
356
|
- Id:idgen.Next(),
|
|
|
|
357
|
- ChanceId:chance.Id,
|
|
|
|
358
|
- Speechs:common.AssertJson(request.Speechs),
|
|
|
|
359
|
- Images:common.AssertJson(request.Pictures),
|
|
|
|
360
|
- Videos:common.AssertJson(request.Videos),
|
|
|
|
361
|
- CreateAt:time.Now(),
|
|
|
|
362
|
- UpdateAt:time.Now(),
|
353
|
+ } else {
|
|
|
|
354
|
+ data := &models.ChanceData{
|
|
|
|
355
|
+ Id: idgen.Next(),
|
|
|
|
356
|
+ ChanceId: chance.Id,
|
|
|
|
357
|
+ Speechs: common.AssertJson(request.Speechs),
|
|
|
|
358
|
+ Images: common.AssertJson(request.Pictures),
|
|
|
|
359
|
+ Videos: common.AssertJson(request.Videos),
|
|
|
|
360
|
+ CreateAt: time.Now(),
|
|
|
|
361
|
+ UpdateAt: time.Now(),
|
|
363
|
}
|
362
|
}
|
|
364
|
if _, err = orm.Insert(data); err != nil {
|
363
|
if _, err = orm.Insert(data); err != nil {
|
|
365
|
log.Error(err)
|
364
|
log.Error(err)
|