serv-模块、权限、成就
This commit is contained in:
@@ -93,116 +93,118 @@ CREATE TABLE `tb_user_achievement_progress` (
|
|||||||
-- 学习时长类成就
|
-- 学习时长类成就
|
||||||
-- =============================================
|
-- =============================================
|
||||||
|
|
||||||
INSERT INTO `tb_achievement` (`id`, `achievement_id`, `name`, `description`, `type`, `level`, `condition_type`, `condition_value`, `points`, `order_num`, `deleted`) VALUES
|
INSERT INTO `tb_achievement` (`id`, `achievement_id`, `name`,`icon`, `description`, `type`, `level`, `condition_type`, `condition_value`, `points`, `order_num`, `deleted`) VALUES
|
||||||
('ACH001', 'learning_time_bronze', '初学者', '累计学习时长达到10小时', 1, 1, 1, 600, 10, 1, 0),
|
('ACH001', 'learning_time_l1', '初学者', 'v1-icon.svg', '累计学习时长达到10小时', 1, 1, 1, 10*60*60, 10, 1, 0),
|
||||||
('ACH002', 'learning_time_silver', '勤学者', '累计学习时长达到50小时', 1, 2, 1, 3000, 50, 2, 0),
|
('ACH002', 'learning_time_l2', '勤学者', 'v2-icon.svg', '累计学习时长达到50小时', 1, 2, 1, 50*60*60, 50, 2, 0),
|
||||||
('ACH003', 'learning_time_gold', '学习达人', '累计学习时长达到100小时', 1, 3, 1, 6000, 100, 3, 0),
|
('ACH003', 'learning_time_l3', '学习达人', 'v3-icon.svg', '累计学习时长达到100小时', 1, 3, 1, 100*60*60, 100, 3, 0),
|
||||||
('ACH004', 'learning_time_diamond', '学习狂人', '累计学习时长达到500小时', 1, 4, 1, 30000, 500, 4, 0);
|
('ACH004', 'learning_time_l4', '学习狂人', 'v4-icon.svg', '累计学习时长达到500小时', 1, 4, 1, 500*60*60, 500, 4, 0),
|
||||||
|
('ACH005', 'learning_time_l5', '学习大师', 'v5-icon.svg', '累计学习时长达到1000小时', 1, 5, 1, 1000*60*60, 1000, 5, 0),
|
||||||
|
('ACH006', 'learning_time_l6', '学习宗师', 'v6-icon.svg', '累计学习时长达到2000小时', 1, 6, 1, 2000*60*60, 2000, 6, 0);
|
||||||
|
|
||||||
-- =============================================
|
-- -- =============================================
|
||||||
-- 课程完成类成就
|
-- -- 课程完成类成就
|
||||||
-- =============================================
|
-- -- =============================================
|
||||||
|
|
||||||
INSERT INTO `tb_achievement` (`id`, `achievement_id`, `name`, `description`, `type`, `level`, `condition_type`, `condition_value`, `points`, `order_num`, `deleted`) VALUES
|
-- INSERT INTO `tb_achievement` (`id`, `achievement_id`, `name`, `description`, `type`, `level`, `condition_type`, `condition_value`, `points`, `order_num`, `deleted`) VALUES
|
||||||
('ACH005', 'course_complete_bronze', '课程新手', '完成1门课程', 1, 1, 3, 1, 10, 5, 0),
|
-- ('ACH005', 'course_complete_bronze', '课程新手', '完成1门课程', 1, 1, 3, 1, 10, 5, 0),
|
||||||
('ACH006', 'course_complete_silver', '课程能手', '完成5门课程', 1, 2, 3, 5, 50, 6, 0),
|
-- ('ACH006', 'course_complete_silver', '课程能手', '完成5门课程', 1, 2, 3, 5, 50, 6, 0),
|
||||||
('ACH007', 'course_complete_gold', '课程专家', '完成20门课程', 1, 3, 3, 20, 200, 7, 0),
|
-- ('ACH007', 'course_complete_gold', '课程专家', '完成20门课程', 1, 3, 3, 20, 200, 7, 0),
|
||||||
('ACH008', 'course_complete_diamond', '课程大师', '完成50门课程', 1, 4, 3, 50, 500, 8, 0);
|
-- ('ACH008', 'course_complete_diamond', '课程大师', '完成50门课程', 1, 4, 3, 50, 500, 8, 0);
|
||||||
|
|
||||||
-- =============================================
|
-- -- =============================================
|
||||||
-- 资源浏览类成就
|
-- -- 资源浏览类成就
|
||||||
-- =============================================
|
-- -- =============================================
|
||||||
|
|
||||||
INSERT INTO `tb_achievement` (`id`, `achievement_id`, `name`, `description`, `type`, `level`, `condition_type`, `condition_value`, `points`, `order_num`, `deleted`) VALUES
|
-- INSERT INTO `tb_achievement` (`id`, `achievement_id`, `name`, `description`, `type`, `level`, `condition_type`, `condition_value`, `points`, `order_num`, `deleted`) VALUES
|
||||||
('ACH009', 'resource_view_bronze', '好奇宝宝', '浏览10个资源', 1, 1, 2, 10, 5, 9, 0),
|
-- ('ACH009', 'resource_view_bronze', '好奇宝宝', '浏览10个资源', 1, 1, 2, 10, 5, 9, 0),
|
||||||
('ACH010', 'resource_view_silver', '探索者', '浏览50个资源', 1, 2, 2, 50, 25, 10, 0),
|
-- ('ACH010', 'resource_view_silver', '探索者', '浏览50个资源', 1, 2, 2, 50, 25, 10, 0),
|
||||||
('ACH011', 'resource_view_gold', '资源猎人', '浏览200个资源', 1, 3, 2, 200, 100, 11, 0),
|
-- ('ACH011', 'resource_view_gold', '资源猎人', '浏览200个资源', 1, 3, 2, 200, 100, 11, 0),
|
||||||
('ACH012', 'resource_view_diamond', '知识探险家', '浏览500个资源', 1, 4, 2, 500, 250, 12, 0);
|
-- ('ACH012', 'resource_view_diamond', '知识探险家', '浏览500个资源', 1, 4, 2, 500, 250, 12, 0);
|
||||||
|
|
||||||
-- =============================================
|
-- -- =============================================
|
||||||
-- 连续登录类成就
|
-- -- 连续登录类成就
|
||||||
-- =============================================
|
-- -- =============================================
|
||||||
|
|
||||||
INSERT INTO `tb_achievement` (`id`, `achievement_id`, `name`, `description`, `type`, `level`, `condition_type`, `condition_value`, `points`, `order_num`, `deleted`) VALUES
|
-- INSERT INTO `tb_achievement` (`id`, `achievement_id`, `name`, `description`, `type`, `level`, `condition_type`, `condition_value`, `points`, `order_num`, `deleted`) VALUES
|
||||||
('ACH013', 'login_streak_bronze', '每日一练', '连续登录7天', 1, 1, 4, 7, 20, 13, 0),
|
-- ('ACH013', 'login_streak_bronze', '每日一练', '连续登录7天', 1, 1, 4, 7, 20, 13, 0),
|
||||||
('ACH014', 'login_streak_silver', '坚持不懈', '连续登录30天', 1, 2, 4, 30, 100, 14, 0),
|
-- ('ACH014', 'login_streak_silver', '坚持不懈', '连续登录30天', 1, 2, 4, 30, 100, 14, 0),
|
||||||
('ACH015', 'login_streak_gold', '毅力之王', '连续登录100天', 1, 3, 4, 100, 500, 15, 0),
|
-- ('ACH015', 'login_streak_gold', '毅力之王', '连续登录100天', 1, 3, 4, 100, 500, 15, 0),
|
||||||
('ACH016', 'login_streak_diamond', '永不放弃', '连续登录365天', 1, 4, 4, 365, 2000, 16, 0);
|
-- ('ACH016', 'login_streak_diamond', '永不放弃', '连续登录365天', 1, 4, 4, 365, 2000, 16, 0);
|
||||||
|
|
||||||
-- =============================================
|
-- -- =============================================
|
||||||
-- 任务完成类成就
|
-- -- 任务完成类成就
|
||||||
-- =============================================
|
-- -- =============================================
|
||||||
|
|
||||||
INSERT INTO `tb_achievement` (`id`, `achievement_id`, `name`, `description`, `type`, `level`, `condition_type`, `condition_value`, `points`, `order_num`, `deleted`) VALUES
|
-- INSERT INTO `tb_achievement` (`id`, `achievement_id`, `name`, `description`, `type`, `level`, `condition_type`, `condition_value`, `points`, `order_num`, `deleted`) VALUES
|
||||||
('ACH017', 'task_complete_bronze', '任务新兵', '完成5个任务', 1, 1, 6, 5, 15, 17, 0),
|
-- ('ACH017', 'task_complete_bronze', '任务新兵', '完成5个任务', 1, 1, 6, 5, 15, 17, 0),
|
||||||
('ACH018', 'task_complete_silver', '任务达人', '完成20个任务', 1, 2, 6, 20, 60, 18, 0),
|
-- ('ACH018', 'task_complete_silver', '任务达人', '完成20个任务', 1, 2, 6, 20, 60, 18, 0),
|
||||||
('ACH019', 'task_complete_gold', '任务专家', '完成50个任务', 1, 3, 6, 50, 150, 19, 0),
|
-- ('ACH019', 'task_complete_gold', '任务专家', '完成50个任务', 1, 3, 6, 50, 150, 19, 0),
|
||||||
('ACH020', 'task_complete_diamond', '任务大师', '完成100个任务', 1, 4, 6, 100, 300, 20, 0);
|
-- ('ACH020', 'task_complete_diamond', '任务大师', '完成100个任务', 1, 4, 6, 100, 300, 20, 0);
|
||||||
|
|
||||||
-- =============================================
|
-- -- =============================================
|
||||||
-- 收藏资源类成就
|
-- -- 收藏资源类成就
|
||||||
-- =============================================
|
-- -- =============================================
|
||||||
|
|
||||||
INSERT INTO `tb_achievement` (`id`, `achievement_id`, `name`, `description`, `type`, `level`, `condition_type`, `condition_value`, `points`, `order_num`, `deleted`) VALUES
|
-- INSERT INTO `tb_achievement` (`id`, `achievement_id`, `name`, `description`, `type`, `level`, `condition_type`, `condition_value`, `points`, `order_num`, `deleted`) VALUES
|
||||||
('ACH021', 'collect_bronze', '收藏家', '收藏10个资源', 1, 1, 5, 10, 10, 21, 0),
|
-- ('ACH021', 'collect_bronze', '收藏家', '收藏10个资源', 1, 1, 5, 10, 10, 21, 0),
|
||||||
('ACH022', 'collect_silver', '资料库', '收藏50个资源', 1, 2, 5, 50, 50, 22, 0),
|
-- ('ACH022', 'collect_silver', '资料库', '收藏50个资源', 1, 2, 5, 50, 50, 22, 0),
|
||||||
('ACH023', 'collect_gold', '知识宝库', '收藏100个资源', 1, 3, 5, 100, 100, 23, 0),
|
-- ('ACH023', 'collect_gold', '知识宝库', '收藏100个资源', 1, 3, 5, 100, 100, 23, 0),
|
||||||
('ACH024', 'collect_diamond', '珍宝收藏家', '收藏200个资源', 1, 4, 5, 200, 200, 24, 0);
|
-- ('ACH024', 'collect_diamond', '珍宝收藏家', '收藏200个资源', 1, 4, 5, 200, 200, 24, 0);
|
||||||
|
|
||||||
-- =============================================
|
-- -- =============================================
|
||||||
-- 章节完成类成就
|
-- -- 章节完成类成就
|
||||||
-- =============================================
|
-- -- =============================================
|
||||||
|
|
||||||
INSERT INTO `tb_achievement` (`id`, `achievement_id`, `name`, `description`, `type`, `level`, `condition_type`, `condition_value`, `points`, `order_num`, `deleted`) VALUES
|
-- INSERT INTO `tb_achievement` (`id`, `achievement_id`, `name`, `description`, `type`, `level`, `condition_type`, `condition_value`, `points`, `order_num`, `deleted`) VALUES
|
||||||
('ACH025', 'chapter_complete_bronze', '章节探索者', '完成10个章节', 1, 1, 9, 10, 20, 25, 0),
|
-- ('ACH025', 'chapter_complete_bronze', '章节探索者', '完成10个章节', 1, 1, 9, 10, 20, 25, 0),
|
||||||
('ACH026', 'chapter_complete_silver', '章节达人', '完成50个章节', 1, 2, 9, 50, 100, 26, 0),
|
-- ('ACH026', 'chapter_complete_silver', '章节达人', '完成50个章节', 1, 2, 9, 50, 100, 26, 0),
|
||||||
('ACH027', 'chapter_complete_gold', '章节专家', '完成100个章节', 1, 3, 9, 100, 200, 27, 0);
|
-- ('ACH027', 'chapter_complete_gold', '章节专家', '完成100个章节', 1, 3, 9, 100, 200, 27, 0);
|
||||||
|
|
||||||
-- =============================================
|
-- -- =============================================
|
||||||
-- 累计登录类成就
|
-- -- 累计登录类成就
|
||||||
-- =============================================
|
-- -- =============================================
|
||||||
|
|
||||||
INSERT INTO `tb_achievement` (`id`, `achievement_id`, `name`, `description`, `type`, `level`, `condition_type`, `condition_value`, `points`, `order_num`, `deleted`) VALUES
|
-- INSERT INTO `tb_achievement` (`id`, `achievement_id`, `name`, `description`, `type`, `level`, `condition_type`, `condition_value`, `points`, `order_num`, `deleted`) VALUES
|
||||||
('ACH028', 'total_login_bronze', '常客', '累计登录30天', 1, 1, 10, 30, 30, 28, 0),
|
-- ('ACH028', 'total_login_bronze', '常客', '累计登录30天', 1, 1, 10, 30, 30, 28, 0),
|
||||||
('ACH029', 'total_login_silver', '老朋友', '累计登录100天', 1, 2, 10, 100, 100, 29, 0),
|
-- ('ACH029', 'total_login_silver', '老朋友', '累计登录100天', 1, 2, 10, 100, 100, 29, 0),
|
||||||
('ACH030', 'total_login_gold', '忠实用户', '累计登录365天', 1, 3, 10, 365, 500, 30, 0);
|
-- ('ACH030', 'total_login_gold', '忠实用户', '累计登录365天', 1, 3, 10, 365, 500, 30, 0);
|
||||||
|
|
||||||
-- =============================================
|
-- -- =============================================
|
||||||
-- 数据验证查询
|
-- -- 数据验证查询
|
||||||
-- =============================================
|
-- -- =============================================
|
||||||
|
|
||||||
-- 查询所有成就数量
|
-- -- 查询所有成就数量
|
||||||
SELECT
|
-- SELECT
|
||||||
'成就总数' AS '统计项',
|
-- '成就总数' AS '统计项',
|
||||||
COUNT(*) AS '数量'
|
-- COUNT(*) AS '数量'
|
||||||
FROM tb_achievement
|
-- FROM tb_achievement
|
||||||
WHERE deleted = 0
|
-- WHERE deleted = 0
|
||||||
|
|
||||||
UNION ALL
|
-- UNION ALL
|
||||||
|
|
||||||
-- 按类型统计
|
-- -- 按类型统计
|
||||||
SELECT
|
-- SELECT
|
||||||
CONCAT('类型', type, '成就') AS '统计项',
|
-- CONCAT('类型', type, '成就') AS '统计项',
|
||||||
COUNT(*) AS '数量'
|
-- COUNT(*) AS '数量'
|
||||||
FROM tb_achievement
|
-- FROM tb_achievement
|
||||||
WHERE deleted = 0
|
-- WHERE deleted = 0
|
||||||
GROUP BY type
|
-- GROUP BY type
|
||||||
|
|
||||||
UNION ALL
|
-- UNION ALL
|
||||||
|
|
||||||
-- 按等级统计
|
-- -- 按等级统计
|
||||||
SELECT
|
-- SELECT
|
||||||
CASE level
|
-- CASE level
|
||||||
WHEN 1 THEN '铜牌成就'
|
-- WHEN 1 THEN '铜牌成就'
|
||||||
WHEN 2 THEN '银牌成就'
|
-- WHEN 2 THEN '银牌成就'
|
||||||
WHEN 3 THEN '金牌成就'
|
-- WHEN 3 THEN '金牌成就'
|
||||||
WHEN 4 THEN '钻石成就'
|
-- WHEN 4 THEN '钻石成就'
|
||||||
END AS '统计项',
|
-- END AS '统计项',
|
||||||
COUNT(*) AS '数量'
|
-- COUNT(*) AS '数量'
|
||||||
FROM tb_achievement
|
-- FROM tb_achievement
|
||||||
WHERE deleted = 0
|
-- WHERE deleted = 0
|
||||||
GROUP BY level
|
-- GROUP BY level
|
||||||
ORDER BY '统计项';
|
-- ORDER BY '统计项';
|
||||||
|
|
||||||
-- =============================================
|
-- =============================================
|
||||||
-- 常用查询SQL示例
|
-- 常用查询SQL示例
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ INSERT INTO `tb_sys_permission` (id,permission_id, name, code, description, modu
|
|||||||
('8','perm_news_manage', '新闻管理', 'news:manage', '新闻管理权限', 'module_news', '1', now()),
|
('8','perm_news_manage', '新闻管理', 'news:manage', '新闻管理权限', 'module_news', '1', now()),
|
||||||
('9','perm_news_article_add', '文章添加', 'news:manage', '文章添加权限', 'module_news', '1', now()),
|
('9','perm_news_article_add', '文章添加', 'news:manage', '文章添加权限', 'module_news', '1', now()),
|
||||||
('10','perm_study_manage', '学习管理', 'study:manage', '学习管理权限', 'module_study', '1', now()),
|
('10','perm_study_manage', '学习管理', 'study:manage', '学习管理权限', 'module_study', '1', now()),
|
||||||
|
('10.1','perm_achievement_manage', '成就管理', 'achievement:manage', '成就管理权限', 'module_study', '1', now()),
|
||||||
('11','perm_ai_manage', 'AI管理', 'ai:manage', 'AI管理权限', 'module_ai', '1', now()),
|
('11','perm_ai_manage', 'AI管理', 'ai:manage', 'AI管理权限', 'module_ai', '1', now()),
|
||||||
('12','perm_usercenter_manage', '用户中心管理', 'usercenter:manage', '用户中心管理权限', 'module_usercenter', '1', now()),
|
('12','perm_usercenter_manage', '用户中心管理', 'usercenter:manage', '用户中心管理权限', 'module_usercenter', '1', now()),
|
||||||
('13','perm_file_manage', '文件管理', 'file:manage', '文件管理权限', 'module_file', '1', now());
|
('13','perm_file_manage', '文件管理', 'file:manage', '文件管理权限', 'module_file', '1', now());
|
||||||
@@ -57,6 +58,7 @@ INSERT INTO `tb_sys_role_permission` (id, role_id, permission_id, creator, creat
|
|||||||
('8', 'superadmin', 'perm_news_manage', '1', now()),
|
('8', 'superadmin', 'perm_news_manage', '1', now()),
|
||||||
('9', 'superadmin', 'perm_news_article_add', '1', now()),
|
('9', 'superadmin', 'perm_news_article_add', '1', now()),
|
||||||
('10', 'superadmin', 'perm_study_manage', '1', now()),
|
('10', 'superadmin', 'perm_study_manage', '1', now()),
|
||||||
|
('10.1', 'superadmin', 'perm_achievement_manage', '1', now()),
|
||||||
('11', 'superadmin', 'perm_ai_manage', '1', now()),
|
('11', 'superadmin', 'perm_ai_manage', '1', now()),
|
||||||
('12', 'superadmin', 'perm_usercenter_manage', '1', now()),
|
('12', 'superadmin', 'perm_usercenter_manage', '1', now()),
|
||||||
('13', 'superadmin', 'perm_file_manage', '1', now()),
|
('13', 'superadmin', 'perm_file_manage', '1', now()),
|
||||||
@@ -99,9 +101,8 @@ INSERT INTO `tb_sys_menu` (id, menu_id, name, parent_id, url, component, icon, o
|
|||||||
('2001', 'menu_admin_user', '用户管理', 'menu_sys_manage', '/admin/manage/system/user', 'admin/manage/system/UserManageView', 'el-icon-user', 1, 1, 'NavigationLayout', '1', now()),
|
('2001', 'menu_admin_user', '用户管理', 'menu_sys_manage', '/admin/manage/system/user', 'admin/manage/system/UserManageView', 'el-icon-user', 1, 1, 'NavigationLayout', '1', now()),
|
||||||
('2002', 'menu_admin_dept', '部门管理', 'menu_sys_manage', '/admin/manage/system/dept', 'admin/manage/system/DeptManageView', 'el-icon-office-building', 2, 1, 'NavigationLayout', '1', now()),
|
('2002', 'menu_admin_dept', '部门管理', 'menu_sys_manage', '/admin/manage/system/dept', 'admin/manage/system/DeptManageView', 'el-icon-office-building', 2, 1, 'NavigationLayout', '1', now()),
|
||||||
('2003', 'menu_admin_role', '角色管理', 'menu_sys_manage', '/admin/manage/system/role', 'admin/manage/system/RoleManageView', 'el-icon-user-solid', 3, 1, 'NavigationLayout', '1', now()),
|
('2003', 'menu_admin_role', '角色管理', 'menu_sys_manage', '/admin/manage/system/role', 'admin/manage/system/RoleManageView', 'el-icon-user-solid', 3, 1, 'NavigationLayout', '1', now()),
|
||||||
('2004', 'menu_admin_permission', '权限管理', 'menu_sys_manage', '/admin/manage/system/permission', 'admin/manage/system/PermissionManageView', 'el-icon-key', 4, 1, 'NavigationLayout', '1', now()),
|
('2005', 'menu_admin_menu', '菜单管理', 'menu_sys_manage', '/admin/manage/system/menu', 'admin/manage/system/MenuManageView', 'el-icon-menu', 4, 1, 'NavigationLayout', '1', now()),
|
||||||
('2005', 'menu_admin_menu', '菜单管理', 'menu_sys_manage', '/admin/manage/system/menu', 'admin/manage/system/MenuManageView', 'el-icon-menu', 5, 1, 'NavigationLayout', '1', now()),
|
('2006', 'menu_admin_module', '模块权限管理', 'menu_sys_manage', '/admin/manage/system/module-permission', 'admin/manage/system/ModulePermissionManageView', 'el-icon-s-grid', 5, 1, 'NavigationLayout', '1', now()),
|
||||||
('2006', 'menu_admin_module', '模块管理', 'menu_sys_manage', '/admin/manage/system/module', 'admin/manage/system/ModuleManageView', 'el-icon-s-grid', 6, 1, 'NavigationLayout', '1', now()),
|
|
||||||
|
|
||||||
-- 资源管理
|
-- 资源管理
|
||||||
('3000', 'menu_admin_resource_manage', '资源管理', NULL, '', '', 'el-icon-folder', 3, 1, '', '1', now()),
|
('3000', 'menu_admin_resource_manage', '资源管理', NULL, '', '', 'el-icon-folder', 3, 1, '', '1', now()),
|
||||||
@@ -125,6 +126,7 @@ INSERT INTO `tb_sys_menu` (id, menu_id, name, parent_id, url, component, icon, o
|
|||||||
('5002', 'menu_admin_task_manage', '任务管理', 'menu_admin_study_manage', '/admin/manage/study/task-manage', 'admin/manage/study/TaskManageView', 'el-icon-s-order', 2, 1, 'NavigationLayout', '1', now()),
|
('5002', 'menu_admin_task_manage', '任务管理', 'menu_admin_study_manage', '/admin/manage/study/task-manage', 'admin/manage/study/TaskManageView', 'el-icon-s-order', 2, 1, 'NavigationLayout', '1', now()),
|
||||||
('5003', 'menu_admin_study_records', '学习记录', 'menu_admin_study_manage', '/admin/manage/study/study-records', 'admin/manage/study/StudyRecordsView', 'el-icon-document', 3, 1, 'NavigationLayout', '1', now()),
|
('5003', 'menu_admin_study_records', '学习记录', 'menu_admin_study_manage', '/admin/manage/study/study-records', 'admin/manage/study/StudyRecordsView', 'el-icon-document', 3, 1, 'NavigationLayout', '1', now()),
|
||||||
('5004', 'menu_admin_course_manage', '课程管理', 'menu_admin_study_manage', '/admin/manage/study/course', 'admin/manage/study/CourseManagementView', 'el-icon-video-play', 4, 1, 'NavigationLayout', '1', now()),
|
('5004', 'menu_admin_course_manage', '课程管理', 'menu_admin_study_manage', '/admin/manage/study/course', 'admin/manage/study/CourseManagementView', 'el-icon-video-play', 4, 1, 'NavigationLayout', '1', now()),
|
||||||
|
('5005', 'menu_admin_achievement_manage', '成就管理', 'menu_admin_study_manage', '/admin/manage/study/achievement', 'admin/manage/achievement/AchievementManagementView', 'el-icon-trophy', 5, 1, 'NavigationLayout', '1', now()),
|
||||||
-- 智能体管理
|
-- 智能体管理
|
||||||
('6000', 'menu_admin_ai_manage', '智能体管理', NULL, '', '', 'el-icon-cpu', 6, 1, '', '1', now()),
|
('6000', 'menu_admin_ai_manage', '智能体管理', NULL, '', '', 'el-icon-cpu', 6, 1, '', '1', now()),
|
||||||
('6001', 'menu_admin_ai', 'AI管理', 'menu_admin_ai_manage', '/admin/manage/ai/ai', 'admin/manage/ai/AIManagementView', 'el-icon-cpu', 1, 1, 'NavigationLayout', '1', now()),
|
('6001', 'menu_admin_ai', 'AI管理', 'menu_admin_ai_manage', '/admin/manage/ai/ai', 'admin/manage/ai/AIManagementView', 'el-icon-cpu', 1, 1, 'NavigationLayout', '1', now()),
|
||||||
@@ -168,9 +170,9 @@ INSERT INTO `tb_sys_menu_permission` (id, permission_id, menu_id, creator, creat
|
|||||||
('203', 'perm_system_user_manage', 'menu_admin_user', '1', now()),
|
('203', 'perm_system_user_manage', 'menu_admin_user', '1', now()),
|
||||||
('204', 'perm_system_dept_manage', 'menu_admin_dept', '1', now()),
|
('204', 'perm_system_dept_manage', 'menu_admin_dept', '1', now()),
|
||||||
('205', 'perm_system_role_manage', 'menu_admin_role', '1', now()),
|
('205', 'perm_system_role_manage', 'menu_admin_role', '1', now()),
|
||||||
('206', 'perm_system_permission_manage', 'menu_admin_permission', '1', now()),
|
|
||||||
('207', 'perm_system_menu_manage', 'menu_admin_menu', '1', now()),
|
('207', 'perm_system_menu_manage', 'menu_admin_menu', '1', now()),
|
||||||
('208', 'perm_system_module_manage', 'menu_admin_module', '1', now()),
|
('208', 'perm_system_module_manage', 'menu_admin_module', '1', now()),
|
||||||
|
('208.1', 'perm_system_permission_manage', 'menu_admin_module', '1', now()),
|
||||||
('209', 'perm_news_manage', 'menu_admin_resource_manage', '1', now()),
|
('209', 'perm_news_manage', 'menu_admin_resource_manage', '1', now()),
|
||||||
('210', 'perm_news_manage', 'menu_admin_resource', '1', now()),
|
('210', 'perm_news_manage', 'menu_admin_resource', '1', now()),
|
||||||
('211', 'perm_news_manage', 'menu_admin_article', '1', now()),
|
('211', 'perm_news_manage', 'menu_admin_article', '1', now()),
|
||||||
@@ -184,6 +186,7 @@ INSERT INTO `tb_sys_menu_permission` (id, permission_id, menu_id, creator, creat
|
|||||||
('220', 'perm_study_manage', 'menu_admin_task_manage', '1', now()),
|
('220', 'perm_study_manage', 'menu_admin_task_manage', '1', now()),
|
||||||
('221', 'perm_study_manage', 'menu_admin_study_records', '1', now()),
|
('221', 'perm_study_manage', 'menu_admin_study_records', '1', now()),
|
||||||
('222', 'perm_study_manage', 'menu_admin_course_manage', '1', now()),
|
('222', 'perm_study_manage', 'menu_admin_course_manage', '1', now()),
|
||||||
|
('222.1', 'perm_achievement_manage', 'menu_admin_achievement_manage', '1', now()),
|
||||||
('223', 'perm_ai_manage', 'menu_admin_ai_manage', '1', now()),
|
('223', 'perm_ai_manage', 'menu_admin_ai_manage', '1', now()),
|
||||||
('224', 'perm_ai_manage', 'menu_admin_ai', '1', now()),
|
('224', 'perm_ai_manage', 'menu_admin_ai', '1', now()),
|
||||||
('225', 'perm_ai_manage', 'menu_admin_ai_config', '1', now()),
|
('225', 'perm_ai_manage', 'menu_admin_ai_config', '1', now()),
|
||||||
|
|||||||
@@ -7,12 +7,12 @@ import org.springframework.web.bind.annotation.*;
|
|||||||
import org.xyzh.api.achievement.AchievementService;
|
import org.xyzh.api.achievement.AchievementService;
|
||||||
import org.xyzh.common.core.domain.ResultDomain;
|
import org.xyzh.common.core.domain.ResultDomain;
|
||||||
import org.xyzh.common.core.event.AchievementEvent;
|
import org.xyzh.common.core.event.AchievementEvent;
|
||||||
import org.xyzh.common.core.page.PageParam;
|
import org.xyzh.common.core.page.PageRequest;
|
||||||
import org.xyzh.common.dto.usercenter.TbAchievement;
|
import org.xyzh.common.dto.usercenter.TbAchievement;
|
||||||
import org.xyzh.common.dto.usercenter.TbUserAchievement;
|
import org.xyzh.common.dto.usercenter.TbUserAchievement;
|
||||||
import org.xyzh.common.dto.usercenter.TbUserAchievementProgress;
|
import org.xyzh.common.dto.usercenter.TbUserAchievementProgress;
|
||||||
|
import org.xyzh.common.vo.AchievementVO;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -23,7 +23,7 @@ import java.util.Map;
|
|||||||
* @since 2025-10-24
|
* @since 2025-10-24
|
||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/achievement")
|
@RequestMapping("/achievements")
|
||||||
public class AchievementController {
|
public class AchievementController {
|
||||||
private static final Logger logger = LoggerFactory.getLogger(AchievementController.class);
|
private static final Logger logger = LoggerFactory.getLogger(AchievementController.class);
|
||||||
|
|
||||||
@@ -35,7 +35,7 @@ public class AchievementController {
|
|||||||
/**
|
/**
|
||||||
* 创建成就
|
* 创建成就
|
||||||
*/
|
*/
|
||||||
@PostMapping("/create")
|
@PostMapping("/achievement")
|
||||||
public ResultDomain<TbAchievement> createAchievement(@RequestBody TbAchievement achievement) {
|
public ResultDomain<TbAchievement> createAchievement(@RequestBody TbAchievement achievement) {
|
||||||
return achievementService.createAchievement(achievement);
|
return achievementService.createAchievement(achievement);
|
||||||
}
|
}
|
||||||
@@ -43,7 +43,7 @@ public class AchievementController {
|
|||||||
/**
|
/**
|
||||||
* 更新成就
|
* 更新成就
|
||||||
*/
|
*/
|
||||||
@PutMapping("/update")
|
@PutMapping("/achievement")
|
||||||
public ResultDomain<TbAchievement> updateAchievement(@RequestBody TbAchievement achievement) {
|
public ResultDomain<TbAchievement> updateAchievement(@RequestBody TbAchievement achievement) {
|
||||||
return achievementService.updateAchievement(achievement);
|
return achievementService.updateAchievement(achievement);
|
||||||
}
|
}
|
||||||
@@ -51,36 +51,32 @@ public class AchievementController {
|
|||||||
/**
|
/**
|
||||||
* 删除成就
|
* 删除成就
|
||||||
*/
|
*/
|
||||||
@DeleteMapping("/delete/{achievementID}")
|
@DeleteMapping("/achievement")
|
||||||
public ResultDomain<Void> deleteAchievement(@PathVariable String achievementID) {
|
public ResultDomain<Void> deleteAchievement(@RequestBody TbAchievement achievement) {
|
||||||
return achievementService.deleteAchievement(achievementID);
|
return achievementService.deleteAchievement(achievement.getAchievementID());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取所有成就列表
|
* 获取所有成就列表
|
||||||
*/
|
*/
|
||||||
@GetMapping("/list")
|
@PostMapping("/list")
|
||||||
public ResultDomain<TbAchievement> getAllAchievements(
|
public ResultDomain<TbAchievement> getAllAchievements(TbAchievement filter) {
|
||||||
@RequestParam(required = false) Integer type,
|
return achievementService.getAllAchievements(filter);
|
||||||
@RequestParam(required = false) Integer level) {
|
|
||||||
return achievementService.getAllAchievements(type, level);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 分页查询成就
|
* 分页查询成就
|
||||||
*/
|
*/
|
||||||
@PostMapping("/page")
|
@PostMapping("/page")
|
||||||
public ResultDomain<TbAchievement> getAchievementPage(
|
public ResultDomain<TbAchievement> getAchievementPage(@RequestBody PageRequest<TbAchievement> pageRequest) {
|
||||||
@RequestBody(required = false) TbAchievement filter,
|
return achievementService.getAchievementPage(pageRequest.getFilter(), pageRequest.getPageParam());
|
||||||
PageParam pageParam) {
|
|
||||||
return achievementService.getAchievementPage(filter, pageParam);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取成就详情
|
* 获取成就详情
|
||||||
*/
|
*/
|
||||||
@GetMapping("/detail/{achievementID}")
|
@GetMapping("/detail/{achievementID}")
|
||||||
public ResultDomain<TbAchievement> getAchievementDetail(@PathVariable String achievementID) {
|
public ResultDomain<TbAchievement> getAchievementDetail(@PathVariable(name = "achievementID") String achievementID) {
|
||||||
return achievementService.getAchievementDetail(achievementID);
|
return achievementService.getAchievementDetail(achievementID);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -90,28 +86,26 @@ public class AchievementController {
|
|||||||
* 获取用户已获得的成就
|
* 获取用户已获得的成就
|
||||||
*/
|
*/
|
||||||
@GetMapping("/user/{userID}")
|
@GetMapping("/user/{userID}")
|
||||||
public ResultDomain<TbUserAchievement> getUserAchievements(
|
public ResultDomain<TbUserAchievement> getUserAchievements(@PathVariable(name = "userID") String userID, @RequestParam(required = false, value = "type") Integer type) {
|
||||||
@PathVariable String userID,
|
|
||||||
@RequestParam(required = false) Integer type) {
|
|
||||||
return achievementService.getUserAchievements(userID, type);
|
return achievementService.getUserAchievements(userID, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取当前用户的成就列表
|
* 获取当前用户的成就列表(含进度信息)
|
||||||
|
* 返回所有成就,包括:
|
||||||
|
* - 已获得的成就:显示获得时间
|
||||||
|
* - 未获得的成就:显示当前进度
|
||||||
*/
|
*/
|
||||||
@GetMapping("/my")
|
@GetMapping("/my")
|
||||||
public ResultDomain<TbUserAchievement> getMyAchievements(
|
public ResultDomain<AchievementVO> getMyAchievements(@RequestParam(required = false, value = "type") Integer type) {
|
||||||
@RequestParam(required = false) Integer type) {
|
return achievementService.getMyAchievementsWithProgress(type);
|
||||||
return achievementService.getMyAchievements(type);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 检查用户是否已获得成就
|
* 检查用户是否已获得成就
|
||||||
*/
|
*/
|
||||||
@GetMapping("/check/{userID}/{achievementID}")
|
@GetMapping("/check/{userID}/{achievementID}")
|
||||||
public ResultDomain<Boolean> hasAchievement(
|
public ResultDomain<Boolean> hasAchievement(@PathVariable(name = "userID") String userID, @PathVariable(name = "achievementID") String achievementID) {
|
||||||
@PathVariable String userID,
|
|
||||||
@PathVariable String achievementID) {
|
|
||||||
return achievementService.hasAchievement(userID, achievementID);
|
return achievementService.hasAchievement(userID, achievementID);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -122,8 +116,8 @@ public class AchievementController {
|
|||||||
*/
|
*/
|
||||||
@PostMapping("/grant")
|
@PostMapping("/grant")
|
||||||
public ResultDomain<TbUserAchievement> grantAchievement(
|
public ResultDomain<TbUserAchievement> grantAchievement(
|
||||||
@RequestParam String userID,
|
@RequestParam(name = "userID") String userID,
|
||||||
@RequestParam String achievementID) {
|
@RequestParam(name = "achievementID") String achievementID) {
|
||||||
return achievementService.grantAchievement(userID, achievementID);
|
return achievementService.grantAchievement(userID, achievementID);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -132,8 +126,8 @@ public class AchievementController {
|
|||||||
*/
|
*/
|
||||||
@DeleteMapping("/revoke")
|
@DeleteMapping("/revoke")
|
||||||
public ResultDomain<Void> revokeAchievement(
|
public ResultDomain<Void> revokeAchievement(
|
||||||
@RequestParam String userID,
|
@RequestParam(name = "userID") String userID,
|
||||||
@RequestParam String achievementID) {
|
@RequestParam(name = "achievementID") String achievementID) {
|
||||||
return achievementService.revokeAchievement(userID, achievementID);
|
return achievementService.revokeAchievement(userID, achievementID);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -144,20 +138,11 @@ public class AchievementController {
|
|||||||
*/
|
*/
|
||||||
@GetMapping("/progress/{userID}")
|
@GetMapping("/progress/{userID}")
|
||||||
public ResultDomain<TbUserAchievementProgress> getUserAchievementProgress(
|
public ResultDomain<TbUserAchievementProgress> getUserAchievementProgress(
|
||||||
@PathVariable String userID,
|
@PathVariable(name = "userID") String userID,
|
||||||
@RequestParam(required = false) String achievementID) {
|
@RequestParam(required = false, value = "achievementID") String achievementID) {
|
||||||
return achievementService.getUserAchievementProgress(userID, achievementID);
|
return achievementService.getUserAchievementProgress(userID, achievementID);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取当前用户的成就进度
|
|
||||||
*/
|
|
||||||
@GetMapping("/progress/my")
|
|
||||||
public ResultDomain<TbUserAchievementProgress> getMyAchievementProgress(
|
|
||||||
@RequestParam(required = false) String achievementID) {
|
|
||||||
return achievementService.getMyAchievementProgress(achievementID);
|
|
||||||
}
|
|
||||||
|
|
||||||
// ==================== 成就检测 ====================
|
// ==================== 成就检测 ====================
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -208,11 +193,9 @@ public class AchievementController {
|
|||||||
/**
|
/**
|
||||||
* 获取最近获得成就的用户
|
* 获取最近获得成就的用户
|
||||||
*/
|
*/
|
||||||
@GetMapping("/recent/{achievementID}")
|
@PostMapping("/recent")
|
||||||
public ResultDomain<TbUserAchievement> getRecentAchievers(
|
public ResultDomain<TbUserAchievement> getRecentAchievers(@RequestBody PageRequest<TbUserAchievement> pageRequest) {
|
||||||
@PathVariable String achievementID,
|
return achievementService.getRecentAchievers(pageRequest.getFilter(), pageRequest.getPageParam());
|
||||||
@RequestParam(required = false, defaultValue = "10") Integer limit) {
|
|
||||||
return achievementService.getRecentAchievers(achievementID, limit);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ import org.xyzh.common.dto.usercenter.TbAchievement;
|
|||||||
import org.xyzh.common.dto.usercenter.TbUserAchievement;
|
import org.xyzh.common.dto.usercenter.TbUserAchievement;
|
||||||
import org.xyzh.common.dto.usercenter.TbUserAchievementProgress;
|
import org.xyzh.common.dto.usercenter.TbUserAchievementProgress;
|
||||||
import org.xyzh.common.utils.IDUtils;
|
import org.xyzh.common.utils.IDUtils;
|
||||||
|
import org.xyzh.common.vo.AchievementVO;
|
||||||
import org.xyzh.system.utils.LoginUtil;
|
import org.xyzh.system.utils.LoginUtil;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
@@ -101,13 +102,13 @@ public class ACHAchievementServiceImpl implements AchievementService {
|
|||||||
ResultDomain<TbAchievement> resultDomain = new ResultDomain<>();
|
ResultDomain<TbAchievement> resultDomain = new ResultDomain<>();
|
||||||
try {
|
try {
|
||||||
// 参数验证
|
// 参数验证
|
||||||
if (achievement == null || !StringUtils.hasText(achievement.getID())) {
|
if (achievement == null || !StringUtils.hasText(achievement.getAchievementID())) {
|
||||||
resultDomain.fail("成就ID不能为空");
|
resultDomain.fail("成就ID不能为空");
|
||||||
return resultDomain;
|
return resultDomain;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 检查成就是否存在
|
// 检查成就是否存在
|
||||||
TbAchievement existing = achievementMapper.selectById(achievement.getID());
|
TbAchievement existing = achievementMapper.selectByAchievementId(achievement.getAchievementID());
|
||||||
if (existing == null) {
|
if (existing == null) {
|
||||||
resultDomain.fail("成就不存在");
|
resultDomain.fail("成就不存在");
|
||||||
return resultDomain;
|
return resultDomain;
|
||||||
@@ -115,7 +116,7 @@ public class ACHAchievementServiceImpl implements AchievementService {
|
|||||||
|
|
||||||
// 检查名称是否重复
|
// 检查名称是否重复
|
||||||
if (StringUtils.hasText(achievement.getName())) {
|
if (StringUtils.hasText(achievement.getName())) {
|
||||||
int count = achievementMapper.countByName(achievement.getName(), achievement.getID());
|
int count = achievementMapper.countByName(achievement.getName(), achievement.getAchievementID());
|
||||||
if (count > 0) {
|
if (count > 0) {
|
||||||
resultDomain.fail("成就名称已存在");
|
resultDomain.fail("成就名称已存在");
|
||||||
return resultDomain;
|
return resultDomain;
|
||||||
@@ -172,19 +173,10 @@ public class ACHAchievementServiceImpl implements AchievementService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResultDomain<TbAchievement> getAllAchievements(Integer type, Integer level) {
|
public ResultDomain<TbAchievement> getAllAchievements(TbAchievement filter) {
|
||||||
ResultDomain<TbAchievement> resultDomain = new ResultDomain<>();
|
ResultDomain<TbAchievement> resultDomain = new ResultDomain<>();
|
||||||
try {
|
try {
|
||||||
List<TbAchievement> list;
|
List<TbAchievement> list = achievementMapper.selectAchievements(filter);
|
||||||
if (type != null && level != null) {
|
|
||||||
list = achievementMapper.selectByTypeAndLevel(type, level);
|
|
||||||
} else if (type != null) {
|
|
||||||
list = achievementMapper.selectByType(type);
|
|
||||||
} else {
|
|
||||||
TbAchievement filter = new TbAchievement();
|
|
||||||
filter.setDeleted(false);
|
|
||||||
list = achievementMapper.selectAchievements(filter);
|
|
||||||
}
|
|
||||||
|
|
||||||
resultDomain.success("获取成就列表成功", list);
|
resultDomain.success("获取成就列表成功", list);
|
||||||
return resultDomain;
|
return resultDomain;
|
||||||
@@ -281,6 +273,110 @@ public class ACHAchievementServiceImpl implements AchievementService {
|
|||||||
return getUserAchievements(user.getID(), type);
|
return getUserAchievements(user.getID(), type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ResultDomain<AchievementVO> getMyAchievementsWithProgress(Integer type) {
|
||||||
|
ResultDomain<AchievementVO> resultDomain = new ResultDomain<>();
|
||||||
|
try {
|
||||||
|
// 获取当前登录用户
|
||||||
|
TbSysUser user = LoginUtil.getCurrentUser();
|
||||||
|
if (user == null) {
|
||||||
|
resultDomain.fail("请先登录");
|
||||||
|
return resultDomain;
|
||||||
|
}
|
||||||
|
|
||||||
|
String userID = user.getID();
|
||||||
|
|
||||||
|
// 1. 获取所有成就列表(根据type过滤)
|
||||||
|
List<TbAchievement> allAchievements;
|
||||||
|
if (type != null) {
|
||||||
|
allAchievements = achievementMapper.selectByType(type);
|
||||||
|
} else {
|
||||||
|
TbAchievement filter = new TbAchievement();
|
||||||
|
filter.setDeleted(false);
|
||||||
|
allAchievements = achievementMapper.selectAchievements(filter);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2. 获取用户已获得的成就列表
|
||||||
|
List<TbUserAchievement> userAchievements = type != null
|
||||||
|
? userAchievementMapper.selectByUserIdAndType(userID, type)
|
||||||
|
: userAchievementMapper.selectByUserId(userID);
|
||||||
|
|
||||||
|
// 转换为Map,key为achievementID
|
||||||
|
Map<String, TbUserAchievement> userAchievementMap = userAchievements.stream()
|
||||||
|
.collect(Collectors.toMap(TbUserAchievement::getAchievementID, ua -> ua));
|
||||||
|
|
||||||
|
// 3. 获取用户的成就进度列表
|
||||||
|
List<TbUserAchievementProgress> progressList = progressMapper.selectByUserId(userID);
|
||||||
|
|
||||||
|
// 转换为Map,key为achievementID
|
||||||
|
Map<String, TbUserAchievementProgress> progressMap = progressList.stream()
|
||||||
|
.collect(Collectors.toMap(TbUserAchievementProgress::getAchievementID, p -> p));
|
||||||
|
|
||||||
|
// 4. 组装AchievementVO列表
|
||||||
|
List<AchievementVO> achievementVOList = new ArrayList<>();
|
||||||
|
for (TbAchievement achievement : allAchievements) {
|
||||||
|
AchievementVO vo = new AchievementVO();
|
||||||
|
|
||||||
|
// 复制成就基本信息
|
||||||
|
vo.setID(achievement.getID());
|
||||||
|
vo.setAchievementID(achievement.getAchievementID());
|
||||||
|
vo.setName(achievement.getName());
|
||||||
|
vo.setDescription(achievement.getDescription());
|
||||||
|
vo.setType(achievement.getType());
|
||||||
|
vo.setLevel(achievement.getLevel());
|
||||||
|
vo.setIcon(achievement.getIcon());
|
||||||
|
vo.setPoints(achievement.getPoints());
|
||||||
|
vo.setConditionType(achievement.getConditionType());
|
||||||
|
vo.setConditionValue(achievement.getConditionValue());
|
||||||
|
vo.setOrderNum(achievement.getOrderNum());
|
||||||
|
vo.setCreator(achievement.getCreator());
|
||||||
|
vo.setUpdater(achievement.getUpdater());
|
||||||
|
vo.setCreateTime(achievement.getCreateTime());
|
||||||
|
vo.setUpdateTime(achievement.getUpdateTime());
|
||||||
|
vo.setDeleted(achievement.getDeleted());
|
||||||
|
|
||||||
|
// 设置用户ID
|
||||||
|
vo.setUserID(userID);
|
||||||
|
|
||||||
|
// 填充用户成就信息(如果已获得)
|
||||||
|
TbUserAchievement userAchievement = userAchievementMap.get(achievement.getAchievementID());
|
||||||
|
if (userAchievement != null) {
|
||||||
|
vo.setUserAchievementID(userAchievement.getID());
|
||||||
|
vo.setObtainTime(userAchievement.getObtainTime());
|
||||||
|
vo.setObtained(true);
|
||||||
|
} else {
|
||||||
|
vo.setObtained(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 填充进度信息
|
||||||
|
TbUserAchievementProgress progress = progressMap.get(achievement.getAchievementID());
|
||||||
|
if (progress != null) {
|
||||||
|
vo.setProgressID(progress.getID());
|
||||||
|
vo.setCurrentValue(progress.getCurrentValue());
|
||||||
|
vo.setTargetValue(progress.getTargetValue());
|
||||||
|
vo.setProgressPercentage(progress.getProgressPercentage());
|
||||||
|
vo.setCompleted(progress.getCompleted());
|
||||||
|
vo.setLastUpdateTime(progress.getLastUpdateTime());
|
||||||
|
} else {
|
||||||
|
// 没有进度记录,设置默认值
|
||||||
|
vo.setCurrentValue(0);
|
||||||
|
vo.setTargetValue(achievement.getConditionValue());
|
||||||
|
vo.setProgressPercentage(0);
|
||||||
|
vo.setCompleted(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
achievementVOList.add(vo);
|
||||||
|
}
|
||||||
|
|
||||||
|
resultDomain.success("获取成就列表成功", achievementVOList);
|
||||||
|
return resultDomain;
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("获取成就列表异常: {}", e.getMessage(), e);
|
||||||
|
resultDomain.fail("获取成就列表失败: " + e.getMessage());
|
||||||
|
return resultDomain;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResultDomain<Boolean> hasAchievement(String userID, String achievementID) {
|
public ResultDomain<Boolean> hasAchievement(String userID, String achievementID) {
|
||||||
ResultDomain<Boolean> resultDomain = new ResultDomain<>();
|
ResultDomain<Boolean> resultDomain = new ResultDomain<>();
|
||||||
@@ -634,19 +730,10 @@ public class ACHAchievementServiceImpl implements AchievementService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResultDomain<TbUserAchievement> getRecentAchievers(String achievementID, Integer limit) {
|
public ResultDomain<TbUserAchievement> getRecentAchievers(TbUserAchievement filter, PageParam pageParam) {
|
||||||
ResultDomain<TbUserAchievement> resultDomain = new ResultDomain<>();
|
ResultDomain<TbUserAchievement> resultDomain = new ResultDomain<>();
|
||||||
try {
|
try {
|
||||||
if (!StringUtils.hasText(achievementID)) {
|
List<TbUserAchievement> achievers = userAchievementMapper.selectUserAchievementsPage(filter, pageParam);
|
||||||
resultDomain.fail("成就ID不能为空");
|
|
||||||
return resultDomain;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (limit == null || limit <= 0) {
|
|
||||||
limit = 10;
|
|
||||||
}
|
|
||||||
|
|
||||||
List<TbUserAchievement> achievers = userAchievementMapper.selectRecentAchievers(achievementID, limit);
|
|
||||||
resultDomain.success("获取最近获得者成功", achievers);
|
resultDomain.success("获取最近获得者成功", achievers);
|
||||||
return resultDomain;
|
return resultDomain;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
|
|||||||
@EnableTransactionManagement
|
@EnableTransactionManagement
|
||||||
@SpringBootApplication(scanBasePackages = "org.xyzh")
|
@SpringBootApplication(scanBasePackages = "org.xyzh")
|
||||||
@MapperScan({"org.xyzh.system.mapper", "org.xyzh.file.mapper", "org.xyzh.news.mapper", "org.xyzh.study.mapper",
|
@MapperScan({"org.xyzh.system.mapper", "org.xyzh.file.mapper", "org.xyzh.news.mapper", "org.xyzh.study.mapper",
|
||||||
"org.xyzh.usercenter.mapper", "org.xyzh.ai.mapper", "org.xyzh.file.mapper"})
|
"org.xyzh.usercenter.mapper", "org.xyzh.ai.mapper", "org.xyzh.achievement.mapper"})
|
||||||
public class App {
|
public class App {
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
|||||||
@@ -2,13 +2,12 @@ package org.xyzh.api.achievement;
|
|||||||
|
|
||||||
import org.xyzh.common.core.domain.ResultDomain;
|
import org.xyzh.common.core.domain.ResultDomain;
|
||||||
import org.xyzh.common.core.event.AchievementEvent;
|
import org.xyzh.common.core.event.AchievementEvent;
|
||||||
import org.xyzh.common.core.page.PageDomain;
|
|
||||||
import org.xyzh.common.core.page.PageParam;
|
import org.xyzh.common.core.page.PageParam;
|
||||||
import org.xyzh.common.dto.usercenter.TbAchievement;
|
import org.xyzh.common.dto.usercenter.TbAchievement;
|
||||||
import org.xyzh.common.dto.usercenter.TbUserAchievement;
|
import org.xyzh.common.dto.usercenter.TbUserAchievement;
|
||||||
import org.xyzh.common.dto.usercenter.TbUserAchievementProgress;
|
import org.xyzh.common.dto.usercenter.TbUserAchievementProgress;
|
||||||
|
import org.xyzh.common.vo.AchievementVO;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -49,7 +48,7 @@ public interface AchievementService {
|
|||||||
* @param level 成就等级(可选)
|
* @param level 成就等级(可选)
|
||||||
* @return ResultDomain<TbAchievement> 成就列表
|
* @return ResultDomain<TbAchievement> 成就列表
|
||||||
*/
|
*/
|
||||||
ResultDomain<TbAchievement> getAllAchievements(Integer type, Integer level);
|
ResultDomain<TbAchievement> getAllAchievements(TbAchievement filter);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description 分页查询成就
|
* @description 分页查询成就
|
||||||
@@ -83,6 +82,16 @@ public interface AchievementService {
|
|||||||
*/
|
*/
|
||||||
ResultDomain<TbUserAchievement> getMyAchievements(Integer type);
|
ResultDomain<TbUserAchievement> getMyAchievements(Integer type);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description 获取当前用户的成就列表(带进度信息)
|
||||||
|
* 返回所有成就的详细信息,包括:
|
||||||
|
* - 已获得的成就:显示获得时间
|
||||||
|
* - 未获得的成就:显示当前进度
|
||||||
|
* @param type 成就类型(可选)
|
||||||
|
* @return ResultDomain<AchievementVO> 成就视图对象列表
|
||||||
|
*/
|
||||||
|
ResultDomain<AchievementVO> getMyAchievementsWithProgress(Integer type);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description 检查用户是否已获得成就
|
* @description 检查用户是否已获得成就
|
||||||
* @param userID 用户ID
|
* @param userID 用户ID
|
||||||
@@ -179,6 +188,6 @@ public interface AchievementService {
|
|||||||
* @param limit 查询条数
|
* @param limit 查询条数
|
||||||
* @return ResultDomain<TbUserAchievement> 用户成就列表(在dataList中)
|
* @return ResultDomain<TbUserAchievement> 用户成就列表(在dataList中)
|
||||||
*/
|
*/
|
||||||
ResultDomain<TbUserAchievement> getRecentAchievers(String achievementID, Integer limit);
|
ResultDomain<TbUserAchievement> getRecentAchievers(TbUserAchievement filter, PageParam pageParam);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package org.xyzh.api.system.module;
|
package org.xyzh.api.system.module;
|
||||||
|
|
||||||
import org.xyzh.common.core.page.PageParam;
|
import org.xyzh.common.core.page.PageParam;
|
||||||
|
import org.xyzh.common.dto.permission.TbSysPermission;
|
||||||
import org.xyzh.common.dto.system.TbSysModule;
|
import org.xyzh.common.dto.system.TbSysModule;
|
||||||
import org.xyzh.common.core.domain.ResultDomain;
|
import org.xyzh.common.core.domain.ResultDomain;
|
||||||
|
|
||||||
@@ -136,51 +137,39 @@ public interface ModuleService {
|
|||||||
ResultDomain<Boolean> checkModuleCodeExists(String code, String excludeID);
|
ResultDomain<Boolean> checkModuleCodeExists(String code, String excludeID);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description 绑定权限到模块
|
* @description 在模块中创建权限
|
||||||
* @param moduleID 模块ID
|
* @param permission 权限信息(必须包含moduleID)
|
||||||
* @param permissionIds 权限ID列表
|
* @return ResultDomain<TbSysPermission> 创建结果
|
||||||
* @return ResultDomain<Boolean> 绑定结果
|
|
||||||
* @author yslg
|
* @author yslg
|
||||||
* @since 2025-10-16
|
* @since 2025-10-16
|
||||||
*/
|
*/
|
||||||
ResultDomain<Boolean> bindPermissionsToModule(String moduleID, List<String> permissionIds);
|
ResultDomain<TbSysPermission> createPermissionInModule(TbSysPermission permission);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description 解绑模块的权限
|
* @description 更新模块中的权限
|
||||||
* @param moduleID 模块ID
|
* @param permission 权限信息
|
||||||
* @param permissionIds 权限ID列表
|
* @return ResultDomain<TbSysPermission> 更新结果
|
||||||
* @return ResultDomain<Boolean> 解绑结果
|
|
||||||
* @author yslg
|
* @author yslg
|
||||||
* @since 2025-10-16
|
* @since 2025-10-16
|
||||||
*/
|
*/
|
||||||
ResultDomain<Boolean> unbindPermissionsFromModule(String moduleID, List<String> permissionIds);
|
ResultDomain<TbSysPermission> updatePermissionInModule(TbSysPermission permission);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description 删除模块中的权限
|
||||||
|
* @param moduleID 模块ID
|
||||||
|
* @param permissionID 权限ID
|
||||||
|
* @return ResultDomain<Boolean> 删除结果
|
||||||
|
* @author yslg
|
||||||
|
* @since 2025-10-16
|
||||||
|
*/
|
||||||
|
ResultDomain<Boolean> deletePermissionInModule(String moduleID, String permissionID);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description 获取模块的权限列表
|
* @description 获取模块的权限列表
|
||||||
* @param moduleID 模块ID
|
* @param moduleID 模块ID
|
||||||
* @return ResultDomain<List<String>> 权限ID列表
|
* @return ResultDomain<TbSysPermission> 权限列表
|
||||||
* @author yslg
|
* @author yslg
|
||||||
* @since 2025-10-16
|
* @since 2025-10-16
|
||||||
*/
|
*/
|
||||||
ResultDomain<List<String>> getModulePermissions(String moduleID);
|
ResultDomain<TbSysPermission> getModulePermissions(String moduleID);
|
||||||
|
|
||||||
/**
|
|
||||||
* @description 批量绑定权限到模块
|
|
||||||
* @param moduleID 模块ID
|
|
||||||
* @param permissionIds 权限ID列表
|
|
||||||
* @return ResultDomain<Boolean> 绑定结果
|
|
||||||
* @author yslg
|
|
||||||
* @since 2025-10-16
|
|
||||||
*/
|
|
||||||
ResultDomain<Boolean> batchBindPermissionsToModule(String moduleID, List<String> permissionIds);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @description 批量解绑模块的权限
|
|
||||||
* @param moduleID 模块ID
|
|
||||||
* @param permissionIds 权限ID列表
|
|
||||||
* @return ResultDomain<Boolean> 解绑结果
|
|
||||||
* @author yslg
|
|
||||||
* @since 2025-10-16
|
|
||||||
*/
|
|
||||||
ResultDomain<Boolean> batchUnbindPermissionsFromModule(String moduleID, List<String> permissionIds);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,181 @@
|
|||||||
|
package org.xyzh.common.vo;
|
||||||
|
|
||||||
|
import org.xyzh.common.dto.usercenter.TbAchievement;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description 成就视图对象,包含成就信息、获得状态和进度信息
|
||||||
|
* 继承TbAchievement,并包含TbUserAchievement和TbUserAchievementProgress的字段
|
||||||
|
* @filename AchievementVO.java
|
||||||
|
* @author yslg
|
||||||
|
* @copyright xyzh
|
||||||
|
* @since 2025-10-24
|
||||||
|
*/
|
||||||
|
public class AchievementVO extends TbAchievement {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
// ==================== TbUserAchievement表的字段 ====================
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description 用户成就记录ID(tb_user_achievement.ID)
|
||||||
|
*/
|
||||||
|
private String userAchievementID;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description 用户ID(tb_user_achievement.userID)
|
||||||
|
*/
|
||||||
|
private String userID;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description 获得时间(tb_user_achievement.obtainTime)
|
||||||
|
*/
|
||||||
|
private Date obtainTime;
|
||||||
|
|
||||||
|
// ==================== TbUserAchievementProgress表的字段 ====================
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description 进度记录ID(tb_user_achievement_progress.ID)
|
||||||
|
*/
|
||||||
|
private String progressID;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description 当前进度值(tb_user_achievement_progress.currentValue)
|
||||||
|
*/
|
||||||
|
private Integer currentValue;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description 目标进度值(tb_user_achievement_progress.targetValue)
|
||||||
|
*/
|
||||||
|
private Integer targetValue;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description 进度百分比 0-100(tb_user_achievement_progress.progressPercentage)
|
||||||
|
*/
|
||||||
|
private Integer progressPercentage;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description 是否已完成(tb_user_achievement_progress.completed)
|
||||||
|
*/
|
||||||
|
private Boolean completed;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description 最后更新时间(tb_user_achievement_progress.lastUpdateTime)
|
||||||
|
*/
|
||||||
|
private Date lastUpdateTime;
|
||||||
|
|
||||||
|
// ==================== 扩展字段(计算得出)====================
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description 是否已获得该成就(根据obtainTime判断)
|
||||||
|
*/
|
||||||
|
private Boolean obtained;
|
||||||
|
|
||||||
|
public AchievementVO() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUserAchievementID() {
|
||||||
|
return userAchievementID;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUserAchievementID(String userAchievementID) {
|
||||||
|
this.userAchievementID = userAchievementID;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUserID() {
|
||||||
|
return userID;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUserID(String userID) {
|
||||||
|
this.userID = userID;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getObtainTime() {
|
||||||
|
return obtainTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setObtainTime(Date obtainTime) {
|
||||||
|
this.obtainTime = obtainTime;
|
||||||
|
// 自动设置obtained标志
|
||||||
|
this.obtained = (obtainTime != null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getProgressID() {
|
||||||
|
return progressID;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setProgressID(String progressID) {
|
||||||
|
this.progressID = progressID;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getCurrentValue() {
|
||||||
|
return currentValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCurrentValue(Integer currentValue) {
|
||||||
|
this.currentValue = currentValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getTargetValue() {
|
||||||
|
return targetValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTargetValue(Integer targetValue) {
|
||||||
|
this.targetValue = targetValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getProgressPercentage() {
|
||||||
|
return progressPercentage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setProgressPercentage(Integer progressPercentage) {
|
||||||
|
this.progressPercentage = progressPercentage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Boolean getCompleted() {
|
||||||
|
return completed;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCompleted(Boolean completed) {
|
||||||
|
this.completed = completed;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getLastUpdateTime() {
|
||||||
|
return lastUpdateTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLastUpdateTime(Date lastUpdateTime) {
|
||||||
|
this.lastUpdateTime = lastUpdateTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Boolean getObtained() {
|
||||||
|
return obtained;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setObtained(Boolean obtained) {
|
||||||
|
this.obtained = obtained;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "AchievementVO{" +
|
||||||
|
"achievementID='" + getAchievementID() + '\'' +
|
||||||
|
", name='" + getName() + '\'' +
|
||||||
|
", type=" + getType() +
|
||||||
|
", level=" + getLevel() +
|
||||||
|
", userAchievementID='" + userAchievementID + '\'' +
|
||||||
|
", userID='" + userID + '\'' +
|
||||||
|
", obtained=" + obtained +
|
||||||
|
", obtainTime=" + obtainTime +
|
||||||
|
", progressID='" + progressID + '\'' +
|
||||||
|
", currentValue=" + currentValue +
|
||||||
|
", targetValue=" + targetValue +
|
||||||
|
", progressPercentage=" + progressPercentage +
|
||||||
|
", completed=" + completed +
|
||||||
|
", lastUpdateTime=" + lastUpdateTime +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -2,6 +2,7 @@ package org.xyzh.common.vo;
|
|||||||
|
|
||||||
import org.xyzh.common.dto.permission.TbSysPermission;
|
import org.xyzh.common.dto.permission.TbSysPermission;
|
||||||
import org.xyzh.common.dto.role.TbSysRole;
|
import org.xyzh.common.dto.role.TbSysRole;
|
||||||
|
import org.xyzh.common.dto.system.TbSysModule;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -20,6 +21,13 @@ public class PermissionVO extends BaseDTO{
|
|||||||
*/
|
*/
|
||||||
private String permissionID;
|
private String permissionID;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description 模块ID
|
||||||
|
* @author yslg
|
||||||
|
* @since 2025-10-25
|
||||||
|
*/
|
||||||
|
private String moduleID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description 权限名称
|
* @description 权限名称
|
||||||
* @author yslg
|
* @author yslg
|
||||||
@@ -90,6 +98,13 @@ public class PermissionVO extends BaseDTO{
|
|||||||
*/
|
*/
|
||||||
private List<TbSysPermission> permissions;
|
private List<TbSysPermission> permissions;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description 模块
|
||||||
|
* @author yslg
|
||||||
|
* @since 2025-10-25
|
||||||
|
*/
|
||||||
|
private TbSysModule module;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description 更新人名称
|
* @description 更新人名称
|
||||||
* @author yslg
|
* @author yslg
|
||||||
@@ -97,6 +112,14 @@ public class PermissionVO extends BaseDTO{
|
|||||||
*/
|
*/
|
||||||
private String updaterName;
|
private String updaterName;
|
||||||
|
|
||||||
|
public String getModuleID() {
|
||||||
|
return moduleID;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setModuleID(String moduleID) {
|
||||||
|
this.moduleID = moduleID;
|
||||||
|
}
|
||||||
|
|
||||||
public String getPermissionID() {
|
public String getPermissionID() {
|
||||||
return permissionID;
|
return permissionID;
|
||||||
}
|
}
|
||||||
@@ -193,4 +216,12 @@ public class PermissionVO extends BaseDTO{
|
|||||||
this.permissions = permissions;
|
this.permissions = permissions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public TbSysModule getModule() {
|
||||||
|
return module;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setModule(TbSysModule module) {
|
||||||
|
this.module = module;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,12 +3,11 @@ package org.xyzh.system.controller;
|
|||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.xyzh.api.system.module.ModuleService;
|
import org.xyzh.api.system.module.ModuleService;
|
||||||
import org.xyzh.common.core.page.PageParam;
|
import org.xyzh.common.core.page.PageRequest;
|
||||||
|
import org.xyzh.common.dto.permission.TbSysPermission;
|
||||||
import org.xyzh.common.dto.system.TbSysModule;
|
import org.xyzh.common.dto.system.TbSysModule;
|
||||||
import org.xyzh.common.core.domain.ResultDomain;
|
import org.xyzh.common.core.domain.ResultDomain;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description 系统模块控制器
|
* @description 系统模块控制器
|
||||||
* @filename ModuleController.java
|
* @filename ModuleController.java
|
||||||
@@ -17,7 +16,7 @@ import java.util.List;
|
|||||||
* @since 2025-10-16
|
* @since 2025-10-16
|
||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/system/module")
|
@RequestMapping("/system/modules")
|
||||||
@CrossOrigin(origins = "*")
|
@CrossOrigin(origins = "*")
|
||||||
public class ModuleController {
|
public class ModuleController {
|
||||||
|
|
||||||
@@ -44,7 +43,7 @@ public class ModuleController {
|
|||||||
* @since 2025-10-16
|
* @since 2025-10-16
|
||||||
*/
|
*/
|
||||||
@GetMapping("/{moduleID}")
|
@GetMapping("/{moduleID}")
|
||||||
public ResultDomain<TbSysModule> getModuleById(@PathVariable String moduleID) {
|
public ResultDomain<TbSysModule> getModuleById(@PathVariable(name = "moduleID") String moduleID) {
|
||||||
return moduleService.getModuleById(moduleID);
|
return moduleService.getModuleById(moduleID);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -56,7 +55,7 @@ public class ModuleController {
|
|||||||
* @since 2025-10-16
|
* @since 2025-10-16
|
||||||
*/
|
*/
|
||||||
@GetMapping("/code/{code}")
|
@GetMapping("/code/{code}")
|
||||||
public ResultDomain<TbSysModule> getModuleByCode(@PathVariable String code) {
|
public ResultDomain<TbSysModule> getModuleByCode(@PathVariable(name = "code") String code) {
|
||||||
return moduleService.getModuleByCode(code);
|
return moduleService.getModuleByCode(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -78,7 +77,7 @@ public class ModuleController {
|
|||||||
* @author yslg
|
* @author yslg
|
||||||
* @since 2025-10-16
|
* @since 2025-10-16
|
||||||
*/
|
*/
|
||||||
@PostMapping("/create")
|
@PostMapping("/module")
|
||||||
public ResultDomain<TbSysModule> createModule(@RequestBody TbSysModule module) {
|
public ResultDomain<TbSysModule> createModule(@RequestBody TbSysModule module) {
|
||||||
return moduleService.createModule(module);
|
return moduleService.createModule(module);
|
||||||
}
|
}
|
||||||
@@ -90,7 +89,7 @@ public class ModuleController {
|
|||||||
* @author yslg
|
* @author yslg
|
||||||
* @since 2025-10-16
|
* @since 2025-10-16
|
||||||
*/
|
*/
|
||||||
@PutMapping("/update")
|
@PutMapping("/module")
|
||||||
public ResultDomain<TbSysModule> updateModule(@RequestBody TbSysModule module) {
|
public ResultDomain<TbSysModule> updateModule(@RequestBody TbSysModule module) {
|
||||||
return moduleService.updateModule(module);
|
return moduleService.updateModule(module);
|
||||||
}
|
}
|
||||||
@@ -102,21 +101,9 @@ public class ModuleController {
|
|||||||
* @author yslg
|
* @author yslg
|
||||||
* @since 2025-10-16
|
* @since 2025-10-16
|
||||||
*/
|
*/
|
||||||
@DeleteMapping("/{moduleID}")
|
@DeleteMapping("/module")
|
||||||
public ResultDomain<Boolean> deleteModule(@PathVariable String moduleID) {
|
public ResultDomain<Boolean> deleteModule(@RequestBody TbSysModule module) {
|
||||||
return moduleService.deleteModule(moduleID);
|
return moduleService.deleteModule(module.getModuleID());
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @description 批量删除模块
|
|
||||||
* @param moduleIDs 模块ID列表
|
|
||||||
* @return ResultDomain<Boolean> 删除结果
|
|
||||||
* @author yslg
|
|
||||||
* @since 2025-10-16
|
|
||||||
*/
|
|
||||||
@DeleteMapping("/batch")
|
|
||||||
public ResultDomain<Boolean> batchDeleteModules(@RequestBody List<String> moduleIDs) {
|
|
||||||
return moduleService.batchDeleteModules(moduleIDs);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -128,7 +115,7 @@ public class ModuleController {
|
|||||||
* @since 2025-10-16
|
* @since 2025-10-16
|
||||||
*/
|
*/
|
||||||
@PutMapping("/{moduleID}/status/{status}")
|
@PutMapping("/{moduleID}/status/{status}")
|
||||||
public ResultDomain<Boolean> updateModuleStatus(@PathVariable String moduleID, @PathVariable Integer status) {
|
public ResultDomain<Boolean> updateModuleStatus(@PathVariable(name = "moduleID") String moduleID, @PathVariable(name = "status") Integer status) {
|
||||||
return moduleService.updateModuleStatus(moduleID, status);
|
return moduleService.updateModuleStatus(moduleID, status);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -141,7 +128,7 @@ public class ModuleController {
|
|||||||
* @since 2025-10-16
|
* @since 2025-10-16
|
||||||
*/
|
*/
|
||||||
@PutMapping("/{moduleID}/order/{orderNum}")
|
@PutMapping("/{moduleID}/order/{orderNum}")
|
||||||
public ResultDomain<Boolean> updateModuleOrder(@PathVariable String moduleID, @PathVariable Integer orderNum) {
|
public ResultDomain<Boolean> updateModuleOrder(@PathVariable(name = "moduleID") String moduleID, @PathVariable(name = "orderNum") Integer orderNum) {
|
||||||
return moduleService.updateModuleOrder(moduleID, orderNum);
|
return moduleService.updateModuleOrder(moduleID, orderNum);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -154,11 +141,8 @@ public class ModuleController {
|
|||||||
* @since 2025-10-16
|
* @since 2025-10-16
|
||||||
*/
|
*/
|
||||||
@PostMapping("/page")
|
@PostMapping("/page")
|
||||||
public ResultDomain<TbSysModule> getModuleListPage(@RequestBody(required = false) TbSysModule filter,
|
public ResultDomain<TbSysModule> getModuleListPage(@RequestBody PageRequest<TbSysModule> pageRequest) {
|
||||||
@RequestParam(defaultValue = "1") int pageNumber,
|
return moduleService.getModuleListPage(pageRequest.getFilter(), pageRequest.getPageParam());
|
||||||
@RequestParam(defaultValue = "10") int pageSize) {
|
|
||||||
PageParam pageParam = new PageParam(pageNumber, pageSize);
|
|
||||||
return moduleService.getModuleListPage(filter, pageParam);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -182,76 +166,64 @@ public class ModuleController {
|
|||||||
* @since 2025-10-16
|
* @since 2025-10-16
|
||||||
*/
|
*/
|
||||||
@GetMapping("/check-code")
|
@GetMapping("/check-code")
|
||||||
public ResultDomain<Boolean> checkModuleCodeExists(@RequestParam String code,
|
public ResultDomain<Boolean> checkModuleCodeExists(@RequestParam(name = "code") String code,
|
||||||
@RequestParam(required = false) String excludeID) {
|
@RequestParam(required = false, value = "excludeID") String excludeID) {
|
||||||
return moduleService.checkModuleCodeExists(code, excludeID);
|
return moduleService.checkModuleCodeExists(code, excludeID);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description 绑定权限到模块
|
* @description 在模块中创建权限
|
||||||
* @param moduleID 模块ID
|
* @param moduleID 模块ID
|
||||||
* @param permissionIds 权限ID列表
|
* @param permission 权限信息
|
||||||
* @return ResultDomain<Boolean> 绑定结果
|
* @return ResultDomain<TbSysPermission> 创建结果
|
||||||
* @author yslg
|
* @author yslg
|
||||||
* @since 2025-10-16
|
* @since 2025-10-16
|
||||||
*/
|
*/
|
||||||
@PostMapping("/{moduleID}/bind-permissions")
|
@PostMapping("/{moduleID}/permissions")
|
||||||
public ResultDomain<Boolean> bindPermissionsToModule(@PathVariable String moduleID,
|
public ResultDomain<TbSysPermission> createPermissionInModule(@PathVariable(name = "moduleID") String moduleID,
|
||||||
@RequestBody List<String> permissionIds) {
|
@RequestBody TbSysPermission permission) {
|
||||||
return moduleService.bindPermissionsToModule(moduleID, permissionIds);
|
permission.setModuleID(moduleID);
|
||||||
|
return moduleService.createPermissionInModule(permission);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description 解绑模块的权限
|
* @description 更新模块中的权限
|
||||||
* @param moduleID 模块ID
|
* @param moduleID 模块ID
|
||||||
* @param permissionIds 权限ID列表
|
* @param permission 权限信息
|
||||||
* @return ResultDomain<Boolean> 解绑结果
|
* @return ResultDomain<TbSysPermission> 更新结果
|
||||||
* @author yslg
|
* @author yslg
|
||||||
* @since 2025-10-16
|
* @since 2025-10-16
|
||||||
*/
|
*/
|
||||||
@PostMapping("/{moduleID}/unbind-permissions")
|
@PutMapping("/{moduleID}/permissions")
|
||||||
public ResultDomain<Boolean> unbindPermissionsFromModule(@PathVariable String moduleID,
|
public ResultDomain<TbSysPermission> updatePermissionInModule(@PathVariable(name = "moduleID") String moduleID,
|
||||||
@RequestBody List<String> permissionIds) {
|
@RequestBody TbSysPermission permission) {
|
||||||
return moduleService.unbindPermissionsFromModule(moduleID, permissionIds);
|
permission.setModuleID(moduleID);
|
||||||
|
return moduleService.updatePermissionInModule(permission);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description 删除模块中的权限
|
||||||
|
* @param moduleID 模块ID
|
||||||
|
* @param permissionID 权限ID
|
||||||
|
* @return ResultDomain<Boolean> 删除结果
|
||||||
|
* @author yslg
|
||||||
|
* @since 2025-10-16
|
||||||
|
*/
|
||||||
|
@DeleteMapping("/{moduleID}/permissions/{permissionID}")
|
||||||
|
public ResultDomain<Boolean> deletePermissionInModule(@PathVariable(name = "moduleID") String moduleID,
|
||||||
|
@PathVariable(name = "permissionID") String permissionID) {
|
||||||
|
return moduleService.deletePermissionInModule(moduleID, permissionID);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description 获取模块的权限列表
|
* @description 获取模块的权限列表
|
||||||
* @param moduleID 模块ID
|
* @param moduleID 模块ID
|
||||||
* @return ResultDomain<List<String>> 权限ID列表
|
* @return ResultDomain<TbSysPermission> 权限列表
|
||||||
* @author yslg
|
* @author yslg
|
||||||
* @since 2025-10-16
|
* @since 2025-10-16
|
||||||
*/
|
*/
|
||||||
@GetMapping("/{moduleID}/permissions")
|
@GetMapping("/{moduleID}/permissions")
|
||||||
public ResultDomain<List<String>> getModulePermissions(@PathVariable String moduleID) {
|
public ResultDomain<TbSysPermission> getModulePermissions(@PathVariable(name = "moduleID") String moduleID) {
|
||||||
return moduleService.getModulePermissions(moduleID);
|
return moduleService.getModulePermissions(moduleID);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @description 批量绑定权限到模块
|
|
||||||
* @param moduleID 模块ID
|
|
||||||
* @param permissionIds 权限ID列表
|
|
||||||
* @return ResultDomain<Boolean> 绑定结果
|
|
||||||
* @author yslg
|
|
||||||
* @since 2025-10-16
|
|
||||||
*/
|
|
||||||
@PostMapping("/{moduleID}/batch-bind-permissions")
|
|
||||||
public ResultDomain<Boolean> batchBindPermissionsToModule(@PathVariable String moduleID,
|
|
||||||
@RequestBody List<String> permissionIds) {
|
|
||||||
return moduleService.batchBindPermissionsToModule(moduleID, permissionIds);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @description 批量解绑模块的权限
|
|
||||||
* @param moduleID 模块ID
|
|
||||||
* @param permissionIds 权限ID列表
|
|
||||||
* @return ResultDomain<Boolean> 解绑结果
|
|
||||||
* @author yslg
|
|
||||||
* @since 2025-10-16
|
|
||||||
*/
|
|
||||||
@PostMapping("/{moduleID}/batch-unbind-permissions")
|
|
||||||
public ResultDomain<Boolean> batchUnbindPermissionsFromModule(@PathVariable String moduleID,
|
|
||||||
@RequestBody List<String> permissionIds) {
|
|
||||||
return moduleService.batchUnbindPermissionsFromModule(moduleID, permissionIds);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -168,31 +168,11 @@ public interface PermissionMapper extends BaseMapper<TbSysPermission> {
|
|||||||
List<TbSysPermission> selectPermissionsByModuleID(@Param("moduleID") String moduleID);
|
List<TbSysPermission> selectPermissionsByModuleID(@Param("moduleID") String moduleID);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description 绑定权限到模块
|
* @description 获取模块的权限列表
|
||||||
* @param moduleID 模块ID
|
* @param moduleID 模块ID
|
||||||
* @param permissionIds 权限ID列表
|
* @return List<TbSysPermission> 权限列表
|
||||||
* @return int 影响行数
|
|
||||||
* @author yslg
|
* @author yslg
|
||||||
* @since 2025-10-16
|
* @since 2025-10-16
|
||||||
*/
|
*/
|
||||||
int bindPermissionsToModule(@Param("moduleID") String moduleID, @Param("permissionIds") List<String> permissionIds);
|
List<TbSysPermission> getModulePermissionIds(@Param("moduleID") String moduleID);
|
||||||
|
|
||||||
/**
|
|
||||||
* @description 解绑模块的权限
|
|
||||||
* @param moduleID 模块ID
|
|
||||||
* @param permissionIds 权限ID列表
|
|
||||||
* @return int 影响行数
|
|
||||||
* @author yslg
|
|
||||||
* @since 2025-10-16
|
|
||||||
*/
|
|
||||||
int unbindPermissionsFromModule(@Param("moduleID") String moduleID, @Param("permissionIds") List<String> permissionIds);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @description 获取模块的权限ID列表
|
|
||||||
* @param moduleID 模块ID
|
|
||||||
* @return List<String> 权限ID列表
|
|
||||||
* @author yslg
|
|
||||||
* @since 2025-10-16
|
|
||||||
*/
|
|
||||||
List<String> getModulePermissionIds(@Param("moduleID") String moduleID);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.xyzh.common.core.page.PageParam;
|
import org.xyzh.common.core.page.PageParam;
|
||||||
|
import org.xyzh.common.dto.permission.TbSysPermission;
|
||||||
import org.xyzh.common.dto.system.TbSysModule;
|
import org.xyzh.common.dto.system.TbSysModule;
|
||||||
import org.xyzh.common.utils.IDUtils;
|
import org.xyzh.common.utils.IDUtils;
|
||||||
import org.xyzh.common.core.domain.ResultDomain;
|
import org.xyzh.common.core.domain.ResultDomain;
|
||||||
@@ -184,6 +185,15 @@ public class ModuleServiceImpl implements ModuleService {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 级联删除模块下的所有权限
|
||||||
|
List<TbSysPermission> permissions = permissionMapper.selectPermissionsByModuleID(moduleID);
|
||||||
|
if (permissions != null && !permissions.isEmpty()) {
|
||||||
|
for (TbSysPermission permission : permissions) {
|
||||||
|
permission.setDeleteTime(new Date());
|
||||||
|
permissionMapper.deletePermission(permission);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
module.setDeleteTime(new Date());
|
module.setDeleteTime(new Date());
|
||||||
int result = moduleMapper.deleteModule(module);
|
int result = moduleMapper.deleteModule(module);
|
||||||
if (result > 0) {
|
if (result > 0) {
|
||||||
@@ -267,16 +277,12 @@ public class ModuleServiceImpl implements ModuleService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResultDomain<TbSysModule> getModuleListPage(TbSysModule filter, PageParam pageParam) {
|
public ResultDomain<TbSysModule> getModuleListPage(TbSysModule filter, PageParam pageParam) {
|
||||||
try {
|
pageParam.setOffset((pageParam.getPageNumber() - 1) * pageParam.getPageSize());
|
||||||
List<TbSysModule> modules = moduleMapper.selectModulesPage(filter, pageParam);
|
List<TbSysModule> modules = moduleMapper.selectModulesPage(filter, pageParam);
|
||||||
ResultDomain<TbSysModule> result = new ResultDomain<>();
|
ResultDomain<TbSysModule> result = new ResultDomain<>();
|
||||||
result.success("查询成功", modules);
|
result.success("查询成功", modules);
|
||||||
return result;
|
return result;
|
||||||
} catch (Exception e) {
|
|
||||||
ResultDomain<TbSysModule> result = new ResultDomain<>();
|
|
||||||
result.fail("分页查询模块列表失败:" + e.getMessage());
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -309,99 +315,124 @@ public class ModuleServiceImpl implements ModuleService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public ResultDomain<Boolean> bindPermissionsToModule(String moduleID, List<String> permissionIds) {
|
public ResultDomain<TbSysPermission> createPermissionInModule(TbSysPermission permission) {
|
||||||
try {
|
try {
|
||||||
int result = permissionMapper.bindPermissionsToModule(moduleID, permissionIds);
|
// 检查模块是否存在
|
||||||
|
TbSysModule module = moduleMapper.selectByModuleID(permission.getModuleID());
|
||||||
|
if (module == null) {
|
||||||
|
ResultDomain<TbSysPermission> result = new ResultDomain<>();
|
||||||
|
result.fail("模块不存在");
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 设置基础信息
|
||||||
|
permission.setID(IDUtils.generateID());
|
||||||
|
permission.setPermissionID(IDUtils.generateID());
|
||||||
|
permission.setCreateTime(new Date());
|
||||||
|
permission.setUpdateTime(new Date());
|
||||||
|
permission.setDeleted(false);
|
||||||
|
|
||||||
|
int result = permissionMapper.insertPermission(permission);
|
||||||
if (result > 0) {
|
if (result > 0) {
|
||||||
ResultDomain<Boolean> resultDomain = new ResultDomain<>();
|
ResultDomain<TbSysPermission> resultDomain = new ResultDomain<>();
|
||||||
resultDomain.success("绑定成功", true);
|
resultDomain.success("创建权限成功", permission);
|
||||||
return resultDomain;
|
return resultDomain;
|
||||||
} else {
|
} else {
|
||||||
ResultDomain<Boolean> resultDomain = new ResultDomain<>();
|
ResultDomain<TbSysPermission> resultDomain = new ResultDomain<>();
|
||||||
resultDomain.fail("绑定权限到模块失败");
|
resultDomain.fail("创建权限失败");
|
||||||
return resultDomain;
|
return resultDomain;
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
ResultDomain<Boolean> result = new ResultDomain<>();
|
ResultDomain<TbSysPermission> result = new ResultDomain<>();
|
||||||
result.fail("绑定权限到模块失败:" + e.getMessage());
|
result.fail("创建权限失败:" + e.getMessage());
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public ResultDomain<Boolean> unbindPermissionsFromModule(String moduleID, List<String> permissionIds) {
|
public ResultDomain<TbSysPermission> updatePermissionInModule(TbSysPermission permission) {
|
||||||
try {
|
try {
|
||||||
int result = permissionMapper.unbindPermissionsFromModule(moduleID, permissionIds);
|
// 检查权限是否存在
|
||||||
if (result > 0) {
|
TbSysPermission existingPermission = permissionMapper.selectPermission(permission);
|
||||||
ResultDomain<Boolean> resultDomain = new ResultDomain<>();
|
if (existingPermission == null) {
|
||||||
resultDomain.success("解绑成功", true);
|
ResultDomain<TbSysPermission> result = new ResultDomain<>();
|
||||||
return resultDomain;
|
result.fail("权限不存在");
|
||||||
} else {
|
|
||||||
ResultDomain<Boolean> resultDomain = new ResultDomain<>();
|
|
||||||
resultDomain.fail("解绑模块权限失败");
|
|
||||||
return resultDomain;
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
ResultDomain<Boolean> result = new ResultDomain<>();
|
|
||||||
result.fail("解绑模块权限失败:" + e.getMessage());
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
// 检查权限是否属于该模块
|
||||||
public ResultDomain<List<String>> getModulePermissions(String moduleID) {
|
if (!existingPermission.getModuleID().equals(permission.getModuleID())) {
|
||||||
try {
|
ResultDomain<TbSysPermission> result = new ResultDomain<>();
|
||||||
List<String> permissionIds = permissionMapper.getModulePermissionIds(moduleID);
|
result.fail("权限不属于该模块");
|
||||||
ResultDomain<List<String>> result = new ResultDomain<>();
|
|
||||||
result.success("查询成功", permissionIds);
|
|
||||||
return result;
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
permission.setID(existingPermission.getID());
|
||||||
|
permission.setUpdateTime(new Date());
|
||||||
|
|
||||||
|
int result = permissionMapper.updatePermission(permission);
|
||||||
|
if (result > 0) {
|
||||||
|
ResultDomain<TbSysPermission> resultDomain = new ResultDomain<>();
|
||||||
|
resultDomain.success("更新权限成功", permission);
|
||||||
|
return resultDomain;
|
||||||
|
} else {
|
||||||
|
ResultDomain<TbSysPermission> resultDomain = new ResultDomain<>();
|
||||||
|
resultDomain.fail("更新权限失败");
|
||||||
|
return resultDomain;
|
||||||
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
ResultDomain<List<String>> result = new ResultDomain<>();
|
ResultDomain<TbSysPermission> result = new ResultDomain<>();
|
||||||
result.fail("获取模块权限失败:" + e.getMessage());
|
result.fail("更新权限失败:" + e.getMessage());
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public ResultDomain<Boolean> batchBindPermissionsToModule(String moduleID, List<String> permissionIds) {
|
public ResultDomain<Boolean> deletePermissionInModule(String moduleID, String permissionID) {
|
||||||
try {
|
try {
|
||||||
int result = permissionMapper.bindPermissionsToModule(moduleID, permissionIds);
|
// 检查权限是否存在
|
||||||
|
TbSysPermission permission = new TbSysPermission();
|
||||||
|
permission.setPermissionID(permissionID);
|
||||||
|
TbSysPermission existingPermission = permissionMapper.selectPermission(permission);
|
||||||
|
|
||||||
|
if (existingPermission == null) {
|
||||||
|
ResultDomain<Boolean> result = new ResultDomain<>();
|
||||||
|
result.fail("权限不存在");
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 检查权限是否属于该模块
|
||||||
|
if (!existingPermission.getModuleID().equals(moduleID)) {
|
||||||
|
ResultDomain<Boolean> result = new ResultDomain<>();
|
||||||
|
result.fail("权限不属于该模块");
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
existingPermission.setDeleteTime(new Date());
|
||||||
|
int result = permissionMapper.deletePermission(existingPermission);
|
||||||
if (result > 0) {
|
if (result > 0) {
|
||||||
ResultDomain<Boolean> resultDomain = new ResultDomain<>();
|
ResultDomain<Boolean> resultDomain = new ResultDomain<>();
|
||||||
resultDomain.success("批量绑定成功", true);
|
resultDomain.success("删除权限成功", true);
|
||||||
return resultDomain;
|
return resultDomain;
|
||||||
} else {
|
} else {
|
||||||
ResultDomain<Boolean> resultDomain = new ResultDomain<>();
|
ResultDomain<Boolean> resultDomain = new ResultDomain<>();
|
||||||
resultDomain.fail("批量绑定权限到模块失败");
|
resultDomain.fail("删除权限失败");
|
||||||
return resultDomain;
|
return resultDomain;
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
ResultDomain<Boolean> result = new ResultDomain<>();
|
ResultDomain<Boolean> result = new ResultDomain<>();
|
||||||
result.fail("批量绑定权限到模块失败:" + e.getMessage());
|
result.fail("删除权限失败:" + e.getMessage());
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
public ResultDomain<TbSysPermission> getModulePermissions(String moduleID) {
|
||||||
public ResultDomain<Boolean> batchUnbindPermissionsFromModule(String moduleID, List<String> permissionIds) {
|
List<TbSysPermission> permissions = permissionMapper.getModulePermissionIds(moduleID);
|
||||||
try {
|
ResultDomain<TbSysPermission> result = new ResultDomain<>();
|
||||||
int result = permissionMapper.unbindPermissionsFromModule(moduleID, permissionIds);
|
result.success("查询成功", permissions);
|
||||||
if (result > 0) {
|
|
||||||
ResultDomain<Boolean> resultDomain = new ResultDomain<>();
|
|
||||||
resultDomain.success("批量解绑成功", true);
|
|
||||||
return resultDomain;
|
|
||||||
} else {
|
|
||||||
ResultDomain<Boolean> resultDomain = new ResultDomain<>();
|
|
||||||
resultDomain.fail("批量解绑模块权限失败");
|
|
||||||
return resultDomain;
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
ResultDomain<Boolean> result = new ResultDomain<>();
|
|
||||||
result.fail("批量解绑模块权限失败:" + e.getMessage());
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
@@ -64,6 +64,9 @@ public class SysPermissionServiceImpl implements SysPermissionService {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private MenuService menuService;
|
private MenuService menuService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private org.xyzh.system.mapper.ModuleMapper moduleMapper;
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
@Override
|
@Override
|
||||||
public ResultDomain<TbSysPermission> createPermission(TbSysPermission permission) {
|
public ResultDomain<TbSysPermission> createPermission(TbSysPermission permission) {
|
||||||
@@ -82,6 +85,19 @@ public class SysPermissionServiceImpl implements SysPermissionService {
|
|||||||
return resultDomain;
|
return resultDomain;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 检查所属模块ID是否存在(权限必须在模块中创建)
|
||||||
|
if (!StringUtils.hasText(permission.getModuleID())) {
|
||||||
|
resultDomain.fail("权限必须指定所属模块");
|
||||||
|
return resultDomain;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 校验模块是否存在
|
||||||
|
org.xyzh.common.dto.system.TbSysModule module = moduleMapper.selectByModuleID(permission.getModuleID());
|
||||||
|
if (module == null) {
|
||||||
|
resultDomain.fail("指定的模块不存在");
|
||||||
|
return resultDomain;
|
||||||
|
}
|
||||||
|
|
||||||
// 检查权限名称是否已存在
|
// 检查权限名称是否已存在
|
||||||
ResultDomain<Boolean> nameCheckResult = checkPermissionNameExists(permission.getName(), null);
|
ResultDomain<Boolean> nameCheckResult = checkPermissionNameExists(permission.getName(), null);
|
||||||
if (!nameCheckResult.isSuccess()) {
|
if (!nameCheckResult.isSuccess()) {
|
||||||
|
|||||||
@@ -53,6 +53,29 @@
|
|||||||
</where>
|
</where>
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
|
<sql id="Filter_Where_Clause">
|
||||||
|
<where>
|
||||||
|
deleted = 0
|
||||||
|
<if test="filter != null">
|
||||||
|
<if test="filter.id != null and filter.id != ''">
|
||||||
|
AND id = #{filter.id}
|
||||||
|
</if>
|
||||||
|
</if>
|
||||||
|
<if test="filter.moduleID != null and filter.moduleID != ''">
|
||||||
|
AND module_id = #{filter.moduleID}
|
||||||
|
</if>
|
||||||
|
<if test="filter.name != null and filter.name != ''">
|
||||||
|
AND name LIKE CONCAT('%', #{filter.name}, '%')
|
||||||
|
</if>
|
||||||
|
<if test="filter.code != null and filter.code != ''">
|
||||||
|
AND code = #{filter.code}
|
||||||
|
</if>
|
||||||
|
<if test="filter.status != null">
|
||||||
|
AND status = #{filter.status}
|
||||||
|
</if>
|
||||||
|
</where>
|
||||||
|
</sql>
|
||||||
|
|
||||||
<!-- 查询模块列表 -->
|
<!-- 查询模块列表 -->
|
||||||
<select id="selectModules" resultMap="BaseResultMap">
|
<select id="selectModules" resultMap="BaseResultMap">
|
||||||
SELECT
|
SELECT
|
||||||
@@ -178,7 +201,7 @@
|
|||||||
SELECT
|
SELECT
|
||||||
<include refid="Base_Column_List" />
|
<include refid="Base_Column_List" />
|
||||||
FROM tb_sys_module
|
FROM tb_sys_module
|
||||||
<include refid="Base_Where_Clause" />
|
<include refid="Filter_Where_Clause" />
|
||||||
ORDER BY order_num ASC, create_time DESC
|
ORDER BY order_num ASC, create_time DESC
|
||||||
LIMIT #{pageParam.pageSize} OFFSET #{pageParam.offset}
|
LIMIT #{pageParam.pageSize} OFFSET #{pageParam.offset}
|
||||||
</select>
|
</select>
|
||||||
@@ -187,7 +210,7 @@
|
|||||||
<select id="countModules" resultType="long">
|
<select id="countModules" resultType="long">
|
||||||
SELECT COUNT(1)
|
SELECT COUNT(1)
|
||||||
FROM tb_sys_module
|
FROM tb_sys_module
|
||||||
<include refid="Base_Where_Clause" />
|
<include refid="Filter_Where_Clause" />
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<!-- 更新模块状态 -->
|
<!-- 更新模块状态 -->
|
||||||
|
|||||||
@@ -150,6 +150,7 @@
|
|||||||
<if test="permission.name != null">name,</if>
|
<if test="permission.name != null">name,</if>
|
||||||
<if test="permission.code != null">code,</if>
|
<if test="permission.code != null">code,</if>
|
||||||
<if test="permission.description != null">description,</if>
|
<if test="permission.description != null">description,</if>
|
||||||
|
<if test="permission.moduleID != null">module_id,</if>
|
||||||
<if test="permission.creator != null">creator,</if>
|
<if test="permission.creator != null">creator,</if>
|
||||||
<if test="permission.createTime != null">create_time,</if>
|
<if test="permission.createTime != null">create_time,</if>
|
||||||
deleted
|
deleted
|
||||||
@@ -160,6 +161,7 @@
|
|||||||
<if test="permission.name != null">#{permission.name},</if>
|
<if test="permission.name != null">#{permission.name},</if>
|
||||||
<if test="permission.code != null">#{permission.code},</if>
|
<if test="permission.code != null">#{permission.code},</if>
|
||||||
<if test="permission.description != null">#{permission.description},</if>
|
<if test="permission.description != null">#{permission.description},</if>
|
||||||
|
<if test="permission.moduleID != null">#{permission.moduleID},</if>
|
||||||
<if test="permission.creator != null">#{permission.creator},</if>
|
<if test="permission.creator != null">#{permission.creator},</if>
|
||||||
<if test="permission.createTime != null">#{permission.createTime},</if>
|
<if test="permission.createTime != null">#{permission.createTime},</if>
|
||||||
0
|
0
|
||||||
@@ -174,6 +176,7 @@
|
|||||||
<if test="permission.name != null">name = #{permission.name},</if>
|
<if test="permission.name != null">name = #{permission.name},</if>
|
||||||
<if test="permission.code != null">code = #{permission.code},</if>
|
<if test="permission.code != null">code = #{permission.code},</if>
|
||||||
<if test="permission.description != null">description = #{permission.description},</if>
|
<if test="permission.description != null">description = #{permission.description},</if>
|
||||||
|
<if test="permission.moduleID != null">module_id = #{permission.moduleID},</if>
|
||||||
<if test="permission.updater != null">updater = #{permission.updater},</if>
|
<if test="permission.updater != null">updater = #{permission.updater},</if>
|
||||||
update_time = NOW()
|
update_time = NOW()
|
||||||
</set>
|
</set>
|
||||||
@@ -298,32 +301,10 @@
|
|||||||
ORDER BY create_time DESC
|
ORDER BY create_time DESC
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<!-- 绑定权限到模块 -->
|
<!-- 获取模块的权限列表 -->
|
||||||
<update id="bindPermissionsToModule">
|
<select id="getModulePermissionIds" resultMap="BaseResultMap">
|
||||||
UPDATE tb_sys_permission
|
SELECT
|
||||||
SET module_id = #{moduleID}, update_time = NOW()
|
<include refid="Base_Column_List" />
|
||||||
WHERE permission_id IN
|
|
||||||
<foreach collection="permissionIds" item="permissionId" open="(" separator="," close=")">
|
|
||||||
#{permissionId}
|
|
||||||
</foreach>
|
|
||||||
AND deleted = 0
|
|
||||||
</update>
|
|
||||||
|
|
||||||
<!-- 解绑模块的权限 -->
|
|
||||||
<update id="unbindPermissionsFromModule">
|
|
||||||
UPDATE tb_sys_permission
|
|
||||||
SET module_id = NULL, update_time = NOW()
|
|
||||||
WHERE permission_id IN
|
|
||||||
<foreach collection="permissionIds" item="permissionId" open="(" separator="," close=")">
|
|
||||||
#{permissionId}
|
|
||||||
</foreach>
|
|
||||||
AND module_id = #{moduleID}
|
|
||||||
AND deleted = 0
|
|
||||||
</update>
|
|
||||||
|
|
||||||
<!-- 获取模块的权限ID列表 -->
|
|
||||||
<select id="getModulePermissionIds" resultType="String">
|
|
||||||
SELECT permission_id
|
|
||||||
FROM tb_sys_permission
|
FROM tb_sys_permission
|
||||||
WHERE module_id = #{moduleID} AND deleted = 0
|
WHERE module_id = #{moduleID} AND deleted = 0
|
||||||
ORDER BY create_time DESC
|
ORDER BY create_time DESC
|
||||||
|
|||||||
Reference in New Issue
Block a user