...
|
...
|
@@ -76,7 +76,7 @@ func SympathyAction(header *protocol.RequestHeader, request *protocol.SympathyAc |
|
|
log.Error("机会不存在", err)
|
|
|
return
|
|
|
}
|
|
|
chanceType = chance.ChanceType
|
|
|
chanceType = chance.ChanceTypeId
|
|
|
table = "chance"
|
|
|
}
|
|
|
if chanceFavoirte != nil {
|
...
|
...
|
@@ -159,7 +159,7 @@ func Templates(header *protocol.RequestHeader, request *protocol.TemplatesReques |
|
|
forms []*models.AuditForm
|
|
|
)
|
|
|
rsp = &protocol.TemplatesResponse{}
|
|
|
if templates, err = models.GetAuditTemplates(header.CompanyId, request.ChanceType); err != nil {
|
|
|
if templates, err = models.GetAuditTemplates(header.CompanyId, request.ChanceTypeId); err != nil {
|
|
|
log.Error(err)
|
|
|
return
|
|
|
}
|
...
|
...
|
@@ -225,7 +225,7 @@ func ChanceSubmit(header *protocol.RequestHeader, request *protocol.ChanceSubmit |
|
|
Id: idgen.Next(),
|
|
|
UserId: header.Uid,
|
|
|
CompanyId: header.CompanyId,
|
|
|
ChanceType: template.ChanceType,
|
|
|
ChanceTypeId: template.ChanceTypeId,
|
|
|
AuditTemplateId: template.Id,
|
|
|
AuditTemplateConfig: common.AssertJson(auditConfig),
|
|
|
Content: request.Content,
|
...
|
...
|
@@ -255,30 +255,119 @@ func ChanceSubmit(header *protocol.RequestHeader, request *protocol.ChanceSubmit |
|
|
orm.Rollback()
|
|
|
return
|
|
|
}
|
|
|
|
|
|
}
|
|
|
//6.文件
|
|
|
for _, v := range GenSpeechs(chance.Id, request.Speechs) {
|
|
|
if _, err = orm.Insert(v); err != nil {
|
|
|
{
|
|
|
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)
|
|
|
orm.Rollback()
|
|
|
return
|
|
|
}
|
|
|
}
|
|
|
for _, v := range GenVideos(chance.Id, request.Videos) {
|
|
|
if _, err = orm.Insert(v); err != nil {
|
|
|
orm.Commit()
|
|
|
|
|
|
//6.激活审核流
|
|
|
//TODO:7.发送消息通知给审核人(审核消息)
|
|
|
rsp = &protocol.ChanceSubmitResponse{}
|
|
|
return
|
|
|
}
|
|
|
|
|
|
func ChanceUpdate(header *protocol.RequestHeader, request *protocol.ChanceSubmitRequest) (rsp *protocol.ChanceSubmitResponse, err error) {
|
|
|
var (
|
|
|
template *models.AuditTemplate
|
|
|
chance *models.Chance
|
|
|
auditConfig *protocol.AuditConfig
|
|
|
chanceData *models.ChanceData
|
|
|
//auditFlows []*models.AuditFlowProcess
|
|
|
updateMap =make(map[string]interface{})
|
|
|
)
|
|
|
if chance,err =models.GetChanceById(request.Id);err!=nil{
|
|
|
log.Error(err)
|
|
|
return
|
|
|
}
|
|
|
//TODO:非本人 1.需要验证角色权限,是否是审核人
|
|
|
if chance.UserId!=header.Uid{
|
|
|
err = protocol.NewErrWithMessage(1)
|
|
|
log.Error(fmt.Sprintf("user:%v 无权限操作机会 chance:%v",header.Uid,chance.Id))
|
|
|
return
|
|
|
}
|
|
|
//TODO:验证机会当前是否在审核中
|
|
|
//1.模板是否存在
|
|
|
if template, err = models.GetAuditTemplateById(request.AuditTemplateId); err != nil {
|
|
|
log.Error("模板不存在:", request.AuditTemplateId, err)
|
|
|
return
|
|
|
}
|
|
|
auditConfig = &protocol.AuditConfig{NoApprover: template.NoApprover}
|
|
|
orm := orm.NewOrm()
|
|
|
orm.Begin()
|
|
|
{
|
|
|
updateMap["AuditTemplateConfig"] = common.AssertJson(auditConfig)
|
|
|
updateMap["Content"] = request.Content
|
|
|
updateMap["SourceContent"] = common.AssertJson(request.FormList)
|
|
|
updateMap["DepartmentId"] = request.RelatedDepartment
|
|
|
|
|
|
if err = utils.UpdateTableByMapWithOrmer(orm,&models.Chance{Id:chance.Id},updateMap); err != nil {
|
|
|
log.Error(err)
|
|
|
orm.Rollback()
|
|
|
return
|
|
|
}
|
|
|
}
|
|
|
for _, v := range GenImages(chance.Id, request.Pictures) {
|
|
|
if _, err = orm.Insert(v); err != nil {
|
|
|
|
|
|
|
|
|
//4.查询审核配置
|
|
|
//5.生成审核流 删除旧的 生成新的
|
|
|
//if auditFlows, err = GenAuditFlowProcess(header, chance.Id, template.Id, auditConfig); err != nil {
|
|
|
// log.Error(err)
|
|
|
// orm.Rollback()
|
|
|
// return
|
|
|
//}
|
|
|
//for i := 0; i < len(auditFlows); i++ {
|
|
|
// if _, err = orm.Insert(auditFlows[i]); err != nil {
|
|
|
// log.Error(err)
|
|
|
// orm.Rollback()
|
|
|
// return
|
|
|
// }
|
|
|
//}
|
|
|
|
|
|
//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{
|
|
|
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(),
|
|
|
}
|
|
|
if _, err = orm.Insert(data); err != nil {
|
|
|
log.Error(err)
|
|
|
orm.Rollback()
|
|
|
return
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
orm.Commit()
|
|
|
|
|
|
//6.激活审核流
|
...
|
...
|
|