|
@@ -0,0 +1,173 @@
|
|
|
|
+package org.jeecg.modules.ctop.controller;
|
|
|
|
+
|
|
|
|
+import cn.com.ctop.manage.modules.actor.entity.Actor;
|
|
|
|
+import cn.com.ctop.manage.modules.actor.entity.ActorComment;
|
|
|
|
+import cn.com.ctop.manage.modules.actor.entity.ActorPhoto;
|
|
|
|
+import cn.com.ctop.manage.modules.actor.entity.ActorVideo;
|
|
|
|
+import cn.com.ctop.manage.modules.actor.service.IActorCommentService;
|
|
|
|
+import cn.com.ctop.manage.modules.actor.service.IActorPhotoService;
|
|
|
|
+import cn.com.ctop.manage.modules.actor.service.IActorService;
|
|
|
|
+import cn.com.ctop.manage.modules.actor.service.IActorVideoService;
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
|
+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
|
|
|
|
+@RequestMapping("/ctop/actor")
|
|
|
|
+public class ActorController {
|
|
|
|
+ @Autowired
|
|
|
|
+ private IActorService actorService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private IActorCommentService actorCommentService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private IActorPhotoService actorPhotoService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private IActorVideoService actorVideoService;
|
|
|
|
+
|
|
|
|
+ @ResponseBody
|
|
|
|
+ @RequestMapping(value = "/detail", method = RequestMethod.GET)
|
|
|
|
+ public Result<Map<String, Object>> getDetail(@RequestParam(name = "actorId") Long actorId) {
|
|
|
|
+ Result<Map<String, Object>> result = new Result<>();
|
|
|
|
+ Actor actor = actorService.getById(actorId);
|
|
|
|
+ ActorComment actorComment = new ActorComment();
|
|
|
|
+ actorComment.setActorId(actorId);
|
|
|
|
+ QueryWrapper<ActorComment> actorCommentQueryWrapper = QueryGenerator.initQueryWrapper(actorComment, null);
|
|
|
|
+ List<ActorComment> actorCommentList = actorCommentService.list(actorCommentQueryWrapper);
|
|
|
|
+
|
|
|
|
+ ActorPhoto actorPhoto = new ActorPhoto();
|
|
|
|
+ actorPhoto.setActorId(actorId);
|
|
|
|
+ QueryWrapper<ActorPhoto> actorPhotoQueryWrapper = QueryGenerator.initQueryWrapper(actorPhoto, null);
|
|
|
|
+ List<ActorPhoto> actorPhotoList = actorPhotoService.list(actorPhotoQueryWrapper);
|
|
|
|
+
|
|
|
|
+ ActorVideo actorVideo = new ActorVideo();
|
|
|
|
+ actorVideo.setActorId(actorId);
|
|
|
|
+ QueryWrapper<ActorVideo> actorVideoQueryWrapper = QueryGenerator.initQueryWrapper(actorVideo, null);
|
|
|
|
+ List<ActorVideo> actorVideoList = actorVideoService.list(actorVideoQueryWrapper);
|
|
|
|
+ Map<String, Object> map = new HashMap<String, Object>();
|
|
|
|
+ map.put("actor", actor);
|
|
|
|
+ map.put("actorCommentList", actorCommentList);
|
|
|
|
+ map.put("actorPhotoList", actorPhotoList);
|
|
|
|
+ map.put("actorVideoList", actorVideoList);
|
|
|
|
+ result.setResult(map);
|
|
|
|
+ result.setSuccess(true);
|
|
|
|
+ return result;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 分页列表查询
|
|
|
|
+ *
|
|
|
|
+ * @param actor
|
|
|
|
+ * @param pageNo
|
|
|
|
+ * @param pageSize
|
|
|
|
+ * @param req
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @GetMapping(value = "/list")
|
|
|
|
+ public Result<IPage<Actor>> queryPageList(Actor actor,
|
|
|
|
+ @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
|
|
|
|
+ @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
|
|
|
|
+ HttpServletRequest req) {
|
|
|
|
+ Result<IPage<Actor>> result = new Result<IPage<Actor>>();
|
|
|
|
+ QueryWrapper<Actor> queryWrapper = QueryGenerator.initQueryWrapper(actor, req.getParameterMap());
|
|
|
|
+ Page<Actor> page = new Page<Actor>(pageNo, pageSize);
|
|
|
|
+ IPage<Actor> pageList = actorService.page(page, queryWrapper);
|
|
|
|
+
|
|
|
|
+ result.setSuccess(true);
|
|
|
|
+ result.setResult(pageList);
|
|
|
|
+ return result;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 添加
|
|
|
|
+ *
|
|
|
|
+ * @param actor
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @PostMapping(value = "/add")
|
|
|
|
+ public Result<Actor> add(@RequestBody Actor actor) {
|
|
|
|
+ Result<Actor> result = new Result<Actor>();
|
|
|
|
+ try {
|
|
|
|
+ actorService.save(actor);
|
|
|
|
+ if (actor.getImageUrl() != null && actor.getImageUrl().size() > 0) {
|
|
|
|
+ for (String url : actor.getImageUrl()) {
|
|
|
|
+ ActorPhoto photo = new ActorPhoto();
|
|
|
|
+ photo.setActorId(actor.getId());
|
|
|
|
+ photo.setPhotoUrl("http:" + url);
|
|
|
|
+ actorPhotoService.save(photo);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (actor.getVideoUrl() != null && actor.getVideoUrl().size() > 0) {
|
|
|
|
+ for (String url : actor.getVideoUrl()) {
|
|
|
|
+ ActorVideo video = new ActorVideo();
|
|
|
|
+ video.setActorId(actor.getId());
|
|
|
|
+ video.setVideoUrl("http:" + url);
|
|
|
|
+ actorVideoService.save(video);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ result.success("添加成功!");
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ log.error(e.getMessage(), e);
|
|
|
|
+ result.error500("操作失败");
|
|
|
|
+ }
|
|
|
|
+ return result;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 编辑
|
|
|
|
+ *
|
|
|
|
+ * @param actor
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @PutMapping(value = "/edit")
|
|
|
|
+ public Result<Actor> edit(@RequestBody Actor actor) {
|
|
|
|
+ Result<Actor> result = new Result<Actor>();
|
|
|
|
+ ActorPhoto actorPhoto = new ActorPhoto();
|
|
|
|
+ actorPhoto.setActorId(actor.getId());
|
|
|
|
+ QueryWrapper photoQueryWrapper = QueryGenerator.initQueryWrapper(actorPhoto, null);
|
|
|
|
+ actorPhotoService.remove(photoQueryWrapper);
|
|
|
|
+
|
|
|
|
+ ActorVideo actorVideo = new ActorVideo();
|
|
|
|
+ actorVideo.setActorId(actor.getId());
|
|
|
|
+ QueryWrapper videoQueryWrapper = QueryGenerator.initQueryWrapper(actorVideo, null);
|
|
|
|
+ actorVideoService.remove(videoQueryWrapper);
|
|
|
|
+ if (actor.getImageUrl() != null && actor.getImageUrl().size() > 0) {
|
|
|
|
+ for (String url : actor.getImageUrl()) {
|
|
|
|
+ ActorPhoto photo = new ActorPhoto();
|
|
|
|
+ photo.setActorId(actor.getId());
|
|
|
|
+ photo.setPhotoUrl("http:" + url);
|
|
|
|
+ actorPhotoService.save(photo);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (actor.getVideoUrl() != null && actor.getVideoUrl().size() > 0) {
|
|
|
|
+ for (String url : actor.getVideoUrl()) {
|
|
|
|
+ ActorVideo video = new ActorVideo();
|
|
|
|
+ video.setActorId(actor.getId());
|
|
|
|
+ video.setVideoUrl("http:" + url);
|
|
|
|
+ actorVideoService.save(video);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ Actor actorEntity = actorService.getById(actor.getId());
|
|
|
|
+ if (actorEntity == null) {
|
|
|
|
+ result.error500("未找到对应实体");
|
|
|
|
+ } else {
|
|
|
|
+ boolean ok = actorService.updateById(actor);
|
|
|
|
+ //TODO 返回false说明什么?
|
|
|
|
+ if (ok) {
|
|
|
|
+ result.success("修改成功!");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return result;
|
|
|
|
+ }
|
|
|
|
+}
|