dingxin 6 년 전
부모
커밋
339aa85bbb

+ 11
- 9
CODE/smart-community/app-api/src/main/java/com/community/huiju/controller/SocialController.java 파일 보기

@@ -302,27 +302,29 @@ public class SocialController extends BaseController {
302 302
     @ApiOperation(value = "修改二手租赁帖子", notes = "修改二手租赁帖子")
303 303
     @ApiImplicitParams({
304 304
             @ApiImplicitParam(paramType = "body", dataType = "String", name = "paramets", value =
305
-                    "id:帖子id,imageUrl:图片url,transactionTitle:小区标题,transactionContent:小区内容"),
305
+                    "imageUrl:图片url,transactionTitle:小区标题,transactionContent:小区内容"),
306
+            @ApiImplicitParam(paramType = "path", dataType = "String", name = "id", value = "id:帖子id"),
306 307
             @ApiImplicitParam(paramType = "header",dataType = "String",name = "X-Auth-Token",value = "Token")
307 308
     })
308
-    @RequestMapping(value = "/updateTransaction/{Id}", method = RequestMethod.PUT)
309
-    public ResponseBean ubdateTransaction(HttpSession session, @RequestBody String paramets) {
309
+    @RequestMapping(value = "/updateTransaction/{id}", method = RequestMethod.PUT)
310
+    public ResponseBean ubdateTransaction(HttpSession session,@PathVariable("id") String id, @RequestBody String paramets) {
310 311
         ResponseBean responseBean = new ResponseBean();
311 312
         UserElement userElement = (UserElement) session.getAttribute(Constant.APP_USER_SESSION);
312 313
         Integer userId = userElement.getId();
313
-        ResponseBean response = socialServiceI.updateTransaction(paramets, userId);
314
+        ResponseBean response = socialServiceI.updateTransaction(paramets,userId,Integer.valueOf(id));
314 315
         return response;
315 316
     }
316 317
 
317 318
     @ApiOperation(value = "删除二手租赁帖子", notes = "删除二手租赁帖子")
318 319
     @ApiImplicitParams({
319
-            @ApiImplicitParam(paramType = "body", dataType = "String", name = "paramets", value =
320
-                    "id:帖子id"),
320
+            @ApiImplicitParam(paramType = "path", dataType = "String", name = "id", value = "id:帖子id"),
321 321
             @ApiImplicitParam(paramType = "header",dataType = "String",name = "X-Auth-Token",value = "Token")
322 322
     })
323
-    @RequestMapping(value = "/deleteTransaction/{Id}", method = RequestMethod.PUT)
324
-    public ResponseBean deleteTransaction(HttpSession session, @RequestBody String paramets) {
325
-        ResponseBean response = socialServiceI.deleteransaction(paramets);
323
+    @RequestMapping(value = "/deleteTransaction/{id}", method = RequestMethod.DELETE)
324
+    public ResponseBean deleteTransaction(HttpSession session, @PathVariable("id") String id) {
325
+        UserElement userElement = (UserElement) session.getAttribute(Constant.APP_USER_SESSION);
326
+        Integer userId = userElement.getId();
327
+        ResponseBean response = socialServiceI.deleteransaction(Integer.valueOf(id),userId);
326 328
         return response;
327 329
     }
328 330
 

+ 3
- 3
CODE/smart-community/app-api/src/main/java/com/community/huiju/service/SocialServiceI.java 파일 보기

@@ -110,7 +110,7 @@ public interface SocialServiceI {
110 110
 	/**
111 111
 	 * 修改当前帖子
112 112
 	 */
113
-	ResponseBean updateTransaction(String paramets,Integer userId);
113
+	ResponseBean updateTransaction(String paramets,Integer userId,Integer id);
114 114
 
115 115
 	/**
116 116
 	 * 评价工单以及评分
@@ -138,8 +138,8 @@ public interface SocialServiceI {
138 138
 
139 139
 	/**
140 140
 	 * 删除二手租赁帖子
141
- 	 * @param paramets
141
+ 	 * @param id
142 142
 	 * @return
143 143
 	 */
144
-	ResponseBean deleteransaction(String paramets);
144
+	ResponseBean deleteransaction(Integer id,Integer userid);
145 145
 }

+ 17
- 15
CODE/smart-community/app-api/src/main/java/com/community/huiju/service/impl/SocialServiceImpl.java 파일 보기

@@ -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("删除成功");