Mybatis-Plus父子菜单
pojo层
@Data
@TableName("platform_role")
public class Role implements Serializable {
private static final long serialVersionUID = 1L;
@TableId(value = "id", type = IdType.AUTO)
private Long id;
private String roleName;
private String roleKey;
private Long createdBy;
@TableField(fill = FieldFill.INSERT)
private LocalDateTime createdDate;
private Long lastModifiedBy;
private LocalDateTime lastModified;
private String owner;
}
MenuMapper
@Mapper
@Repository
public interface MenuMapper extends BaseMapper
MenuService
public interface IMenuRoleService extends IService {
}
MenuServiceImpl
package com.zcx.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.zcx.pojo.Menu;
import com.zcx.mapper.MenuMapper;
import com.zcx.service.IMenuService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
/**
*
* 菜单实现层
*
*
* @author zcx
* @since 2022-03-31
*/
@Service
public class MenuServiceImpl extends ServiceImpl implements IMenuService {
@Autowired
MenuMapper menuMapper;
/**
* @author zhaochangxin
* @Description:查询所有菜单
* @return: java.util.List
* @date 2022/3/31 17:13
* @throws
*/
@Override
public List
MenuController
package com.zcx.controller;
import com.zcx.common.vo.ApiResult;
import com.zcx.pojo.Menu;
import com.zcx.service.IMenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.List;
/**
*
* 前端控制器
*
*
* @author zcx
* @since 2022-03-31
*/
@Controller
@RequestMapping("/menu")
public class MenuController {
@Autowired
IMenuService menuService;
@ResponseBody
@RequestMapping("/list")
public ApiResult queryAllMenu(){
List menus = menuService.queryAllMenu();
return ApiResult.success("查询所有菜单",menus);
}
}
有问题或更好的办法请留言告知,谢谢您的观看。