...
|
...
|
@@ -40,7 +40,7 @@ func Favorite(header *protocol.RequestHeader, request *protocol.FavoriteRequest) |
|
|
Id: f.Id,
|
|
|
}
|
|
|
switch f.SourceType {
|
|
|
case protocol.SourceType_Chance:
|
|
|
case protocol.SourceTypeChance:
|
|
|
chance, err = agg.GetChance(f.SourceId, f.CompanyId)
|
|
|
if err != nil {
|
|
|
log.Error(err)
|
...
|
...
|
@@ -49,7 +49,7 @@ func Favorite(header *protocol.RequestHeader, request *protocol.FavoriteRequest) |
|
|
chance.IsZan = (f.MarkFlag & protocol.MarkFlag_Zan) == protocol.MarkFlag_Zan
|
|
|
chance.IsCollect = (f.MarkFlag & protocol.MarkFlag_Collect) == protocol.MarkFlag_Collect
|
|
|
item.Favorite = chance
|
|
|
case protocol.SourceType_Comment:
|
|
|
case protocol.SourceTypeComment:
|
|
|
}
|
|
|
rsp.Lists[i] = item
|
|
|
}
|
...
|
...
|
@@ -71,7 +71,7 @@ func SympathyAction(header *protocol.RequestHeader, request *protocol.SympathyAc |
|
|
log.Error(err)
|
|
|
return
|
|
|
}
|
|
|
if request.SourceType == protocol.SourceType_Chance {
|
|
|
if request.SourceType == protocol.SourceTypeChance {
|
|
|
if chance, err = repository.Chance.GetChanceById(request.Id); err != nil {
|
|
|
log.Error("机会不存在", err)
|
|
|
return
|
...
|
...
|
@@ -258,14 +258,14 @@ func ChanceSubmit(header *protocol.RequestHeader, request *protocol.ChanceSubmit |
|
|
}
|
|
|
//6.文件
|
|
|
{
|
|
|
data :=&models.ChanceData{
|
|
|
Id:idgen.Next(),
|
|
|
ChanceId:chance.Id,
|
|
|
Speechs:common.AssertJson(request.Speechs),
|
|
|
Images:common.AssertJson(request.Pictures),
|
|
|
Videos:common.AssertJson(request.Videos),
|
|
|
CreateAt:time.Now(),
|
|
|
UpdateAt:time.Now(),
|
|
|
data := &models.ChanceData{
|
|
|
Id: idgen.Next(),
|
|
|
ChanceId: chance.Id,
|
|
|
Speechs: common.AssertJson(request.Speechs),
|
|
|
Images: common.AssertJson(request.Pictures),
|
|
|
Videos: common.AssertJson(request.Videos),
|
|
|
CreateAt: time.Now(),
|
|
|
UpdateAt: time.Now(),
|
|
|
}
|
|
|
if _, err = orm.Insert(data); err != nil {
|
|
|
log.Error(err)
|
...
|
...
|
@@ -288,16 +288,16 @@ func ChanceUpdate(header *protocol.RequestHeader, request *protocol.ChanceSubmit |
|
|
auditConfig *protocol.AuditConfig
|
|
|
chanceData *models.ChanceData
|
|
|
//auditFlows []*models.AuditFlowProcess
|
|
|
updateMap =make(map[string]interface{})
|
|
|
updateMap = make(map[string]interface{})
|
|
|
)
|
|
|
if chance,err =models.GetChanceById(request.Id);err!=nil{
|
|
|
if chance, err = models.GetChanceById(request.Id); err != nil {
|
|
|
log.Error(err)
|
|
|
return
|
|
|
}
|
|
|
//TODO:非本人 1.需要验证角色权限,是否是审核人
|
|
|
if chance.UserId!=header.Uid{
|
|
|
if chance.UserId != header.Uid {
|
|
|
err = protocol.NewErrWithMessage(1)
|
|
|
log.Error(fmt.Sprintf("user:%v 无权限操作机会 chance:%v",header.Uid,chance.Id))
|
|
|
log.Error(fmt.Sprintf("user:%v 无权限操作机会 chance:%v", header.Uid, chance.Id))
|
|
|
return
|
|
|
}
|
|
|
//TODO:验证机会当前是否在审核中
|
...
|
...
|
@@ -315,14 +315,13 @@ func ChanceUpdate(header *protocol.RequestHeader, request *protocol.ChanceSubmit |
|
|
updateMap["SourceContent"] = common.AssertJson(request.FormList)
|
|
|
updateMap["DepartmentId"] = request.RelatedDepartment
|
|
|
|
|
|
if err = utils.UpdateTableByMapWithOrmer(orm,&models.Chance{Id:chance.Id},updateMap); err != nil {
|
|
|
if err = utils.UpdateTableByMapWithOrmer(orm, &models.Chance{Id: chance.Id}, updateMap); err != nil {
|
|
|
log.Error(err)
|
|
|
orm.Rollback()
|
|
|
return
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
//4.查询审核配置
|
|
|
//5.生成审核流 删除旧的 生成新的
|
|
|
//if auditFlows, err = GenAuditFlowProcess(header, chance.Id, template.Id, auditConfig); err != nil {
|
...
|
...
|
@@ -340,26 +339,26 @@ func ChanceUpdate(header *protocol.RequestHeader, request *protocol.ChanceSubmit |
|
|
|
|
|
//6.更新文件
|
|
|
{
|
|
|
if chanceData,err = models.GetChanceDataByChanceId(chance.Id);err==nil{
|
|
|
if err = utils.UpdateTableByMapWithOrmer(orm,chanceData,map[string]interface{}{
|
|
|
"Speechs":common.AssertJson(request.Speechs),
|
|
|
"Images":common.AssertJson(request.Pictures),
|
|
|
"Videos":common.AssertJson(request.Videos),
|
|
|
"UpdateAt":time.Now(),
|
|
|
});err!=nil{
|
|
|
if chanceData, err = models.GetChanceDataByChanceId(chance.Id); err == nil {
|
|
|
if err = utils.UpdateTableByMapWithOrmer(orm, chanceData, map[string]interface{}{
|
|
|
"Speechs": common.AssertJson(request.Speechs),
|
|
|
"Images": common.AssertJson(request.Pictures),
|
|
|
"Videos": common.AssertJson(request.Videos),
|
|
|
"UpdateAt": time.Now(),
|
|
|
}); err != nil {
|
|
|
log.Error(err)
|
|
|
orm.Rollback()
|
|
|
return
|
|
|
}
|
|
|
}else{
|
|
|
data :=&models.ChanceData{
|
|
|
Id:idgen.Next(),
|
|
|
ChanceId:chance.Id,
|
|
|
Speechs:common.AssertJson(request.Speechs),
|
|
|
Images:common.AssertJson(request.Pictures),
|
|
|
Videos:common.AssertJson(request.Videos),
|
|
|
CreateAt:time.Now(),
|
|
|
UpdateAt:time.Now(),
|
|
|
} else {
|
|
|
data := &models.ChanceData{
|
|
|
Id: idgen.Next(),
|
|
|
ChanceId: chance.Id,
|
|
|
Speechs: common.AssertJson(request.Speechs),
|
|
|
Images: common.AssertJson(request.Pictures),
|
|
|
Videos: common.AssertJson(request.Videos),
|
|
|
CreateAt: time.Now(),
|
|
|
UpdateAt: time.Now(),
|
|
|
}
|
|
|
if _, err = orm.Insert(data); err != nil {
|
|
|
log.Error(err)
|
...
|
...
|
|