ソースを参照

1.add 只用管理员才能发布图层
2.add 发布时,要指定图层的访问角色
3.在outputfile表上添加了layerRole

wuweihao 5 年 前
コミット
5dde969d76

+ 18 - 0
src/main/java/com/fd/controller/ExceptionController.java

@@ -2,6 +2,8 @@ package com.fd.controller;
 
 import com.fd.util.R;
 import org.apache.shiro.ShiroException;
+import org.apache.shiro.authc.IncorrectCredentialsException;
+import org.apache.shiro.authc.UnknownAccountException;
 import org.apache.shiro.authz.UnauthorizedException;
 import org.springframework.http.HttpStatus;
 import org.springframework.web.bind.annotation.ExceptionHandler;
@@ -38,6 +40,22 @@ public class ExceptionController {
     }
 
 
+//    @ExceptionHandler(ShiroException.class)
+//    public R doHandleShiroException(ShiroException e) {
+//        R r = null;
+//        if (e instanceof UnknownAccountException) {
+//            r = new R(40001, "此账户不存在");
+//        } else if (e instanceof IncorrectCredentialsException) {
+//            r = new R(40001, "密码不正确");
+//        } else  {
+//            r = new R(40001, e.getMessage());
+//
+//    }
+//
+//        return r;
+//    }
+
+
 
 
 

+ 2 - 2
src/main/java/com/fd/controller/ModelController.java

@@ -150,7 +150,7 @@ public class ModelController {
 //    @RequiresAuthentication
     public R list(@RequestBody PageDto param) {
         log.warn("run list");
-        System.out.println("11111111111");
+//        System.out.println("11111111111");
         return modelServer.findByType(TypeCode.FILE_TYPE_MODEL, param);
     }
 
@@ -218,7 +218,7 @@ public class ModelController {
 
     }
 
-
+    @RequiresRoles("admin")
     @ApiOperation("移动数据到服务器上")
     @PostMapping("move/{fileId}/")
     public R moveFile(@PathVariable("fileId") Long fileId, @RequestBody ConfigJsonDto param) {

+ 8 - 1
src/main/java/com/fd/dto/ConfigJsonDto.java

@@ -13,9 +13,16 @@ public class ConfigJsonDto {
 
 //    private String name;
 
+    /**
+     * 图层名称
+     */
     private String text;
 
-//    private String type;
+
+    /**
+     * 图层角色
+     */
+    private String role;
 
 //    private boolean checked;
 

+ 10 - 0
src/main/java/com/fd/entity/OutputFileEntity.java

@@ -114,4 +114,14 @@ public class OutputFileEntity extends BaseEntity implements Serializable {
     @Column
     private String userGroup;
 
+    /**
+     * 图层角色
+     * 指定角色才能看图层
+     *
+     * admin
+     * user
+     */
+    @Column
+    private String layerRole;
+
 }

+ 3 - 0
src/main/java/com/fd/server/impl/ModelServerImpl.java

@@ -239,6 +239,9 @@ public class ModelServerImpl extends BaseServerImpl implements ModelServer  {
             // 成功,状态
             entity.setStatus(8);
             entity.setUpdateTime(new Date());
+
+            // 添加图层角色
+            entity.setLayerRole(param.getRole());
             outputFileRepository.save(entity);
 
             return new R(200, MsgCode.SUCCESS);

+ 3 - 0
src/main/java/com/fd/server/impl/RasterServerImpl.java

@@ -192,6 +192,9 @@ public class RasterServerImpl implements RasterServer {
             // 成功,更新状态
             entity.setStatus(8);
             entity.setUpdateTime(new Date());
+
+            // 添加图层角色
+            entity.setLayerRole(param.getRole());
             outputFileRepository.save(entity);
             return new R(200, MsgCode.SUCCESS);
         } catch (Exception e) {

+ 4 - 0
src/main/java/com/fd/server/impl/VectorServerImpl.java

@@ -108,6 +108,10 @@ public class VectorServerImpl implements VectorServer {
             entity.setStatus(8);
             entity.setServicePath(entity.getSlicePath());
             entity.setUpdateTime(new Date());
+
+            // 添加图层角色
+            entity.setLayerRole(param.getRole());
+
             outputFileRepository.save(entity);
             return new R(200, MsgCode.SUCCESS);
         } catch (Exception e) {