Showing
8 changed files
with
29 additions
and
20 deletions
... | ... | @@ -76,7 +76,7 @@ public class TkThirdPlatformController extends BaseController { |
76 | 76 | @ApiOperation("绑定") |
77 | 77 | public TkLoginResponse saveOrUpdateAlarmProfile(@Validated @RequestBody TkThirdUserDTO dto) { |
78 | 78 | UserDTO userDto = thirdService.bindUser(dto); |
79 | - return buildJwtToken(userDto, dto.getThirdUserId()); | |
79 | + return buildJwtToken(userDto, dto.getThirdUserId(),false); | |
80 | 80 | } |
81 | 81 | |
82 | 82 | @DeleteMapping |
... | ... | @@ -101,17 +101,17 @@ public class TkThirdPlatformController extends BaseController { |
101 | 101 | if (userDto == null) { |
102 | 102 | return new TkLoginResponse().setThirdUserId(thirdUserId); |
103 | 103 | } |
104 | - return buildJwtToken(userDto, thirdUserId); | |
104 | + return buildJwtToken(userDto, thirdUserId,false); | |
105 | 105 | } |
106 | 106 | |
107 | 107 | @GetMapping("login/id/{userId}") |
108 | 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 | 110 | UserDTO userDto = tkUserService.findUserInfoById(userId); |
111 | 111 | if (userDto == null) { |
112 | 112 | return new TkLoginResponse().setThirdUserId(userId); |
113 | 113 | } |
114 | - return buildJwtToken(userDto, userId); | |
114 | + return buildJwtToken(userDto, userId,isOpenApi); | |
115 | 115 | } |
116 | 116 | |
117 | 117 | private String authrizeKey = "zhiyun"; |
... | ... | @@ -128,11 +128,11 @@ public class TkThirdPlatformController extends BaseController { |
128 | 128 | if (userDto == null) { |
129 | 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 | 134 | @NotNull |
135 | - private TkLoginResponse buildJwtToken(UserDTO userDto, String thirdUserId) { | |
135 | + private TkLoginResponse buildJwtToken(UserDTO userDto, String thirdUserId,Boolean isOpenApi) { | |
136 | 136 | checkTenantExpireTime(userDto); |
137 | 137 | String accessToken = ""; |
138 | 138 | String refreshToken = ""; |
... | ... | @@ -170,7 +170,10 @@ public class TkThirdPlatformController extends BaseController { |
170 | 170 | TkLoginResponse result = new TkLoginResponse(); |
171 | 171 | result.setToken(accessToken); |
172 | 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 | 179 | private void checkTenantExpireTime(UserDTO user) | ... | ... |
... | ... | @@ -69,7 +69,7 @@ public class OpenApiController extends BaseController { |
69 | 69 | }else{ |
70 | 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 | 135 | return new ResponseEntity<>(HttpStatus.METHOD_NOT_ALLOWED); |
136 | 136 | } |
137 | 137 | |
138 | - @PostMapping("/getApi") | |
138 | + @GetMapping("/getApi") | |
139 | 139 | @ApiOperation(value = "获取可调用api") |
140 | - public ResponseEntity<List<OpenApiContrlooerDTO>> getApi(HttpServletRequest request) throws ThingsboardException { | |
140 | + public ResponseEntity<List<OpenApiContrlooerDTO>> getApi() throws ThingsboardException { | |
141 | 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 | 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 | 208 | non.existent.tenant = Rule chain is referencing to non-existent tenant! |
209 | 209 | root.rule.chain.is.present = Another root rule chain is present in scope of current tenant! |
210 | 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 | ... | ... |
... | ... | @@ -202,7 +202,7 @@ public enum ErrorMessage { |
202 | 202 | NON_EXISTENT_TENANT(400166,"规则链正在引用不存在的租户!","non.existent.tenant"), |
203 | 203 | ROOT_RULE_CHAIN_IS_PRESENT (400167,"当前租户范围内存在另一个根规则链!","root.rule.chain.is.present"), |
204 | 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 | 208 | HAVE_NO_PERMISSION(500002, "没有修改权限", "have.no.permission"), | ... | ... |
... | ... | @@ -6,17 +6,17 @@ import lombok.Data; |
6 | 6 | import org.thingsboard.server.common.data.yunteng.enums.ApplicationApiEnum; |
7 | 7 | |
8 | 8 | @Data |
9 | -public class OpenApiContrlooerDTO extends BaseDTO { | |
9 | +public class OpenApiContrlooerDTO { | |
10 | + | |
11 | + @ApiModelProperty(value = "ID") | |
12 | + private String id; | |
10 | 13 | |
11 | 14 | @ApiModelProperty(value = "名称") |
12 | 15 | private String name; |
16 | + | |
13 | 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 | 21 | @ApiModelProperty(value = "调用参数") |
22 | 22 | /**调用参数*/ | ... | ... |