正在显示
4 个修改的文件
包含
58 行增加
和
23 行删除
@@ -34,8 +34,14 @@ type Chance struct { | @@ -34,8 +34,14 @@ type Chance struct { | ||
34 | AuditLevel int `orm:"column(audit_level)" description:"当前审批步骤"` | 34 | AuditLevel int `orm:"column(audit_level)" description:"当前审批步骤"` |
35 | ApproveTime time.Time `orm:"column(approve_time);type(timestamp)" description:"审批时间"` | 35 | ApproveTime time.Time `orm:"column(approve_time);type(timestamp)" description:"审批时间"` |
36 | Code string `orm:"column(code)" description:"机会编码 一级编码+二级编码"` | 36 | Code string `orm:"column(code)" description:"机会编码 一级编码+二级编码"` |
37 | + Status int8 `orm:"column(status)" description:"状态 1:开启 2:关闭 "` | ||
37 | } | 38 | } |
38 | 39 | ||
40 | +const ( | ||
41 | + ChanceStatusOpen = 1 //开启 | ||
42 | + ChanceStatusClose = 2 //关闭 | ||
43 | +) | ||
44 | + | ||
39 | func (t *Chance) TableName() string { | 45 | func (t *Chance) TableName() string { |
40 | return "chance" | 46 | return "chance" |
41 | } | 47 | } |
@@ -105,7 +111,7 @@ func DeleteChance(id int64) (err error) { | @@ -105,7 +111,7 @@ func DeleteChance(id int64) (err error) { | ||
105 | func GetChanceMyChance(uid, cid int64, reviewStatus []int8, lastId int64, pageSize int, v interface{}) (total int, err error) { | 111 | func GetChanceMyChance(uid, cid int64, reviewStatus []int8, lastId int64, pageSize int, v interface{}) (total int, err error) { |
106 | sql := `select a.*,b.images,speechs,videos | 112 | sql := `select a.*,b.images,speechs,videos |
107 | from ( | 113 | from ( |
108 | -select id,user_id,create_at,update_at,approve_time chance_approve_time,source_content,approve_data,review_status from chance | 114 | +select id,user_id,create_at,update_at,approve_time chance_approve_time,source_content,approve_data,review_status,enable_status,status from chance |
109 | where user_id=? and company_id=? and review_status in (?) and (?=0 or id<?) | 115 | where user_id=? and company_id=? and review_status in (?) and (?=0 or id<?) |
110 | ) a left JOIN chance_data b on a.id =b.chance_id | 116 | ) a left JOIN chance_data b on a.id =b.chance_id |
111 | order by update_at desc | 117 | order by update_at desc |
@@ -129,7 +135,7 @@ where user_id=? and company_id=? and review_status in (%v) | @@ -129,7 +135,7 @@ where user_id=? and company_id=? and review_status in (%v) | ||
129 | 135 | ||
130 | func GetChanceMyApproveChance(uid, cid int64, reviewStatus []int8, lastId int64, pageSize int, v interface{}) (total int, err error) { | 136 | func GetChanceMyApproveChance(uid, cid int64, reviewStatus []int8, lastId int64, pageSize int, v interface{}) (total int, err error) { |
131 | sql := fmt.Sprintf(`select a.*,b.images,b.speechs,b.videos from ( | 137 | sql := fmt.Sprintf(`select a.*,b.images,b.speechs,b.videos from ( |
132 | -select a.*,b.user_id,b.source_content,b.enable_status,b.review_status,b.create_at,b.update_at,b.approve_time chance_approve_time from ( | 138 | +select a.*,b.user_id,b.source_content,b.enable_status,b.review_status,b.create_at,b.update_at,b.approve_time chance_approve_time,b.status from ( |
133 | select id,approve_time,approve_data,uid,chance_id,approve_message,update_at process_create_time | 139 | select id,approve_time,approve_data,uid,chance_id,approve_message,update_at process_create_time |
134 | from audit_flow_process where uid=? and enable_status =1 and review_status in (%v) and (?=0 or id<?) | 140 | from audit_flow_process where uid=? and enable_status =1 and review_status in (%v) and (?=0 or id<?) |
135 | )a left outer join chance b on a.chance_id = b.id | 141 | )a left outer join chance b on a.chance_id = b.id |
@@ -152,7 +158,7 @@ from audit_flow_process where uid=? and enable_status =1 and review_status in (% | @@ -152,7 +158,7 @@ from audit_flow_process where uid=? and enable_status =1 and review_status in (% | ||
152 | 158 | ||
153 | func GetChanceCollect(uid int64, lastId int64, pageSize int, v interface{}) (total int, err error) { | 159 | func GetChanceCollect(uid int64, lastId int64, pageSize int, v interface{}) (total int, err error) { |
154 | sql := fmt.Sprintf(`select a.*,b.images,b.speechs,b.videos from ( | 160 | sql := fmt.Sprintf(`select a.*,b.images,b.speechs,b.videos from ( |
155 | -select a.*,b.user_id,b.id,b.create_at,b.source_content,b.enable_status,b.review_status,b.audit_template_id,b.chance_type_id,comment_total,zan_total,view_total,b.publish_status from ( | 161 | +select a.*,b.user_id,b.id,b.create_at,b.source_content,b.enable_status,b.review_status,b.audit_template_id,b.chance_type_id,comment_total,zan_total,view_total,b.publish_status,b.status from ( |
156 | select id collect_id,source_id,update_at collect_time,chance_id from chance_favorite where (0=? or id<?) and user_id =? and enable_status=1 | 162 | select id collect_id,source_id,update_at collect_time,chance_id from chance_favorite where (0=? or id<?) and user_id =? and enable_status=1 |
157 | and source_type=1 | 163 | and source_type=1 |
158 | and (mark_flag&2)>0 | 164 | and (mark_flag&2)>0 |
@@ -175,7 +181,7 @@ limit ?`) | @@ -175,7 +181,7 @@ limit ?`) | ||
175 | 181 | ||
176 | func GetChanceThumbUp(uid int64, lastId int64, pageSize int, v interface{}) (total int, err error) { | 182 | func GetChanceThumbUp(uid int64, lastId int64, pageSize int, v interface{}) (total int, err error) { |
177 | sql := fmt.Sprintf(`select a.*,b.images,b.speechs,b.videos from ( | 183 | sql := fmt.Sprintf(`select a.*,b.images,b.speechs,b.videos from ( |
178 | -select a.*,b.user_id,b.id,b.create_at,b.source_content,b.enable_status,b.review_status,b.audit_template_id,b.chance_type_id,comment_total,zan_total,view_total,b.publish_status from ( | 184 | +select a.*,b.user_id,b.id,b.create_at,b.source_content,b.enable_status,b.review_status,b.audit_template_id,b.chance_type_id,comment_total,zan_total,view_total,b.publish_status,b.status from ( |
179 | select id collect_id,source_id,update_at collect_time from chance_favorite where (0=? or id<?) and user_id =? and enable_status=1 | 185 | select id collect_id,source_id,update_at collect_time from chance_favorite where (0=? or id<?) and user_id =? and enable_status=1 |
180 | and source_type=1 | 186 | and source_type=1 |
181 | and (mark_flag&1)>0 | 187 | and (mark_flag&1)>0 |
@@ -196,6 +196,7 @@ type ChanceItemOrm struct { | @@ -196,6 +196,7 @@ type ChanceItemOrm struct { | ||
196 | ReviewStatus int `orm:"column(review_status)"` //审核状态 1:待审核 2:被退回 3:已通过 | 196 | ReviewStatus int `orm:"column(review_status)"` //审核状态 1:待审核 2:被退回 3:已通过 |
197 | 197 | ||
198 | ApproveData string `json:"approveData"` //审核数据 | 198 | ApproveData string `json:"approveData"` //审核数据 |
199 | + Status int `orm:"column(status)"` //状态 1:开启 2:关闭 | ||
199 | } | 200 | } |
200 | 201 | ||
201 | /*MyApproveChance 我审核的机会*/ | 202 | /*MyApproveChance 我审核的机会*/ |
@@ -221,6 +222,7 @@ type ChanceApproveItemOrm struct { | @@ -221,6 +222,7 @@ type ChanceApproveItemOrm struct { | ||
221 | Voices string `orm:"column(speechs)"` | 222 | Voices string `orm:"column(speechs)"` |
222 | Videos string `orm:"column(videos)"` | 223 | Videos string `orm:"column(videos)"` |
223 | ReviewStatus int `orm:"column(review_status)"` | 224 | ReviewStatus int `orm:"column(review_status)"` |
225 | + Status int `orm:"column(status)"` | ||
224 | 226 | ||
225 | Id int64 `orm:"column(id)"` //审核id | 227 | Id int64 `orm:"column(id)"` //审核id |
226 | ApproveTime time.Time `orm:"column(approve_time)"` | 228 | ApproveTime time.Time `orm:"column(approve_time)"` |
@@ -293,6 +295,7 @@ type ChanceCollectItemOrm struct { | @@ -293,6 +295,7 @@ type ChanceCollectItemOrm struct { | ||
293 | Voices string `orm:"column(speechs)"` | 295 | Voices string `orm:"column(speechs)"` |
294 | Videos string `orm:"column(videos)"` | 296 | Videos string `orm:"column(videos)"` |
295 | PublishStatus int `orm:"column(publish_status)"` //公开状态 | 297 | PublishStatus int `orm:"column(publish_status)"` //公开状态 |
298 | + Status int `orm:"column(status)"` | ||
296 | 299 | ||
297 | //ApproveData string `json:"approveData"` //审核数据 | 300 | //ApproveData string `json:"approveData"` //审核数据 |
298 | TemplateId int `orm:"column(audit_template_id)"` | 301 | TemplateId int `orm:"column(audit_template_id)"` |
@@ -321,6 +324,7 @@ type ChanceThumbUpItemOrm struct { | @@ -321,6 +324,7 @@ type ChanceThumbUpItemOrm struct { | ||
321 | Voices string `orm:"column(speechs)"` | 324 | Voices string `orm:"column(speechs)"` |
322 | Videos string `orm:"column(videos)"` | 325 | Videos string `orm:"column(videos)"` |
323 | PublishStatus int `orm:"column(publish_status)"` //公开状态 | 326 | PublishStatus int `orm:"column(publish_status)"` //公开状态 |
327 | + Status int `orm:"column(status)"` //公开状态 | ||
324 | 328 | ||
325 | //ApproveData string `json:"approveData"` //审核数据 | 329 | //ApproveData string `json:"approveData"` //审核数据 |
326 | TemplateId int `orm:"column(audit_template_id)"` | 330 | TemplateId int `orm:"column(audit_template_id)"` |
@@ -373,6 +373,7 @@ func ChanceSubmit(header *protocol.RequestHeader, request *protocol.ChanceSubmit | @@ -373,6 +373,7 @@ func ChanceSubmit(header *protocol.RequestHeader, request *protocol.ChanceSubmit | ||
373 | ReviewStatus: protocol.ReviewStatusAuditging, | 373 | ReviewStatus: protocol.ReviewStatusAuditging, |
374 | DepartmentId: request.RelatedDepartment, | 374 | DepartmentId: request.RelatedDepartment, |
375 | Code: fmt.Sprintf("%v%v", chanceType.Code, template.Code), | 375 | Code: fmt.Sprintf("%v%v", chanceType.Code, template.Code), |
376 | + Status: models.ChanceStatusOpen, | ||
376 | } | 377 | } |
377 | //生成提交记录 | 378 | //生成提交记录 |
378 | if _, err = orm.Insert(GenAuditFlowProcess_Submit(header.UserId, chance.Id, template.Id, protocol.ReviewStatusSubmit)); err != nil { | 379 | if _, err = orm.Insert(GenAuditFlowProcess_Submit(header.UserId, chance.Id, template.Id, protocol.ReviewStatusSubmit)); err != nil { |
@@ -536,7 +537,7 @@ func ChanceUpdate(header *protocol.RequestHeader, request *protocol.ChanceUpdate | @@ -536,7 +537,7 @@ func ChanceUpdate(header *protocol.RequestHeader, request *protocol.ChanceUpdate | ||
536 | log.Info(fmt.Sprintf("机会编辑 is_publish:%v chance.review_status:%v 是否是本人:%v", request.IsPublish, chance.ReviewStatus, chance.UserId == header.UserId)) | 537 | log.Info(fmt.Sprintf("机会编辑 is_publish:%v chance.review_status:%v 是否是本人:%v", request.IsPublish, chance.ReviewStatus, chance.UserId == header.UserId)) |
537 | } | 538 | } |
538 | //1.需要验证角色权限 2是否是审核人 3.是否是本人 | 539 | //1.需要验证角色权限 2是否是审核人 3.是否是本人 |
539 | - if chance.ReviewStatus != protocol.ReviewStatusPass { //chance.UserId != header.UserId | 540 | + if chance.ReviewStatus != protocol.ReviewStatusPass && chance.UserId != header.UserId { //chance.UserId != header.UserId |
540 | err = protocol.NewErrWithMessage(5206) | 541 | err = protocol.NewErrWithMessage(5206) |
541 | log.Error(fmt.Sprintf("user:%v 无权限操作机会 chance:%v", header.UserId, chance.Id)) | 542 | log.Error(fmt.Sprintf("user:%v 无权限操作机会 chance:%v", header.UserId, chance.Id)) |
542 | return | 543 | return |
@@ -1305,6 +1306,9 @@ func MySubmitChance(header *protocol.RequestHeader, request *protocol.MySubmitCh | @@ -1305,6 +1306,9 @@ func MySubmitChance(header *protocol.RequestHeader, request *protocol.MySubmitCh | ||
1305 | jsonUnmarshal(chance.Videos, &item.Videos) | 1306 | jsonUnmarshal(chance.Videos, &item.Videos) |
1306 | commItem.Chance = item | 1307 | commItem.Chance = item |
1307 | } | 1308 | } |
1309 | + if chance.Status == models.ChanceStatusClose { | ||
1310 | + commItem.ChanceStatus = protocol.ChanceStatusClose | ||
1311 | + } | ||
1308 | commItem.ReviewStatus = chance.ReviewStatus | 1312 | commItem.ReviewStatus = chance.ReviewStatus |
1309 | if request.ReviewStatus == protocol.ReviewStatusPass { | 1313 | if request.ReviewStatus == protocol.ReviewStatusPass { |
1310 | var approveData protocol.ApproveData | 1314 | var approveData protocol.ApproveData |
@@ -1410,11 +1414,13 @@ func MyApproveChance(header *protocol.RequestHeader, request *protocol.MyApprove | @@ -1410,11 +1414,13 @@ func MyApproveChance(header *protocol.RequestHeader, request *protocol.MyApprove | ||
1410 | chance := myChances[i] | 1414 | chance := myChances[i] |
1411 | commItem := protocol.CommonListItem{} | 1415 | commItem := protocol.CommonListItem{} |
1412 | commItem.ReviewStatus = chance.ReviewStatus | 1416 | commItem.ReviewStatus = chance.ReviewStatus |
1413 | - if len(chance.SourceContent) == 0 { //机会删除 | 1417 | + if len(chance.SourceContent) == 0 || chance.ChanceEnableStatus == 0 { //机会删除 |
1414 | commItem.ChanceStatus = protocol.ChanceStatusDelete | 1418 | commItem.ChanceStatus = protocol.ChanceStatusDelete |
1415 | - } else if chance.ChanceEnableStatus == 0 { //机会关闭 | 1419 | + } |
1420 | + if chance.Status == models.ChanceStatusClose { | ||
1416 | commItem.ChanceStatus = protocol.ChanceStatusClose | 1421 | commItem.ChanceStatus = protocol.ChanceStatusClose |
1417 | - } else { | 1422 | + } |
1423 | + if chance.ChanceUserId > 0 { | ||
1418 | if provider, err = agg.GetUserBaseInfo(chance.ChanceUserId, header.CompanyId); err != nil { | 1424 | if provider, err = agg.GetUserBaseInfo(chance.ChanceUserId, header.CompanyId); err != nil { |
1419 | commItem.ChanceStatus = protocol.ChanceStatusDelete | 1425 | commItem.ChanceStatus = protocol.ChanceStatusDelete |
1420 | log.Error(chance.ChanceUserId, header.CompanyId, err) | 1426 | log.Error(chance.ChanceUserId, header.CompanyId, err) |
@@ -1491,11 +1497,14 @@ func MyCollectChance(header *protocol.RequestHeader, request *protocol.MyCollect | @@ -1491,11 +1497,14 @@ func MyCollectChance(header *protocol.RequestHeader, request *protocol.MyCollect | ||
1491 | commItem := &protocol.CommonListItem{} | 1497 | commItem := &protocol.CommonListItem{} |
1492 | commItem.ReviewStatus = chance.ReviewStatus | 1498 | commItem.ReviewStatus = chance.ReviewStatus |
1493 | commItem.ChanceId = chance.ChanceId | 1499 | commItem.ChanceId = chance.ChanceId |
1494 | - if len(chance.SourceContent) == 0 { //机会删除 | 1500 | + if len(chance.SourceContent) == 0 || chance.ChanceEnableStatus == 0 { //机会删除 |
1495 | commItem.ChanceStatus = protocol.ChanceStatusDelete | 1501 | commItem.ChanceStatus = protocol.ChanceStatusDelete |
1496 | - } else if chance.ChanceEnableStatus == 0 { //机会关闭 | 1502 | + } |
1503 | + if chance.Status == models.ChanceStatusClose { //机会关闭 | ||
1497 | commItem.ChanceStatus = protocol.ChanceStatusClose | 1504 | commItem.ChanceStatus = protocol.ChanceStatusClose |
1498 | - } else { | 1505 | + } |
1506 | + | ||
1507 | + if chance.ChanceUserId > 0 { | ||
1499 | if provider, err = agg.GetUserBaseInfo(chance.ChanceUserId, header.CompanyId); err != nil { | 1508 | if provider, err = agg.GetUserBaseInfo(chance.ChanceUserId, header.CompanyId); err != nil { |
1500 | commItem.ChanceStatus = protocol.ChanceStatusDelete | 1509 | commItem.ChanceStatus = protocol.ChanceStatusDelete |
1501 | log.Error(err) | 1510 | log.Error(err) |
@@ -1515,6 +1524,7 @@ func MyCollectChance(header *protocol.RequestHeader, request *protocol.MyCollect | @@ -1515,6 +1524,7 @@ func MyCollectChance(header *protocol.RequestHeader, request *protocol.MyCollect | ||
1515 | commItem.Chance = item | 1524 | commItem.Chance = item |
1516 | } | 1525 | } |
1517 | } | 1526 | } |
1527 | + | ||
1518 | commItem.ReviewStatus = chance.ReviewStatus | 1528 | commItem.ReviewStatus = chance.ReviewStatus |
1519 | { | 1529 | { |
1520 | var chanceData = protocol.ChanceData{ | 1530 | var chanceData = protocol.ChanceData{ |
@@ -1565,11 +1575,13 @@ func MyThumbUpChance(header *protocol.RequestHeader, request *protocol.MyThumbUp | @@ -1565,11 +1575,13 @@ func MyThumbUpChance(header *protocol.RequestHeader, request *protocol.MyThumbUp | ||
1565 | commItem := &protocol.CommonListItem{} | 1575 | commItem := &protocol.CommonListItem{} |
1566 | commItem.ReviewStatus = chance.ReviewStatus | 1576 | commItem.ReviewStatus = chance.ReviewStatus |
1567 | commItem.ChanceId = chance.ChanceId | 1577 | commItem.ChanceId = chance.ChanceId |
1568 | - if len(chance.SourceContent) == 0 { //机会删除 | 1578 | + if len(chance.SourceContent) == 0 || chance.ChanceEnableStatus == 0 { //机会删除 |
1569 | commItem.ChanceStatus = protocol.ChanceStatusDelete | 1579 | commItem.ChanceStatus = protocol.ChanceStatusDelete |
1570 | - } else if chance.ChanceEnableStatus == 0 { //机会关闭 | 1580 | + } |
1581 | + if chance.Status == models.ChanceStatusClose { //机会关闭 | ||
1571 | commItem.ChanceStatus = protocol.ChanceStatusClose | 1582 | commItem.ChanceStatus = protocol.ChanceStatusClose |
1572 | - } else { | 1583 | + } |
1584 | + if chance.ChanceUserId > 0 { | ||
1573 | if provider, err = agg.GetUserBaseInfo(chance.ChanceUserId, header.CompanyId); err != nil { | 1585 | if provider, err = agg.GetUserBaseInfo(chance.ChanceUserId, header.CompanyId); err != nil { |
1574 | commItem.ChanceStatus = protocol.ChanceStatusDelete | 1586 | commItem.ChanceStatus = protocol.ChanceStatusDelete |
1575 | log.Error(err) | 1587 | log.Error(err) |
@@ -1921,6 +1933,13 @@ func Permission(header *protocol.RequestHeader, request *protocol.PermissionRequ | @@ -1921,6 +1933,13 @@ func Permission(header *protocol.RequestHeader, request *protocol.PermissionRequ | ||
1921 | } | 1933 | } |
1922 | //判断机会权限 | 1934 | //判断机会权限 |
1923 | if request.ChanceId > 0 { | 1935 | if request.ChanceId > 0 { |
1936 | + if chance.Status == models.ChanceStatusClose || chance.EnableStatus == 0 { //机会关闭 / 删除 | ||
1937 | + rsp.EditChance = 0 | ||
1938 | + rsp.EditPublicStatus = 0 | ||
1939 | + rsp.EditScore = 0 | ||
1940 | + log.Debug(fmt.Sprintf("用户:%v chance_id:%v 机会关闭/删除 无权限", header.UserId, chance.Id)) | ||
1941 | + return | ||
1942 | + } | ||
1924 | if chance, err = models.GetChanceById(request.ChanceId); err != nil { | 1943 | if chance, err = models.GetChanceById(request.ChanceId); err != nil { |
1925 | err = protocol.NewErrWithMessage(5101) | 1944 | err = protocol.NewErrWithMessage(5101) |
1926 | return | 1945 | return |
@@ -1928,13 +1947,16 @@ func Permission(header *protocol.RequestHeader, request *protocol.PermissionRequ | @@ -1928,13 +1947,16 @@ func Permission(header *protocol.RequestHeader, request *protocol.PermissionRequ | ||
1928 | //本人 | 1947 | //本人 |
1929 | if chance.UserId == header.UserId { | 1948 | if chance.UserId == header.UserId { |
1930 | //审核通过 或者 已经被人审核过 就不能编辑了 | 1949 | //审核通过 或者 已经被人审核过 就不能编辑了 |
1931 | - if len(chance.ApproveData) > 0 || chance.ReviewStatus == protocol.ReviewStatusPass { | 1950 | + if len(chance.ApproveData) > 0 && chance.ReviewStatus == protocol.ReviewStatusAuditging { //审批中 且有人审批 本人不可编辑 |
1932 | rsp.EditChance = 0 | 1951 | rsp.EditChance = 0 |
1933 | } else if chance.ReviewStatus == protocol.ReviewStatusAuditging { //未有人审核过 | 1952 | } else if chance.ReviewStatus == protocol.ReviewStatusAuditging { //未有人审核过 |
1934 | rsp.EditChance = 1 | 1953 | rsp.EditChance = 1 |
1935 | rsp.EditPublicStatus = 0 | 1954 | rsp.EditPublicStatus = 0 |
1936 | rsp.EditScore = 0 | 1955 | rsp.EditScore = 0 |
1937 | } | 1956 | } |
1957 | + if chance.ReviewStatus == protocol.ReviewStatusPass { | ||
1958 | + rsp.EditScore = 1 | ||
1959 | + } | ||
1938 | return | 1960 | return |
1939 | } else { | 1961 | } else { |
1940 | if chance.ReviewStatus == protocol.ReviewStatusReturn { //退回的机会不可编辑 | 1962 | if chance.ReviewStatus == protocol.ReviewStatusReturn { //退回的机会不可编辑 |
@@ -357,7 +357,7 @@ func MsgChanceSubmit(header *protocol.RequestHeader, request *protocol.MsgChance | @@ -357,7 +357,7 @@ func MsgChanceSubmit(header *protocol.RequestHeader, request *protocol.MsgChance | ||
357 | commItem.Score = approveData.Score | 357 | commItem.Score = approveData.Score |
358 | } | 358 | } |
359 | } | 359 | } |
360 | - if len(chance.Data) > 0 { //获取评分 | 360 | + if len(chance.Data) > 0 && chance.ReviewStatus == protocol.ReviewStatusPass { //获取评分 |
361 | var msgData *protocol.MsgData | 361 | var msgData *protocol.MsgData |
362 | utils.JsonUnmarshal(chance.Data, &msgData) | 362 | utils.JsonUnmarshal(chance.Data, &msgData) |
363 | commItem.Score = msgData.Score | 363 | commItem.Score = msgData.Score |
@@ -621,21 +621,23 @@ func H5AnnouncementSubmit(header *protocol.RequestHeader, request *protocol.Anno | @@ -621,21 +621,23 @@ func H5AnnouncementSubmit(header *protocol.RequestHeader, request *protocol.Anno | ||
621 | err = protocol.NewErrWithMessage(2060) | 621 | err = protocol.NewErrWithMessage(2060) |
622 | return | 622 | return |
623 | } | 623 | } |
624 | + orm := orm.NewOrm() | ||
625 | + orm.Begin() | ||
626 | + { | ||
627 | + var e error | ||
624 | //获取回答详情数据 | 628 | //获取回答详情数据 |
625 | - if bulletinAnswer, err = models.GetBulletinQuestionAnswerBy(request.Id, int64(request.Uid)); err == nil { | 629 | + if bulletinAnswer, e = models.GetBulletinQuestionAnswerBy(request.Id, int64(request.Uid)); e == nil { |
626 | bulletinAnswer.Answer = common.AssertJson(protocol.Answer{ | 630 | bulletinAnswer.Answer = common.AssertJson(protocol.Answer{ |
627 | EditContent: request.EditContent, | 631 | EditContent: request.EditContent, |
628 | VoteResults: request.VoteResults, | 632 | VoteResults: request.VoteResults, |
629 | }) | 633 | }) |
630 | bulletinAnswer.UpdateAt = time.Now() | 634 | bulletinAnswer.UpdateAt = time.Now() |
631 | - if err = models.UpdateBulletinQuestionAnswerById(bulletinAnswer); err != nil { | ||
632 | - return | ||
633 | - } | 635 | + if e = models.UpdateBulletinQuestionAnswerById(bulletinAnswer); e != nil { |
636 | + log.Error(e) | ||
637 | + orm.Rollback() | ||
634 | return | 638 | return |
635 | } | 639 | } |
636 | - orm := orm.NewOrm() | ||
637 | - orm.Begin() | ||
638 | - { | 640 | + } else { |
639 | bulletinAnswer = &models.BulletinQuestionAnswer{ | 641 | bulletinAnswer = &models.BulletinQuestionAnswer{ |
640 | Answer: common.AssertJson(&protocol.Answer{ | 642 | Answer: common.AssertJson(&protocol.Answer{ |
641 | VoteResults: request.VoteResults, | 643 | VoteResults: request.VoteResults, |
@@ -653,6 +655,7 @@ func H5AnnouncementSubmit(header *protocol.RequestHeader, request *protocol.Anno | @@ -653,6 +655,7 @@ func H5AnnouncementSubmit(header *protocol.RequestHeader, request *protocol.Anno | ||
653 | return | 655 | return |
654 | } | 656 | } |
655 | } | 657 | } |
658 | + } | ||
656 | { | 659 | { |
657 | if userMsg.IsRead != 1 { | 660 | if userMsg.IsRead != 1 { |
658 | if err = utils.UpdateTableByMapWithOrmer(orm, userMsg, map[string]interface{}{"IsRead": int8(1)}); err != nil { | 661 | if err = utils.UpdateTableByMapWithOrmer(orm, userMsg, map[string]interface{}{"IsRead": int8(1)}); err != nil { |
-
请 注册 或 登录 后发表评论