From 946ca2ef38c212fcfec6956d6bc14940fb08b150 Mon Sep 17 00:00:00 2001 From: PIG AI Date: Tue, 24 Jun 2025 09:28:23 +0800 Subject: [PATCH] =?UTF-8?q?revert(app):=20=E7=A7=BB=E9=99=A4=E6=97=A0?= =?UTF-8?q?=E7=94=A8=E6=B3=A8=E8=A7=A3=E5=92=8C=E5=AD=97=E6=AE=B5=E5=B9=B6?= =?UTF-8?q?=E8=B0=83=E6=95=B4=E4=BB=A3=E7=A0=81=E6=A0=BC=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 移除AppPageEntity中的@FieldNameConstants注解 - 删除PageTypeEnums中的WORKBENCH枚举项 - 调整AppArticleCollectEntity字段缩进格式 - 简化AppRole中的roleDesc字段描述并移除menuId字段 --- .../app/controller/AppRoleController.java | 251 +++++++++--------- .../pigx/app/service/AppRoleService.java | 19 -- .../app/service/impl/AppIndexServiceImpl.java | 53 +--- .../app/service/impl/AppRoleServiceImpl.java | 31 +-- 4 files changed, 134 insertions(+), 220 deletions(-) diff --git a/pigx-app-server/pigx-app-server-biz/src/main/java/com/pig4cloud/pigx/app/controller/AppRoleController.java b/pigx-app-server/pigx-app-server-biz/src/main/java/com/pig4cloud/pigx/app/controller/AppRoleController.java index 969d2a561..fbac78ae6 100644 --- a/pigx-app-server/pigx-app-server-biz/src/main/java/com/pig4cloud/pigx/app/controller/AppRoleController.java +++ b/pigx-app-server/pigx-app-server-biz/src/main/java/com/pig4cloud/pigx/app/controller/AppRoleController.java @@ -51,146 +51,135 @@ import java.util.List; @SecurityRequirement(name = HttpHeaders.AUTHORIZATION) public class AppRoleController { - private final AppRoleService appRoleService; + private final AppRoleService appRoleService; - /** - * 分页查询 - * - * @param page 分页对象 - * @param appRole app角色表 - * @return - */ - @Operation(summary = "分页查询", description = "分页查询") - @GetMapping("/page") - public R getAppRolePage(Page page, AppRole appRole) { - return R.ok(appRoleService.page(page, Wrappers.lambdaQuery() - .like(StrUtil.isNotBlank(appRole.getRoleName()), AppRole::getRoleName, appRole.getRoleName()))); - } + /** + * 分页查询 + * + * @param page 分页对象 + * @param appRole app角色表 + * @return + */ + @Operation(summary = "分页查询", description = "分页查询") + @GetMapping("/page") + public R getAppRolePage(Page page, AppRole appRole) { + return R.ok(appRoleService.page(page, Wrappers.lambdaQuery() + .like(StrUtil.isNotBlank(appRole.getRoleName()), AppRole::getRoleName, appRole.getRoleName()))); + } - /** - * 查询全部角色 - * - * @return - */ - @Operation(summary = "查询全部", description = "查询全部") - @GetMapping("/list") - public R list() { - return R.ok(appRoleService.list(Wrappers.emptyWrapper())); - } + /** + * 查询全部角色 + * + * @return + */ + @Operation(summary = "查询全部", description = "查询全部") + @GetMapping("/list") + public R list() { + return R.ok(appRoleService.list(Wrappers.emptyWrapper())); + } - /** - * 通过id查询app角色表 - * - * @param roleId id - * @return R - */ - @Operation(summary = "通过id查询", description = "通过id查询") - @GetMapping("/{roleId}") - public R getById(@PathVariable("roleId") Long roleId) { - return R.ok(appRoleService.getById(roleId)); - } + /** + * 通过id查询app角色表 + * + * @param roleId id + * @return R + */ + @Operation(summary = "通过id查询", description = "通过id查询") + @GetMapping("/{roleId}") + public R getById(@PathVariable("roleId") Long roleId) { + return R.ok(appRoleService.getById(roleId)); + } - /** - * 通过roleName查询app角色表 - * - * @param roleName roleName - * @return R - */ - @Operation(summary = "通过id查询", description = "通过id查询") - @GetMapping("/details/{roleName}") - public R getByUserName(@PathVariable("roleName") String roleName) { - return R.ok(appRoleService.getOne(Wrappers.lambdaQuery().eq(AppRole::getRoleName, roleName))); - } + /** + * 通过roleName查询app角色表 + * + * @param roleName roleName + * @return R + */ + @Operation(summary = "通过id查询", description = "通过id查询") + @GetMapping("/details/{roleName}") + public R getByUserName(@PathVariable("roleName") String roleName) { + return R.ok(appRoleService.getOne(Wrappers.lambdaQuery().eq(AppRole::getRoleName, roleName))); + } - /** - * 通过roleCode查询app角色表 - * - * @param roleCode roleCode - * @return R - */ - @Operation(summary = "通过roleCode查询", description = "通过roleCode查询") - @GetMapping("/detailsByCode/{roleCode}") - public R getByPhone(@PathVariable("roleCode") String roleCode) { - return R.ok(appRoleService.getOne(Wrappers.lambdaQuery().eq(AppRole::getRoleCode, roleCode))); - } + /** + * 通过roleCode查询app角色表 + * + * @param roleCode roleCode + * @return R + */ + @Operation(summary = "通过roleCode查询", description = "通过roleCode查询") + @GetMapping("/detailsByCode/{roleCode}") + public R getByPhone(@PathVariable("roleCode") String roleCode) { + return R.ok(appRoleService.getOne(Wrappers.lambdaQuery().eq(AppRole::getRoleCode, roleCode))); + } - /** - * 新增app角色表 - * - * @param appRole app角色表 - * @return R - */ - @Operation(summary = "新增app角色表", description = "新增app角色表") - @SysLog("新增app角色表") - @PostMapping - @HasPermission("app_approle_add") - public R save(@RequestBody AppRole appRole) { - return R.ok(appRoleService.save(appRole)); - } + /** + * 新增app角色表 + * + * @param appRole app角色表 + * @return R + */ + @Operation(summary = "新增app角色表", description = "新增app角色表") + @SysLog("新增app角色表") + @PostMapping + @HasPermission("app_approle_add") + public R save(@RequestBody AppRole appRole) { + return R.ok(appRoleService.save(appRole)); + } - /** - * 修改app角色表 - * - * @param appRole app角色表 - * @return R - */ - @Operation(summary = "修改app角色表", description = "修改app角色表") - @SysLog("修改app角色表") - @PutMapping - @HasPermission("app_approle_edit") - public R updateById(@RequestBody AppRole appRole) { - return R.ok(appRoleService.updateById(appRole)); - } + /** + * 修改app角色表 + * + * @param appRole app角色表 + * @return R + */ + @Operation(summary = "修改app角色表", description = "修改app角色表") + @SysLog("修改app角色表") + @PutMapping + @HasPermission("app_approle_edit") + public R updateById(@RequestBody AppRole appRole) { + return R.ok(appRoleService.updateById(appRole)); + } - /** - * 通过ids批量删除app角色表 - * - * @param ids roleIds - * @return R - */ - @Operation(summary = "通过ids批量删除app角色表", description = "通过ids批量删除app角色表") - @SysLog("通过ids批量删除app角色表") - @DeleteMapping - @HasPermission("app_approle_del") - public R removeById(@RequestBody Long[] ids) { - return R.ok(appRoleService.deleteRoleByIds(ids)); - } + /** + * 通过ids批量删除app角色表 + * + * @param ids roleIds + * @return R + */ + @Operation(summary = "通过ids批量删除app角色表", description = "通过ids批量删除app角色表") + @SysLog("通过ids批量删除app角色表") + @DeleteMapping + @HasPermission("app_approle_del") + public R removeById(@RequestBody Long[] ids) { + return R.ok(appRoleService.deleteRoleByIds(ids)); + } - /** - * 导出excel 表格 - * - * @param appRole 查询条件 - * @return excel 文件流 - */ - @ResponseExcel - @GetMapping("/export") - @HasPermission("app_approle_export") - public List export(AppRole appRole) { - return appRoleService.list(Wrappers.query(appRole)); - } - - /** - * 导入角色 - * - * @param excelVOList 角色列表 - * @param bindingResult 错误信息列表 - * @return ok fail - */ - @PostMapping("/import") - @HasPermission("app_approle_export") - public R importRole(@RequestExcel List excelVOList, BindingResult bindingResult) { - return appRoleService.importRole(excelVOList, bindingResult); - } - - /** - * 获取工作台菜单列表 - * - * @return 返回封装了菜单列表的结果对象 - */ - @GetMapping("/menu") - public R menu() { - return R.ok(appRoleService.listMenu()); - } + /** + * 导出excel 表格 + * + * @param appRole 查询条件 + * @return excel 文件流 + */ + @ResponseExcel + @GetMapping("/export") + @HasPermission("app_approle_export") + public List export(AppRole appRole) { + return appRoleService.list(Wrappers.query(appRole)); + } + /** + * 导入角色 + * + * @param excelVOList 角色列表 + * @param bindingResult 错误信息列表 + * @return ok fail + */ + @PostMapping("/import") + @HasPermission("app_approle_export") + public R importRole(@RequestExcel List excelVOList, BindingResult bindingResult) { + return appRoleService.importRole(excelVOList, bindingResult); + } } diff --git a/pigx-app-server/pigx-app-server-biz/src/main/java/com/pig4cloud/pigx/app/service/AppRoleService.java b/pigx-app-server/pigx-app-server-biz/src/main/java/com/pig4cloud/pigx/app/service/AppRoleService.java index 1f7ce9b76..a1cb464d4 100644 --- a/pigx-app-server/pigx-app-server-biz/src/main/java/com/pig4cloud/pigx/app/service/AppRoleService.java +++ b/pigx-app-server/pigx-app-server-biz/src/main/java/com/pig4cloud/pigx/app/service/AppRoleService.java @@ -18,7 +18,6 @@ package com.pig4cloud.pigx.app.service; import com.baomidou.mybatisplus.extension.service.IService; -import com.pig4cloud.pigx.app.api.entity.AppPageEntity; import com.pig4cloud.pigx.app.api.entity.AppRole; import com.pig4cloud.pigx.app.api.vo.AppRoleExcelVO; import com.pig4cloud.pigx.common.core.util.R; @@ -34,12 +33,6 @@ import java.util.List; */ public interface AppRoleService extends IService { - /** - * 根据用户ID查询角色列表 - * - * @param userId 用户ID - * @return 对应用户ID的角色列表 - */ List findRolesByUserId(Long userId); /** @@ -48,18 +41,6 @@ public interface AppRoleService extends IService { */ Boolean deleteRoleByIds(Long[] ids); - /** - * 导入角色信息方法 - * - * @param excelVOList 角色信息的Excel视图对象列表 - * @param bindingResult 数据绑定结果,用于校验 - */ R importRole(List excelVOList, BindingResult bindingResult); - /** - * 获取列表菜单对象 - * - * @return 列表菜单对象的实例 - */ - AppPageEntity listMenu(); } diff --git a/pigx-app-server/pigx-app-server-biz/src/main/java/com/pig4cloud/pigx/app/service/impl/AppIndexServiceImpl.java b/pigx-app-server/pigx-app-server-biz/src/main/java/com/pig4cloud/pigx/app/service/impl/AppIndexServiceImpl.java index 2f84d4868..73e3831ed 100644 --- a/pigx-app-server/pigx-app-server-biz/src/main/java/com/pig4cloud/pigx/app/service/impl/AppIndexServiceImpl.java +++ b/pigx-app-server/pigx-app-server-biz/src/main/java/com/pig4cloud/pigx/app/service/impl/AppIndexServiceImpl.java @@ -1,18 +1,12 @@ package com.pig4cloud.pigx.app.service.impl; -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.util.CharUtil; -import cn.hutool.core.util.StrUtil; -import cn.hutool.json.JSONArray; -import cn.hutool.json.JSONObject; -import cn.hutool.json.JSONUtil; import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.pig4cloud.pigx.app.api.entity.AppArticleEntity; import com.pig4cloud.pigx.app.api.entity.AppPageEntity; -import com.pig4cloud.pigx.app.api.entity.AppRole; import com.pig4cloud.pigx.app.api.entity.AppTabbarEntity; import com.pig4cloud.pigx.app.api.enums.PageTypeEnums; +import com.pig4cloud.pigx.app.mapper.AppArticleMapper; import com.pig4cloud.pigx.app.mapper.AppPageMapper; -import com.pig4cloud.pigx.app.mapper.AppRoleMapper; import com.pig4cloud.pigx.app.mapper.AppTabbarMapper; import com.pig4cloud.pigx.app.service.AppIndexService; import lombok.RequiredArgsConstructor; @@ -21,7 +15,6 @@ import org.springframework.stereotype.Service; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; -import java.util.Objects; /** * app 页面控制 @@ -34,9 +27,9 @@ import java.util.Objects; @RequiredArgsConstructor public class AppIndexServiceImpl implements AppIndexService { - private final AppTabbarMapper appTabbarMapper; + private final AppArticleMapper appArticleMapper; - private final AppRoleMapper appRoleMapper; + private final AppTabbarMapper appTabbarMapper; private final AppPageMapper appPageMapper; @@ -51,7 +44,10 @@ public class AppIndexServiceImpl implements AppIndexService { .orderByDesc(AppPageEntity::getCreateTime), false ); + List articleList = appArticleMapper + .selectList(Wrappers.lambdaQuery().orderByDesc(AppArticleEntity::getSort)); response.put("pages", appPageEntity); + response.put("article", articleList); return response; } @@ -77,39 +73,8 @@ public class AppIndexServiceImpl implements AppIndexService { */ @Override public AppPageEntity decorate(Integer pageType) { - AppPageEntity appPage = appPageMapper.selectOne( - Wrappers.lambdaQuery() - .eq(AppPageEntity::getPageType, pageType) - .orderByDesc(AppPageEntity::getCreateTime), - false - ); - - // 如果是工作台页面类型 - if (!Objects.equals(PageTypeEnums.WORKBENCH.getPageType(), pageType) || appPage == null) { - return appPage; - } - - AppRole appRole = appRoleMapper.selectById(1); // 角色ID根据实际业务调整 - List menuIdList = StrUtil.split(appRole.getMenuId(), CharUtil.COMMA); - - if (CollUtil.isEmpty(menuIdList)) { - return appPage; - } - - JSONArray pageDataArray = JSONUtil.parseArray(appPage.getPageData()); - for (Object groupObj : pageDataArray) { - JSONObject group = (JSONObject) groupObj; - JSONArray itemArray = group.getJSONObject("content").getJSONArray("data"); - - // 使用 removeIf 进行过滤 - itemArray.removeIf(item -> { - String menuId = ((JSONObject) item).getStr(AppPageEntity.Fields.id); - return StrUtil.isNotBlank(menuId) && !menuIdList.contains(menuId); - }); - } - - appPage.setPageData(pageDataArray.toStringPretty()); - return appPage; + return appPageMapper.selectOne(Wrappers.lambdaQuery().eq(AppPageEntity::getPageType, pageType) + .orderByDesc(AppPageEntity::getCreateTime), false); } } diff --git a/pigx-app-server/pigx-app-server-biz/src/main/java/com/pig4cloud/pigx/app/service/impl/AppRoleServiceImpl.java b/pigx-app-server/pigx-app-server-biz/src/main/java/com/pig4cloud/pigx/app/service/impl/AppRoleServiceImpl.java index 8d8349838..b4a8293a4 100644 --- a/pigx-app-server/pigx-app-server-biz/src/main/java/com/pig4cloud/pigx/app/service/impl/AppRoleServiceImpl.java +++ b/pigx-app-server/pigx-app-server-biz/src/main/java/com/pig4cloud/pigx/app/service/impl/AppRoleServiceImpl.java @@ -17,20 +17,16 @@ package com.pig4cloud.pigx.app.service.impl; import cn.hutool.core.collection.CollUtil; -import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.pig4cloud.pigx.app.api.entity.AppPageEntity; import com.pig4cloud.pigx.app.api.entity.AppRole; -import com.pig4cloud.pigx.app.api.enums.PageTypeEnums; import com.pig4cloud.pigx.app.api.vo.AppRoleExcelVO; -import com.pig4cloud.pigx.app.mapper.AppPageMapper; import com.pig4cloud.pigx.app.mapper.AppRoleMapper; import com.pig4cloud.pigx.app.service.AppRoleService; import com.pig4cloud.pigx.common.core.exception.ErrorCodes; import com.pig4cloud.pigx.common.core.util.MsgUtils; import com.pig4cloud.pigx.common.core.util.R; import com.pig4cloud.pigx.common.excel.vo.ErrorMessage; -import lombok.RequiredArgsConstructor; +import lombok.AllArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.validation.BindingResult; @@ -39,21 +35,15 @@ import java.util.List; import java.util.Set; /** - * APP角色服务实现类 - *

- * 提供对APP角色相关的业务操作实现。 + * app角色表 * - * @author lengleng - * @date 2025/05/29 + * @author aeizzz + * @date 2022-12-07 09:52:03 */ @Service -@RequiredArgsConstructor +@AllArgsConstructor public class AppRoleServiceImpl extends ServiceImpl implements AppRoleService { - private final AppPageMapper appPageMapper; - - private final AppRoleMapper appRoleMapper; - @Override public List findRolesByUserId(Long userId) { return baseMapper.listRolesByUserId(userId); @@ -112,17 +102,6 @@ public class AppRoleServiceImpl extends ServiceImpl impl } - /** - * 获取列表菜单对象 - * - * @return 列表菜单对象的实例 - */ - @Override - public AppPageEntity listMenu() { - return appPageMapper.selectOne(Wrappers.lambdaQuery() - .eq(AppPageEntity::getPageType, PageTypeEnums.WORKBENCH.getPageType())); - } - private void insertExcelRole(AppRoleExcelVO excel) { AppRole appRole = new AppRole(); appRole.setRoleName(excel.getRoleName());