项目场景:
工业系统的前台界面,直接传递数据给到后台,导致业务数据错误
问题描述
前台展示的数据
c
id: 001
weigth: 100
前台传递给后台的数据
c
id: 001
weigth: 100
DB的数据
c
id: 001
weigth: 20
后台处理的数据
c
id: 001
weigth: 100
原因分析:
在传递数据给到后台时,DB的数据,已经变更了,但是还是使用的老数据,导致业务数据错误
解决方案:
前台展示的数据
c
id: 001
weigth: 100
前台传递给后台的数据
c
id: 001
DB的数据
c
id: 001
weigth: 20
后台处理的数据
c
Object obj = dao.query("001");
id: 001
weigth: 20
总结:前台传递标识,后台做业务逻辑处理的时候,根据标识,重新查询DB数据,然后做更新处理
(先不考虑并发等等 其它原因)