fix IJPACommData

V0.5.x
jay 2023-06-05 15:30:59 +08:00
parent a2b3dfca87
commit c6d168b495
43 changed files with 215 additions and 6 deletions

View File

@ -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;
}

View File

@ -38,11 +38,10 @@ public class AlertConfigDataImpl implements IAlertConfigData, IJPACommData<Alert
return TbAlertConfig.class;
}
@Override
public Class getTClass() {
return AlertConfig.class;
}
@Override

View File

@ -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) {

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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) {

View File

@ -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() + "%",

View File

@ -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) {
}

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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(() ->

View File

@ -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) {

View File

@ -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) {

View File

@ -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) {

View File

@ -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)));

View File

@ -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(() ->

View File

@ -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) {

View File

@ -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;

View File

@ -48,5 +48,10 @@ public class SysOssConfigDataImpl implements ISysOssConfigData, IJPACommData<Sys
return TbSysOssConfig.class;
}
@Override
public Class getTClass() {
return SysOssConfig.class;
}
}

View File

@ -38,6 +38,10 @@ public class SysOssDataImpl implements ISysOssData, IJPACommData<SysOss, Long> {
return TbSysOss.class;
}
@Override
public Class getTClass() {
return SysOss.class;
}
}

View File

@ -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)));

View File

@ -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);

View File

@ -50,4 +50,9 @@ public class SysRoleDeptDataImpl implements ISysRoleDeptData, IJPACommData<SysRo
public Class getJpaRepositoryClass() {
return TbSysRoleDept.class;
}
@Override
public Class getTClass() {
return SysRoleDept.class;
}
}

View File

@ -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

View File

@ -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);

View File

@ -37,6 +37,10 @@ public class SysTenantPackageDataImpl implements ISysTenantPackageData, IJPAComm
return TbSysTenantPackage.class;
}
@Override
public Class getTClass() {
return SysTenantPackage.class;
}
}

View File

@ -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) {

View File

@ -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));

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);