Commit 52307bc3173e6c74645aa6aa759453311f56fce2

Authored by chenjunyu_1481036421
1 parent 853aebeb

fix:openApibug修改

@@ -76,7 +76,7 @@ public class TkThirdPlatformController extends BaseController { @@ -76,7 +76,7 @@ public class TkThirdPlatformController extends BaseController {
76 @ApiOperation("绑定") 76 @ApiOperation("绑定")
77 public TkLoginResponse saveOrUpdateAlarmProfile(@Validated @RequestBody TkThirdUserDTO dto) { 77 public TkLoginResponse saveOrUpdateAlarmProfile(@Validated @RequestBody TkThirdUserDTO dto) {
78 UserDTO userDto = thirdService.bindUser(dto); 78 UserDTO userDto = thirdService.bindUser(dto);
79 - return buildJwtToken(userDto, dto.getThirdUserId()); 79 + return buildJwtToken(userDto, dto.getThirdUserId(),false);
80 } 80 }
81 81
82 @DeleteMapping 82 @DeleteMapping
@@ -101,17 +101,17 @@ public class TkThirdPlatformController extends BaseController { @@ -101,17 +101,17 @@ public class TkThirdPlatformController extends BaseController {
101 if (userDto == null) { 101 if (userDto == null) {
102 return new TkLoginResponse().setThirdUserId(thirdUserId); 102 return new TkLoginResponse().setThirdUserId(thirdUserId);
103 } 103 }
104 - return buildJwtToken(userDto, thirdUserId); 104 + return buildJwtToken(userDto, thirdUserId,false);
105 } 105 }
106 106
107 @GetMapping("login/id/{userId}") 107 @GetMapping("login/id/{userId}")
108 @ApiOperation("组态用户认证") 108 @ApiOperation("组态用户认证")
109 - public TkLoginResponse unionidLogin(@PathVariable("userId") String userId) { 109 + public TkLoginResponse unionidLogin(@PathVariable("userId") String userId,@RequestParam(value = ORDER_TYPE, required = false)Boolean isOpenApi) {
110 UserDTO userDto = tkUserService.findUserInfoById(userId); 110 UserDTO userDto = tkUserService.findUserInfoById(userId);
111 if (userDto == null) { 111 if (userDto == null) {
112 return new TkLoginResponse().setThirdUserId(userId); 112 return new TkLoginResponse().setThirdUserId(userId);
113 } 113 }
114 - return buildJwtToken(userDto, userId); 114 + return buildJwtToken(userDto, userId,isOpenApi);
115 } 115 }
116 116
117 private String authrizeKey = "zhiyun"; 117 private String authrizeKey = "zhiyun";
@@ -128,11 +128,11 @@ public class TkThirdPlatformController extends BaseController { @@ -128,11 +128,11 @@ public class TkThirdPlatformController extends BaseController {
128 if (userDto == null) { 128 if (userDto == null) {
129 return new TkLoginResponse().setThirdUserId(dto.getAuthrizeKey()); 129 return new TkLoginResponse().setThirdUserId(dto.getAuthrizeKey());
130 } 130 }
131 - return buildJwtToken(userDto, dto.getAuthrizeKey()); 131 + return buildJwtToken(userDto, dto.getAuthrizeKey(),false);
132 } 132 }
133 133
134 @NotNull 134 @NotNull
135 - private TkLoginResponse buildJwtToken(UserDTO userDto, String thirdUserId) { 135 + private TkLoginResponse buildJwtToken(UserDTO userDto, String thirdUserId,Boolean isOpenApi) {
136 checkTenantExpireTime(userDto); 136 checkTenantExpireTime(userDto);
137 String accessToken = ""; 137 String accessToken = "";
138 String refreshToken = ""; 138 String refreshToken = "";
@@ -170,7 +170,10 @@ public class TkThirdPlatformController extends BaseController { @@ -170,7 +170,10 @@ public class TkThirdPlatformController extends BaseController {
170 TkLoginResponse result = new TkLoginResponse(); 170 TkLoginResponse result = new TkLoginResponse();
171 result.setToken(accessToken); 171 result.setToken(accessToken);
172 result.setRefreshToken(refreshToken); 172 result.setRefreshToken(refreshToken);
173 - return result.setThirdUserId(thirdUserId); 173 + if(!isOpenApi){
  174 + result.setThirdUserId(thirdUserId);
  175 + }
  176 + return result;
174 } 177 }
175 178
176 private void checkTenantExpireTime(UserDTO user) 179 private void checkTenantExpireTime(UserDTO user)
@@ -69,7 +69,7 @@ public class OpenApiController extends BaseController { @@ -69,7 +69,7 @@ public class OpenApiController extends BaseController {
69 }else{ 69 }else{
70 userId =app.getUserId(); 70 userId =app.getUserId();
71 } 71 }
72 - return tkThirdPlatformController.unionidLogin(userId); 72 + return tkThirdPlatformController.unionidLogin(userId,true);
73 } 73 }
74 74
75 75
@@ -135,10 +135,14 @@ public class OpenApiController extends BaseController { @@ -135,10 +135,14 @@ public class OpenApiController extends BaseController {
135 return new ResponseEntity<>(HttpStatus.METHOD_NOT_ALLOWED); 135 return new ResponseEntity<>(HttpStatus.METHOD_NOT_ALLOWED);
136 } 136 }
137 137
138 - @PostMapping("/getApi") 138 + @GetMapping("/getApi")
139 @ApiOperation(value = "获取可调用api") 139 @ApiOperation(value = "获取可调用api")
140 - public ResponseEntity<List<OpenApiContrlooerDTO>> getApi(HttpServletRequest request) throws ThingsboardException { 140 + public ResponseEntity<List<OpenApiContrlooerDTO>> getApi() throws ThingsboardException {
141 ApplicationDTO appDto = applicationService.getDtoByUserId(getCurrentUser().getCurrentUserId()); 141 ApplicationDTO appDto = applicationService.getDtoByUserId(getCurrentUser().getCurrentUserId());
  142 + if(null==appDto.getApiList()||appDto.getApiList().isEmpty()){
  143 + throw new DataValidationException(String.format(MessageUtils.message(ErrorMessage.
  144 + APP_OPENAPI_API_ISNULL.getI18nCode())));
  145 + }
142 return ResponseEntity.ok(openApiService.getByListId(appDto.getApiList())); 146 return ResponseEntity.ok(openApiService.getByListId(appDto.getApiList()));
143 } 147 }
144 148
@@ -208,7 +208,7 @@ rule.chain.to.tenant = Rule chain should be assigned to tenant @@ -208,7 +208,7 @@ rule.chain.to.tenant = Rule chain should be assigned to tenant
208 non.existent.tenant = Rule chain is referencing to non-existent tenant! 208 non.existent.tenant = Rule chain is referencing to non-existent tenant!
209 root.rule.chain.is.present = Another root rule chain is present in scope of current tenant! 209 root.rule.chain.is.present = Another root rule chain is present in scope of current tenant!
210 edge.root.rule.chain.is.present = Another edge template root rule chain is present in scope of current tenant! 210 edge.root.rule.chain.is.present = Another edge template root rule chain is present in scope of current tenant!
211 - 211 +app.openapi.api.isnull = The current application does not have a callable API. Please contact the administrator
212 212
213 213
214 214
@@ -208,4 +208,6 @@ rule.chain.to.tenant =规则链应分配给租户 @@ -208,4 +208,6 @@ rule.chain.to.tenant =规则链应分配给租户
208 non.existent.tenant =规则链正在引用不存在的租户 208 non.existent.tenant =规则链正在引用不存在的租户
209 root.rule.chain.is.present =当前租户范围内存在另一个根规则链 209 root.rule.chain.is.present =当前租户范围内存在另一个根规则链
210 edge.root.rule.chain.is.present =当前租户范围内存在另一个边缘模板根规则链 210 edge.root.rule.chain.is.present =当前租户范围内存在另一个边缘模板根规则链
  211 +app.openapi.api.isnull = 当前应用不存在可调用api请联系管理员
  212 +
211 213
@@ -202,7 +202,7 @@ public enum ErrorMessage { @@ -202,7 +202,7 @@ public enum ErrorMessage {
202 NON_EXISTENT_TENANT(400166,"规则链正在引用不存在的租户!","non.existent.tenant"), 202 NON_EXISTENT_TENANT(400166,"规则链正在引用不存在的租户!","non.existent.tenant"),
203 ROOT_RULE_CHAIN_IS_PRESENT (400167,"当前租户范围内存在另一个根规则链!","root.rule.chain.is.present"), 203 ROOT_RULE_CHAIN_IS_PRESENT (400167,"当前租户范围内存在另一个根规则链!","root.rule.chain.is.present"),
204 EDGE_ROOT_RULE_CHAIN_IS_PRESENT(400168,"当前租户范围内存在另一个边缘模板根规则链!","edge.root.rule.chain.is.present"), 204 EDGE_ROOT_RULE_CHAIN_IS_PRESENT(400168,"当前租户范围内存在另一个边缘模板根规则链!","edge.root.rule.chain.is.present"),
205 - 205 + APP_OPENAPI_API_ISNULL(400169,"当前应用不存在可调用api请联系管理员","app.openapi.api.isnull"),
206 206
207 207
208 HAVE_NO_PERMISSION(500002, "没有修改权限", "have.no.permission"), 208 HAVE_NO_PERMISSION(500002, "没有修改权限", "have.no.permission"),
@@ -6,17 +6,17 @@ import lombok.Data; @@ -6,17 +6,17 @@ import lombok.Data;
6 import org.thingsboard.server.common.data.yunteng.enums.ApplicationApiEnum; 6 import org.thingsboard.server.common.data.yunteng.enums.ApplicationApiEnum;
7 7
8 @Data 8 @Data
9 -public class OpenApiContrlooerDTO extends BaseDTO { 9 +public class OpenApiContrlooerDTO {
  10 +
  11 + @ApiModelProperty(value = "ID")
  12 + private String id;
10 13
11 @ApiModelProperty(value = "名称") 14 @ApiModelProperty(value = "名称")
12 private String name; 15 private String name;
  16 +
13 @ApiModelProperty(value = "请求方式") 17 @ApiModelProperty(value = "请求方式")
14 /** 请求方式 */ 18 /** 请求方式 */
15 - private Integer requestMethod;  
16 -  
17 - @ApiModelProperty(value = "文档地址")  
18 - /**文档地址*/  
19 - private String documentUrl; 19 + private String requestMethod;
20 20
21 @ApiModelProperty(value = "调用参数") 21 @ApiModelProperty(value = "调用参数")
22 /**调用参数*/ 22 /**调用参数*/
@@ -17,7 +17,7 @@ public class OpenApiDTO extends BaseDTO { @@ -17,7 +17,7 @@ public class OpenApiDTO extends BaseDTO {
17 17
18 @ApiModelProperty(value = "请求方式") 18 @ApiModelProperty(value = "请求方式")
19 /** 请求方式 */ 19 /** 请求方式 */
20 - private Integer requestMethod; 20 + private String requestMethod;
21 21
22 @ApiModelProperty(value = "请求路由") 22 @ApiModelProperty(value = "请求路由")
23 /**请求路由*/ 23 /**请求路由*/
@@ -21,7 +21,7 @@ public class TkOpenApiEntity extends TenantBaseEntity { @@ -21,7 +21,7 @@ public class TkOpenApiEntity extends TenantBaseEntity {
21 private ApplicationApiEnum classify; 21 private ApplicationApiEnum classify;
22 22
23 /** 请求方式 */ 23 /** 请求方式 */
24 - private Integer requestMethod; 24 + private String requestMethod;
25 25
26 /**请求路由*/ 26 /**请求路由*/
27 private String uri; 27 private String uri;