|
@@ -380,34 +380,36 @@ public class SocialServiceImpl implements SocialServiceI {
|
380
|
380
|
|
381
|
381
|
@Override
|
382
|
382
|
@Transactional(rollbackFor = Exception.class)
|
383
|
|
- public ResponseBean updateTransaction(String paramets,Integer userId) {
|
|
383
|
+ public ResponseBean updateTransaction(String paramets,Integer userId,Integer id) {
|
384
|
384
|
ResponseBean response = new ResponseBean();
|
385
|
385
|
JSONObject jsonObject = JSONObject.parseObject(paramets);
|
386
|
|
- String id = (String) jsonObject.get("id");
|
387
|
386
|
String transactionTitle = (String) jsonObject.get("transactionTitle");
|
388
|
387
|
String transactionContent = (String) jsonObject.get("transactionContent");
|
389
|
388
|
String imageUrl = (String) jsonObject.get("imageUrl");
|
390
|
|
- TpTransaction tpTransaction = JSONObject.parseObject(paramets,TpTransaction.class);
|
|
389
|
+ TpTransaction tpTransaction = JSONObject.parseObject(paramets, TpTransaction.class);
|
|
390
|
+ TpTransaction taUser = tpTransactionMapper.getById(id);
|
|
391
|
+ if (null != taUser && userId.equals(taUser.getTaUserId())) {
|
|
392
|
+ tdImagesMapper.deleteTdImages(Integer.valueOf(id), Constant.TRANSACTION);
|
|
393
|
+ try {
|
|
394
|
+ insertTdImage(tpTransaction, imageUrl, userId, Constant.TRANSACTION);
|
|
395
|
+ } catch (IOException e) {
|
|
396
|
+ e.printStackTrace();
|
|
397
|
+ throw new RuntimeException("图片修改异常");
|
|
398
|
+ }
|
|
399
|
+ tpTransactionMapper.updateTransaction(Integer.valueOf(id), transactionTitle, transactionContent, userId);
|
|
400
|
+ response.addSuccess("修改成功");
|
|
401
|
+ return response;
|
391
|
402
|
|
392
|
|
- tdImagesMapper.deleteTdImages( Integer.valueOf(id),Constant.TRANSACTION);
|
393
|
|
- try {
|
394
|
|
- insertTdImage(tpTransaction, imageUrl, userId,Constant.TRANSACTION);
|
395
|
|
- } catch (IOException e) {
|
396
|
|
- e.printStackTrace();
|
397
|
|
- throw new RuntimeException("图片修改异常");
|
398
|
403
|
}
|
399
|
|
- tpTransactionMapper.updateTransaction(Integer.valueOf(id),transactionTitle,transactionContent,userId);
|
400
|
|
- response.addSuccess("修改成功");
|
|
404
|
+ response.addError("操作失败");
|
401
|
405
|
return response;
|
402
|
406
|
}
|
403
|
407
|
|
404
|
408
|
@Override
|
405
|
|
- public ResponseBean deleteransaction(String paramets) {
|
|
409
|
+ public ResponseBean deleteransaction(Integer id,Integer userId) {
|
406
|
410
|
ResponseBean responseBean= new ResponseBean();
|
407
|
|
- JSONObject jsonObject = JSONObject.parseObject(paramets);
|
408
|
|
- String id = (String) jsonObject.get("id");
|
409
|
411
|
TpTransaction tpTransaction=tpTransactionMapper.getById(Integer.valueOf(id));
|
410
|
|
- if(null!= tpTransaction) {
|
|
412
|
+ if(null!= tpTransaction && userId.equals(tpTransaction.getTaUserId())) {
|
411
|
413
|
tpTransaction.setStatus("0");
|
412
|
414
|
tpTransactionMapper.updateByPrimaryKeySelective(tpTransaction);
|
413
|
415
|
responseBean.addSuccess("删除成功");
|