Commit 620b83433e0db41a89943827bc5ee372168e1b8b

Authored by 黄 x
1 parent 1af622ed

feat: add things model PreAuthorize

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