revert(app): 移除无用注解和字段并调整代码格式

- 移除AppPageEntity中的@FieldNameConstants注解
- 删除PageTypeEnums中的WORKBENCH枚举项
- 调整AppArticleCollectEntity字段缩进格式
- 简化AppRole中的roleDesc字段描述并移除menuId字段
This commit is contained in:
PIG AI committed 2025-06-24 09:28:23 +08:00
1 parent de7e1fb4df
commit 946ca2ef38
4 files changed
+134 -220

No files matched your search

@@ -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.<AppRole>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.<AppRole>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.<AppRole>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.<AppRole>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.<AppRole>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.<AppRole>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<AppRole> 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<AppRoleExcelVO> 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<AppRole> 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<AppRoleExcelVO> excelVOList, BindingResult bindingResult) {
return appRoleService.importRole(excelVOList, bindingResult);
}
}
@@ -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<AppRole> {
/**
* 根据用户ID查询角色列表
*
* @param userId 用户ID
* @return 对应用户ID的角色列表
*/
List<AppRole> findRolesByUserId(Long userId);
/**
@@ -48,18 +41,6 @@ public interface AppRoleService extends IService<AppRole> {
*/
Boolean deleteRoleByIds(Long[] ids);
/**
* 导入角色信息方法
*
* @param excelVOList 角色信息的Excel视图对象列表
* @param bindingResult 数据绑定结果,用于校验
*/
R importRole(List<AppRoleExcelVO> excelVOList, BindingResult bindingResult);
/**
* 获取列表菜单对象
*
* @return 列表菜单对象的实例
*/
AppPageEntity listMenu();
}
@@ -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<AppArticleEntity> articleList = appArticleMapper
.selectList(Wrappers.<AppArticleEntity>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.<AppPageEntity>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<String> 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.<AppPageEntity>lambdaQuery().eq(AppPageEntity::getPageType, pageType)
.orderByDesc(AppPageEntity::getCreateTime), false);
}
}
@@ -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角色服务实现类
* <p>
* 提供对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<AppRoleMapper, AppRole> implements AppRoleService {
private final AppPageMapper appPageMapper;
private final AppRoleMapper appRoleMapper;
@Override
public List<AppRole> findRolesByUserId(Long userId) {
return baseMapper.listRolesByUserId(userId);
@@ -112,17 +102,6 @@ public class AppRoleServiceImpl extends ServiceImpl<AppRoleMapper, AppRole> impl
}
/**
* 获取列表菜单对象
*
* @return 列表菜单对象的实例
*/
@Override
public AppPageEntity listMenu() {
return appPageMapper.selectOne(Wrappers.<AppPageEntity>lambdaQuery()
.eq(AppPageEntity::getPageType, PageTypeEnums.WORKBENCH.getPageType()));
}
private void insertExcelRole(AppRoleExcelVO excel) {
AppRole appRole = new AppRole();
appRole.setRoleName(excel.getRoleName());