package edu.travel.tenant.web;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import edu.travel.resp.BaseResponse;
import edu.travel.resp.PageResponse;
import edu.travel.tenant.dto.AssignRolesOrMenus;
import edu.travel.tenant.dto.SysMenuPageDto;
import edu.travel.tenant.entity.EduTenant;
import edu.travel.tenant.entity.SysMenu;
import edu.travel.tenant.service.ISysMenuService;
import edu.travel.tenant.service.ISysRoleService;
import edu.travel.web.BaseController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.Errors;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.List;
/**
* SysMenuController 类。
*
* 描述:
*
* @author huangwenwen
* @date 2025/2/6
*/
@RestController
@RequestMapping("/sysMenu")
public class SysMenuController extends BaseController {
@Autowired
private ISysMenuService sysMenuService;
/**
* 新增菜单
* @param sysMenu
* @return
*/
@PostMapping("/addMenu")
// @PreAuthorize("hasRole('超级管理员')")
public BaseResponse addMenu(@RequestBody SysMenu sysMenu) {
sysMenuService.addMenu(sysMenu);
return new BaseResponse<>(200,"sucess",true);
}
/**
* 删除菜单单个
* @param id
* @return
*/
@PostMapping("/deleteMenuById")
// @PreAuthorize("hasRole('超级管理员')")
public BaseResponse deleteMenuById(Long id) {
List longs = new ArrayList<>();
longs.add(id);
sysMenuService.deleteMenuByIds(longs);
return new BaseResponse<>(200,"sucess",true);
}
/**
* 删除菜单多个
* @param ids
* @return
*/
@PostMapping("/deleteMenuByIds")
// @PreAuthorize("hasRole('超级管理员')")
public BaseResponse deleteMenuByIds(@RequestBody List ids) {
sysMenuService.deleteMenuByIds(ids);
return new BaseResponse<>(200,"sucess",true);
}
/**
* 获取菜单分页列表
* @param sysMenuPageDto
* @return
*/
@GetMapping("/getMenuList")
// @PreAuthorize("hasRole('超级管理员')")
public BaseResponse> getMenuList(SysMenuPageDto sysMenuPageDto) {
IPage page = new Page<>(sysMenuPageDto.getPageNum(), sysMenuPageDto.getPageSize());
IPage tenantIPage = sysMenuService.page(page, new LambdaQueryWrapper().eq(SysMenu::getDeleteFlag, 0));
return PageResponse.out(200,"success",tenantIPage.getRecords(),(int)tenantIPage.getTotal(),(int)tenantIPage.getSize());
}
}