diff --git a/continew-admin-monitor/src/main/resources/mapper/LogMapper.xml b/continew-admin-monitor/src/main/resources/mapper/LogMapper.xml index d482d5e4..eb69f249 100644 --- a/continew-admin-monitor/src/main/resources/mapper/LogMapper.xml +++ b/continew-admin-monitor/src/main/resources/mapper/LogMapper.xml @@ -5,8 +5,8 @@ SELECT (SELECT COUNT(*) FROM sys_log) AS pvCount, (SELECT COUNT(DISTINCT ip) FROM sys_log) AS ipCount, - (SELECT COUNT(*) FROM sys_log WHERE DATE(create_time) = CURDATE()) AS todayPvCount, - (SELECT COUNT(*) FROM sys_log WHERE DATE(create_time) = DATE_SUB(CURDATE(), INTERVAL 1 DAY)) AS yesterdayPvCount + (SELECT COUNT(*) FROM sys_log WHERE DATE(create_time) = CURRENT_DATE) AS todayPvCount, + (SELECT COUNT(*) FROM sys_log WHERE DATE(create_time) = CURRENT_DATE - 1) AS yesterdayPvCount \ No newline at end of file diff --git a/continew-admin-system/src/main/java/top/charles7c/continew/admin/system/service/impl/DeptServiceImpl.java b/continew-admin-system/src/main/java/top/charles7c/continew/admin/system/service/impl/DeptServiceImpl.java index 10bc4364..776f2654 100644 --- a/continew-admin-system/src/main/java/top/charles7c/continew/admin/system/service/impl/DeptServiceImpl.java +++ b/continew-admin-system/src/main/java/top/charles7c/continew/admin/system/service/impl/DeptServiceImpl.java @@ -18,6 +18,8 @@ package top.charles7c.continew.admin.system.service.impl; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.util.ObjectUtil; +import cn.hutool.extra.spring.SpringUtil; +import com.baomidou.dynamic.datasource.DynamicRoutingDataSource; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import top.charles7c.continew.admin.common.enums.DisEnableStatusEnum; @@ -31,6 +33,8 @@ import top.charles7c.continew.admin.system.service.DeptService; import top.charles7c.continew.admin.system.service.RoleDeptService; import top.charles7c.continew.admin.system.service.UserService; import top.charles7c.continew.starter.core.util.validate.CheckUtils; +import top.charles7c.continew.starter.data.core.enums.DatabaseType; +import top.charles7c.continew.starter.data.core.util.MetaUtils; import top.charles7c.continew.starter.extension.crud.service.impl.BaseServiceImpl; import java.util.ArrayList; @@ -155,7 +159,8 @@ public class DeptServiceImpl extends BaseServiceImpl listChildren(Long id) { - return baseMapper.lambdaQuery().apply("find_in_set(%s, ancestors)".formatted(id)).list(); + DatabaseType databaseType = MetaUtils.getDatabaseTypeOrDefault(SpringUtil.getBean(DynamicRoutingDataSource.class), DatabaseType.MYSQL); + return baseMapper.lambdaQuery().apply(databaseType.findInSet(id, "ancestors")).list(); } /** @@ -169,8 +174,9 @@ public class DeptServiceImpl extends BaseServiceImpl baseMapper.lambdaQuery().apply("find_in_set(%s, ancestors)".formatted(id)).count()) + .mapToLong(id -> baseMapper.lambdaQuery().apply(databaseType.findInSet(id, "ancestors")).count()) .sum(); } diff --git a/continew-admin-webapi/src/main/resources/db/changelog/postgresql/continew-admin_data.sql b/continew-admin-webapi/src/main/resources/db/changelog/postgresql/continew-admin_data.sql index c4355767..20d11367 100644 --- a/continew-admin-webapi/src/main/resources/db/changelog/postgresql/continew-admin_data.sql +++ b/continew-admin-webapi/src/main/resources/db/changelog/postgresql/continew-admin_data.sql @@ -72,12 +72,12 @@ INSERT INTO "sys_dept" VALUES (1, 'Xxx科技有限公司', 0, '0', '系统初始部门', 1, 1, true, 1, NOW(), NULL, NULL), (547887852587843590, '天津总部', 1, '0,1', NULL, 1, 1, false, 1, NOW(), NULL, NULL), -(547888008188133385, '研发部', 547887852587843590, '0,1,2', NULL, 1, 1, false, 1, NOW(), NULL, NULL), -(547888460711591948, 'UI部', 547887852587843590, '0,1,2', NULL, 2, 1, false, 1, NOW(), NULL, NULL), -(547888483713155087, '测试部', 547887852587843590, '0,1,2', NULL, 3, 1, false, 1, NOW(), NULL, NULL), -(547888505959743506, '运维部', 547887852587843590, '0,1,2', NULL, 4, 1, false, 1, NOW(), NULL, NULL), -(547888556819873814, '研发一组', 547888008188133385, '0,1,2,3', NULL, 1, 1, false, 1, NOW(), NULL, NULL), -(547888580614160409, '研发二组', 547888008188133385, '0,1,2,3', NULL, 2, 2, false, 1, NOW(), NULL, NULL); +(547888008188133385, '研发部', 547887852587843590, '0,1,547887852587843590', NULL, 1, 1, false, 1, NOW(), NULL, NULL), +(547888460711591948, 'UI部', 547887852587843590, '0,1,547887852587843590', NULL, 2, 1, false, 1, NOW(), NULL, NULL), +(547888483713155087, '测试部', 547887852587843590, '0,1,547887852587843590', NULL, 3, 1, false, 1, NOW(), NULL, NULL), +(547888505959743506, '运维部', 547887852587843590, '0,1,547887852587843590', NULL, 4, 1, false, 1, NOW(), NULL, NULL), +(547888556819873814, '研发一组', 547888008188133385, '0,1,547887852587843590,547888008188133385', NULL, 1, 1, false, 1, NOW(), NULL, NULL), +(547888580614160409, '研发二组', 547888008188133385, '0,1,547887852587843590,547888008188133385', NULL, 2, 2, false, 1, NOW(), NULL, NULL); -- 初始化默认角色 INSERT INTO "sys_role"