...
|
...
|
@@ -313,7 +313,8 @@ func getQuestionTitle(groupIdx int, idx int, title string) string { |
|
|
}
|
|
|
|
|
|
//自查问题回答批量入库
|
|
|
func BulkInsertSelfChecks(header *protocol.RequestHeader, relateId, chanceId int64, selfChecks protocol.SelfChecks) {
|
|
|
//@isDelete
|
|
|
func BulkInsertSelfChecks(header *protocol.RequestHeader, relateId, chanceId int64, selfChecks protocol.SelfChecks, isDeleteExisted bool) {
|
|
|
defer func() {
|
|
|
if p := recover(); p != nil {
|
|
|
log.Warn(p)
|
...
|
...
|
@@ -323,7 +324,7 @@ func BulkInsertSelfChecks(header *protocol.RequestHeader, relateId, chanceId int |
|
|
count int
|
|
|
err error
|
|
|
Exists = `select count(0) from chance_self_check where chanceId=? and relateId=?`
|
|
|
DeleteExistedRow = `update chance_self_check set enable=0 where chanceId=? and relateId=?`
|
|
|
DeleteExistedRow = `update chance_self_check set enable=0,update_at=Now() where relateId=? and enable=1`
|
|
|
)
|
|
|
if len(selfChecks) == 0 {
|
|
|
return
|
...
|
...
|
@@ -335,32 +336,48 @@ func BulkInsertSelfChecks(header *protocol.RequestHeader, relateId, chanceId int |
|
|
o.Rollback()
|
|
|
return
|
|
|
}
|
|
|
if count > 0 {
|
|
|
if err = utils.ExecuteSQLWithOrmer(o, DeleteExistedRow, relateId, chanceId); err != nil {
|
|
|
if isDeleteExisted {
|
|
|
if err = utils.ExecuteSQLWithOrmer(o, DeleteExistedRow, chanceId); err != nil {
|
|
|
log.Error(err)
|
|
|
o.Rollback()
|
|
|
return
|
|
|
}
|
|
|
}
|
|
|
for i := range selfChecks {
|
|
|
check := selfChecks[i]
|
|
|
m := models.ChanceSelfCheck{
|
|
|
Id: idgen.Next(),
|
|
|
UserCompanyId: header.UserId,
|
|
|
ChanceId: chanceId,
|
|
|
RelateId: relateId,
|
|
|
CheckItem: check.CheckItem,
|
|
|
GroupId: check.GroupId,
|
|
|
Answer: check.Answer,
|
|
|
Reason: check.Reason,
|
|
|
CreateAt: time.Now(),
|
|
|
}
|
|
|
if _, err = o.Insert(m); err != nil {
|
|
|
log.Error(err)
|
|
|
o.Rollback()
|
|
|
if count == 0 {
|
|
|
insertFunc := func(check protocol.SelfCheck, r int64) (err error) {
|
|
|
m := &models.ChanceSelfCheck{
|
|
|
Id: idgen.Next(),
|
|
|
UserCompanyId: header.UserId,
|
|
|
ChanceId: chanceId,
|
|
|
RelateId: r,
|
|
|
CheckItem: check.CheckItem,
|
|
|
GroupId: check.GroupId,
|
|
|
Answer: check.Answer,
|
|
|
Reason: check.Reason,
|
|
|
CreateAt: time.Now(),
|
|
|
UpdateAt: time.Now(),
|
|
|
Enable: protocol.Valid,
|
|
|
}
|
|
|
//插入审核的自查内容
|
|
|
if _, err = o.Insert(m); err != nil {
|
|
|
log.Error(err)
|
|
|
o.Rollback()
|
|
|
return
|
|
|
}
|
|
|
return
|
|
|
}
|
|
|
for i := range selfChecks {
|
|
|
check := selfChecks[i]
|
|
|
if err = insertFunc(check, relateId); err != nil {
|
|
|
return
|
|
|
}
|
|
|
//审核通过更新之前机会的自查内容(重新插入一条机会的自查内容)
|
|
|
if isDeleteExisted {
|
|
|
if err = insertFunc(check, chanceId); err != nil {
|
|
|
return
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
o.Commit()
|
|
|
} |
...
|
...
|
|