Pārlūkot izejas kodu

feat:添加人情往来事件删除接口

liuchuanwei 7 mēneši atpakaļ
vecāks
revīzija
e79c77dcc3

+ 13 - 0
src/main/java/com/anyway/favor/controller/FavorController.java

@@ -164,4 +164,17 @@ public class FavorController {
         return mv;
     }
 
+    /**
+     * 删除
+     *
+     * @param id
+     * @return
+     */
+    @RequestMapping("/delete/{id}")
+    @ResponseBody
+    public R delete(@PathVariable Long id) {
+        boolean b = favorService.deleteById(id);
+        return b ? R.ok() : R.fail("删除失败");
+    }
+
 }

+ 7 - 0
src/main/java/com/anyway/favor/service/FavorService.java

@@ -54,4 +54,11 @@ public interface FavorService {
      */
     Favor findById(Long id);
 
+    /**
+     * 根据ID移除
+     *
+     * @param id
+     * @return
+     */
+    boolean deleteById(Long id);
 }

+ 9 - 0
src/main/java/com/anyway/favor/service/impl/FavorServiceImpl.java

@@ -77,4 +77,13 @@ public class FavorServiceImpl implements FavorService {
     public Favor findById(Long id) {
         return favorMapper.findById(id);
     }
+
+    @Override
+    public boolean deleteById(Long id) {
+        int i = favorMapper.deleteById(id);
+        if (i>0) {
+            favorItemMapper.deleteByFavorId(id);
+        }
+        return i>0;
+    }
 }