houzhongjian
2024-10-16 7da8f196dee8e3c526c009a4bc7f5983ece6bb97
提交 | 用户 | 时间
818a01 1 package com.iailab.module.system.api.app;
H 2
3 import cn.hutool.core.collection.CollUtil;
4 import com.iailab.framework.common.pojo.CommonResult;
5 import com.iailab.framework.common.util.object.BeanUtils;
6 import com.iailab.module.system.api.app.dto.AppMenuRespDTO;
7 import com.iailab.module.system.api.app.dto.AppRespDTO;
8 import com.iailab.module.system.convert.app.AppConvert;
9 import com.iailab.module.system.dal.dataobject.app.AppDO;
10 import com.iailab.module.system.dal.dataobject.app.AppMenuDO;
11 import com.iailab.module.system.service.app.AppMenuService;
12 import com.iailab.module.system.service.app.AppService;
13 import org.springframework.validation.annotation.Validated;
14 import org.springframework.web.bind.annotation.RestController;
15
16 import javax.annotation.Resource;
17 import java.util.*;
18
19 import static com.iailab.framework.common.pojo.CommonResult.success;
20 import static com.iailab.framework.common.util.collection.CollectionUtils.convertSet;
21
22 @RestController // 提供 RESTful API 接口,给 Feign 调用
23 @Validated
24 public class AppApiImpl implements AppApi {
25
26     @Resource
27     private AppService appService;
28
29 //    @Override
30 //    public CommonResult<List<AppMenuRespDTO>> getAppMenuList(Long id) {
31 //        List<AppMenuDO> children = new LinkedList<>();
32 //        // 遍历每一层
33 //        Collection<Long> parentIds = Collections.singleton(id);
34 //        for (int i = 0; i < Short.MAX_VALUE; i++) { // 使用 Short.MAX_VALUE 避免 bug 场景下,存在死循环
35 //            // 查询当前层,所有的子应用菜单
36 //            List<AppMenuDO> menus = appMenuService.selectListByParentId(parentIds);
37 //            // 1. 如果没有子菜单,则结束遍历
38 //            if (CollUtil.isEmpty(menus)) {
39 //                break;
40 //            }
41 //            // 2. 如果有子应用菜单,继续遍历
42 //            children.addAll(menus);
43 //            parentIds = convertSet(menus, AppMenuDO::getId);
44 //        }
45 ////        children = appMenuService.filterDisableMenus(children);
46 //        return success(AppConvert.INSTANCE.buildMenuTree(id, children));
47 //    }
48
49     @Override
50     public CommonResult<List<AppRespDTO>> getAppList() {
51         List<AppDO> list = appService.getList();
52         list.sort(Comparator.comparing(AppDO::getOrderNum));
53         return success(BeanUtils.toBean(list, AppRespDTO.class));
54     }
55 }