Showing
6 changed files
with
27 additions
and
7 deletions
@@ -12,10 +12,13 @@ import org.springframework.web.bind.annotation.*; | @@ -12,10 +12,13 @@ import org.springframework.web.bind.annotation.*; | ||
12 | import org.springframework.web.client.RestTemplate; | 12 | import org.springframework.web.client.RestTemplate; |
13 | import org.thingsboard.server.common.data.StringUtils; | 13 | import org.thingsboard.server.common.data.StringUtils; |
14 | import org.thingsboard.server.common.data.exception.ThingsboardException; | 14 | import org.thingsboard.server.common.data.exception.ThingsboardException; |
15 | +import org.thingsboard.server.common.data.yunteng.core.exception.TkDataValidationException; | ||
16 | +import org.thingsboard.server.common.data.yunteng.core.message.ErrorMessage; | ||
15 | import org.thingsboard.server.common.data.yunteng.dto.ApplicationDTO; | 17 | import org.thingsboard.server.common.data.yunteng.dto.ApplicationDTO; |
16 | import org.thingsboard.server.common.data.yunteng.dto.OpenApiContrlooerDTO; | 18 | import org.thingsboard.server.common.data.yunteng.dto.OpenApiContrlooerDTO; |
17 | import org.thingsboard.server.common.data.yunteng.dto.OpenApiDTO; | 19 | import org.thingsboard.server.common.data.yunteng.dto.OpenApiDTO; |
18 | import org.thingsboard.server.common.data.yunteng.dto.UserDTO; | 20 | import org.thingsboard.server.common.data.yunteng.dto.UserDTO; |
21 | +import org.thingsboard.server.common.data.yunteng.utils.i18n.MessageUtils; | ||
19 | import org.thingsboard.server.controller.BaseController; | 22 | import org.thingsboard.server.controller.BaseController; |
20 | import org.thingsboard.server.controller.yunteng.TkThirdPlatformController; | 23 | import org.thingsboard.server.controller.yunteng.TkThirdPlatformController; |
21 | import org.thingsboard.server.controller.yunteng.TkUserController; | 24 | import org.thingsboard.server.controller.yunteng.TkUserController; |
@@ -82,7 +85,8 @@ public class OpenApiController extends BaseController { | @@ -82,7 +85,8 @@ public class OpenApiController extends BaseController { | ||
82 | //记录日志 | 85 | //记录日志 |
83 | setRecord(api,appDto,record); | 86 | setRecord(api,appDto,record); |
84 | if (!appDto.getApiList().contains(api.getId())) { | 87 | if (!appDto.getApiList().contains(api.getId())) { |
85 | - throw new RuntimeException("没有权限"); | 88 | + throw new TkDataValidationException(String.format(MessageUtils.message(ErrorMessage. |
89 | + NOT_HAVE_PERMISSION.getI18nCode()))); | ||
86 | } | 90 | } |
87 | // 构建URL | 91 | // 构建URL |
88 | String url = MiscUtils.constructBaseUrl(request) + api.getUri(); | 92 | String url = MiscUtils.constructBaseUrl(request) + api.getUri(); |
@@ -191,6 +191,8 @@ rule.chain.used.by.device.profile = This rule chain is being used by the [% s] p | @@ -191,6 +191,8 @@ rule.chain.used.by.device.profile = This rule chain is being used by the [% s] p | ||
191 | same.type.node.name.already.exists = Node names of the same type have already been used. | 191 | same.type.node.name.already.exists = Node names of the same type have already been used. |
192 | choice.device.profile.rule.chain.is.used.for.convert = The selected product [% s] is currently being used by the data flow [% s] and cannot change the rule chain!! | 192 | choice.device.profile.rule.chain.is.used.for.convert = The selected product [% s] is currently being used by the data flow [% s] and cannot change the rule chain!! |
193 | choice.device.profile.rule.chain.is.used.for.scene = The selected product [% s] is currently being used by the scene linkage [% s] and cannot change the rule chain!! | 193 | choice.device.profile.rule.chain.is.used.for.scene = The selected product [% s] is currently being used by the scene linkage [% s] and cannot change the rule chain!! |
194 | +openapi.app.isnull= The application does not exist | ||
195 | +openapi.api.isnull= API does not exist | ||
194 | 196 | ||
195 | 197 | ||
196 | 198 |
@@ -190,4 +190,6 @@ scene.react.is.edge = 场景联动来自于边端请勿操作 | @@ -190,4 +190,6 @@ scene.react.is.edge = 场景联动来自于边端请勿操作 | ||
190 | rule.chain.used.by.device.profile = 该规则链正在被【%s】产品使用,不能被删除!! | 190 | rule.chain.used.by.device.profile = 该规则链正在被【%s】产品使用,不能被删除!! |
191 | same.type.node.name.already.exists = 同类型的节点名称已被使用 | 191 | same.type.node.name.already.exists = 同类型的节点名称已被使用 |
192 | choice.device.profile.rule.chain.is.used.for.convert = 选中的产品【%s】正在被数据流转【%s】使用,不能更换规则链!! | 192 | choice.device.profile.rule.chain.is.used.for.convert = 选中的产品【%s】正在被数据流转【%s】使用,不能更换规则链!! |
193 | -choice.device.profile.rule.chain.is.used.for.scene = 选中的产品【%s】正在被场景联动【%s】使用,不能更换规则链!! | ||
193 | +choice.device.profile.rule.chain.is.used.for.scene = 选中的产品【%s】正在被场景联动【%s】使用,不能更换规则链!! | ||
194 | +openapi.app.isnull= 应用不存在 | ||
195 | +openapi.api.isnull= api不存在 |
@@ -194,6 +194,8 @@ public enum ErrorMessage { | @@ -194,6 +194,8 @@ public enum ErrorMessage { | ||
194 | SAME_TYPE_NODE_NAME_ALREADY_EXISTS(400159,"同类型的节点名称已被使用","same.type.node.name.already.exists"), | 194 | SAME_TYPE_NODE_NAME_ALREADY_EXISTS(400159,"同类型的节点名称已被使用","same.type.node.name.already.exists"), |
195 | CHOICE_DEVICE_PROFILE_RULE_CHAIN_IS_USED_FOR_CONVERT(400160,"选中的产品【%s】正在被数据流转【%s】使用,不能更换规则链!!","choice.device.profile.rule.chain.is.used.for.convert"), | 195 | CHOICE_DEVICE_PROFILE_RULE_CHAIN_IS_USED_FOR_CONVERT(400160,"选中的产品【%s】正在被数据流转【%s】使用,不能更换规则链!!","choice.device.profile.rule.chain.is.used.for.convert"), |
196 | CHOICE_DEVICE_PROFILE_RULE_CHAIN_IS_USED_FOR_SCENE(400161,"选中的产品【%s】正在被场景联动【%s】使用,不能更换规则链!!","choice.device.profile.rule.chain.is.used.for.scene"), | 196 | CHOICE_DEVICE_PROFILE_RULE_CHAIN_IS_USED_FOR_SCENE(400161,"选中的产品【%s】正在被场景联动【%s】使用,不能更换规则链!!","choice.device.profile.rule.chain.is.used.for.scene"), |
197 | + OPENAPI_APP_ISNULL(400162,"应用不存在","openapi.app.isnull"), | ||
198 | + OPENAPI_API_ISNULL(400163,"api不存在","openapi.api.isnull"), | ||
197 | 199 | ||
198 | HAVE_NO_PERMISSION(500002, "没有修改权限", "have.no.permission"), | 200 | HAVE_NO_PERMISSION(500002, "没有修改权限", "have.no.permission"), |
199 | NOT_ALLOWED_ISOLATED_IN_MONOLITH(500003, "【monolith】模式下,不能选择【isolated】类型的租户配置", "not.allowed.isolated.in.monolith"), | 201 | NOT_ALLOWED_ISOLATED_IN_MONOLITH(500003, "【monolith】模式下,不能选择【isolated】类型的租户配置", "not.allowed.isolated.in.monolith"), |
@@ -7,7 +7,10 @@ import lombok.RequiredArgsConstructor; | @@ -7,7 +7,10 @@ import lombok.RequiredArgsConstructor; | ||
7 | import lombok.extern.slf4j.Slf4j; | 7 | import lombok.extern.slf4j.Slf4j; |
8 | import org.springframework.stereotype.Service; | 8 | import org.springframework.stereotype.Service; |
9 | import org.springframework.transaction.annotation.Transactional; | 9 | import org.springframework.transaction.annotation.Transactional; |
10 | +import org.thingsboard.server.common.data.yunteng.core.exception.TkDataValidationException; | ||
11 | +import org.thingsboard.server.common.data.yunteng.core.message.ErrorMessage; | ||
10 | import org.thingsboard.server.common.data.yunteng.dto.ApplicationDTO; | 12 | import org.thingsboard.server.common.data.yunteng.dto.ApplicationDTO; |
13 | +import org.thingsboard.server.common.data.yunteng.utils.i18n.MessageUtils; | ||
11 | import org.thingsboard.server.common.data.yunteng.utils.tools.TkPageData; | 14 | import org.thingsboard.server.common.data.yunteng.utils.tools.TkPageData; |
12 | import org.thingsboard.server.dao.yunteng.entities.TkApplicationApiEntity; | 15 | import org.thingsboard.server.dao.yunteng.entities.TkApplicationApiEntity; |
13 | import org.thingsboard.server.dao.yunteng.entities.TkApplicationEntity; | 16 | import org.thingsboard.server.dao.yunteng.entities.TkApplicationEntity; |
@@ -118,7 +121,8 @@ public class ApplicationServiceImpl extends AbstractBaseService<ApplicationMappe | @@ -118,7 +121,8 @@ public class ApplicationServiceImpl extends AbstractBaseService<ApplicationMappe | ||
118 | .eq(TkApplicationEntity::getKey, key) | 121 | .eq(TkApplicationEntity::getKey, key) |
119 | .eq(TkApplicationEntity::getSecret,secret)); | 122 | .eq(TkApplicationEntity::getSecret,secret)); |
120 | if(null == entity){ | 123 | if(null == entity){ |
121 | - throw new RuntimeException("应用不存在"); | 124 | + throw new TkDataValidationException(String.format(MessageUtils.message(ErrorMessage. |
125 | + OPENAPI_APP_ISNULL.getI18nCode()))); | ||
122 | } | 126 | } |
123 | ApplicationDTO dto = new ApplicationDTO(); | 127 | ApplicationDTO dto = new ApplicationDTO(); |
124 | entity.copyToDTO(dto); | 128 | entity.copyToDTO(dto); |
@@ -131,7 +135,8 @@ public class ApplicationServiceImpl extends AbstractBaseService<ApplicationMappe | @@ -131,7 +135,8 @@ public class ApplicationServiceImpl extends AbstractBaseService<ApplicationMappe | ||
131 | new LambdaQueryWrapper<TkApplicationEntity>() | 135 | new LambdaQueryWrapper<TkApplicationEntity>() |
132 | .eq(TkApplicationEntity::getUserId, userId)); | 136 | .eq(TkApplicationEntity::getUserId, userId)); |
133 | if(null == entity){ | 137 | if(null == entity){ |
134 | - throw new RuntimeException("应用不存在"); | 138 | + throw new TkDataValidationException(String.format(MessageUtils.message(ErrorMessage. |
139 | + OPENAPI_APP_ISNULL.getI18nCode()))); | ||
135 | } | 140 | } |
136 | ApplicationDTO dto = new ApplicationDTO(); | 141 | ApplicationDTO dto = new ApplicationDTO(); |
137 | entity.copyToDTO(dto); | 142 | entity.copyToDTO(dto); |
@@ -8,11 +8,13 @@ import lombok.extern.slf4j.Slf4j; | @@ -8,11 +8,13 @@ import lombok.extern.slf4j.Slf4j; | ||
8 | import org.springframework.stereotype.Service; | 8 | import org.springframework.stereotype.Service; |
9 | import org.springframework.transaction.annotation.Transactional; | 9 | import org.springframework.transaction.annotation.Transactional; |
10 | import org.thingsboard.server.common.data.yunteng.core.exception.TkDataValidationException; | 10 | import org.thingsboard.server.common.data.yunteng.core.exception.TkDataValidationException; |
11 | +import org.thingsboard.server.common.data.yunteng.core.message.ErrorMessage; | ||
11 | import org.thingsboard.server.common.data.yunteng.dto.DeviceDTO; | 12 | import org.thingsboard.server.common.data.yunteng.dto.DeviceDTO; |
12 | import org.thingsboard.server.common.data.yunteng.dto.OpenApiContrlooerDTO; | 13 | import org.thingsboard.server.common.data.yunteng.dto.OpenApiContrlooerDTO; |
13 | import org.thingsboard.server.common.data.yunteng.dto.OpenApiDTO; | 14 | import org.thingsboard.server.common.data.yunteng.dto.OpenApiDTO; |
14 | import org.thingsboard.server.common.data.yunteng.dto.ApiMenuDTO; | 15 | import org.thingsboard.server.common.data.yunteng.dto.ApiMenuDTO; |
15 | import org.thingsboard.server.common.data.yunteng.utils.CopyUtils; | 16 | import org.thingsboard.server.common.data.yunteng.utils.CopyUtils; |
17 | +import org.thingsboard.server.common.data.yunteng.utils.i18n.MessageUtils; | ||
16 | import org.thingsboard.server.common.data.yunteng.utils.tools.TkPageData; | 18 | import org.thingsboard.server.common.data.yunteng.utils.tools.TkPageData; |
17 | import org.thingsboard.server.dao.yunteng.entities.TkOpenApiEntity; | 19 | import org.thingsboard.server.dao.yunteng.entities.TkOpenApiEntity; |
18 | import org.thingsboard.server.dao.yunteng.mapper.OpenApiMapper; | 20 | import org.thingsboard.server.dao.yunteng.mapper.OpenApiMapper; |
@@ -33,7 +35,8 @@ public class OpenApiImpl extends AbstractBaseService<OpenApiMapper, TkOpenApiEnt | @@ -33,7 +35,8 @@ public class OpenApiImpl extends AbstractBaseService<OpenApiMapper, TkOpenApiEnt | ||
33 | public OpenApiDTO getDto(String id) { | 35 | public OpenApiDTO getDto(String id) { |
34 | TkOpenApiEntity entity = baseMapper.selectById(id); | 36 | TkOpenApiEntity entity = baseMapper.selectById(id); |
35 | if(null == entity){ | 37 | if(null == entity){ |
36 | - throw new RuntimeException("Api不存在"); | 38 | + throw new TkDataValidationException(String.format(MessageUtils.message(ErrorMessage. |
39 | + OPENAPI_API_ISNULL.getI18nCode()))); | ||
37 | } | 40 | } |
38 | OpenApiDTO dto = new OpenApiDTO(); | 41 | OpenApiDTO dto = new OpenApiDTO(); |
39 | entity.copyToDTO(dto); | 42 | entity.copyToDTO(dto); |
@@ -79,7 +82,8 @@ public class OpenApiImpl extends AbstractBaseService<OpenApiMapper, TkOpenApiEnt | @@ -79,7 +82,8 @@ public class OpenApiImpl extends AbstractBaseService<OpenApiMapper, TkOpenApiEnt | ||
79 | .in(TkOpenApiEntity::getId,apiIds)); | 82 | .in(TkOpenApiEntity::getId,apiIds)); |
80 | list.stream().forEach(entity ->{ | 83 | list.stream().forEach(entity ->{ |
81 | if(!entity.getTenantId().equals(tenantId)){ | 84 | if(!entity.getTenantId().equals(tenantId)){ |
82 | - throw new TkDataValidationException("没有权限删除"); | 85 | + throw new TkDataValidationException(String.format(MessageUtils.message(ErrorMessage. |
86 | + NOT_HAVE_PERMISSION.getI18nCode()))); | ||
83 | } | 87 | } |
84 | }); | 88 | }); |
85 | return baseMapper.deleteBatchIds(apiIds) > 0; | 89 | return baseMapper.deleteBatchIds(apiIds) > 0; |
@@ -90,7 +94,8 @@ public class OpenApiImpl extends AbstractBaseService<OpenApiMapper, TkOpenApiEnt | @@ -90,7 +94,8 @@ public class OpenApiImpl extends AbstractBaseService<OpenApiMapper, TkOpenApiEnt | ||
90 | public OpenApiDTO update(OpenApiDTO dto, String tenantId) { | 94 | public OpenApiDTO update(OpenApiDTO dto, String tenantId) { |
91 | TkOpenApiEntity openApi = baseMapper.selectById(dto.getId()); | 95 | TkOpenApiEntity openApi = baseMapper.selectById(dto.getId()); |
92 | if(!openApi.getTenantId().equals(tenantId)){ | 96 | if(!openApi.getTenantId().equals(tenantId)){ |
93 | - throw new TkDataValidationException("没有权限删除"); | 97 | + throw new TkDataValidationException(String.format(MessageUtils.message(ErrorMessage. |
98 | + NOT_HAVE_PERMISSION.getI18nCode()))); | ||
94 | } | 99 | } |
95 | dto.copyToEntity(openApi); | 100 | dto.copyToEntity(openApi); |
96 | baseMapper.updateById(openApi); | 101 | baseMapper.updateById(openApi); |