package ink.wgink.service.permission.init.build;

import ink.wgink.interfaces.init.build.IBuildServiceMenu;
import ink.wgink.pojo.bos.menu.InitMenuBO;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @ClassName: BuildPermissionMenu
 * @Description: 构建权限菜单
 * @Author: wanggeng
 * @Date: 2022/7/28 23:34
 * @Version: 1.0
 */
@Component
public class BuildPermissionMenu implements IBuildServiceMenu {
    @Override
    public void buildMenu(List<InitMenuBO> initMenus) {
        // 获取角色权限管理
        InitMenuBO parentMenu = initMenus.get(2);
        // 获取子菜单
        List<InitMenuBO> subMenus = parentMenu.getSubMenus();
        InitMenuBO insertInitMenu = new InitMenuBO();
        insertInitMenu.setMenuName("新增权限");
        insertInitMenu.setMenuSummary("新增权限");
        insertInitMenu.setMenuUrl("/route/permission/list?permissionType=permissionInsert");
        subMenus.add(insertInitMenu);

        InitMenuBO deleteInitMenu = new InitMenuBO();
        deleteInitMenu.setMenuName("删除权限");
        deleteInitMenu.setMenuSummary("删除权限");
        deleteInitMenu.setMenuUrl("/route/permission/list?permissionType=permissionDelete");
        subMenus.add(deleteInitMenu);

        InitMenuBO updateInitMenu = new InitMenuBO();
        updateInitMenu.setMenuName("修改权限");
        updateInitMenu.setMenuSummary("修改权限");
        updateInitMenu.setMenuUrl("/route/permission/list?permissionType=permissionUpdate");
        subMenus.add(updateInitMenu);

        InitMenuBO queryInitMenu = new InitMenuBO();
        queryInitMenu.setMenuName("查询权限");
        queryInitMenu.setMenuSummary("查询权限");
        queryInitMenu.setMenuUrl("/route/permission/list?permissionType=permissionQuery");
        subMenus.add(queryInitMenu);
        // 更新子菜单
        parentMenu.setSubMenus(subMenus);
    }
}
