From cb6f165a027d63db058ed49a537ee27cfd815602 Mon Sep 17 00:00:00 2001 From: jay <75509151@qq.com> Date: Thu, 1 Jun 2023 15:00:30 +0800 Subject: [PATCH] =?UTF-8?q?feat=20system=E5=9F=BA=E7=A1=80=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E6=93=8D=E4=BD=9C=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/cc/iotkit/data/ICommonData.java | 49 ++++----------- .../cc/iotkit/data/system/ISysDeptData.java | 7 +-- .../data/dao/SysRoleDeptRepository.java | 19 ++++++ .../data/dao/SysRoleMenuRepository.java | 19 ++++++ .../data/service/SysConfigDataImpl.java | 23 -------- .../iotkit/data/service/SysDeptDataImpl.java | 16 ++++- .../data/service/SysLogininfoDataImpl.java | 39 +++++++++--- .../iotkit/data/service/SysMenuDataImpl.java | 37 ++++-------- .../data/service/SysOperLogDataImpl.java | 15 ++++- .../iotkit/data/service/SysPostDataImpl.java | 16 ++++- .../iotkit/data/service/SysRoleDataImpl.java | 14 ++++- .../data/service/SysRoleDeptDataImpl.java | 19 +++++- .../data/service/SysRoleMenuDataImpl.java | 19 +++++- .../data/service/SysTenantDataImpl.java | 35 +++++------ .../iotkit/data/service/SysUserDataImpl.java | 48 ++++++--------- .../data/service/SysUserPostDataImpl.java | 14 ++++- .../data/service/SysUserRoleDataImpl.java | 15 ++++- .../iotkit/data/service/TaskInfoDataImpl.java | 59 +++++-------------- .../data/service/ThingModelDataImpl.java | 51 +++++----------- .../iotkit/data/service/UserInfoDataImpl.java | 40 ++++--------- .../data/service/VirtualDeviceDataImpl.java | 47 +++++---------- .../java/cc/iotkit/data/util/PageBuilder.java | 9 ++- .../system/controller/SysRoleController.java | 3 +- 23 files changed, 309 insertions(+), 304 deletions(-) create mode 100644 iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/dao/SysRoleDeptRepository.java create mode 100644 iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/dao/SysRoleMenuRepository.java diff --git a/iot-common/iot-common-dao/iot-data-service/src/main/java/cc/iotkit/data/ICommonData.java b/iot-common/iot-common-dao/iot-data-service/src/main/java/cc/iotkit/data/ICommonData.java index 9bcc14a3..32deba95 100644 --- a/iot-common/iot-common-dao/iot-data-service/src/main/java/cc/iotkit/data/ICommonData.java +++ b/iot-common/iot-common-dao/iot-data-service/src/main/java/cc/iotkit/data/ICommonData.java @@ -25,80 +25,53 @@ public interface ICommonData, ID> { /** * 通过ID取数据 */ - default T findById(ID id) { - return null; - - } + T findById(ID id); /** * 通过ID取数据 */ - default List findByIds(Collection id) { - return Collections.EMPTY_LIST; - - } + List findByIds(Collection id); /** * 保存数据,id不为空更新,否则添加 */ - default T save(T data) { - return data; - - } + T save(T data) ; /** * 批量保存数据 */ - default void batchSave(List data) { - } - + void batchSave(List data) ; /** * 按id删除 */ - default void deleteById(ID id) { - } - + void deleteById(ID id) ; /** * 按id批量删除 */ - default void deleteByIds(Collection ids) { - } - + void deleteByIds(Collection ids) ; /** * 总数统计 */ - default long count() { - return 0L; - } - + long count(); /** * 取所有数据 */ - default List findAll() { - return null; - } + List findAll() ; /** * 分页获取所有信息 */ - default Paging findAll(PageRequest pageRequest) { - return null; - } + Paging findAll(PageRequest pageRequest) ; /** * 按条件查询多个结果 */ - default List findAllByCondition(T data) { - return Collections.EMPTY_LIST; - - } + List findAllByCondition(T data); /** * 按条件查询单个结果 */ - default T findOneByCondition(T data) { - return data; - } + T findOneByCondition(T data); } diff --git a/iot-common/iot-common-dao/iot-data-service/src/main/java/cc/iotkit/data/system/ISysDeptData.java b/iot-common/iot-common-dao/iot-data-service/src/main/java/cc/iotkit/data/system/ISysDeptData.java index e99d5ef7..dc9ee397 100644 --- a/iot-common/iot-common-dao/iot-data-service/src/main/java/cc/iotkit/data/system/ISysDeptData.java +++ b/iot-common/iot-common-dao/iot-data-service/src/main/java/cc/iotkit/data/system/ISysDeptData.java @@ -14,11 +14,8 @@ import java.util.List; */ public interface ISysDeptData extends ICommonData { - /** - * 按条件分页查询 - */ - Paging findByConditions(Long parentId, String deptName, - String status, int page, int size); + + /** * 复合备件查询 diff --git a/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/dao/SysRoleDeptRepository.java b/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/dao/SysRoleDeptRepository.java new file mode 100644 index 00000000..1aace8d5 --- /dev/null +++ b/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/dao/SysRoleDeptRepository.java @@ -0,0 +1,19 @@ +/* + * +---------------------------------------------------------------------- + * | Copyright (c) 奇特物联 2021-2022 All rights reserved. + * +---------------------------------------------------------------------- + * | Licensed 未经许可不能去掉「奇特物联」相关版权 + * +---------------------------------------------------------------------- + * | Author: xw2sy@163.com + * +---------------------------------------------------------------------- + */ +package cc.iotkit.data.dao; + +import cc.iotkit.data.model.TbSysRole; +import cc.iotkit.data.model.TbSysRoleDept; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.querydsl.QuerydslPredicateExecutor; + +public interface SysRoleDeptRepository extends JpaRepository, QuerydslPredicateExecutor { + +} diff --git a/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/dao/SysRoleMenuRepository.java b/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/dao/SysRoleMenuRepository.java new file mode 100644 index 00000000..f4d1d858 --- /dev/null +++ b/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/dao/SysRoleMenuRepository.java @@ -0,0 +1,19 @@ +/* + * +---------------------------------------------------------------------- + * | Copyright (c) 奇特物联 2021-2022 All rights reserved. + * +---------------------------------------------------------------------- + * | Licensed 未经许可不能去掉「奇特物联」相关版权 + * +---------------------------------------------------------------------- + * | Author: xw2sy@163.com + * +---------------------------------------------------------------------- + */ +package cc.iotkit.data.dao; + +import cc.iotkit.data.model.TbSysRoleDept; +import cc.iotkit.data.model.TbSysRoleMenu; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.querydsl.QuerydslPredicateExecutor; + +public interface SysRoleMenuRepository extends JpaRepository, QuerydslPredicateExecutor { + +} diff --git a/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/SysConfigDataImpl.java b/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/SysConfigDataImpl.java index 40481715..ada2a919 100644 --- a/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/SysConfigDataImpl.java +++ b/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/SysConfigDataImpl.java @@ -66,30 +66,7 @@ public class SysConfigDataImpl implements ISysConfigData, IJPACommData data) { - throw new BizException(ErrCode.UNSUPPORTED_OPERATION_EXCEPTION); - } - @Override - public void deleteById(Long aLong) { - throw new BizException(ErrCode.UNSUPPORTED_OPERATION_EXCEPTION); - } - - @Override - public void deleteByIds(Collection longs) { - throw new BizException(ErrCode.UNSUPPORTED_OPERATION_EXCEPTION); - } - - @Override - public long count() { - throw new BizException(ErrCode.UNSUPPORTED_OPERATION_EXCEPTION); - } - - @Override - public List findAll() { - throw new BizException(ErrCode.UNSUPPORTED_OPERATION_EXCEPTION); - } @Override public Paging findAll(PageRequest pageRequest) { diff --git a/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/SysDeptDataImpl.java b/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/SysDeptDataImpl.java index 94236bb4..a24ff444 100644 --- a/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/SysDeptDataImpl.java +++ b/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/SysDeptDataImpl.java @@ -4,7 +4,9 @@ import cc.iotkit.common.api.Paging; import cc.iotkit.common.constant.UserConstants; import cc.iotkit.common.utils.MapstructUtils; import cc.iotkit.common.utils.StringUtils; +import cc.iotkit.data.dao.IJPACommData; import cc.iotkit.data.dao.SysDeptRepository; +import cc.iotkit.data.model.TbSysDept; import cc.iotkit.data.system.ISysDeptData; import cc.iotkit.data.util.PredicateBuilder; import cc.iotkit.model.system.SysDept; @@ -13,6 +15,7 @@ import com.querydsl.jpa.impl.JPAQueryFactory; import lombok.RequiredArgsConstructor; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Primary; +import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Service; import java.util.List; @@ -28,18 +31,25 @@ import static cc.iotkit.data.model.QTbSysDept.tbSysDept; @Primary @Service @RequiredArgsConstructor -public class SysDeptDataImpl implements ISysDeptData { +public class SysDeptDataImpl implements ISysDeptData, IJPACommData { @Autowired private SysDeptRepository deptRepository; private final JPAQueryFactory jpaQueryFactory; + @Override - public Paging findByConditions(Long parentId, String deptName, String status, int page, int size) { - return null; + public JpaRepository getBaseRepository() { + return deptRepository; } + @Override + public Class getJpaRepositoryClass() { + return TbSysDept.class; + } + + @Override public List findDepts(SysDept dept) { PredicateBuilder predicateBuilder = PredicateBuilder.instance() diff --git a/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/SysLogininfoDataImpl.java b/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/SysLogininfoDataImpl.java index 56002c6a..8c78f856 100644 --- a/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/SysLogininfoDataImpl.java +++ b/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/SysLogininfoDataImpl.java @@ -3,14 +3,21 @@ package cc.iotkit.data.service; import cc.iotkit.common.api.Paging; import cc.iotkit.common.utils.MapstructUtils; import cc.iotkit.common.utils.StringUtils; +import cc.iotkit.data.dao.IJPACommData; import cc.iotkit.data.dao.SysLogininforRepository; +import cc.iotkit.data.model.TbSysConfig; import cc.iotkit.data.model.TbSysLogininfor; import cc.iotkit.data.system.ISysLogininforData; +import cc.iotkit.data.util.PageBuilder; import cc.iotkit.data.util.PredicateBuilder; +import cc.iotkit.model.system.SysConfig; import cc.iotkit.model.system.SysLogininfor; +import com.querydsl.core.types.Predicate; import com.querydsl.jpa.impl.JPAQueryFactory; import lombok.RequiredArgsConstructor; import org.springframework.context.annotation.Primary; +import org.springframework.data.domain.Page; +import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Service; import java.util.Collection; @@ -25,27 +32,43 @@ import static cc.iotkit.data.model.QTbSysLogininfor.tbSysLogininfor; @Primary @Service @RequiredArgsConstructor -public class SysLogininfoDataImpl implements ISysLogininforData { +public class SysLogininfoDataImpl implements ISysLogininforData, IJPACommData { private SysLogininforRepository logininfoRepository; private final JPAQueryFactory jpaQueryFactory; + + @Override + public JpaRepository getBaseRepository() { + return logininfoRepository; + } + + @Override + public Class getJpaRepositoryClass() { + return TbSysLogininfor.class; + } + @Override public List findByConditions(SysLogininfor data) { - List ret=jpaQueryFactory.selectFrom(tbSysLogininfor).where(PredicateBuilder.instance() - .and(StringUtils.isNotBlank(data.getIpaddr()),()->tbSysLogininfor.ipaddr.like(data.getIpaddr())) - .and(StringUtils.isNotBlank(data.getStatus()),()->tbSysLogininfor.status.eq(data.getStatus())) - .and(StringUtils.isNotBlank(data.getUserName()),()->tbSysLogininfor.userName.like(data.getUserName())) - .build()) + List ret=jpaQueryFactory.selectFrom(tbSysLogininfor).where(genPredicate(data)) .orderBy(tbSysLogininfor.id.desc()).fetch(); return MapstructUtils.convert(ret, SysLogininfor.class); } + private static Predicate genPredicate(SysLogininfor data) { + return PredicateBuilder.instance() + .and(StringUtils.isNotBlank(data.getIpaddr()), () -> tbSysLogininfor.ipaddr.like(data.getIpaddr())) + .and(StringUtils.isNotBlank(data.getStatus()), () -> tbSysLogininfor.status.eq(data.getStatus())) + .and(StringUtils.isNotBlank(data.getUserName()), () -> tbSysLogininfor.userName.like(data.getUserName())) + .build(); + } + @Override public Paging findByConditions(SysLogininfor cond, int page, int size) { - return null; + Page all = logininfoRepository.findAll(genPredicate(cond), PageBuilder.buildPageable(page, size)); + return PageBuilder.toPaging(all, SysConfig.class); } @Override @@ -58,6 +81,8 @@ public class SysLogininfoDataImpl implements ISysLogininforData { logininfoRepository.deleteAll(); } + + @Override public void deleteByIds(Collection longs) { logininfoRepository.deleteAllByIdInBatch(longs); diff --git a/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/SysMenuDataImpl.java b/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/SysMenuDataImpl.java index 5c61344a..9f396425 100644 --- a/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/SysMenuDataImpl.java +++ b/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/SysMenuDataImpl.java @@ -7,6 +7,7 @@ import cc.iotkit.common.enums.ErrCode; import cc.iotkit.common.exception.BizException; import cc.iotkit.common.utils.MapstructUtils; import cc.iotkit.common.utils.StringUtils; +import cc.iotkit.data.dao.IJPACommData; import cc.iotkit.data.dao.SysMenuRepository; import cc.iotkit.data.model.QTbSysMenu; import cc.iotkit.data.model.TbSysMenu; @@ -18,6 +19,7 @@ import com.querydsl.core.types.Projections; import com.querydsl.jpa.impl.JPAQueryFactory; import lombok.RequiredArgsConstructor; import org.springframework.context.annotation.Primary; +import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Service; import java.util.Collection; @@ -40,12 +42,22 @@ import static cc.iotkit.data.model.QTbSysUserRole.tbSysUserRole; @Primary @Service @RequiredArgsConstructor -public class SysMenuDataImpl implements ISysMenuData { +public class SysMenuDataImpl implements ISysMenuData, IJPACommData { private final SysMenuRepository sysMenuRepository; private final JPAQueryFactory jpaQueryFactory; + @Override + public JpaRepository getBaseRepository() { + return sysMenuRepository; + } + + @Override + public Class getJpaRepositoryClass() { + return TbSysMenu.class; + } + @Override public SysMenu findById(Long id) { TbSysMenu tbSysMenu = sysMenuRepository.findById(id).orElseThrow(() -> @@ -81,30 +93,7 @@ public class SysMenuDataImpl implements ISysMenuData { sysMenuRepository.deleteAllByIdInBatch(ids); } - @Override - public long count() { - return 0; - } - @Override - public List findAll() { - return null; - } - - @Override - public Paging findAll(PageRequest pageRequest) { - return null; - } - - @Override - public List findAllByCondition(SysMenu data) { - return null; - } - - @Override - public SysMenu findOneByCondition(SysMenu data) { - return null; - } @Override public List selectMenuList(SysMenu menu, Long userId, boolean isSuperAdmin) { diff --git a/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/SysOperLogDataImpl.java b/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/SysOperLogDataImpl.java index df615fbd..59bf838d 100644 --- a/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/SysOperLogDataImpl.java +++ b/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/SysOperLogDataImpl.java @@ -3,6 +3,7 @@ package cc.iotkit.data.service; import cc.iotkit.common.api.Paging; import cc.iotkit.common.utils.MapstructUtils; import cc.iotkit.common.utils.StringUtils; +import cc.iotkit.data.dao.IJPACommData; import cc.iotkit.data.dao.SysOperLogRepository; import cc.iotkit.data.model.TbSysOperLog; import cc.iotkit.data.system.ISysOperLogData; @@ -12,6 +13,7 @@ import cn.hutool.core.util.ArrayUtil; import com.querydsl.jpa.impl.JPAQueryFactory; import lombok.RequiredArgsConstructor; import org.springframework.context.annotation.Primary; +import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Service; import java.util.Arrays; @@ -27,13 +29,23 @@ import static cc.iotkit.data.model.QTbSysOperLog.tbSysOperLog; @Primary @Service @RequiredArgsConstructor -public class SysOperLogDataImpl implements ISysOperLogData { +public class SysOperLogDataImpl implements ISysOperLogData, IJPACommData { private SysOperLogRepository operLogRepository; private final JPAQueryFactory jpaQueryFactory; + @Override + public JpaRepository getBaseRepository() { + return operLogRepository; + } + + @Override + public Class getJpaRepositoryClass() { + return TbSysOperLog.class; + } + @Override public Paging findByConditions(String tenantId, String title, Integer businessType, Integer status, int page, int size) { return null; @@ -49,6 +61,7 @@ public class SysOperLogDataImpl implements ISysOperLogData { operLogRepository.deleteAll(); } + @Override public void deleteByIds(Collection longs) { operLogRepository.deleteAllByIdInBatch(longs); diff --git a/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/SysPostDataImpl.java b/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/SysPostDataImpl.java index 1fb8615a..adbfe2f8 100644 --- a/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/SysPostDataImpl.java +++ b/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/SysPostDataImpl.java @@ -2,6 +2,7 @@ package cc.iotkit.data.service; import cc.iotkit.common.utils.MapstructUtils; import cc.iotkit.common.utils.StringUtils; +import cc.iotkit.data.dao.IJPACommData; import cc.iotkit.data.dao.SysPostRepository; import cc.iotkit.data.model.TbSysPost; import cc.iotkit.data.system.ISysPostData; @@ -11,6 +12,7 @@ import com.querydsl.core.types.Projections; import com.querydsl.jpa.impl.JPAQueryFactory; import lombok.RequiredArgsConstructor; import org.springframework.context.annotation.Primary; +import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Service; import java.util.Collection; @@ -28,13 +30,23 @@ import static cc.iotkit.data.model.QTbSysUserPost.tbSysUserPost; @Primary @Service @RequiredArgsConstructor -public class SysPostDataImpl implements ISysPostData { +public class SysPostDataImpl implements ISysPostData, IJPACommData { private SysPostRepository postRepository; private final JPAQueryFactory jpaQueryFactory; + @Override + public JpaRepository getBaseRepository() { + return postRepository; + } + + @Override + public Class getJpaRepositoryClass() { + return TbSysPost.class; + } + @Override public List findAll() { return MapstructUtils.convert(postRepository.findAll(),SysPost.class); @@ -81,6 +93,8 @@ public class SysPostDataImpl implements ISysPostData { return Objects.isNull(ret); } + + @Override public SysPost findById(Long aLong) { return MapstructUtils.convert(postRepository.findById(aLong),SysPost.class); diff --git a/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/SysRoleDataImpl.java b/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/SysRoleDataImpl.java index 30db1cd0..449d9dc7 100644 --- a/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/SysRoleDataImpl.java +++ b/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/SysRoleDataImpl.java @@ -2,6 +2,7 @@ package cc.iotkit.data.service; import cc.iotkit.common.constant.UserConstants; import cc.iotkit.common.utils.MapstructUtils; +import cc.iotkit.data.dao.IJPACommData; import cc.iotkit.data.dao.SysRoleRepository; import cc.iotkit.data.model.TbSysRole; import cc.iotkit.data.system.ISysRoleData; @@ -13,6 +14,7 @@ import com.querydsl.jpa.impl.JPAQueryFactory; import lombok.RequiredArgsConstructor; import org.apache.commons.lang3.StringUtils; import org.springframework.context.annotation.Primary; +import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Service; import java.util.List; @@ -33,12 +35,22 @@ import static cc.iotkit.data.model.QTbSysUserRole.tbSysUserRole; @Primary @Service @RequiredArgsConstructor -public class SysRoleDataImpl implements ISysRoleData { +public class SysRoleDataImpl implements ISysRoleData, IJPACommData { private final SysRoleRepository sysRoleRepository; private final JPAQueryFactory jpaQueryFactory; + @Override + public JpaRepository getBaseRepository() { + return sysRoleRepository; + } + + @Override + public Class getJpaRepositoryClass() { + return TbSysRole.class; + } + @Override public SysRole findById(Long id) { return MapstructUtils.convert(sysRoleRepository.findById(id), SysRole.class); diff --git a/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/SysRoleDeptDataImpl.java b/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/SysRoleDeptDataImpl.java index 68b4ac34..0092ae74 100644 --- a/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/SysRoleDeptDataImpl.java +++ b/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/SysRoleDeptDataImpl.java @@ -1,11 +1,16 @@ package cc.iotkit.data.service; +import cc.iotkit.data.dao.IJPACommData; +import cc.iotkit.data.dao.SysRoleDeptRepository; +import cc.iotkit.data.model.TbSysDept; +import cc.iotkit.data.model.TbSysRoleDept; import cc.iotkit.data.system.ISysRoleDeptData; import cc.iotkit.data.util.PredicateBuilder; import cc.iotkit.model.system.SysRoleDept; import com.querydsl.jpa.impl.JPAQueryFactory; import lombok.RequiredArgsConstructor; import org.springframework.context.annotation.Primary; +import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Service; import java.util.List; @@ -20,8 +25,10 @@ import static cc.iotkit.data.model.QTbSysRoleDept.tbSysRoleDept; @Primary @Service @RequiredArgsConstructor -public class SysRoleDeptDataImpl implements ISysRoleDeptData { +public class SysRoleDeptDataImpl implements ISysRoleDeptData, IJPACommData { + + private final SysRoleDeptRepository sysRoleDeptRepository; private final JPAQueryFactory jpaQueryFactory; @Override @@ -33,4 +40,14 @@ public class SysRoleDeptDataImpl implements ISysRoleDeptData { public long insertBatch(List list) { return 0; } + + @Override + public JpaRepository getBaseRepository() { + return sysRoleDeptRepository; + } + + @Override + public Class getJpaRepositoryClass() { + return TbSysRoleDept.class; + } } diff --git a/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/SysRoleMenuDataImpl.java b/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/SysRoleMenuDataImpl.java index 361c9ae9..df764b9a 100644 --- a/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/SysRoleMenuDataImpl.java +++ b/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/SysRoleMenuDataImpl.java @@ -1,6 +1,8 @@ package cc.iotkit.data.service; import cc.iotkit.common.utils.MapstructUtils; +import cc.iotkit.data.dao.IJPACommData; +import cc.iotkit.data.dao.SysRoleMenuRepository; import cc.iotkit.data.model.QTbSysRoleMenu; import cc.iotkit.data.model.TbSysRoleMenu; import cc.iotkit.data.model.TbSysUserRole; @@ -10,6 +12,7 @@ import cc.iotkit.model.system.SysRoleMenu; import com.querydsl.jpa.impl.JPAQueryFactory; import lombok.RequiredArgsConstructor; import org.springframework.context.annotation.Primary; +import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Service; import java.util.*; @@ -24,10 +27,22 @@ import static cc.iotkit.data.model.QTbSysRoleMenu.tbSysRoleMenu; @Primary @Service @RequiredArgsConstructor -public class SysRoleMenuDataImpl implements ISysRoleMenuData { +public class SysRoleMenuDataImpl implements ISysRoleMenuData, IJPACommData { + + private final SysRoleMenuRepository sysRoleMenuRepository; private final JPAQueryFactory jpaQueryFactory; + @Override + public JpaRepository getBaseRepository() { + return sysRoleMenuRepository; + } + + @Override + public Class getJpaRepositoryClass() { + return TbSysRoleMenu.class; + } + @Override public boolean checkMenuExistRole(Long menuId) { TbSysRoleMenu tbSysRoleMenu = jpaQueryFactory @@ -48,4 +63,6 @@ public class SysRoleMenuDataImpl implements ISysRoleMenuData { public long deleteByRoleId(List ids) { return jpaQueryFactory.delete(tbSysRoleMenu).where(tbSysRoleMenu.roleId.in(ids)).execute(); } + + } diff --git a/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/SysTenantDataImpl.java b/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/SysTenantDataImpl.java index 30fad610..89c6a7a8 100644 --- a/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/SysTenantDataImpl.java +++ b/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/SysTenantDataImpl.java @@ -2,6 +2,7 @@ package cc.iotkit.data.service; import cc.iotkit.common.utils.MapstructUtils; import cc.iotkit.common.utils.StringUtils; +import cc.iotkit.data.dao.IJPACommData; import cc.iotkit.data.dao.SysTenantRepository; import cc.iotkit.data.model.TbSysTenant; import cc.iotkit.data.system.ISysTenantData; @@ -10,6 +11,7 @@ import cc.iotkit.model.system.SysTenant; import com.querydsl.jpa.impl.JPAQueryFactory; import lombok.RequiredArgsConstructor; import org.springframework.context.annotation.Primary; +import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Service; import java.util.Collection; @@ -24,36 +26,27 @@ import static cc.iotkit.data.model.QTbSysTenant.tbSysTenant; @Primary @Service @RequiredArgsConstructor -public class SysTenantDataImpl implements ISysTenantData { +public class SysTenantDataImpl implements ISysTenantData, IJPACommData { - private SysTenantRepository sysTenantRepository; + private final SysTenantRepository sysTenantRepository; private final JPAQueryFactory jpaQueryFactory; + @Override + public JpaRepository getBaseRepository() { + return sysTenantRepository; + } + + @Override + public Class getJpaRepositoryClass() { + return TbSysTenant.class; + } + @Override public SysTenant findById(Long aLong) { return MapstructUtils.convert(sysTenantRepository.findById(aLong),SysTenant.class); } - @Override - public SysTenant save(SysTenant data) { - return null; - } - - @Override - public void batchSave(List data) { - - } - - @Override - public void deleteById(Long aLong) { - - } - - @Override - public void deleteByIds(Collection longs) { - - } @Override public List findAllByCondition(SysTenant data) { diff --git a/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/SysUserDataImpl.java b/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/SysUserDataImpl.java index 9261f744..b9e99093 100644 --- a/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/SysUserDataImpl.java +++ b/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/SysUserDataImpl.java @@ -6,6 +6,7 @@ import cc.iotkit.common.constant.UserConstants; import cc.iotkit.common.utils.MapstructUtils; import cc.iotkit.common.utils.StreamUtils; import cc.iotkit.common.utils.StringUtils; +import cc.iotkit.data.dao.IJPACommData; import cc.iotkit.data.dao.SysUserRepository; import cc.iotkit.data.model.TbSysUser; import cc.iotkit.data.system.ISysDeptData; @@ -18,6 +19,7 @@ import com.querydsl.core.types.Projections; import com.querydsl.jpa.impl.JPAQueryFactory; import lombok.RequiredArgsConstructor; import org.springframework.context.annotation.Primary; +import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Service; import java.util.Collection; @@ -35,7 +37,7 @@ import static cc.iotkit.data.model.QTbSysUser.tbSysUser; @Primary @Service @RequiredArgsConstructor -public class SysUserDataImpl implements ISysUserData { +public class SysUserDataImpl implements ISysUserData, IJPACommData { private SysUserRepository userRepository; @@ -43,6 +45,18 @@ public class SysUserDataImpl implements ISysUserData { private JPAQueryFactory jpaQueryFactory; + + @Override + public JpaRepository getBaseRepository() { + return userRepository; + } + + @Override + public Class getJpaRepositoryClass() { + return TbSysUser.class; + } + + @Override public long countByDeptId(Long aLong) { return 0; @@ -78,50 +92,26 @@ public class SysUserDataImpl implements ISysUserData { return Objects.isNull(ret); } + @Override public SysUser findById(Long aLong) { return MapstructUtils.convert(userRepository.findById(aLong),SysUser.class); } - @Override - public List findByIds(Collection collection) { - return null; - } + @Override public SysUser save(SysUser sysUser) { return MapstructUtils.convert(userRepository.save(MapstructUtils.convert(sysUser,TbSysUser.class)),SysUser.class); } - @Override - public void batchSave(List list) { - - } - - @Override - public void deleteById(Long aLong) { - - } @Override public void deleteByIds(Collection collection) { userRepository.deleteAllByIdInBatch(collection); } - @Override - public long count() { - return userRepository.count(); - } - @Override - public List findAll() { - return null; - } - - @Override - public Paging findAll(PageRequest pageRequest) { - return null; - } @Override public List findAllByCondition(SysUser user) { @@ -145,8 +135,4 @@ public class SysUserDataImpl implements ISysUserData { return MapstructUtils.convert(users, SysUser.class); } - @Override - public SysUser findOneByCondition(SysUser sysUser) { - return null; - } } diff --git a/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/SysUserPostDataImpl.java b/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/SysUserPostDataImpl.java index b67c97e7..07f31a23 100644 --- a/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/SysUserPostDataImpl.java +++ b/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/SysUserPostDataImpl.java @@ -1,11 +1,13 @@ package cc.iotkit.data.service; import cc.iotkit.common.utils.MapstructUtils; +import cc.iotkit.data.dao.IJPACommData; import cc.iotkit.data.dao.SysUserPostRepository; import cc.iotkit.data.model.TbSysUserPost; import cc.iotkit.data.system.ISysUserPostData; import cc.iotkit.model.system.SysUserPost; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.jpa.repository.JpaRepository; import java.util.List; @@ -13,7 +15,7 @@ import java.util.List; * @Author:tfd * @Date:2023/5/30 17:04 */ -public class SysUserPostDataImpl implements ISysUserPostData { +public class SysUserPostDataImpl implements ISysUserPostData, IJPACommData { @Autowired private SysUserPostRepository sysUserPostRepository; @@ -23,6 +25,16 @@ public class SysUserPostDataImpl implements ISysUserPostData { return sysUserPostRepository.deleteAllByUserId(userId); } + @Override + public JpaRepository getBaseRepository() { + return sysUserPostRepository; + } + + @Override + public Class getJpaRepositoryClass() { + return TbSysUserPost.class; + } + @Override public void batchSave(List data) { sysUserPostRepository.saveAll(MapstructUtils.convert(data, TbSysUserPost.class)); diff --git a/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/SysUserRoleDataImpl.java b/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/SysUserRoleDataImpl.java index 8b9c8391..d216a6db 100644 --- a/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/SysUserRoleDataImpl.java +++ b/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/SysUserRoleDataImpl.java @@ -1,6 +1,7 @@ package cc.iotkit.data.service; import cc.iotkit.common.utils.MapstructUtils; +import cc.iotkit.data.dao.IJPACommData; import cc.iotkit.data.dao.SysUserRoleRepository; import cc.iotkit.data.model.TbSysUserRole; import cc.iotkit.data.system.ISysUserRoleData; @@ -9,6 +10,7 @@ import cc.iotkit.model.system.SysUserRole; import com.querydsl.jpa.impl.JPAQueryFactory; import lombok.RequiredArgsConstructor; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.jpa.repository.JpaRepository; import java.util.List; import java.util.Objects; @@ -22,11 +24,21 @@ import static cc.iotkit.data.model.QTbSysUserRole.tbSysUserRole; * @Date:2023/5/30 16:36 */ @RequiredArgsConstructor -public class SysUserRoleDataImpl implements ISysUserRoleData { +public class SysUserRoleDataImpl implements ISysUserRoleData, IJPACommData { @Autowired private final SysUserRoleRepository sysUserRoleRepository; private final JPAQueryFactory jpaQueryFactory; + @Override + public JpaRepository getBaseRepository() { + return sysUserRoleRepository; + } + + @Override + public Class getJpaRepositoryClass() { + return TbSysUserRole.class; + } + @Override public int deleteByUserId(Long userId) { return sysUserRoleRepository.deleteAllByUserId(userId); @@ -49,4 +61,5 @@ public class SysUserRoleDataImpl implements ISysUserRoleData { .and(tbSysUserRole.userId.in(userIds)) .build()).execute(); } + } diff --git a/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/TaskInfoDataImpl.java b/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/TaskInfoDataImpl.java index bd2d37a2..0c83f39b 100644 --- a/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/TaskInfoDataImpl.java +++ b/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/TaskInfoDataImpl.java @@ -10,6 +10,7 @@ package cc.iotkit.data.service; import cc.iotkit.common.api.PageRequest; +import cc.iotkit.data.dao.IJPACommData; import cc.iotkit.data.manager.ITaskInfoData; import cc.iotkit.data.dao.TaskInfoRepository; import cc.iotkit.data.model.TbTaskInfo; @@ -21,6 +22,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Primary; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; +import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Service; import java.util.Collection; @@ -29,7 +31,7 @@ import java.util.UUID; @Primary @Service -public class TaskInfoDataImpl implements ITaskInfoData { +public class TaskInfoDataImpl implements ITaskInfoData, IJPACommData { @Autowired private TaskInfoRepository taskInfoRepository; @@ -52,15 +54,22 @@ public class TaskInfoDataImpl implements ITaskInfoData { return 0; } + @Override + public JpaRepository getBaseRepository() { + return taskInfoRepository; + } + + @Override + public Class getJpaRepositoryClass() { + return TbTaskInfo.class; + } + @Override public TaskInfo findById(String s) { return TaskInfoMapper.toDtoFix(taskInfoRepository.findById(s).orElse(null)); } - @Override - public List findByIds(Collection id) { - return null; - } + @Override public TaskInfo save(TaskInfo data) { @@ -72,47 +81,7 @@ public class TaskInfoDataImpl implements ITaskInfoData { return data; } - @Override - public void batchSave(List data) { - } - - @Override - public void deleteById(String s) { - taskInfoRepository.deleteById(s); - } - - @Override - public void deleteByIds(Collection strings) { - - } - - - - @Override - public long count() { - return taskInfoRepository.count(); - } - - @Override - public List findAll() { - return TaskInfoMapper.toDto(taskInfoRepository.findAll()); - } - - @Override - public Paging findAll(PageRequest pageRequest) { - return null; - } - - @Override - public List findAllByCondition(TaskInfo data) { - return null; - } - - @Override - public TaskInfo findOneByCondition(TaskInfo data) { - return null; - } diff --git a/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/ThingModelDataImpl.java b/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/ThingModelDataImpl.java index a950e466..cb1f258c 100644 --- a/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/ThingModelDataImpl.java +++ b/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/ThingModelDataImpl.java @@ -10,14 +10,17 @@ package cc.iotkit.data.service; import cc.iotkit.common.api.PageRequest; +import cc.iotkit.data.dao.IJPACommData; import cc.iotkit.data.manager.IThingModelData; import cc.iotkit.data.dao.ThingModelRepository; +import cc.iotkit.data.model.TbThingModel; import cc.iotkit.data.service.convert.ThingModelMapper; import cc.iotkit.common.api.Paging; import cc.iotkit.model.product.ThingModel; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Primary; +import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Service; import java.util.Collection; @@ -26,20 +29,26 @@ import java.util.UUID; @Primary @Service -public class ThingModelDataImpl implements IThingModelData { +public class ThingModelDataImpl implements IThingModelData, IJPACommData { @Autowired private ThingModelRepository thingModelRepository; + @Override + public JpaRepository getBaseRepository() { + return thingModelRepository; + } + + @Override + public Class getJpaRepositoryClass() { + return TbThingModel.class; + } + @Override public ThingModel findById(String s) { return ThingModelMapper.toDtoFix(thingModelRepository.findById(s).orElse(null)); } - @Override - public List findByIds(Collection id) { - return null; - } @Override public ThingModel save(ThingModel data) { @@ -50,46 +59,14 @@ public class ThingModelDataImpl implements IThingModelData { return data; } - @Override - public void batchSave(List data) { - } @Override public void deleteById(String s) { thingModelRepository.deleteById(s); } - @Override - public void deleteByIds(Collection strings) { - } - - - @Override - public long count() { - return 0; - } - - @Override - public List findAll() { - return null; - } - - @Override - public Paging findAll(PageRequest pageRequest) { - return null; - } - - @Override - public List findAllByCondition(ThingModel data) { - return null; - } - - @Override - public ThingModel findOneByCondition(ThingModel data) { - return null; - } } diff --git a/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/UserInfoDataImpl.java b/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/UserInfoDataImpl.java index cc6d2ba0..a1109230 100644 --- a/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/UserInfoDataImpl.java +++ b/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/UserInfoDataImpl.java @@ -10,6 +10,7 @@ package cc.iotkit.data.service; import cc.iotkit.common.api.PageRequest; +import cc.iotkit.data.dao.IJPACommData; import cc.iotkit.data.manager.IUserInfoData; import cc.iotkit.data.dao.UserInfoRepository; import cc.iotkit.data.model.TbUserInfo; @@ -21,6 +22,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Primary; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; +import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Service; import java.util.Collection; @@ -29,7 +31,7 @@ import java.util.UUID; @Primary @Service -public class UserInfoDataImpl implements IUserInfoData { +public class UserInfoDataImpl implements IUserInfoData, IJPACommData { @Autowired private UserInfoRepository userInfoRepository; @@ -49,6 +51,16 @@ public class UserInfoDataImpl implements IUserInfoData { return UserInfoMapper.toDto(userInfoRepository.findByTypeAndOwnerId(type, ownerId)); } + @Override + public JpaRepository getBaseRepository() { + return userInfoRepository; + } + + @Override + public Class getJpaRepositoryClass() { + return TbUserInfo.class; + } + @Override public UserInfo findById(String s) { return UserInfoMapper.toDtoFix(userInfoRepository.findById(s).orElse(null)); @@ -69,46 +81,20 @@ public class UserInfoDataImpl implements IUserInfoData { return data; } - @Override - public void batchSave(List data) { - - } @Override public void deleteById(String s) { userInfoRepository.deleteById(s); } - @Override - public void deleteByIds(Collection strings) { - } - - - @Override - public long count() { - return userInfoRepository.count(); - } @Override public List findAll() { return UserInfoMapper.toDto(userInfoRepository.findAll()); } - @Override - public Paging findAll(PageRequest pageRequest) { - return null; - } - @Override - public List findAllByCondition(UserInfo data) { - return null; - } - - @Override - public UserInfo findOneByCondition(UserInfo data) { - return null; - } } diff --git a/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/VirtualDeviceDataImpl.java b/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/VirtualDeviceDataImpl.java index cd8b327b..e9558eb7 100644 --- a/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/VirtualDeviceDataImpl.java +++ b/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/VirtualDeviceDataImpl.java @@ -10,6 +10,7 @@ package cc.iotkit.data.service; import cc.iotkit.common.api.PageRequest; +import cc.iotkit.data.dao.IJPACommData; import cc.iotkit.data.manager.IVirtualDeviceData; import cc.iotkit.data.dao.VirtualDeviceMappingRepository; import cc.iotkit.data.dao.VirtualDeviceRepository; @@ -24,6 +25,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Primary; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; +import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -33,7 +35,7 @@ import java.util.stream.Collectors; @Primary @Service -public class VirtualDeviceDataImpl implements IVirtualDeviceData { +public class VirtualDeviceDataImpl implements IVirtualDeviceData, IJPACommData { @Autowired private VirtualDeviceRepository virtualDeviceRepository; @@ -41,6 +43,17 @@ public class VirtualDeviceDataImpl implements IVirtualDeviceData { @Autowired private VirtualDeviceMappingRepository virtualDeviceMappingRepository; + + @Override + public JpaRepository getBaseRepository() { + return virtualDeviceRepository; + } + + @Override + public Class getJpaRepositoryClass() { + return TbVirtualDevice.class; + } + @Override public List findByUid(String uid) { return VirtualDeviceMapper.toDto(virtualDeviceRepository.findByUid(uid)); @@ -81,10 +94,6 @@ public class VirtualDeviceDataImpl implements IVirtualDeviceData { return dto; } - @Override - public List findByIds(Collection id) { - return null; - } private List getVirtualDeviceIds(String virtualId) { List deviceMappings = virtualDeviceMappingRepository.findByVirtualId(virtualId); @@ -112,10 +121,6 @@ public class VirtualDeviceDataImpl implements IVirtualDeviceData { return data; } - @Override - public void batchSave(List data) { - - } @Override @Transactional @@ -124,36 +129,12 @@ public class VirtualDeviceDataImpl implements IVirtualDeviceData { virtualDeviceMappingRepository.deleteByVirtualId(s); } - @Override - public void deleteByIds(Collection strings) { - - } - - - @Override - public long count() { - return virtualDeviceRepository.count(); - } @Override public List findAll() { return VirtualDeviceMapper.toDto(virtualDeviceRepository.findAll()); } - @Override - public Paging findAll(PageRequest pageRequest) { - return null; - } - - @Override - public List findAllByCondition(VirtualDevice data) { - return null; - } - - @Override - public VirtualDevice findOneByCondition(VirtualDevice data) { - return null; - } } diff --git a/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/util/PageBuilder.java b/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/util/PageBuilder.java index 73032394..e12d8e13 100644 --- a/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/util/PageBuilder.java +++ b/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/util/PageBuilder.java @@ -8,6 +8,7 @@ import cc.iotkit.data.model.TbSysConfig; import cc.iotkit.model.product.Product; import cc.iotkit.model.system.SysConfig; import cn.hutool.core.collection.CollUtil; +import com.querydsl.core.types.OrderSpecifier; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Sort; @@ -64,12 +65,16 @@ public class PageBuilder { return orders; } - public static Paging toPaging(Page all, Class clz) { + public static Paging toPaging(Page all, Class clz) { return new Paging<>(all.getTotalElements(), MapstructUtils.convert(all.getContent(), clz)); } - public static Paging toPaging(Page all) { + public static Paging toPaging(Page all) { return new Paging<>(all.getTotalElements(), all.getContent()); } + + public static Pageable buildPageable(int page, int size) { + return org.springframework.data.domain.PageRequest.of(page, size); + } } diff --git a/iot-module/iot-system/src/main/java/cc/iotkit/system/controller/SysRoleController.java b/iot-module/iot-system/src/main/java/cc/iotkit/system/controller/SysRoleController.java index 33961102..26420140 100644 --- a/iot-module/iot-system/src/main/java/cc/iotkit/system/controller/SysRoleController.java +++ b/iot-module/iot-system/src/main/java/cc/iotkit/system/controller/SysRoleController.java @@ -6,7 +6,8 @@ import cc.iotkit.common.excel.utils.ExcelUtil; import cc.iotkit.common.log.annotation.Log; import cc.iotkit.common.log.enums.BusinessType; import cc.iotkit.common.web.core.BaseController; -import cc.iotkit.system.dto.SysUserRole; + +import cc.iotkit.model.system.SysUserRole; import cc.iotkit.system.dto.bo.SysDeptBo; import cc.iotkit.system.dto.bo.SysRoleBo; import cc.iotkit.system.dto.bo.SysUserBo;