Bläddra i källkod

编辑作品时需要检查是否该用户的作品
删除无用代码

wuweihao 4 år sedan
förälder
incheckning
502fba4bee

+ 19 - 40
720yun_fd_manage/gis_service/src/main/java/com/gis/service/impl/WorkServiceImpl.java

@@ -1,7 +1,6 @@
 package com.gis.service.impl;
 
 import cn.hutool.core.io.FileUtil;
-import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.gis.common.constant.ConfigConstant;
 import com.gis.common.constant.MsgCode;
@@ -14,7 +13,6 @@ import com.gis.domain.entity.CatalogEntity;
 import com.gis.domain.entity.SceneEntity;
 import com.gis.domain.entity.WorkEntity;
 import com.gis.domain.tree.CatalogTree;
-import com.gis.domain.vo.ProSceneVo;
 import com.gis.domain.vo.WorkInfoVo;
 import com.gis.mapper.CatalogMapper;
 import com.gis.mapper.SceneMapper;
@@ -242,11 +240,25 @@ public class WorkServiceImpl extends IBaseServiceImpl<WorkEntity, Long> implemen
     @Override
     public Result edit(SomeDataDto param) {
 
+        // 检查是否是改用户的作品
+        Long id = param.getId();
+        WorkEntity entity = this.findById(id);
+        if (entity == null) {
+            log.error("作品已被删除,无法编辑, id: " + id);
+            throw new BaseRuntimeException(MsgCode.e3006, "作品已被删除,无法编辑, id: " + id);
+        }
+
+        String userNameForToken = getUserNameForToken();
+        if (!userNameForToken.equals(entity.getUserId())) {
+            return Result.failure(MsgCode.e3005, "不是该用户作品");
+        }
+
         // 更新作品信息
-        boolean isEdit = editEntity(param);
+        boolean isEdit = editEntity(param, entity);
         if (!isEdit) {
             return Result.failure("对象不存在");
         }
+
         log.info("更新作品完成");
         // 保存someData.json
         editSomeData( param);
@@ -257,14 +269,9 @@ public class WorkServiceImpl extends IBaseServiceImpl<WorkEntity, Long> implemen
     /**
      * 更新作品实体信息
      */
-    private boolean editEntity(SomeDataDto param) {
+    private boolean editEntity(SomeDataDto param, WorkEntity entity) {
+
 
-        Long id = param.getId();
-        WorkEntity entity = this.findById(id);
-        if (entity == null) {
-            log.error("作品已被删除,无法编辑, id: " + id);
-            throw new BaseRuntimeException(MsgCode.e3006, "作品已被删除,无法编辑, id: " + id);
-        }
 
         String someData = param.getSomeData();
         JSONObject sd = JSONObject.parseObject(someData);
@@ -278,7 +285,7 @@ public class WorkServiceImpl extends IBaseServiceImpl<WorkEntity, Long> implemen
         Boolean logoChange = sd.getBoolean("logoChange");
         String logoUrl = sd.getString("logo");
         if (logoChange) {
-            Boolean isLogo = updateQrCode(id, logoUrl);
+            Boolean isLogo = updateQrCode(entity.getId(), logoUrl);
             if (!isLogo) {
                 log.error("二维码创建失败");
                 return false;
@@ -384,35 +391,7 @@ public class WorkServiceImpl extends IBaseServiceImpl<WorkEntity, Long> implemen
                     } catch (Exception e) {
             e.printStackTrace();
         }
-//            JSONArray list = dataJson.getJSONArray("list");
-//
-//
-//            // 作品场景查重
-//            List<String> useScenes = this.strFindByWorkId(workId, "4dkk");
-//
-//            List<ProSceneVo> result = new ArrayList<>();
-//            if (list.size() > 0) {
-//                for (Object entity : list) {
-//                    JSONObject proJson = JSONObject.parseObject(entity.toString());
-//                    ProSceneVo pro = new ProSceneVo();
-//                    pro.setNum(proJson.getString("num"));
-//                    pro.setSceneName(proJson.getString("sceneName"));
-//                    pro.setThumb(proJson.getString("thumb"));
-//                    pro.setStatus(proJson.getInteger("status"));
-//                    pro.setCreateTime(proJson.getString("createTime"));
-//
-//                    if (useScenes.contains(pro.getNum())) {
-//                        pro.setIsUse(1);
-//                    }
-//                    result.add(pro);
-//                }
-//            }
-//            dataJson.put("list", result);
-//
-//
-//        } catch (Exception e) {
-//            e.printStackTrace();
-//        }
+
         return Result.success(reJson);
 
 

+ 0 - 88
720yun_fd_manage/gis_web/src/main/java/com/gis/web/controller/CatalogController.java

@@ -1,88 +0,0 @@
-package com.gis.web.controller;
-
-
-import com.gis.common.util.Result;
-import com.gis.domain.dto.BaseDto;
-import com.gis.domain.dto.CatalogDto;
-import com.gis.domain.entity.CatalogEntity;
-import com.gis.domain.entity.WorkEntity;
-import com.gis.service.CatalogService;
-import com.gis.service.FodderService;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiImplicitParam;
-import io.swagger.annotations.ApiImplicitParams;
-import io.swagger.annotations.ApiOperation;
-import lombok.extern.log4j.Log4j2;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.*;
-import org.springframework.web.multipart.MultipartFile;
-
-import javax.validation.Valid;
-import java.util.Date;
-
-
-/**
- * Created by owen on 2020/2/22 0018 12:17
- */
-@Log4j2
-@Api(tags = "场景分组")
-//@RestController
-@RequestMapping("manage/catalog")
-public class CatalogController extends BaseController {
-
-    @Autowired
-    private CatalogService catalogService;
-
-
-    @ApiOperation(value = "获取场景", position = 1)
-    @GetMapping("getScene/{catalogId}")
-    public Result getScene(@PathVariable Long catalogId) {
-        return catalogService.getScene(catalogId);
-    }
-
-    @ApiOperation(value = "获取分组")
-    @GetMapping("getCatalog/{workId}")
-    public Result getCatalog(@PathVariable Long workId) {
-        return catalogService.getCatalog(workId);
-    }
-
-    @ApiOperation(value = "场景列表", position = 1)
-    @PostMapping("listTree/{workId}")
-    public Result listTree(@PathVariable Long workId) {
-        return catalogService.listTree(workId);
-    }
-
-
-
-
-    @ApiOperation(value = "重命名分组", position = 1)
-    @PostMapping("edit")
-    public Result edit(@Valid @RequestBody BaseDto param) {
-        return catalogService.editEntity(param);
-    }
-
-    @ApiOperation(value = "新增/修改分组", position = 1)
-    @PostMapping("save")
-    public Result save(@Valid @RequestBody CatalogDto param) {
-        return catalogService.saveEntity(param);
-    }
-
-    @ApiOperation(value = "详情", position = 1)
-    @GetMapping("detail/{id}")
-    public Result<CatalogEntity> detail(@PathVariable Long id) {
-        CatalogEntity entity = catalogService.findById(id);
-        if (entity == null) {
-            return Result.failure("对象不存在");
-        }
-        return Result.success(entity);
-    }
-
-
-    @ApiOperation(value = "删除", position = 1)
-    @GetMapping("remove/{id}")
-    public Result remove( @PathVariable Long id) {
-        return catalogService.remove(id);
-    }
-
-
-}

+ 0 - 217
720yun_fd_manage/gis_web/src/main/java/com/gis/web/controller/SceneController.java

@@ -1,217 +0,0 @@
-package com.gis.web.controller;
-
-
-import com.gis.common.constant.MsgCode;
-import com.gis.common.util.Result;
-import com.gis.domain.dto.*;
-import com.gis.domain.entity.SceneEntity;
-import com.gis.domain.entity.WorkEntity;
-import com.gis.service.FodderService;
-import com.gis.service.SceneService;
-import com.gis.service.WorkService;
-import com.gis.web.aop.WebControllerLog;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiImplicitParam;
-import io.swagger.annotations.ApiImplicitParams;
-import io.swagger.annotations.ApiOperation;
-import lombok.extern.log4j.Log4j2;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.*;
-import org.springframework.web.multipart.MultipartFile;
-
-import javax.validation.Valid;
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
-
-
-/**
- * Created by owen on 2020/2/18 0018 12:17
- *
- * 全景图在素材上传时已经切好
- * 这里只是把关系添加进来
- *
- * 一个场景可以被多个作品绑定
- */
-@Log4j2
-@Api(tags = "场景管理")
-//@RestController
-@RequestMapping("manage/scene")
-//@RequestMapping("aa/scene")
-public class SceneController extends BaseController {
-
-    @Autowired
-    private SceneService sceneService;
-
-    @Autowired
-    FodderService fodderService;
-
-    @Autowired
-    WorkService workService;
-
-
-    @ApiOperation(value = "保存关联场景热点", position = 1, notes = "sceneCodes:场景关联的场景码")
-    @PostMapping("save/useHots")
-    public Result saveUseHots(@Valid @RequestBody UseHotsDto param) {
-        return sceneService.saveUseHots(param);
-    }
-
-    @ApiOperation(value = "选择三维场景", position = 1)
-    @PostMapping("select/4dkk/{workId}")
-    public Result select4dkk(@RequestBody PageDto param, @PathVariable Long workId) {
-        return sceneService.select4dkk(param, workId);
-    }
-
-
-
-    @ApiOperation("场景详情")
-    @GetMapping("detail/{id}")
-    public Result detail(@PathVariable Long id) {
-        SceneEntity entity = sceneService.findById(id);
-        if (entity == null) {
-            log.error("对象不存在, 场景ID:{}", id);
-            return Result.failure("对象不存在");
-        }
-        return Result.success(entity);
-    }
-
-
-
-    @ApiOperation(value = "批量场景新增/修改", position = 1, notes = "注意创建目录层次问题, 有parentId表示有父级,有catalogId则更新,否则新建分组 ")
-    @PostMapping("saves")
-    public Result saves(@RequestBody CatalogSceneDto param) {
-        return sceneService.saves(param);
-    }
-
-
-    @ApiOperation(value = "重命名场景名称", position = 1)
-    @PostMapping("edit")
-    public Result edit(@Valid @RequestBody BaseDto param) {
-        return sceneService.editEntity(param);
-    }
-
-    @ApiOperation(value = "查询该作品是否存在场景")
-    @GetMapping("findByWork/{workId}")
-    public Result findByWorkId(@PathVariable Long workId) {
-        List<SceneEntity> list = sceneService.findByWorkId(workId);
-        return Result.success(list);
-    }
-
-
-    @ApiOperation(value = "上传-图标", position = 2)
-    @PostMapping(value = "upload")
-    public Result upload(@RequestParam("file") MultipartFile file) {
-        log.info("上传图片");
-        return sceneService.upload(file);
-    }
-
-
-
-    @WebControllerLog(description = "场景管理-场景排序")
-    @ApiOperation(value = "场景排序")
-    @PostMapping(value = "setSort")
-    public Result setSort(@RequestBody Map<String, String> param) {
-        log.info("场景排序");
-        return sceneService.setSort(param);
-    }
-
-
-    @WebControllerLog(description = "场景管理-编辑场景")
-    @ApiOperation(value = "编辑someData,(重命名)", position = 3)
-    @PostMapping("editSomeData")
-    public Result editSomeData(@Valid @RequestBody EditSomeDataDto param) {
-        return sceneService.editSomeData(param);
-    }
-
-    @ApiOperation(value = "初始场景-设置", position = 3)
-    @PostMapping("setIndex/{id}/{workId}")
-    public Result setIndex(@PathVariable String id, @PathVariable Long workId) {
-        return sceneService.setIndex(id, workId);
-    }
-
-    @ApiOperation(value = "初始场景-获取", position = 3)
-    @GetMapping("getIndex/{workId}")
-    public Result getIndex(@PathVariable Long workId) {
-        return sceneService.getIndex(workId);
-    }
-
-    @ApiOperation(value = "初始场景-删除", position = 3)
-    @GetMapping("removeIndex/{workId}")
-    public Result removeIndex(@PathVariable Long workId) {
-        WorkEntity entity = workService.findById(workId);
-        entity.setSceneIndex("");
-        entity.setUpdateTime(new Date());
-        workService.update(entity);
-        return Result.success();
-    }
-
-
-    @WebControllerLog(description = "场景管理-保存初始画面")
-    @ApiOperation("保存初始画面")
-    @PostMapping("saveIndex")
-    @ApiImplicitParams({
-            @ApiImplicitParam(name = "id", value = "场景id", dataType = "String", required = true),
-            @ApiImplicitParam(name = "icon", value = "iconURL", dataType = "String", required = true)
-    })
-    public Result saveIndex(@RequestParam Long id, @RequestParam String icon) {
-        log.info("保存初始画面");
-        SceneEntity entity = sceneService.findByIdForUpdate(id);
-        if (entity == null) {
-            log.error("对象不存在: {}", id);
-            return Result.failure("对象不存在");
-        }
-
-        entity.setIcon(icon);
-        entity.setUpdateTime(new Date());
-        sceneService.update(entity);
-        log.info("更新初始画面成功");
-
-        return Result.success();
-    }
-
-
-    @ApiOperation("保存初始角度")
-    @PostMapping("editXml")
-    public Result editXml(@Valid @RequestBody XmlDataDto param) {
-        return sceneService.editXml(param);
-    }
-
-
-
-    @WebControllerLog(description = "场景管理-场景删除")
-    @ApiOperation("场景删除")
-    @GetMapping("remove/{id}")
-    public Result remove(@PathVariable Long id) {
-        log.info("场景删除");
-
-        // 最后一个场景不能删除
-        SceneEntity entity = sceneService.findById(id);
-        List<SceneEntity> list = sceneService.findByWorkId(entity.getWorkId());
-        if (list.size() == 1) {
-            return Result.failure(MsgCode.e3002,"请至少保留一个场景");
-        }
-
-
-        Long workId = entity.getWorkId();
-        entity.setIsDelete(1);
-        entity.setUpdateTime(new Date());
-        sceneService.update(entity);
-
-        // 检查此场景id是否为初始场景,如是:设置为null;
-        WorkEntity workEntity = workService.findById(workId);
-
-        if (workEntity != null  || workEntity.getSceneIndex().equals(id) ) {
-            workEntity.setSceneIndex("");
-            workEntity.setUpdateTime(new Date());
-            workService.update(workEntity);
-        }
-
-
-        return Result.success();
-    }
-
-
-
-
-
-}

+ 2 - 20
720yun_fd_manage/gis_web/src/main/java/com/gis/web/controller/TestController.java

@@ -50,8 +50,8 @@ public class TestController extends BaseController {
     @Autowired
     FileUtils fileUtils;
 
-    @Autowired
-    SceneService sceneService;
+//    @Autowired
+//    SceneService sceneService;
 
     @Autowired
     SceneMapper sceneMapper;
@@ -147,23 +147,11 @@ public class TestController extends BaseController {
         return Result.success(new Date());
     }
 
-    @ApiOperation(value = "根据分组id查询场景")
-    @GetMapping(value = "scene/{catalogId}" )
-    public Result findByCatalogId(@PathVariable Long catalogId){
-        return Result.success(sceneService.findByCatalogId(catalogId));
-    }
-
 
 
 
 
 
-    @ApiOperation(value = "场景排序")
-    @PostMapping(value = "setSort" )
-    public Result setSort(@RequestBody Map<String, String> param){
-        return sceneService.setSort(param);
-    }
-
 
 
 
@@ -246,11 +234,5 @@ public class TestController extends BaseController {
 
     }
 
-    @ApiOperation(value = "上传-图标", position = 2)
-    @PostMapping(value = "upload")
-    public Result upload(@RequestParam("file") MultipartFile file) {
-        return sceneService.upload(file);
-    }
-
 
 }

+ 0 - 25
720yun_fd_manage/gis_web/src/main/java/com/gis/web/controller/WebController.java

@@ -117,30 +117,5 @@ public class WebController extends BaseController {
     }
 
 
-//    @ApiOperation(value = "上传素材", notes = "type:类型, 全景图:pano, 图片:image, 音频:audio, 视频:video")
-//    @PostMapping("upload2/{type}")
-//    public Result upload2(MultipartFile file, @PathVariable String type) {
-//
-//        if (file == null) {
-//            log.error("文件不能为空");
-//            return Result.failure("文件不能为空");
-//        }
-//        return fodderService.upload2(file, type);
-//    }
-//
-//    @ApiOperation(value = "普通上传")
-//    @PostMapping("upload3")
-//    public Result upload3(MultipartFile file) throws IOException {
-//
-//        if (file == null) {
-//            log.error("文件不能为空");
-//            return Result.failure("文件不能为空");
-//        }
-//        String savePath = configConstant.serverBasePath+ "test/" + file.getOriginalFilename();
-//        FileUtil.writeFromStream(file.getInputStream(), savePath);
-//
-//        return Result.success(savePath);
-//    }
-
 
 }

+ 6 - 0
720yun_fd_manage/gis_web/src/main/java/com/gis/web/controller/WorkController.java

@@ -60,6 +60,12 @@ public class WorkController extends BaseController {
     }
 
 
+    /**
+     * 2021-04-20
+     * 这个接口好像没用
+     * @param id
+     * @return
+     */
     @ApiOperation(value = "详情", position = 1)
     @GetMapping("detail/{id}")
     public Result<WorkInfoVo> detail(@PathVariable Long id) {