zlisen 4 anni fa
parent
commit
8c430b2309

+ 80
- 3
src/main/java/com/yunzhi/demo/controller/TdSchoolController.java Vedi File

@@ -67,6 +67,25 @@ public class TdSchoolController extends BaseController {
67 67
             return ResponseBean.success(result);
68 68
     }
69 69
 
70
+    /**
71
+     * 分页查询列表
72
+     * @param pageNum
73
+     * @param pageSize
74
+     * @return
75
+     */
76
+    @RequestMapping(value="/admin/school",method= RequestMethod.GET)
77
+    @ApiOperation(value="列表", notes = "列表", httpMethod = "GET", response = ResponseBean.class)
78
+    public ResponseBean schoolList(@ApiParam("页码") @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
79
+                                     @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize) throws Exception{
80
+
81
+        IPage<TdSchool> pg = new Page<>(pageNum, pageSize);
82
+        QueryWrapper<TdSchool> queryWrapper = new QueryWrapper<>();
83
+        queryWrapper.orderByDesc("create_date");
84
+
85
+        IPage<TdSchool> result = iTdSchoolService.page(pg, queryWrapper);
86
+        return ResponseBean.success(result);
87
+    }
88
+
70 89
     /**
71 90
      * 保存对象
72 91
      * @param tdSchool 实体对象
@@ -83,13 +102,43 @@ public class TdSchoolController extends BaseController {
83 102
         }
84 103
     }
85 104
 
105
+    /**
106
+     * 保存对象
107
+     * @param tdSchool 实体对象
108
+     * @return
109
+     */
110
+    @RequestMapping(value="/admin/school",method= RequestMethod.POST)
111
+    @ApiOperation(value="保存", notes = "保存", httpMethod = "POST", response = ResponseBean.class)
112
+    public ResponseBean schoolAdd(@ApiParam("保存内容") @RequestBody TdSchool tdSchool) throws Exception{
113
+
114
+        if (iTdSchoolService.save(tdSchool)){
115
+            return ResponseBean.success(tdSchool);
116
+        }else {
117
+            return ResponseBean.error("保存失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
118
+        }
119
+    }
120
+
86 121
     /**
87 122
      * 根据id删除对象
88 123
      * @param id  实体ID
89 124
      */
90 125
     @RequestMapping(value="/tdSchool/{id}", method= RequestMethod.DELETE)
91 126
     @ApiOperation(value="删除", notes = "删除", httpMethod = "DELETE", response = ResponseBean.class)
92
-    public ResponseBean tdSchoolDelete(@ApiParam("对象ID") @PathVariable Integer id) throws Exception{
127
+    public ResponseBean tdSchoolDelete(@ApiParam("对象ID") @PathVariable String id) throws Exception{
128
+        if(iTdSchoolService.removeById(id)){
129
+            return ResponseBean.success("success");
130
+        }else {
131
+            return ResponseBean.error("删除失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
132
+        }
133
+    }
134
+
135
+    /**
136
+     * 根据id删除对象
137
+     * @param id  实体ID
138
+     */
139
+    @RequestMapping(value="/admin/school/{id}", method= RequestMethod.DELETE)
140
+    @ApiOperation(value="删除", notes = "删除", httpMethod = "DELETE", response = ResponseBean.class)
141
+    public ResponseBean schoolDelete(@ApiParam("对象ID") @PathVariable String id) throws Exception{
93 142
         if(iTdSchoolService.removeById(id)){
94 143
             return ResponseBean.success("success");
95 144
         }else {
@@ -105,7 +154,7 @@ public class TdSchoolController extends BaseController {
105 154
      */
106 155
     @RequestMapping(value="/tdSchool/{id}",method= RequestMethod.PUT)
107 156
     @ApiOperation(value="更新", notes = "更新", httpMethod = "PUT", response = ResponseBean.class)
108
-    public ResponseBean tdSchoolUpdate(@ApiParam("对象ID") @PathVariable Integer id,
157
+    public ResponseBean tdSchoolUpdate(@ApiParam("对象ID") @PathVariable String id,
109 158
                                         @ApiParam("更新内容") @RequestBody TdSchool tdSchool) throws Exception{
110 159
 
111 160
         if (iTdSchoolService.updateById(tdSchool)){
@@ -115,13 +164,41 @@ public class TdSchoolController extends BaseController {
115 164
         }
116 165
     }
117 166
 
167
+    /**
168
+     * 修改对象
169
+     * @param id  实体ID
170
+     * @param tdSchool 实体对象
171
+     * @return
172
+     */
173
+    @RequestMapping(value="/admin/school/{id}",method= RequestMethod.PUT)
174
+    @ApiOperation(value="更新", notes = "更新", httpMethod = "PUT", response = ResponseBean.class)
175
+    public ResponseBean schoolUpdate(@ApiParam("对象ID") @PathVariable String id,
176
+                                       @ApiParam("更新内容") @RequestBody TdSchool tdSchool) throws Exception{
177
+
178
+        if (iTdSchoolService.updateById(tdSchool)){
179
+            return ResponseBean.success(iTdSchoolService.getById(id));
180
+        }else {
181
+            return ResponseBean.error("修改失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
182
+        }
183
+    }
184
+
118 185
     /**
119 186
      * 根据id查询对象
120 187
      * @param id  实体ID
121 188
      */
122 189
     @RequestMapping(value="/tdSchool/{id}",method= RequestMethod.GET)
123 190
     @ApiOperation(value="详情", notes = "详情", httpMethod = "GET", response = ResponseBean.class)
124
-    public ResponseBean tdSchoolGet(@ApiParam("对象ID") @PathVariable Integer id) throws Exception{
191
+    public ResponseBean tdSchoolGet(@ApiParam("对象ID") @PathVariable String id) throws Exception{
192
+        return ResponseBean.success(iTdSchoolService.getById(id));
193
+    }
194
+
195
+    /**
196
+     * 根据id查询对象
197
+     * @param id  实体ID
198
+     */
199
+    @RequestMapping(value="/admin/school/{id}",method= RequestMethod.GET)
200
+    @ApiOperation(value="详情", notes = "详情", httpMethod = "GET", response = ResponseBean.class)
201
+    public ResponseBean schoolGet(@ApiParam("对象ID") @PathVariable String id) throws Exception{
125 202
         return ResponseBean.success(iTdSchoolService.getById(id));
126 203
     }
127 204
 }

+ 4
- 1
src/main/java/com/yunzhi/demo/entity/TdSchool.java Vedi File

@@ -2,6 +2,8 @@ package com.yunzhi.demo.entity;
2 2
 
3 3
 import com.baomidou.mybatisplus.annotation.IdType;
4 4
 import java.time.LocalDateTime;
5
+
6
+import com.baomidou.mybatisplus.annotation.TableField;
5 7
 import com.baomidou.mybatisplus.annotation.TableId;
6 8
 import java.io.Serializable;
7 9
 import io.swagger.annotations.ApiModel;
@@ -27,7 +29,7 @@ public class TdSchool implements Serializable {
27 29
     private static final long serialVersionUID = 1L;
28 30
 
29 31
     @ApiModelProperty(value = "学校ID")
30
-    @TableId(value = "school_id", type = IdType.INPUT)
32
+    @TableId(value = "school_id", type = IdType.UUID)
31 33
     private String schoolId;
32 34
 
33 35
     @ApiModelProperty(value = "名称")
@@ -37,6 +39,7 @@ public class TdSchool implements Serializable {
37 39
     private String logo;
38 40
 
39 41
     @ApiModelProperty(value = "简介")
42
+    @TableField ("`desc`")
40 43
     private String desc;
41 44
 
42 45
     @ApiModelProperty(value = "排序")