fix IJPACommData
parent
a2b3dfca87
commit
c6d168b495
|
@ -27,6 +27,8 @@ public interface IJPACommData< T extends Id<ID>, ID> extends ICommonData<T , ID
|
|||
|
||||
Class getJpaRepositoryClass();
|
||||
|
||||
Class getTClass();
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -101,7 +103,10 @@ public interface IJPACommData< T extends Id<ID>, ID> extends ICommonData<T , ID
|
|||
Example example = genExample(data);
|
||||
|
||||
Optional one = getBaseRepository().findOne(example);
|
||||
return (T) one.orElse(null);
|
||||
if(one.isPresent()){
|
||||
MapstructUtils.convert(one.get(), getTClass());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -38,11 +38,10 @@ public class AlertConfigDataImpl implements IAlertConfigData, IJPACommData<Alert
|
|||
return TbAlertConfig.class;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public Class getTClass() {
|
||||
return AlertConfig.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
|
|
|
@ -37,6 +37,11 @@ public class AlertRecordDataImpl implements IAlertRecordData, IJPACommData<Alert
|
|||
return TbAlertRecord.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class getTClass() {
|
||||
return AlertRecord.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Paging<AlertRecord> selectAlertConfigPage(PageRequest<AlertRecord> request) {
|
||||
|
|
|
@ -44,6 +44,11 @@ public class CategoryDataImpl implements ICategoryData, IJPACommData<Category, S
|
|||
return TbCategory.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class getTClass() {
|
||||
return Category.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Category findById(String s) {
|
||||
return MapstructUtils.convert(categoryRepository.findById(s).orElse(null), Category.class);
|
||||
|
|
|
@ -7,6 +7,7 @@ import cc.iotkit.data.manager.IChannelConfigData;
|
|||
import cc.iotkit.data.dao.ChannelConfigRepository;
|
||||
import cc.iotkit.data.model.TbChannelConfig;
|
||||
import cc.iotkit.common.api.Paging;
|
||||
import cc.iotkit.model.notify.Channel;
|
||||
import cc.iotkit.model.notify.ChannelConfig;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.context.annotation.Primary;
|
||||
|
@ -42,6 +43,11 @@ public class ChannelConfigDataImpl implements IChannelConfigData, IJPACommData<C
|
|||
return TbChannelConfig.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class getTClass() {
|
||||
return ChannelConfig.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelConfig findById(String id) {
|
||||
return MapstructUtils.convert(channelConfigRepository.findById(id).orElse(null), ChannelConfig.class);
|
||||
|
|
|
@ -42,6 +42,11 @@ public class ChannelDataImpl implements IChannelData, IJPACommData<Channel, Stri
|
|||
return TbChannel.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class getTClass() {
|
||||
return Channel.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Channel findById(String id) {
|
||||
return MapstructUtils.convert(channelRepository.findById(id).orElse(null), Channel.class);
|
||||
|
|
|
@ -43,6 +43,11 @@ public class ChannelTemplateDataImpl implements IChannelTemplateData, IJPACommDa
|
|||
return TbChannelTemplate.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class getTClass() {
|
||||
return ChannelTemplate.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelTemplate findById(String id) {
|
||||
return MapstructUtils.convert(channelTemplateRepository.findById(id).orElse(null), ChannelTemplate.class);
|
||||
|
|
|
@ -57,6 +57,11 @@ public class DeviceConfigDataImpl implements IDeviceConfigData, IJPACommData<Dev
|
|||
return TbDeviceConfig.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class getTClass() {
|
||||
return DeviceConfig.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public DeviceConfig save(DeviceConfig data) {
|
||||
|
|
|
@ -37,6 +37,11 @@ public class DeviceGroupDataImpl implements IDeviceGroupData, IJPACommData<Devic
|
|||
return TbDeviceGroup.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class getTClass() {
|
||||
return DeviceGroup.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Paging<DeviceGroup> findByNameLike(String name, int page, int size) {
|
||||
Page<TbDeviceGroup> groups = deviceGroupRepository.findByNameLike("%" + name.trim() + "%",
|
||||
|
|
|
@ -61,6 +61,11 @@ public class DeviceInfoDataImpl implements IDeviceInfoData,IJPACommData<DeviceIn
|
|||
return TbDeviceInfo.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class getTClass() {
|
||||
return DeviceInfo.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveProperties(String deviceId, Map<String, Object> properties) {
|
||||
}
|
||||
|
|
|
@ -36,6 +36,11 @@ public class HomeDataImpl implements IHomeData, IJPACommData<Home, String> {
|
|||
return TbHome.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class getTClass() {
|
||||
return Home.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Home findByUidAndCurrent(String uid, boolean current) {
|
||||
return MapstructUtils.convert(homeRepository.findByUidAndCurrent(uid, current), Home.class);
|
||||
|
|
|
@ -50,6 +50,11 @@ public class OauthClientDataImpl implements IOauthClientData, IJPACommData<Oauth
|
|||
return TbOauthClient.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class getTClass() {
|
||||
return OauthClient.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public OauthClient findById(String s) {
|
||||
return MapstructUtils.convert(oauthClientRepository.findById(s).orElse(null), OauthClient.class);
|
||||
|
|
|
@ -35,6 +35,11 @@ public class ProductDataImpl implements IProductData, IJPACommData<Product, Stri
|
|||
return TbProduct.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class getTClass() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Product> findByCategory(String category) {
|
||||
return MapstructUtils.convert(productRepository.findByCategory(category), Product.class);
|
||||
|
|
|
@ -37,6 +37,11 @@ public class ProductModelDataImpl implements IProductModelData, IJPACommData<Pro
|
|||
return TbProductModel.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class getTClass() {
|
||||
return ProductModel.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProductModel findByModel(String model) {
|
||||
return MapstructUtils.convert(productModelRepository.findByModel(model), ProductModel.class);
|
||||
|
|
|
@ -43,6 +43,11 @@ public class ProtocolComponentDataImpl implements IProtocolComponentData, IJPACo
|
|||
return TbProtocolComponent.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class getTClass() {
|
||||
return ProtocolComponent.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ProtocolComponent> findByState(String state) {
|
||||
return MapstructUtils.convert(protocolComponentRepository.findByState(state), ProtocolComponent.class);
|
||||
|
|
|
@ -46,6 +46,11 @@ public class ProtocolConverterDataImpl implements IProtocolConverterData, IJPACo
|
|||
return TbProtocolConverter.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class getTClass() {
|
||||
return ProtocolConverter.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ProtocolConverter> findByUid(String uid) {
|
||||
return MapstructUtils.convert(protocolConverterRepository.findByUid(uid), ProtocolConverter.class);
|
||||
|
|
|
@ -45,6 +45,11 @@ public class RuleInfoDataImpl implements IRuleInfoData, IJPACommData<RuleInfo, S
|
|||
return TbRuleInfo.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class getTClass() {
|
||||
return RuleInfo.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RuleInfo> findByUidAndType(String uid, String type) {
|
||||
return MapstructUtils.convert(ruleInfoRepository.findByUidAndType(uid, type), RuleInfo.class);
|
||||
|
|
|
@ -38,6 +38,11 @@ public class SpaceDataImpl implements ISpaceData, IJPACommData<Space, String> {
|
|||
return TbSpace.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class getTClass() {
|
||||
return Space.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Space> findByUidOrderByCreateAtDesc(String uid) {
|
||||
return MapstructUtils.convert(spaceRepository.findByUidOrderByCreateAtDesc(uid), Space.class);
|
||||
|
|
|
@ -45,6 +45,11 @@ public class SpaceDeviceDataImpl implements ISpaceDeviceData, IJPACommData<Space
|
|||
return TbSpaceDevice.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class getTClass() {
|
||||
return SpaceDevice.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SpaceDevice> findByUidOrderByUseAtDesc(String uid) {
|
||||
return MapstructUtils.convert(spaceDeviceRepository.findByUidOrderByUseAtDesc(uid), SpaceDevice.class);
|
||||
|
|
|
@ -46,6 +46,11 @@ public class SysConfigDataImpl implements ISysConfigData, IJPACommData<SysConfig
|
|||
return TbSysConfig.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class getTClass() {
|
||||
return SysConfig.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SysConfig findById(Long id) {
|
||||
TbSysConfig tbSysConfig = baseRepository.findById(id).orElseThrow(() ->
|
||||
|
|
|
@ -49,6 +49,11 @@ public class SysDeptDataImpl implements ISysDeptData, IJPACommData<SysDept, Long
|
|||
return TbSysDept.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class getTClass() {
|
||||
return SysDept.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<SysDept> findDepts(SysDept dept) {
|
||||
|
|
|
@ -52,6 +52,11 @@ public class SysDictDataImpl implements ISysDictData, IJPACommData<SysDictData,
|
|||
return TbSysDictData.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class getTClass() {
|
||||
return SysDictData.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<SysDictData> findByConditions(SysDictData query) {
|
||||
|
|
|
@ -41,6 +41,11 @@ public class SysDictTypeDataImpl implements ISysDictTypeData, IJPACommData<SysDi
|
|||
return TbSysDictType.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class getTClass() {
|
||||
return SysDictType.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<SysDictType> findByConditions(SysDictType query) {
|
||||
|
|
|
@ -48,6 +48,11 @@ public class SysLogininfoDataImpl implements ISysLogininforData, IJPACommData<Sy
|
|||
return TbSysLogininfor.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class getTClass() {
|
||||
return SysLogininfor.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Paging<SysLogininfor> findAll(PageRequest<SysLogininfor> pageRequest) {
|
||||
return PageBuilder.toPaging(logininfoRepository.findAll(genPredicate(pageRequest.getData()), PageBuilder.toPageable(pageRequest)));
|
||||
|
|
|
@ -58,6 +58,11 @@ public class SysMenuDataImpl implements ISysMenuData, IJPACommData<SysMenu, Long
|
|||
return TbSysMenu.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class getTClass() {
|
||||
return SysMenu.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SysMenu findById(Long id) {
|
||||
TbSysMenu tbSysMenu = sysMenuRepository.findById(id).orElseThrow(() ->
|
||||
|
|
|
@ -40,6 +40,11 @@ public class SysNoticeDataImpl implements ISysNoticeData, IJPACommData<SysNotice
|
|||
return TbSysNotice.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class getTClass() {
|
||||
return SysNotice.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Paging<SysNotice> findByConditions(String noticeTitle, String noticeType, String status, int page, int size) {
|
||||
|
|
|
@ -48,6 +48,11 @@ public class SysOperLogDataImpl implements ISysOperLogData, IJPACommData<SysOper
|
|||
return TbSysOperLog.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class getTClass() {
|
||||
return SysOperLog.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Paging<SysOperLog> findByConditions(String tenantId, String title, Integer businessType, Integer status, int page, int size) {
|
||||
return null;
|
||||
|
|
|
@ -48,5 +48,10 @@ public class SysOssConfigDataImpl implements ISysOssConfigData, IJPACommData<Sys
|
|||
return TbSysOssConfig.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class getTClass() {
|
||||
return SysOssConfig.class;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -38,6 +38,10 @@ public class SysOssDataImpl implements ISysOssData, IJPACommData<SysOss, Long> {
|
|||
return TbSysOss.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class getTClass() {
|
||||
return SysOss.class;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -50,6 +50,11 @@ public class SysPostDataImpl implements ISysPostData, IJPACommData<SysPost, Long
|
|||
return TbSysPost.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class getTClass() {
|
||||
return SysPost.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Paging<SysPost> findAll(PageRequest<SysPost> pageRequest) {
|
||||
return PageBuilder.toPaging(postRepository.findAll(buildQueryCondition(pageRequest.getData()), PageBuilder.toPageable(pageRequest)));
|
||||
|
|
|
@ -54,6 +54,11 @@ public class SysRoleDataImpl implements ISysRoleData, IJPACommData<SysRole, Long
|
|||
return TbSysRole.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class getTClass() {
|
||||
return SysRole.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SysRole findById(Long id) {
|
||||
return MapstructUtils.convert(sysRoleRepository.findById(id), SysRole.class);
|
||||
|
|
|
@ -50,4 +50,9 @@ public class SysRoleDeptDataImpl implements ISysRoleDeptData, IJPACommData<SysRo
|
|||
public Class getJpaRepositoryClass() {
|
||||
return TbSysRoleDept.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class getTClass() {
|
||||
return SysRoleDept.class;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,6 +43,11 @@ public class SysRoleMenuDataImpl implements ISysRoleMenuData, IJPACommData<SysRo
|
|||
return TbSysRoleMenu.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class getTClass() {
|
||||
return SysRoleMenu.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkMenuExistRole(Long menuId) {
|
||||
TbSysRoleMenu tbSysRoleMenu = jpaQueryFactory
|
||||
|
|
|
@ -42,6 +42,11 @@ public class SysTenantDataImpl implements ISysTenantData, IJPACommData<SysTenant
|
|||
return TbSysTenant.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class getTClass() {
|
||||
return SysTenant.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SysTenant findById(Long aLong) {
|
||||
return MapstructUtils.convert(sysTenantRepository.findById(aLong),SysTenant.class);
|
||||
|
|
|
@ -37,6 +37,10 @@ public class SysTenantPackageDataImpl implements ISysTenantPackageData, IJPAComm
|
|||
return TbSysTenantPackage.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class getTClass() {
|
||||
return SysTenantPackage.class;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -57,6 +57,11 @@ public class SysUserDataImpl implements ISysUserData, IJPACommData<SysUser, Long
|
|||
return TbSysUser.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class getTClass() {
|
||||
return SysUser.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public long countByDeptId(Long aLong) {
|
||||
|
|
|
@ -42,6 +42,11 @@ public class SysUserPostDataImpl implements ISysUserPostData, IJPACommData<SysUs
|
|||
return TbSysUserPost.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class getTClass() {
|
||||
return SysUserPost.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void batchSave(List<SysUserPost> data) {
|
||||
sysUserPostRepository.saveAll(MapstructUtils.convert(data, TbSysUserPost.class));
|
||||
|
|
|
@ -43,6 +43,11 @@ public class SysUserRoleDataImpl implements ISysUserRoleData, IJPACommData<SysUs
|
|||
return TbSysUserRole.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class getTClass() {
|
||||
return SysUserRole.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int deleteByUserId(Long userId) {
|
||||
return sysUserRoleRepository.deleteAllByUserId(userId);
|
||||
|
|
|
@ -64,6 +64,11 @@ public class TaskInfoDataImpl implements ITaskInfoData, IJPACommData<TaskInfo, S
|
|||
return TbTaskInfo.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class getTClass() {
|
||||
return TaskInfo.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TaskInfo findById(String s) {
|
||||
return MapstructUtils.convert(taskInfoRepository.findById(s).orElse(null), TaskInfo.class);
|
||||
|
|
|
@ -46,6 +46,11 @@ public class ThingModelDataImpl implements IThingModelData, IJPACommData<ThingMo
|
|||
return TbThingModel.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class getTClass() {
|
||||
return ThingModel.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ThingModel findById(String s) {
|
||||
return MapstructUtils.convert(thingModelRepository.findById(s).orElse(null),ThingModel.class);
|
||||
|
|
|
@ -60,6 +60,11 @@ public class UserInfoDataImpl implements IUserInfoData, IJPACommData<UserInfo, S
|
|||
return TbUserInfo.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class getTClass() {
|
||||
return UserInfo.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserInfo findById(String s) {
|
||||
return MapstructUtils.convert(userInfoRepository.findById(s).orElse(null), UserInfo.class);
|
||||
|
|
|
@ -56,6 +56,11 @@ public class VirtualDeviceDataImpl implements IVirtualDeviceData, IJPACommData<V
|
|||
return TbVirtualDevice.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class getTClass() {
|
||||
return VirtualDevice.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<VirtualDevice> findByUid(String uid) {
|
||||
return MapstructUtils.convert(virtualDeviceRepository.findByUid(uid), VirtualDevice.class);
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
*/
|
||||
package cc.iotkit.common.web.handler;
|
||||
|
||||
import cc.iotkit.common.exception.BizException;
|
||||
import cn.dev33.satoken.exception.NotLoginException;
|
||||
import cn.dev33.satoken.exception.NotPermissionException;
|
||||
import cn.dev33.satoken.exception.NotRoleException;
|
||||
|
@ -39,6 +40,11 @@ public class GlobalExceptionHandler {
|
|||
response.setStatus(403);
|
||||
return new RequestResult(403, "没有权限");
|
||||
}
|
||||
if (e instanceof BizException){
|
||||
BizException bizException = (BizException) e;
|
||||
response.setStatus(500);
|
||||
return new RequestResult(bizException.getCode(), bizException.getMessage());
|
||||
}
|
||||
|
||||
if (e.getMessage().contains("Unauthorized")) {
|
||||
response.setStatus(403);
|
||||
|
|
Loading…
Reference in New Issue