fangmingyue 2 лет назад
Родитель
Сommit
9cee293a08

Двоичные данные
db/ybai.db Просмотреть файл


+ 8
- 4
src/main/java/com/yunzhi/inte/controller/DishesController.java Просмотреть файл

@@ -67,7 +67,7 @@ public class DishesController extends BaseController {
67 67
      */
68 68
     @ApiOperation("新增数据")
69 69
     @PostMapping("/dishes")
70
-    public ResponseBean add(Dishes dishes) throws Exception {
70
+    public ResponseBean add(@ApiParam("对象实例") @RequestBody Dishes dishes) throws Exception {
71 71
         dishesService.save(dishes);
72 72
         return ResponseBean.success(dishes);
73 73
     }
@@ -80,8 +80,11 @@ public class DishesController extends BaseController {
80 80
      */
81 81
     @ApiOperation("更新数据")
82 82
     @PutMapping("/dishes/{id}")
83
-    public ResponseBean edit(Dishes dishes) throws Exception {
84
-        dishesService.updateById(dishes);
83
+    public ResponseBean edit(@ApiParam("对象ID") @PathVariable Integer id, @ApiParam("对象实例") @RequestBody Dishes dishes) throws Exception {
84
+        dishes.setId(id);
85
+        if(dishesService.updateById(dishes)){
86
+            dishesService.getById(id);
87
+        }
85 88
         return ResponseBean.success(dishes);
86 89
     }
87 90
 
@@ -94,7 +97,8 @@ public class DishesController extends BaseController {
94 97
     @ApiOperation("通过主键删除数据")
95 98
     @DeleteMapping("/dishes/{id}")
96 99
     public ResponseBean deleteById(@ApiParam("对象ID") @PathVariable Integer id){
97
-        dishesService.removeLogicById(id);
100
+//        dishesService.removeLogicById(id);
101
+        dishesService.removeById(id);
98 102
         return ResponseBean.success("success");
99 103
     }
100 104
 }

+ 1
- 1
src/main/java/com/yunzhi/inte/entity/Dishes.java Просмотреть файл

@@ -24,7 +24,7 @@ import lombok.experimental.Accessors;
24 24
 public class Dishes implements Serializable,Cloneable{
25 25
     /** 菜肴ID */
26 26
     @ApiModelProperty(name = "菜肴ID",notes = "")
27
-    @TableId(value = "id", type = IdType.INPUT)
27
+    @TableId(value = "id", type = IdType.AUTO)
28 28
     private Integer id ;
29 29
     /** 菜肴名称 */
30 30
     @ApiModelProperty(name = "菜肴名称",notes = "")

+ 1
- 1
src/main/resources/application.yml Просмотреть файл

@@ -7,7 +7,7 @@ server:
7 7
 spring:
8 8
   datasource:
9 9
     driver-class-name: org.sqlite.JDBC
10
-    url: jdbc:sqlite:E:\work\jgz\service\db\ybai.db
10
+    url: jdbc:sqlite:E:\work\jungongzhang\service\db\ybai.db
11 11
     username:
12 12
     password:
13 13
   application: