浏览代码

'开发移动端系统管理-菜单管理-新增、移动端系统管理-菜单管理-修改和移动端系统管理-菜单管理-删除三个接口'

james 2 年之前
父节点
当前提交
2874f90ffa

+ 85 - 7
base-modules/service-system/service-system-biz/src/main/java/com/usky/system/controller/web/SysMobileMenuController.java

@@ -2,21 +2,25 @@ package com.usky.system.controller.web;
 
 
 
 
 import com.usky.common.core.bean.ApiResult;
 import com.usky.common.core.bean.ApiResult;
+import com.usky.common.core.constants.CommonConst;
+import com.usky.common.core.exception.BusinessErrorCode;
+import com.usky.common.core.util.ServletUtils;
+import com.usky.common.core.util.StringUtils;
+import com.usky.common.security.service.TokenService;
 import com.usky.common.security.utils.SecurityUtils;
 import com.usky.common.security.utils.SecurityUtils;
-import com.usky.system.domain.SysMenu;
 import com.usky.system.domain.SysMobileMenu;
 import com.usky.system.domain.SysMobileMenu;
-import com.usky.system.domain.SysUser;
+import com.usky.system.domain.constants.UserConstants;
+import com.usky.system.model.LoginUser;
 import com.usky.system.service.SysMobileMenuService;
 import com.usky.system.service.SysMobileMenuService;
-import com.usky.system.service.impl.SysMenuServiceImpl;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.*;
 
 
 import org.springframework.stereotype.Controller;
 import org.springframework.stereotype.Controller;
-import org.springframework.web.bind.annotation.RestController;
 
 
 import java.util.ArrayList;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.List;
+import java.util.Objects;
 
 
 /**
 /**
  * <p>
  * <p>
@@ -28,11 +32,14 @@ import java.util.List;
  */
  */
 @RestController
 @RestController
 @RequestMapping("/sysMobileMenu")
 @RequestMapping("/sysMobileMenu")
-public class SysMobileMenuController {
+public class SysMobileMenuController  extends BaseController {
 
 
     @Autowired
     @Autowired
     private SysMobileMenuService sysMobileMenuService;
     private SysMobileMenuService sysMobileMenuService;
 
 
+    @Autowired
+    private TokenService tokenService;
+
     @GetMapping("getRouters")
     @GetMapping("getRouters")
     public ApiResult getRouters()
     public ApiResult getRouters()
     {
     {
@@ -40,5 +47,76 @@ public class SysMobileMenuController {
         return ApiResult.success(menus);
         return ApiResult.success(menus);
     }
     }
 
 
+    /**
+     * 移动端系统管理-菜单管理-列表展示
+     */
+    @GetMapping("/list")
+    public ApiResult list(SysMobileMenu menu)
+    {
+        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
+        Long userId = loginUser.getUserid();
+        List<SysMobileMenu> menus = sysMobileMenuService.selectMobileMenuList(menu, userId);
+        return ApiResult.success(menus);
+    }
+
+    /**
+     * 移动端系统管理-菜单管理-新增菜单
+     */
+    @PostMapping
+    public ApiResult add(@Validated @RequestBody SysMobileMenu menu)
+    {
+        if (UserConstants.NOT_UNIQUE.equals(sysMobileMenuService.checkMenuNameUnique(menu)))
+        {
+            return ApiResult.error(BusinessErrorCode.BIZ_BUSINESS_ERROR.getCode(), "新增菜单'" + menu.getMenuName() + "'失败,菜单名称已存在");
+        }
+        else if (UserConstants.YES_FRAME.equals(menu.getIsFrame())
+                && !StringUtils.startsWithAny(menu.getPath(), CommonConst.HTTP_PREFIX, CommonConst.HTTPS_PREFIX))
+        {
+            return ApiResult.error(BusinessErrorCode.BIZ_BUSINESS_ERROR.getCode(), "新增菜单'" + menu.getMenuName() + "'失败,地址必须以http(s)://开头");
+        }
+        menu.setCreateBy(SecurityUtils.getUsername());
+        return toAjax(sysMobileMenuService.insertMobileMenu(menu));
+    }
+
+    /**
+     * 移动端系统管理-菜单管理-修改菜单
+     */
+    @PutMapping
+    public ApiResult edit(@Validated @RequestBody SysMobileMenu menu)
+    {
+        if (UserConstants.NOT_UNIQUE.equals(sysMobileMenuService.checkMenuNameUnique(menu)))
+        {
+            return ApiResult.error(BusinessErrorCode.BIZ_BUSINESS_ERROR.getCode(), "修改菜单'" + menu.getMenuName() + "'失败,菜单名称已存在");
+        }
+        else if (UserConstants.YES_FRAME.equals(menu.getIsFrame())
+                && !StringUtils.startsWithAny(menu.getPath(), CommonConst.HTTP_PREFIX, CommonConst.HTTPS_PREFIX))
+        {
+            return ApiResult.error(BusinessErrorCode.BIZ_BUSINESS_ERROR.getCode(), "新增菜单'" + menu.getMenuName() + "'失败,地址必须以http(s)://开头");
+        }
+        else if (Objects.equals(menu.getMenuId(), menu.getParentId()))
+        {
+            return ApiResult.error(BusinessErrorCode.BIZ_BUSINESS_ERROR.getCode(), "新增菜单'" + menu.getMenuName() + "'失败,上级菜单不能选择自己");
+        }
+        menu.setUpdateBy(SecurityUtils.getUsername());
+        return toAjax(sysMobileMenuService.updateMenu(menu));
+    }
+
+    /**
+     * 移动端系统管理-菜单管理-删除菜单
+     */
+    @DeleteMapping("/{menuId}")
+    public ApiResult remove(@PathVariable("menuId") Long menuId)
+    {
+        if (sysMobileMenuService.hasChildByMenuId(menuId))
+        {
+            return ApiResult.error(BusinessErrorCode.BIZ_BUSINESS_ERROR.getCode(), "存在子菜单,不允许删除");
+        }
+        if (sysMobileMenuService.checkMenuExistRole(menuId))
+        {
+            return ApiResult.error(BusinessErrorCode.BIZ_BUSINESS_ERROR.getCode(), "菜单已分配,不允许删除");
+        }
+        return toAjax(sysMobileMenuService.deleteMenuById(menuId));
+    }
+
 }
 }
 
 

+ 188 - 40
base-modules/service-system/service-system-biz/src/main/java/com/usky/system/domain/SysMobileMenu.java

@@ -1,14 +1,12 @@
 package com.usky.system.domain;
 package com.usky.system.domain;
 
 
-import com.baomidou.mybatisplus.annotation.IdType;
+import com.usky.common.core.bean.BaseEntity;
 import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableField;
-import com.baomidou.mybatisplus.annotation.TableId;
-import lombok.Data;
-import lombok.EqualsAndHashCode;
-import lombok.experimental.Accessors;
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringStyle;
 
 
-import java.io.Serializable;
-import java.time.LocalDateTime;
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.Size;
 import java.util.ArrayList;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.List;
 
 
@@ -20,18 +18,14 @@ import java.util.List;
  * @author JCB
  * @author JCB
  * @since 2022-08-11
  * @since 2022-08-11
  */
  */
-@Data
-@EqualsAndHashCode(callSuper = false)
-@Accessors(chain = true)
-public class SysMobileMenu implements Serializable {
+public class SysMobileMenu extends BaseEntity {
 
 
     private static final long serialVersionUID = 1L;
     private static final long serialVersionUID = 1L;
 
 
     /**
     /**
      * 菜单ID
      * 菜单ID
      */
      */
-    @TableId(value = "menu_id", type = IdType.AUTO)
-    private Integer menuId;
+    private long menuId;
 
 
     /**
     /**
      * 菜单名称
      * 菜单名称
@@ -50,7 +44,7 @@ public class SysMobileMenu implements Serializable {
     /**
     /**
      * 显示顺序
      * 显示顺序
      */
      */
-    private Integer orderNum;
+    private String orderNum;
 
 
     /**
     /**
      * 路由地址
      * 路由地址
@@ -70,12 +64,12 @@ public class SysMobileMenu implements Serializable {
     /**
     /**
      * 是否为外链(0是 1否)
      * 是否为外链(0是 1否)
      */
      */
-    private Integer isFrame;
+    private String isFrame;
 
 
     /**
     /**
      * 是否缓存(0缓存 1不缓存)
      * 是否缓存(0缓存 1不缓存)
      */
      */
-    private Integer isCache;
+    private String isCache;
 
 
     /**
     /**
      * 菜单类型(M目录 C菜单 F按钮)
      * 菜单类型(M目录 C菜单 F按钮)
@@ -83,7 +77,7 @@ public class SysMobileMenu implements Serializable {
     private String menuType;
     private String menuType;
 
 
     /**
     /**
-     * 菜单状态(0显示 1隐藏)
+     * 显示状态(0显示 1隐藏)
      */
      */
     private String visible;
     private String visible;
 
 
@@ -103,35 +97,189 @@ public class SysMobileMenu implements Serializable {
     private String icon;
     private String icon;
 
 
     /**
     /**
-     * 创建者
+     * 子菜单
      */
      */
-    private String createBy;
+    @TableField(exist = false)
+    private List<SysMobileMenu> children = new ArrayList<SysMobileMenu>();
 
 
-    /**
-     * 创建时间
-     */
-    private LocalDateTime createTime;
+    public long getMenuId()
+    {
+        return menuId;
+    }
 
 
-    /**
-     * 更新者
-     */
-    private String updateBy;
+    public void setMenuId(long menuId)
+    {
+        this.menuId = menuId;
+    }
 
 
-    /**
-     * 更新时间
-     */
-    private LocalDateTime updateTime;
+    @NotBlank(message = "菜单名称不能为空")
+    @Size(min = 0, max = 50, message = "菜单名称长度不能超过50个字符")
+    public String getMenuName()
+    {
+        return menuName;
+    }
 
 
-    /**
-     * 备注
-     */
-    private String remark;
+    public void setMenuName(String menuName)
+    {
+        this.menuName = menuName;
+    }
 
 
-    /**
-     * 子菜单
-     */
-    @TableField(exist = false)
-    private List<SysMobileMenu> children = new ArrayList<SysMobileMenu>();
+    public String getParentName()
+    {
+        return parentName;
+    }
+
+    public void setParentName(String parentName)
+    {
+        this.parentName = parentName;
+    }
+
+    public Long getParentId()
+    {
+        return parentId;
+    }
+
+    public void setParentId(Long parentId)
+    {
+        this.parentId = parentId;
+    }
+
+    @NotBlank(message = "显示顺序不能为空")
+    public String getOrderNum()
+    {
+        return orderNum;
+    }
+
+    public void setOrderNum(String orderNum)
+    {
+        this.orderNum = orderNum;
+    }
+
+    @Size(min = 0, max = 200, message = "路由地址不能超过200个字符")
+    public String getPath()
+    {
+        return path;
+    }
+
+    public void setPath(String path)
+    {
+        this.path = path;
+    }
+
+    @Size(min = 0, max = 200, message = "组件路径不能超过255个字符")
+    public String getComponent()
+    {
+        return component;
+    }
+
+    public void setComponent(String component)
+    {
+        this.component = component;
+    }
+
+    public String getIsFrame()
+    {
+        return isFrame;
+    }
+
+    public void setIsFrame(String isFrame)
+    {
+        this.isFrame = isFrame;
+    }
+
+    public String getIsCache()
+    {
+        return isCache;
+    }
+
+    public void setIsCache(String isCache)
+    {
+        this.isCache = isCache;
+    }
+
+    @NotBlank(message = "菜单类型不能为空")
+    public String getMenuType()
+    {
+        return menuType;
+    }
+
+    public void setMenuType(String menuType)
+    {
+        this.menuType = menuType;
+    }
+
+    public String getVisible()
+    {
+        return visible;
+    }
+
+    public void setVisible(String visible)
+    {
+        this.visible = visible;
+    }
+
+    public String getStatus()
+    {
+        return status;
+    }
+
+    public void setStatus(String status)
+    {
+        this.status = status;
+    }
+
+    @Size(min = 0, max = 100, message = "权限标识长度不能超过100个字符")
+    public String getPerms()
+    {
+        return perms;
+    }
+
+    public void setPerms(String perms)
+    {
+        this.perms = perms;
+    }
+
+    public String getIcon()
+    {
+        return icon;
+    }
+
+    public void setIcon(String icon)
+    {
+        this.icon = icon;
+    }
+
+    public List<SysMobileMenu> getChildren()
+    {
+        return children;
+    }
 
 
+    public void setChildren(List<SysMobileMenu> children)
+    {
+        this.children = children;
+    }
 
 
+    @Override
+    public String toString() {
+        return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
+                .append("menuId", getMenuId())
+                .append("menuName", getMenuName())
+                .append("parentId", getParentId())
+                .append("orderNum", getOrderNum())
+                .append("path", getPath())
+                .append("component", getComponent())
+                .append("isFrame", getIsFrame())
+                .append("IsCache", getIsCache())
+                .append("menuType", getMenuType())
+                .append("visible", getVisible())
+                .append("status ", getStatus())
+                .append("perms", getPerms())
+                .append("icon", getIcon())
+                .append("createBy", getCreateBy())
+                .append("createTime", getCreateTime())
+                .append("updateBy", getUpdateBy())
+                .append("updateTime", getUpdateTime())
+                .append("remark", getRemark())
+                .toString();
+    }
 }
 }

+ 71 - 0
base-modules/service-system/service-system-biz/src/main/java/com/usky/system/mapper/SysMobileMenuMapper.java

@@ -1,7 +1,12 @@
 package com.usky.system.mapper;
 package com.usky.system.mapper;
 
 
+import com.usky.system.domain.SysMenu;
 import com.usky.system.domain.SysMobileMenu;
 import com.usky.system.domain.SysMobileMenu;
 import com.usky.common.mybatis.core.CrudMapper;
 import com.usky.common.mybatis.core.CrudMapper;
+import org.apache.ibatis.annotations.Param;
+import org.springframework.stereotype.Repository;
+
+import java.util.List;
 
 
 /**
 /**
  * <p>
  * <p>
@@ -11,6 +16,72 @@ import com.usky.common.mybatis.core.CrudMapper;
  * @author JCB
  * @author JCB
  * @since 2022-08-11
  * @since 2022-08-11
  */
  */
+@Repository
 public interface SysMobileMenuMapper extends CrudMapper<SysMobileMenu> {
 public interface SysMobileMenuMapper extends CrudMapper<SysMobileMenu> {
 
 
+    /**
+     * 查询菜单使用数量
+     *
+     * @param menuId 菜单ID
+     * @return 结果
+     */
+    public int checkMenuExistRole(@Param("menuId") Long menuId);
+
+    /**
+     * 查询系统菜单列表
+     *
+     * @param menu 菜单信息
+     * @return 菜单列表
+     */
+    public List<SysMobileMenu> selectMobileMenuList(SysMobileMenu menu);
+
+    /**
+     * 根据用户查询系统菜单列表
+     *
+     * @param menu 菜单信息
+     * @return 菜单列表
+     */
+    public List<SysMobileMenu> selectMobileMenuListByUserId(SysMobileMenu menu);
+
+    /**
+     * 校验菜单名称是否唯一
+     *
+     * @param menuName 菜单名称
+     * @param parentId 父菜单ID
+     * @return 结果
+     */
+    public SysMobileMenu checkMobileMenuNameUnique(@Param("menuName") String menuName,
+                                       @Param("parentId") Long parentId);
+
+    /**
+     * 是否存在菜单子节点
+     *
+     * @param menuId 菜单ID
+     * @return 结果
+     */
+    public int hasChildByMenuId(@Param("menuId") Long menuId);
+
+    /**
+     * 新增菜单信息
+     *
+     * @param menu 菜单信息
+     * @return 结果
+     */
+    public int insertMobileMenu(SysMobileMenu menu);
+
+    /**
+     * 修改菜单信息
+     *
+     * @param menu 菜单信息
+     * @return 结果
+     */
+    public int updateMenu(SysMobileMenu menu);
+
+    /**
+     * 删除菜单管理信息
+     *
+     * @param menuId 菜单ID
+     * @return 结果
+     */
+    public int deleteMenuById(@Param("menuId") Long menuId);
 }
 }

+ 58 - 0
base-modules/service-system/service-system-biz/src/main/java/com/usky/system/service/SysMobileMenuService.java

@@ -1,5 +1,6 @@
 package com.usky.system.service;
 package com.usky.system.service;
 
 
+import com.usky.system.domain.SysMenu;
 import com.usky.system.domain.SysMobileMenu;
 import com.usky.system.domain.SysMobileMenu;
 import com.usky.common.mybatis.core.CrudService;
 import com.usky.common.mybatis.core.CrudService;
 
 
@@ -20,4 +21,61 @@ public interface SysMobileMenuService extends CrudService<SysMobileMenu> {
      * @return
      * @return
      */
      */
     List<SysMobileMenu> moveRoute();
     List<SysMobileMenu> moveRoute();
+
+    /**
+     * 根据用户查询系统菜单列表
+     *
+     * @param menu 菜单信息
+     * @param userId 用户ID
+     * @return 菜单列表
+     */
+    public List<SysMobileMenu> selectMobileMenuList(SysMobileMenu menu, Long userId);
+
+    /**
+     * 校验菜单名称是否唯一
+     *
+     * @param menu 菜单信息
+     * @return 结果
+     */
+    public String checkMenuNameUnique(SysMobileMenu menu);
+
+    /**
+     * 新增保存菜单信息
+     *
+     * @param menu 菜单信息
+     * @return 结果
+     */
+    public int insertMobileMenu(SysMobileMenu menu);
+
+    /**
+     * 修改保存菜单信息
+     *
+     * @param menu 菜单信息
+     * @return 结果
+     */
+    public int updateMenu(SysMobileMenu menu);
+
+    /**
+     * 删除菜单管理信息
+     *
+     * @param menuId 菜单ID
+     * @return 结果
+     */
+    public int deleteMenuById(Long menuId);
+
+    /**
+     * 是否存在菜单子节点
+     *
+     * @param menuId 菜单ID
+     * @return 结果 true 存在 false 不存在
+     */
+    public boolean hasChildByMenuId(Long menuId);
+
+    /**
+     * 查询菜单是否存在角色
+     *
+     * @param menuId 菜单ID
+     * @return 结果 true 存在 false 不存在
+     */
+    public boolean checkMenuExistRole(Long menuId);
 }
 }

+ 2 - 2
base-modules/service-system/service-system-biz/src/main/java/com/usky/system/service/impl/SysMenuServiceImpl.java

@@ -285,7 +285,7 @@ public class SysMenuServiceImpl extends AbstractCrudService<SysMenuMapper, SysMe
         List<Long> tempList = new ArrayList<Long>();
         List<Long> tempList = new ArrayList<Long>();
         for (SysMobileMenu dept : menus)
         for (SysMobileMenu dept : menus)
         {
         {
-            tempList.add(dept.getMenuId().longValue());
+            tempList.add(dept.getMenuId());
         }
         }
         for (Iterator<SysMobileMenu> iterator = menus.iterator(); iterator.hasNext();)
         for (Iterator<SysMobileMenu> iterator = menus.iterator(); iterator.hasNext();)
         {
         {
@@ -616,7 +616,7 @@ public class SysMenuServiceImpl extends AbstractCrudService<SysMenuMapper, SysMe
         while (it.hasNext())
         while (it.hasNext())
         {
         {
             SysMobileMenu n = (SysMobileMenu) it.next();
             SysMobileMenu n = (SysMobileMenu) it.next();
-            if (n.getParentId().longValue() == t.getMenuId().longValue())
+            if (n.getParentId().longValue() == t.getMenuId())
             {
             {
                 tlist.add(n);
                 tlist.add(n);
             }
             }

+ 113 - 5
base-modules/service-system/service-system-biz/src/main/java/com/usky/system/service/impl/SysMobileMenuServiceImpl.java

@@ -10,8 +10,10 @@ import com.usky.system.controller.web.SysMenuController;
 import com.usky.system.domain.SysMenu;
 import com.usky.system.domain.SysMenu;
 import com.usky.system.domain.SysMobileMenu;
 import com.usky.system.domain.SysMobileMenu;
 import com.usky.system.domain.SysMobileTenantMenu;
 import com.usky.system.domain.SysMobileTenantMenu;
+import com.usky.system.domain.SysUserVO;
 import com.usky.system.domain.constants.UserConstants;
 import com.usky.system.domain.constants.UserConstants;
 import com.usky.system.mapper.SysMobileMenuMapper;
 import com.usky.system.mapper.SysMobileMenuMapper;
+import com.usky.system.mapper.SysRoleMenuMapper;
 import com.usky.system.service.SysMobileMenuService;
 import com.usky.system.service.SysMobileMenuService;
 import com.usky.common.mybatis.core.AbstractCrudService;
 import com.usky.common.mybatis.core.AbstractCrudService;
 import com.usky.system.service.SysMobileTenantMenuService;
 import com.usky.system.service.SysMobileTenantMenuService;
@@ -20,10 +22,7 @@ import com.usky.system.service.vo.RouterVo;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
 
 
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
+import java.util.*;
 
 
 /**
 /**
  * <p>
  * <p>
@@ -36,9 +35,92 @@ import java.util.List;
 @Service
 @Service
 public class SysMobileMenuServiceImpl extends AbstractCrudService<SysMobileMenuMapper, SysMobileMenu> implements SysMobileMenuService {
 public class SysMobileMenuServiceImpl extends AbstractCrudService<SysMobileMenuMapper, SysMobileMenu> implements SysMobileMenuService {
 
 
+    @Autowired
+    private SysMobileMenuMapper sysMobileMenuMapper;
+
+    @Autowired
+    private SysRoleMenuMapper sysRoleMenuMapper;
+
     @Autowired
     @Autowired
     private SysMobileTenantMenuService sysMobileTenantMenuService;
     private SysMobileTenantMenuService sysMobileTenantMenuService;
 
 
+    /**
+     * 查询系统菜单列表
+     *
+     * @param menu 菜单信息
+     * @return 菜单列表
+     */
+    @Override
+    public List<SysMobileMenu> selectMobileMenuList(SysMobileMenu menu, Long userId)
+    {
+        List<SysMobileMenu> menuList = null;
+        // 管理员显示所有菜单信息
+        if (SysUserVO.isAdmin(userId))
+        {
+            menuList = sysMobileMenuMapper.selectMobileMenuList(menu);
+        }
+        else
+        {
+            menu.getParams().put("userId", userId);
+            menuList = sysMobileMenuMapper.selectMobileMenuListByUserId(menu);
+        }
+        return menuList;
+    }
+
+    /**
+     * 修改保存菜单信息
+     *
+     * @param menu 菜单信息
+     * @return 结果
+     */
+    @Override
+    public int updateMenu(SysMobileMenu menu)
+    {
+        return sysMobileMenuMapper.updateMenu(menu);
+    }
+
+    /**
+     * 删除菜单管理信息
+     *
+     * @param menuId 菜单ID
+     * @return 结果
+     */
+    @Override
+    public int deleteMenuById(Long menuId)
+    {
+        return sysMobileMenuMapper.deleteMenuById(menuId);
+    }
+
+    /**
+     * 校验菜单名称是否唯一
+     *
+     * @param menu 菜单信息
+     * @return 结果
+     */
+    @Override
+    public String checkMenuNameUnique(SysMobileMenu menu)
+    {
+        Long menuId = Objects.isNull(menu.getMenuId()) ? -1L : menu.getMenuId();
+        SysMobileMenu info = sysMobileMenuMapper.checkMobileMenuNameUnique(menu.getMenuName(), menu.getParentId());
+        if (Objects.nonNull(info) && info.getMenuId() != menuId.longValue())
+        {
+            return UserConstants.NOT_UNIQUE;
+        }
+        return UserConstants.UNIQUE;
+    }
+
+    /**
+     * 新增保存菜单信息
+     *
+     * @param menu 菜单信息
+     * @return 结果
+     */
+    @Override
+    public int insertMobileMenu(SysMobileMenu menu)
+    {
+        return sysMobileMenuMapper.insertMobileMenu(menu);
+    }
+
     @Override
     @Override
     public List<SysMobileMenu> moveRoute(){
     public List<SysMobileMenu> moveRoute(){
         List<SysMobileMenu> list = new ArrayList<>();
         List<SysMobileMenu> list = new ArrayList<>();
@@ -61,6 +143,32 @@ public class SysMobileMenuServiceImpl extends AbstractCrudService<SysMobileMenuM
         return list;
         return list;
     }
     }
 
 
+    /**
+     * 是否存在菜单子节点
+     *
+     * @param menuId 菜单ID
+     * @return 结果
+     */
+    @Override
+    public boolean hasChildByMenuId(Long menuId)
+    {
+        int result = sysMobileMenuMapper.hasChildByMenuId(menuId);
+        return result > 0 ? true : false;
+    }
+
+    /**
+     * 查询菜单使用数量
+     *
+     * @param menuId 菜单ID
+     * @return 结果
+     */
+    @Override
+    public boolean checkMenuExistRole(Long menuId)
+    {
+        int result = sysRoleMenuMapper.checkMenuExistRole(menuId);
+        return result > 0 ? true : false;
+    }
+
     /**
     /**
      * 根据父节点的ID获取所有子节点
      * 根据父节点的ID获取所有子节点
      *
      *
@@ -115,7 +223,7 @@ public class SysMobileMenuServiceImpl extends AbstractCrudService<SysMobileMenuM
         while (it.hasNext())
         while (it.hasNext())
         {
         {
             SysMobileMenu n = (SysMobileMenu) it.next();
             SysMobileMenu n = (SysMobileMenu) it.next();
-            if (n.getParentId().longValue() == t.getMenuId().longValue())
+            if (n.getParentId().longValue() == t.getMenuId())
             {
             {
                 tlist.add(n);
                 tlist.add(n);
             }
             }

+ 1 - 1
base-modules/service-system/service-system-biz/src/main/java/com/usky/system/service/vo/TreeMobileSelect.java

@@ -41,7 +41,7 @@ public class TreeMobileSelect {
 
 
     public TreeMobileSelect(SysMobileMenu menu)
     public TreeMobileSelect(SysMobileMenu menu)
     {
     {
-        this.id = menu.getMenuId().longValue();
+        this.id = menu.getMenuId();
         this.label = menu.getMenuName();
         this.label = menu.getMenuName();
         this.children = menu.getChildren().stream().map(TreeMobileSelect::new).collect(Collectors.toList());
         this.children = menu.getChildren().stream().map(TreeMobileSelect::new).collect(Collectors.toList());
     }
     }

+ 131 - 0
base-modules/service-system/service-system-biz/src/main/resources/mapper/system/SysMobileMenuMapper.xml

@@ -25,4 +25,135 @@
         <result column="remark" property="remark" />
         <result column="remark" property="remark" />
     </resultMap>
     </resultMap>
 
 
+    <sql id="selectMobileMenuVo">
+        select menu_id,
+               menu_name,
+               parent_id,
+               order_num,
+               path,
+               component,
+               is_frame,
+               is_cache,
+               menu_type,
+               visible,
+               status,
+               ifnull(perms, '') as perms,
+               icon,
+               create_time
+        from sys_mobile_menu
+    </sql>
+
+    <select id="selectMobileMenuList" parameterType="com.usky.system.domain.SysMobileMenu" resultMap="BaseResultMap">
+        <include refid="selectMobileMenuVo"/>
+        <where>
+            <if test="menuName != null and menuName != ''">
+                AND menu_name like concat('%', #{menuName}, '%')
+            </if>
+            <if test="visible != null and visible != ''">
+                AND visible = #{visible}
+            </if>
+            <if test="status != null and status != ''">
+                AND status = #{status}
+            </if>
+        </where>
+        order by parent_id, order_num
+    </select>
+
+    <select id="selectMobileMenuListByUserId" parameterType="com.usky.system.domain.SysMobileMenu" resultMap="BaseResultMap">
+        select distinct m.menu_id, m.parent_id, m.menu_name, m.path, m.component, m.visible, m.status,
+        ifnull(m.perms,'') as perms, m.is_frame, m.is_cache, m.menu_type, m.icon, m.order_num, m.create_time
+        from sys_mobile_menu m
+        left join sys_role_menu rm on m.menu_id = rm.menu_id
+        left join sys_user_role ur on rm.role_id = ur.role_id
+        left join sys_role ro on ur.role_id = ro.role_id
+        where ur.user_id = #{params.userId}
+        <if test="menuName != null and menuName != ''">
+            AND menu_name like concat('%', #{menuName}, '%')
+        </if>
+        <if test="visible != null and visible != ''">
+            AND visible = #{visible}
+        </if>
+        <if test="status != null and status != ''">
+            AND status = #{status}
+        </if>
+        order by m.parent_id, m.order_num
+    </select>
+
+    <select id="checkMobileMenuNameUnique" parameterType="com.usky.system.domain.SysMobileMenu" resultMap="BaseResultMap">
+        <include refid="selectMobileMenuVo"/>
+        where menu_name=#{menuName} and parent_id = #{parentId} limit 1
+    </select>
+
+    <select id="hasChildByMenuId" resultType="Integer">
+        select count(1)
+        from sys_mobile_menu
+        where parent_id = #{menuId}
+    </select>
+
+    <insert id="insertMobileMenu" parameterType="com.usky.system.domain.SysMobileMenu">
+        insert into sys_mobile_menu(
+        <if test="menuId != null and menuId != 0">menu_id,</if>
+        <if test="parentId != null and parentId != 0">parent_id,</if>
+        <if test="menuName != null and menuName != ''">menu_name,</if>
+        <if test="orderNum != null and orderNum != ''">order_num,</if>
+        <if test="path != null and path != ''">path,</if>
+        <if test="component != null and component != ''">component,</if>
+        <if test="isFrame != null and isFrame != ''">is_frame,</if>
+        <if test="isCache != null and isCache != ''">is_cache,</if>
+        <if test="menuType != null and menuType != ''">menu_type,</if>
+        <if test="visible != null">visible,</if>
+        <if test="status != null">status,</if>
+        <if test="perms !=null and perms != ''">perms,</if>
+        <if test="icon != null and icon != ''">icon,</if>
+        <if test="remark != null and remark != ''">remark,</if>
+        <if test="createBy != null and createBy != ''">create_by,</if>
+        create_time
+        )values(
+        <if test="menuId != null and menuId != 0">#{menuId},</if>
+        <if test="parentId != null and parentId != 0">#{parentId},</if>
+        <if test="menuName != null and menuName != ''">#{menuName},</if>
+        <if test="orderNum != null and orderNum != ''">#{orderNum},</if>
+        <if test="path != null and path != ''">#{path},</if>
+        <if test="component != null and component != ''">#{component},</if>
+        <if test="isFrame != null and isFrame != ''">#{isFrame},</if>
+        <if test="isCache != null and isCache != ''">#{isCache},</if>
+        <if test="menuType != null and menuType != ''">#{menuType},</if>
+        <if test="visible != null">#{visible},</if>
+        <if test="status != null">#{status},</if>
+        <if test="perms !=null and perms != ''">#{perms},</if>
+        <if test="icon != null and icon != ''">#{icon},</if>
+        <if test="remark != null and remark != ''">#{remark},</if>
+        <if test="createBy != null and createBy != ''">#{createBy},</if>
+        sysdate()
+        )
+    </insert>
+
+    <update id="updateMenu" parameterType="com.usky.system.domain.SysMobileMenu">
+        update sys_mobile_menu
+        <set>
+            <if test="menuName != null and menuName != ''">menu_name = #{menuName},</if>
+            <if test="parentId != null">parent_id = #{parentId},</if>
+            <if test="orderNum != null and orderNum != ''">order_num = #{orderNum},</if>
+            <if test="path != null and path != ''">path = #{path},</if>
+            <if test="component != null">component = #{component},</if>
+            <if test="isFrame != null and isFrame != ''">is_frame = #{isFrame},</if>
+            <if test="isCache != null and isCache != ''">is_cache = #{isCache},</if>
+            <if test="menuType != null and menuType != ''">menu_type = #{menuType},</if>
+            <if test="visible != null">visible = #{visible},</if>
+            <if test="status != null">status = #{status},</if>
+            <if test="perms !=null">perms = #{perms},</if>
+            <if test="icon !=null and icon != ''">icon = #{icon},</if>
+            <if test="remark != null and remark != ''">remark = #{remark},</if>
+            <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
+            update_time = sysdate()
+        </set>
+        where menu_id = #{menuId}
+    </update>
+
+    <delete id="deleteMenuById" parameterType="Long">
+        delete
+        from sys_mobile_menu
+        where menu_id = #{menuId}
+    </delete>
+
 </mapper>
 </mapper>