|
@@ -1,10 +1,7 @@
|
|
|
package org.jeecg.modules.ctop.controller;
|
|
|
|
|
|
import cn.com.ctop.manage.modules.actor.entity.*;
|
|
|
-import cn.com.ctop.manage.modules.actor.service.IYardPhotoService;
|
|
|
-import cn.com.ctop.manage.modules.actor.service.IYardSchedulerService;
|
|
|
-import cn.com.ctop.manage.modules.actor.service.IYardService;
|
|
|
-import cn.com.ctop.manage.modules.actor.service.IYardVideoService;
|
|
|
+import cn.com.ctop.manage.modules.actor.service.*;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
@@ -13,11 +10,7 @@ import org.jeecg.common.api.vo.Result;
|
|
|
import org.jeecg.common.system.query.QueryGenerator;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
-
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
|
|
|
@RestController
|
|
|
@Slf4j
|
|
@@ -31,30 +24,32 @@ public class YardController {
|
|
|
private IYardService yardService;
|
|
|
@Autowired
|
|
|
private IYardVideoService yardVideoService;
|
|
|
+ @Autowired
|
|
|
+ private IYardCommentService yardCommentService;
|
|
|
|
|
|
@ResponseBody
|
|
|
@RequestMapping(value = "/detail", method = RequestMethod.GET)
|
|
|
- public Result<Map<String, Object>> getDetail(@RequestParam(name = "yardId") Long yardId) {
|
|
|
- Result<Map<String, Object>> result = new Result<>();
|
|
|
- Yard yard = yardService.getById(yardId);
|
|
|
- YardPhoto yardPhoto = new YardPhoto();
|
|
|
- YardVideo yardVideo = new YardVideo();
|
|
|
- YardScheduler yardScheduler = new YardScheduler();
|
|
|
- yardPhoto.setYardId(yardId);
|
|
|
- yardVideo.setYardId(yardId);
|
|
|
- yardScheduler.setYardId(yardId);
|
|
|
- QueryWrapper<YardPhoto> yardPhotoQueryWrapper = QueryGenerator.initQueryWrapper(yardPhoto, null);
|
|
|
- QueryWrapper<YardVideo> yardVideoQueryWrapper = QueryGenerator.initQueryWrapper(yardVideo, null);
|
|
|
- QueryWrapper<YardScheduler> yardSchedulerQueryWrapper = QueryGenerator.initQueryWrapper(yardScheduler, null);
|
|
|
- List<YardPhoto> yardPhotoList = yardPhotoService.list(yardPhotoQueryWrapper);
|
|
|
- List<YardVideo> yardVideoList = yardVideoService.list(yardVideoQueryWrapper);
|
|
|
- List<YardScheduler> yardSchedulerList = yardSchedulerService.list(yardSchedulerQueryWrapper);
|
|
|
- Map<String, Object> map = new HashMap<String, Object>();
|
|
|
- map.put("yard", yard);
|
|
|
- map.put("yardPhotoList", yardPhotoList);
|
|
|
- map.put("yardVideoList", yardVideoList);
|
|
|
- map.put("yardSchedulerList", yardSchedulerList);
|
|
|
- result.setResult(map);
|
|
|
+ public Result<Yard> getDetail(@RequestParam(name = "id") Long id) {
|
|
|
+ Result<Yard> result = new Result<>();
|
|
|
+ Yard yard = yardService.getById(id);
|
|
|
+// YardPhoto yardPhoto = new YardPhoto();
|
|
|
+// YardVideo yardVideo = new YardVideo();
|
|
|
+// YardScheduler yardScheduler = new YardScheduler();
|
|
|
+// yardPhoto.setYardId(yardId);
|
|
|
+// yardVideo.setYardId(yardId);
|
|
|
+// yardScheduler.setYardId(yardId);
|
|
|
+// QueryWrapper<YardPhoto> yardPhotoQueryWrapper = QueryGenerator.initQueryWrapper(yardPhoto, null);
|
|
|
+// QueryWrapper<YardVideo> yardVideoQueryWrapper = QueryGenerator.initQueryWrapper(yardVideo, null);
|
|
|
+// QueryWrapper<YardScheduler> yardSchedulerQueryWrapper = QueryGenerator.initQueryWrapper(yardScheduler, null);
|
|
|
+// List<YardPhoto> yardPhotoList = yardPhotoService.list(yardPhotoQueryWrapper);
|
|
|
+// List<YardVideo> yardVideoList = yardVideoService.list(yardVideoQueryWrapper);
|
|
|
+// List<YardScheduler> yardSchedulerList = yardSchedulerService.list(yardSchedulerQueryWrapper);
|
|
|
+// Map<String, Object> map = new HashMap<String, Object>();
|
|
|
+// map.put("yard", yard);
|
|
|
+// map.put("yardPhotoList", yardPhotoList);
|
|
|
+// map.put("yardVideoList", yardVideoList);
|
|
|
+// map.put("yardSchedulerList", yardSchedulerList);
|
|
|
+ result.setResult(yard);
|
|
|
result.setSuccess(true);
|
|
|
return result;
|
|
|
}
|
|
@@ -64,22 +59,22 @@ public class YardController {
|
|
|
Result<Yard> result = new Result<Yard>();
|
|
|
try {
|
|
|
yardService.save(yard);
|
|
|
- if (yard.getImageUrl() != null && yard.getImageUrl().size() > 0) {
|
|
|
- for (String url : yard.getImageUrl()) {
|
|
|
- YardPhoto yardPhoto = new YardPhoto();
|
|
|
- yardPhoto.setYardId(yard.getId());
|
|
|
- yardPhoto.setPhotoUrl("http:" + url);
|
|
|
- yardPhotoService.save(yardPhoto);
|
|
|
- }
|
|
|
- }
|
|
|
- if (yard.getVideoUrl() != null && yard.getVideoUrl().size() > 0) {
|
|
|
- for (String url : yard.getVideoUrl()) {
|
|
|
- YardVideo yardVideo = new YardVideo();
|
|
|
- yardVideo.setYardId(yard.getId());
|
|
|
- yardVideo.setVideoUrl("http:" + url);
|
|
|
- yardVideoService.save(yardVideo);
|
|
|
- }
|
|
|
- }
|
|
|
+// if (yard.getImageUrl() != null && yard.getImageUrl().size() > 0) {
|
|
|
+// for (String url : yard.getImageUrl()) {
|
|
|
+// YardPhoto yardPhoto = new YardPhoto();
|
|
|
+// yardPhoto.setYardId(yard.getId());
|
|
|
+// yardPhoto.setPhotoUrl("http:" + url);
|
|
|
+// yardPhotoService.save(yardPhoto);
|
|
|
+// }
|
|
|
+// }
|
|
|
+// if (yard.getVideoUrl() != null && yard.getVideoUrl().size() > 0) {
|
|
|
+// for (String url : yard.getVideoUrl()) {
|
|
|
+// YardVideo yardVideo = new YardVideo();
|
|
|
+// yardVideo.setYardId(yard.getId());
|
|
|
+// yardVideo.setVideoUrl("http:" + url);
|
|
|
+// yardVideoService.save(yardVideo);
|
|
|
+// }
|
|
|
+// }
|
|
|
result.success("添加成功!");
|
|
|
} catch (Exception e) {
|
|
|
log.error(e.getMessage(), e);
|
|
@@ -97,31 +92,31 @@ public class YardController {
|
|
|
result.error500("未找到对应实体");
|
|
|
} else {
|
|
|
boolean ok = yardService.updateById(yard);
|
|
|
- YardPhoto yardPhoto = new YardPhoto();
|
|
|
- yardPhoto.setYardId(yard.getId());
|
|
|
- QueryWrapper photoQueryWrapper = QueryGenerator.initQueryWrapper(yardPhoto, null);
|
|
|
- yardPhotoService.remove(photoQueryWrapper);
|
|
|
-
|
|
|
- YardVideo yardVideo = new YardVideo();
|
|
|
- yardVideo.setYardId(yard.getId());
|
|
|
- QueryWrapper videoQueryWrapper = QueryGenerator.initQueryWrapper(yardVideo, null);
|
|
|
- yardVideoService.remove(videoQueryWrapper);
|
|
|
- if (yard.getImageUrl() != null && yard.getImageUrl().size() > 0) {
|
|
|
- for (String url : yard.getImageUrl()) {
|
|
|
- YardPhoto photo = new YardPhoto();
|
|
|
- photo.setYardId(yard.getId());
|
|
|
- photo.setPhotoUrl("http:" + url);
|
|
|
- yardPhotoService.save(photo);
|
|
|
- }
|
|
|
- }
|
|
|
- if (yard.getVideoUrl() != null && yard.getVideoUrl().size() > 0) {
|
|
|
- for (String url : yard.getVideoUrl()) {
|
|
|
- YardVideo video = new YardVideo();
|
|
|
- video.setYardId(yard.getId());
|
|
|
- video.setVideoUrl("http:" + url);
|
|
|
- yardVideoService.save(video);
|
|
|
- }
|
|
|
- }
|
|
|
+// YardPhoto yardPhoto = new YardPhoto();
|
|
|
+// yardPhoto.setYardId(yard.getId());
|
|
|
+// QueryWrapper photoQueryWrapper = QueryGenerator.initQueryWrapper(yardPhoto, null);
|
|
|
+// yardPhotoService.remove(photoQueryWrapper);
|
|
|
+//
|
|
|
+// YardVideo yardVideo = new YardVideo();
|
|
|
+// yardVideo.setYardId(yard.getId());
|
|
|
+// QueryWrapper videoQueryWrapper = QueryGenerator.initQueryWrapper(yardVideo, null);
|
|
|
+// yardVideoService.remove(videoQueryWrapper);
|
|
|
+// if (yard.getImageUrl() != null && yard.getImageUrl().size() > 0) {
|
|
|
+// for (String url : yard.getImageUrl()) {
|
|
|
+// YardPhoto photo = new YardPhoto();
|
|
|
+// photo.setYardId(yard.getId());
|
|
|
+// photo.setPhotoUrl("http:" + url);
|
|
|
+// yardPhotoService.save(photo);
|
|
|
+// }
|
|
|
+// }
|
|
|
+// if (yard.getVideoUrl() != null && yard.getVideoUrl().size() > 0) {
|
|
|
+// for (String url : yard.getVideoUrl()) {
|
|
|
+// YardVideo video = new YardVideo();
|
|
|
+// video.setYardId(yard.getId());
|
|
|
+// video.setVideoUrl("http:" + url);
|
|
|
+// yardVideoService.save(video);
|
|
|
+// }
|
|
|
+// }
|
|
|
//TODO 返回false说明什么?
|
|
|
if (ok) {
|
|
|
result.success("修改成功!");
|
|
@@ -144,4 +139,133 @@ public class YardController {
|
|
|
result.setResult(pageList);
|
|
|
return result;
|
|
|
}
|
|
|
+
|
|
|
+ @GetMapping(value = "/photo/list")
|
|
|
+ public Result<IPage<YardPhoto>> queryPhotoPageList(YardPhoto yardPhoto,
|
|
|
+ @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
|
|
|
+ @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
|
|
|
+ HttpServletRequest req) {
|
|
|
+ Result<IPage<YardPhoto>> result = new Result<IPage<YardPhoto>>();
|
|
|
+
|
|
|
+ QueryWrapper<YardPhoto> queryWrapper = QueryGenerator.initQueryWrapper(yardPhoto, req.getParameterMap());
|
|
|
+ Page<YardPhoto> page = new Page<YardPhoto>(pageNo, pageSize);
|
|
|
+ IPage<YardPhoto> pageList = yardPhotoService.page(page, queryWrapper);
|
|
|
+ result.setSuccess(true);
|
|
|
+ result.setResult(pageList);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping(value = "/comment/list")
|
|
|
+ public Result<IPage<YardComment>> queryCommentPageList(YardComment yardComment,
|
|
|
+ @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
|
|
|
+ @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
|
|
|
+ HttpServletRequest req) {
|
|
|
+ Result<IPage<YardComment>> result = new Result<IPage<YardComment>>();
|
|
|
+
|
|
|
+ QueryWrapper<YardComment> queryWrapper = QueryGenerator.initQueryWrapper(yardComment, req.getParameterMap());
|
|
|
+ Page<YardComment> page = new Page<YardComment>(pageNo, pageSize);
|
|
|
+ IPage<YardComment> pageList = yardCommentService.page(page, queryWrapper);
|
|
|
+ result.setSuccess(true);
|
|
|
+ result.setResult(pageList);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ @DeleteMapping(value = "/comment/delete")
|
|
|
+ public Result<YardComment> deleteComment(@RequestParam(name = "id", required = true) String id) {
|
|
|
+ Result<YardComment> result = new Result<YardComment>();
|
|
|
+ YardComment yardComment = yardCommentService.getById(id);
|
|
|
+ if (yardComment == null) {
|
|
|
+ result.error500("未找到对应实体");
|
|
|
+ } else {
|
|
|
+ boolean ok = yardCommentService.removeById(id);
|
|
|
+ if (ok) {
|
|
|
+ result.success("删除成功!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ @DeleteMapping(value = "/video/delete")
|
|
|
+ public Result<YardVideo> deleteVideo(@RequestParam(name = "id", required = true) String id) {
|
|
|
+ Result<YardVideo> result = new Result<YardVideo>();
|
|
|
+ YardVideo yardVideo = yardVideoService.getById(id);
|
|
|
+ if (yardVideo == null) {
|
|
|
+ result.error500("未找到对应实体");
|
|
|
+ } else {
|
|
|
+ boolean ok = yardVideoService.removeById(id);
|
|
|
+ if (ok) {
|
|
|
+ result.success("删除成功!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ @DeleteMapping(value = "/photo/delete")
|
|
|
+ public Result<YardPhoto> deletePhoto(@RequestParam(name = "id", required = true) String id) {
|
|
|
+ Result<YardPhoto> result = new Result<YardPhoto>();
|
|
|
+ YardPhoto yardPhoto = yardPhotoService.getById(id);
|
|
|
+ if (yardPhoto == null) {
|
|
|
+ result.error500("未找到对应实体");
|
|
|
+ } else {
|
|
|
+ boolean ok = yardPhotoService.removeById(id);
|
|
|
+ if (ok) {
|
|
|
+ result.success("删除成功!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping(value = "/comment/add")
|
|
|
+ public Result<YardComment> addComment(YardComment yardComment) {
|
|
|
+ Result<YardComment> result = new Result<YardComment>();
|
|
|
+ try {
|
|
|
+ yardCommentService.save(yardComment);
|
|
|
+ result.success("添加成功!");
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error(e.getMessage(), e);
|
|
|
+ result.error500("操作失败");
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping(value = "/video/add")
|
|
|
+ public Result<YardVideo> addVideo(YardVideo yardVideo) {
|
|
|
+ Result<YardVideo> result = new Result<YardVideo>();
|
|
|
+ try {
|
|
|
+ yardVideoService.save(yardVideo);
|
|
|
+ result.success("添加成功!");
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error(e.getMessage(), e);
|
|
|
+ result.error500("操作失败");
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping(value = "/photo/add")
|
|
|
+ public Result<YardPhoto> addPhoto(YardPhoto yardPhoto) {
|
|
|
+ Result<YardPhoto> result = new Result<YardPhoto>();
|
|
|
+ try {
|
|
|
+ yardPhotoService.save(yardPhoto);
|
|
|
+ result.success("添加成功!");
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error(e.getMessage(), e);
|
|
|
+ result.error500("操作失败");
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping(value = "/video/list")
|
|
|
+ public Result<IPage<YardVideo>> queryVideoPageList(YardVideo yardVideo,
|
|
|
+ @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
|
|
|
+ @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
|
|
|
+ HttpServletRequest req) {
|
|
|
+ Result<IPage<YardVideo>> result = new Result<IPage<YardVideo>>();
|
|
|
+
|
|
|
+ QueryWrapper<YardVideo> queryWrapper = QueryGenerator.initQueryWrapper(yardVideo, req.getParameterMap());
|
|
|
+ Page<YardVideo> page = new Page<YardVideo>(pageNo, pageSize);
|
|
|
+ IPage<YardVideo> pageList = yardVideoService.page(page, queryWrapper);
|
|
|
+ result.setSuccess(true);
|
|
|
+ result.setResult(pageList);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
}
|