Commit 620b83433e0db41a89943827bc5ee372168e1b8b

Authored by 黄 x
1 parent 1af622ed

feat: add things model PreAuthorize

... ... @@ -6,6 +6,7 @@ import io.swagger.annotations.ApiOperation;
6 6 import lombok.RequiredArgsConstructor;
7 7 import org.apache.commons.lang3.StringUtils;
8 8 import org.springframework.http.ResponseEntity;
  9 +import org.springframework.security.access.prepost.PreAuthorize;
9 10 import org.springframework.validation.annotation.Validated;
10 11 import org.springframework.web.bind.annotation.*;
11 12 import org.thingsboard.server.common.data.exception.ThingsboardException;
... ... @@ -72,7 +73,7 @@ public class ThingsModelController extends BaseController {
72 73
73 74 @PostMapping()
74 75 @ApiOperation("保存物模型")
75   - // @PreAuthorize("@check.checkPermissions({'TENANT_ADMIN'},{'api:yt:things_model:post'})")
  76 + @PreAuthorize("@check.checkPermissions({'TENANT_ADMIN'},{'api:yt:things_model:post'})")
76 77 public ResponseEntity<ThingsModelDTO> save(
77 78 @Validated(AddGroup.class) @RequestBody ThingsModelDTO thingsModelDTO)
78 79 throws ThingsboardException {
... ... @@ -81,7 +82,7 @@ public class ThingsModelController extends BaseController {
81 82
82 83 @PutMapping()
83 84 @ApiOperation("修改物模型")
84   - // @PreAuthorize("@check.checkPermissions({'TENANT_ADMIN'},{'api:yt:things_model:put'})")
  85 + @PreAuthorize("@check.checkPermissions({'TENANT_ADMIN'},{'api:yt:things_model:put'})")
85 86 public ResponseEntity<ThingsModelDTO> update(
86 87 @Validated(UpdateGroup.class) @RequestBody ThingsModelDTO thingsModelDTO)
87 88 throws ThingsboardException {
... ... @@ -90,7 +91,7 @@ public class ThingsModelController extends BaseController {
90 91
91 92 @DeleteMapping
92 93 @ApiOperation("删除")
93   - // @PreAuthorize("@check.checkPermissions({'TENANT_ADMIN'},{'api:yt:things_model:delete'})")
  94 + @PreAuthorize("@check.checkPermissions({'TENANT_ADMIN'},{'api:yt:things_model:delete'})")
94 95 public boolean delete(@Validated(DeleteGroup.class) @RequestBody DeleteDTO deleteDTO)
95 96 throws ThingsboardException {
96 97 deleteDTO.setTenantId(getCurrentUser().getCurrentTenantId());
... ... @@ -99,7 +100,6 @@ public class ThingsModelController extends BaseController {
99 100
100 101 @GetMapping("/{functionType}/{deviceProfileId}")
101 102 @ApiOperation("获取物模型TSL")
102   - // @PreAuthorize("@check.checkPermissions({'TENANT_ADMIN'},{'api:yt:things_model:json:view'})")
103 103 public ResponseEntity<JsonNode> getTSL(
104 104 @PathVariable("functionType") FunctionTypeEnum functionType,
105 105 @PathVariable("deviceProfileId") String deviceProfileId)
... ... @@ -110,7 +110,7 @@ public class ThingsModelController extends BaseController {
110 110 }
111 111
112 112 @PutMapping("/{deviceProfileId}")
113   - // @PreAuthorize("@check.checkPermissions({'TENANT_ADMIN'},{'api:yt:things_model:release'})")
  113 + @PreAuthorize("@check.checkPermissions({'TENANT_ADMIN'},{'api:yt:things_model:release'})")
114 114 @ApiOperation("物模型发布")
115 115 public ResponseEntity<Boolean> releaseTSL(@PathVariable("deviceProfileId") String deviceProfileId)
116 116 throws ThingsboardException {
... ...