zlisen 4 年 前
コミット
8c430b2309
共有2 個のファイルを変更した84 個の追加4 個の削除を含む
  1. 80
    3
      src/main/java/com/yunzhi/demo/controller/TdSchoolController.java
  2. 4
    1
      src/main/java/com/yunzhi/demo/entity/TdSchool.java

+ 80
- 3
src/main/java/com/yunzhi/demo/controller/TdSchoolController.java ファイルの表示

67
             return ResponseBean.success(result);
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
      * @param tdSchool 实体对象
91
      * @param tdSchool 实体对象
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
      * 根据id删除对象
122
      * 根据id删除对象
88
      * @param id  实体ID
123
      * @param id  实体ID
89
      */
124
      */
90
     @RequestMapping(value="/tdSchool/{id}", method= RequestMethod.DELETE)
125
     @RequestMapping(value="/tdSchool/{id}", method= RequestMethod.DELETE)
91
     @ApiOperation(value="删除", notes = "删除", httpMethod = "DELETE", response = ResponseBean.class)
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
         if(iTdSchoolService.removeById(id)){
142
         if(iTdSchoolService.removeById(id)){
94
             return ResponseBean.success("success");
143
             return ResponseBean.success("success");
95
         }else {
144
         }else {
105
      */
154
      */
106
     @RequestMapping(value="/tdSchool/{id}",method= RequestMethod.PUT)
155
     @RequestMapping(value="/tdSchool/{id}",method= RequestMethod.PUT)
107
     @ApiOperation(value="更新", notes = "更新", httpMethod = "PUT", response = ResponseBean.class)
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
                                         @ApiParam("更新内容") @RequestBody TdSchool tdSchool) throws Exception{
158
                                         @ApiParam("更新内容") @RequestBody TdSchool tdSchool) throws Exception{
110
 
159
 
111
         if (iTdSchoolService.updateById(tdSchool)){
160
         if (iTdSchoolService.updateById(tdSchool)){
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
      * 根据id查询对象
186
      * 根据id查询对象
120
      * @param id  实体ID
187
      * @param id  实体ID
121
      */
188
      */
122
     @RequestMapping(value="/tdSchool/{id}",method= RequestMethod.GET)
189
     @RequestMapping(value="/tdSchool/{id}",method= RequestMethod.GET)
123
     @ApiOperation(value="详情", notes = "详情", httpMethod = "GET", response = ResponseBean.class)
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
         return ResponseBean.success(iTdSchoolService.getById(id));
202
         return ResponseBean.success(iTdSchoolService.getById(id));
126
     }
203
     }
127
 }
204
 }

+ 4
- 1
src/main/java/com/yunzhi/demo/entity/TdSchool.java ファイルの表示

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