zlisen 4 years ago
parent
commit
3e8f2fe953

+ 81
- 0
src/main/java/com/yunzhi/demo/controller/SysBannerController.java View File

4
 import com.baomidou.mybatisplus.core.metadata.IPage;
4
 import com.baomidou.mybatisplus.core.metadata.IPage;
5
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
5
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
6
 import com.yunzhi.demo.common.BaseController;
6
 import com.yunzhi.demo.common.BaseController;
7
+import com.yunzhi.demo.common.Constants;
7
 import com.yunzhi.demo.common.ResponseBean;
8
 import com.yunzhi.demo.common.ResponseBean;
9
+import com.yunzhi.demo.common.StringUtils;
10
+import com.yunzhi.demo.entity.TaPost;
8
 import io.swagger.annotations.Api;
11
 import io.swagger.annotations.Api;
9
 import io.swagger.annotations.ApiOperation;
12
 import io.swagger.annotations.ApiOperation;
10
 import io.swagger.annotations.ApiParam;
13
 import io.swagger.annotations.ApiParam;
59
             return ResponseBean.success(result);
62
             return ResponseBean.success(result);
60
     }
63
     }
61
 
64
 
65
+    /**
66
+     * 分页查询列表
67
+     * @param pageNum
68
+     * @param pageSize
69
+     * @return
70
+     */
71
+    @RequestMapping(value="/admin/banner",method= RequestMethod.GET)
72
+    @ApiOperation(value="列表", notes = "列表", httpMethod = "GET", response = ResponseBean.class)
73
+    public ResponseBean bannerList(@ApiParam("页码") @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
74
+                                   @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize,
75
+                                   @ApiParam("标题") @RequestParam(value = "title", required = false) String title) throws Exception{
76
+
77
+        IPage<SysBanner> pg = new Page<>(pageNum, pageSize);
78
+        QueryWrapper<SysBanner> queryWrapper = new QueryWrapper<SysBanner>().like(!StringUtils.isEmpty(title), "title", title);
79
+        queryWrapper.orderByDesc("create_date");
80
+
81
+        IPage<SysBanner> result = iSysBannerService.page(pg, queryWrapper);
82
+        return ResponseBean.success(result);
83
+    }
84
+
62
     /**
85
     /**
63
      * 保存对象
86
      * 保存对象
64
      * @param sysBanner 实体对象
87
      * @param sysBanner 实体对象
75
         }
98
         }
76
     }
99
     }
77
 
100
 
101
+    /**
102
+     * 保存对象
103
+     * @param sysBanner 实体对象
104
+     * @return
105
+     */
106
+    @RequestMapping(value="/admin/banner",method= RequestMethod.POST)
107
+    @ApiOperation(value="保存", notes = "保存", httpMethod = "POST", response = ResponseBean.class)
108
+    public ResponseBean bannerAdd(@ApiParam("保存内容") @RequestBody SysBanner sysBanner) throws Exception{
109
+
110
+        if (iSysBannerService.save(sysBanner)){
111
+            return ResponseBean.success(sysBanner);
112
+        }else {
113
+            return ResponseBean.error("保存失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
114
+        }
115
+    }
116
+
78
     /**
117
     /**
79
      * 根据id删除对象
118
      * 根据id删除对象
80
      * @param id  实体ID
119
      * @param id  实体ID
89
         }
128
         }
90
     }
129
     }
91
 
130
 
131
+    /**
132
+     * 根据id删除对象
133
+     * @param id  实体ID
134
+     */
135
+    @RequestMapping(value="/admin/banner/{id}", method= RequestMethod.DELETE)
136
+    @ApiOperation(value="删除", notes = "删除", httpMethod = "DELETE", response = ResponseBean.class)
137
+    public ResponseBean bannerDelete(@ApiParam("对象ID") @PathVariable Integer id) throws Exception{
138
+        if(iSysBannerService.removeById(id)){
139
+            return ResponseBean.success("success");
140
+        }else {
141
+            return ResponseBean.error("删除失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
142
+        }
143
+    }
144
+
92
     /**
145
     /**
93
      * 修改对象
146
      * 修改对象
94
      * @param id  实体ID
147
      * @param id  实体ID
107
         }
160
         }
108
     }
161
     }
109
 
162
 
163
+    /**
164
+     * 修改对象
165
+     * @param id  实体ID
166
+     * @param sysBanner 实体对象
167
+     * @return
168
+     */
169
+    @RequestMapping(value="/admin/banner/{id}",method= RequestMethod.PUT)
170
+    @ApiOperation(value="更新", notes = "更新", httpMethod = "PUT", response = ResponseBean.class)
171
+    public ResponseBean bannerUpdate(@ApiParam("对象ID") @PathVariable Integer id,
172
+                                        @ApiParam("更新内容") @RequestBody SysBanner sysBanner) throws Exception{
173
+
174
+        if (iSysBannerService.updateById(sysBanner)){
175
+            return ResponseBean.success(iSysBannerService.getById(id));
176
+        }else {
177
+            return ResponseBean.error("修改失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
178
+        }
179
+    }
180
+
110
     /**
181
     /**
111
      * 根据id查询对象
182
      * 根据id查询对象
112
      * @param id  实体ID
183
      * @param id  实体ID
116
     public ResponseBean sysBannerGet(@ApiParam("对象ID") @PathVariable Integer id) throws Exception{
187
     public ResponseBean sysBannerGet(@ApiParam("对象ID") @PathVariable Integer id) throws Exception{
117
         return ResponseBean.success(iSysBannerService.getById(id));
188
         return ResponseBean.success(iSysBannerService.getById(id));
118
     }
189
     }
190
+
191
+    /**
192
+     * 根据id查询对象
193
+     * @param id  实体ID
194
+     */
195
+    @RequestMapping(value="/admin/banner/{id}",method= RequestMethod.GET)
196
+    @ApiOperation(value="详情", notes = "详情", httpMethod = "GET", response = ResponseBean.class)
197
+    public ResponseBean bannerGet(@ApiParam("对象ID") @PathVariable Integer id) throws Exception{
198
+        return ResponseBean.success(iSysBannerService.getById(id));
199
+    }
119
 }
200
 }

+ 77
- 0
src/main/java/com/yunzhi/demo/controller/TaTopicController.java View File

59
             return ResponseBean.success(result);
59
             return ResponseBean.success(result);
60
     }
60
     }
61
 
61
 
62
+    /**
63
+     * 分页查询列表
64
+     * @param pageNum
65
+     * @param pageSize
66
+     * @return
67
+     */
68
+    @RequestMapping(value="/admin/topic",method= RequestMethod.GET)
69
+    @ApiOperation(value="列表", notes = "列表", httpMethod = "GET", response = ResponseBean.class)
70
+    public ResponseBean topicList(@ApiParam("页码") @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
71
+                                    @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize) throws Exception{
72
+
73
+        IPage<TaTopic> pg = new Page<>(pageNum, pageSize);
74
+        QueryWrapper<TaTopic> queryWrapper = new QueryWrapper<>();
75
+        queryWrapper.orderByDesc("create_date");
76
+
77
+        IPage<TaTopic> result = iTaTopicService.page(pg, queryWrapper);
78
+        return ResponseBean.success(result);
79
+    }
80
+
62
     /**
81
     /**
63
      * 保存对象
82
      * 保存对象
64
      * @param taTopic 实体对象
83
      * @param taTopic 实体对象
75
         }
94
         }
76
     }
95
     }
77
 
96
 
97
+    /**
98
+     * 保存对象
99
+     * @param taTopic 实体对象
100
+     * @return
101
+     */
102
+    @RequestMapping(value="/admin/topic",method= RequestMethod.POST)
103
+    @ApiOperation(value="保存", notes = "保存", httpMethod = "POST", response = ResponseBean.class)
104
+    public ResponseBean topicAdd(@ApiParam("保存内容") @RequestBody TaTopic taTopic) throws Exception{
105
+
106
+        if (iTaTopicService.save(taTopic)){
107
+            return ResponseBean.success(taTopic);
108
+        }else {
109
+            return ResponseBean.error("保存失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
110
+        }
111
+    }
112
+
78
     /**
113
     /**
79
      * 根据id删除对象
114
      * 根据id删除对象
80
      * @param id  实体ID
115
      * @param id  实体ID
89
         }
124
         }
90
     }
125
     }
91
 
126
 
127
+    /**
128
+     * 根据id删除对象
129
+     * @param id  实体ID
130
+     */
131
+    @RequestMapping(value="/admin/topic/{id}", method= RequestMethod.DELETE)
132
+    @ApiOperation(value="删除", notes = "删除", httpMethod = "DELETE", response = ResponseBean.class)
133
+    public ResponseBean topicDelete(@ApiParam("对象ID") @PathVariable Integer id) throws Exception{
134
+        if(iTaTopicService.removeById(id)){
135
+            return ResponseBean.success("success");
136
+        }else {
137
+            return ResponseBean.error("删除失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
138
+        }
139
+    }
140
+
92
     /**
141
     /**
93
      * 修改对象
142
      * 修改对象
94
      * @param id  实体ID
143
      * @param id  实体ID
107
         }
156
         }
108
     }
157
     }
109
 
158
 
159
+    /**
160
+     * 修改对象
161
+     * @param id  实体ID
162
+     * @param taTopic 实体对象
163
+     * @return
164
+     */
165
+    @RequestMapping(value="/admin/topic/{id}",method= RequestMethod.PUT)
166
+    @ApiOperation(value="更新", notes = "更新", httpMethod = "PUT", response = ResponseBean.class)
167
+    public ResponseBean topicUpdate(@ApiParam("对象ID") @PathVariable Integer id,
168
+                                      @ApiParam("更新内容") @RequestBody TaTopic taTopic) throws Exception{
169
+
170
+        if (iTaTopicService.updateById(taTopic)){
171
+            return ResponseBean.success(iTaTopicService.getById(id));
172
+        }else {
173
+            return ResponseBean.error("修改失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
174
+        }
175
+    }
176
+
110
     /**
177
     /**
111
      * 根据id查询对象
178
      * 根据id查询对象
112
      * @param id  实体ID
179
      * @param id  实体ID
116
     public ResponseBean taTopicGet(@ApiParam("对象ID") @PathVariable Integer id) throws Exception{
183
     public ResponseBean taTopicGet(@ApiParam("对象ID") @PathVariable Integer id) throws Exception{
117
         return ResponseBean.success(iTaTopicService.getById(id));
184
         return ResponseBean.success(iTaTopicService.getById(id));
118
     }
185
     }
186
+
187
+    /**
188
+     * 根据id查询对象
189
+     * @param id  实体ID
190
+     */
191
+    @RequestMapping(value="/admin/topic/{id}",method= RequestMethod.GET)
192
+    @ApiOperation(value="详情", notes = "详情", httpMethod = "GET", response = ResponseBean.class)
193
+    public ResponseBean topicGet(@ApiParam("对象ID") @PathVariable Integer id) throws Exception{
194
+        return ResponseBean.success(iTaTopicService.getById(id));
195
+    }
119
 }
196
 }