diff --git a/iot-common/iot-common-dao/iot-data-service/src/main/java/cc/iotkit/data/system/ISysUserRoleData.java b/iot-common/iot-common-dao/iot-data-service/src/main/java/cc/iotkit/data/system/ISysUserRoleData.java index 8f4dfceb..7aac0886 100644 --- a/iot-common/iot-common-dao/iot-data-service/src/main/java/cc/iotkit/data/system/ISysUserRoleData.java +++ b/iot-common/iot-common-dao/iot-data-service/src/main/java/cc/iotkit/data/system/ISysUserRoleData.java @@ -16,4 +16,12 @@ public interface ISysUserRoleData extends ICommonData { * @return 数量 */ int deleteByUserId(Long userId); + + /** + * 通过角色ID查询角色使用数量 + * + * @param roleId 角色ID + * @return 结果 + */ + long countUserRoleByRoleId(Long roleId); } diff --git a/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/.flattened-pom.xml b/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/.flattened-pom.xml index 4f7f9194..8bd30058 100644 --- a/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/.flattened-pom.xml +++ b/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/.flattened-pom.xml @@ -46,6 +46,10 @@ lombok provided + + com.github.biyanwen + jpa-comment-spring-boot-starter + cc.iotkit iot-common-core 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 5cf7e0f4..5c61344a 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 @@ -197,9 +197,8 @@ public class SysMenuDataImpl implements ISysMenuData { @Override public boolean hasChildByMenuId(Long menuId) { - TbSysMenu tbSysMenu = jpaQueryFactory.select(QTbSysMenu.tbSysMenu).from(QTbSysMenu.tbSysMenu).where(PredicateBuilder.instance() - .and(QTbSysMenu.tbSysMenu.parentId.eq(menuId)) - .build()).fetchOne(); + TbSysMenu tbSysMenu = jpaQueryFactory.select(QTbSysMenu.tbSysMenu).from(QTbSysMenu.tbSysMenu) + .where(QTbSysMenu.tbSysMenu.parentId.eq(menuId)).fetchOne(); return Objects.nonNull(tbSysMenu); } 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 7de1a8c6..c6dcd7aa 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 @@ -4,6 +4,8 @@ import cc.iotkit.data.dao.SysUserRoleRepository; import cc.iotkit.data.system.ISysUserRoleData; import org.springframework.beans.factory.annotation.Autowired; +import static cc.iotkit.data.model.QTbSysUserRole.tbSysUserRole; + /** * @Author:tfd * @Date:2023/5/30 16:36 @@ -16,4 +18,9 @@ public class SysUserRoleDataImpl implements ISysUserRoleData { public int deleteByUserId(Long userId) { return sysUserRoleRepository.deleteAllByUserId(userId); } + + @Override + public long countUserRoleByRoleId(Long roleId) { + return sysUserRoleRepository.count(tbSysUserRole.roleId.eq(roleId)); + } }