Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
guns-vip
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
chenjunxiong
guns-vip
Commits
0119ac9e
Commit
0119ac9e
authored
Dec 23, 2018
by
fengshuonan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
完善菜单管理,整理部分代码
parent
a263c7b6
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
107 additions
and
111 deletions
+107
-111
src/main/java/cn/stylefeng/guns/GunsApplication.java
+0
-11
src/main/java/cn/stylefeng/guns/core/common/constant/DefaultAvatar.java
+15
-0
src/main/java/cn/stylefeng/guns/core/common/constant/factory/ConstantFactory.java
+16
-63
src/main/java/cn/stylefeng/guns/core/common/constant/factory/IConstantFactory.java
+5
-0
src/main/java/cn/stylefeng/guns/core/metadata/GunsMpFieldHandler.java
+15
-0
src/main/java/cn/stylefeng/guns/core/util/DefaultImages.java
+15
-0
src/main/java/cn/stylefeng/guns/modular/system/controller/MenuController.java
+29
-29
src/main/java/cn/stylefeng/guns/modular/system/model/MenuDto.java
+4
-0
src/main/webapp/WEB-INF/system/menu/menu_add.html
+1
-1
src/main/webapp/WEB-INF/system/menu/menu_edit.html
+1
-1
src/main/webapp/assets/modular/system/menu/menu_add.js
+3
-3
src/main/webapp/assets/modular/system/menu/menu_edit.js
+3
-3
No files found.
src/main/java/cn/stylefeng/guns/GunsApplication.java
View file @
0119ac9e
...
@@ -36,16 +36,5 @@ public class GunsApplication {
...
@@ -36,16 +36,5 @@ public class GunsApplication {
public
static
void
main
(
String
[]
args
)
{
public
static
void
main
(
String
[]
args
)
{
SpringApplication
.
run
(
GunsApplication
.
class
,
args
);
SpringApplication
.
run
(
GunsApplication
.
class
,
args
);
logger
.
info
(
"GunsApplication is success!"
);
logger
.
info
(
"GunsApplication is success!"
);
// GenerateParams generateParams = new GenerateParams();
//
// generateParams.setRemoveTablePrefix(new String[]{"sys_"});
// generateParams.setAuthor("stylefeng");
// generateParams.setJdbcUrl("jdbc:mysql://127.0.0.1:3306/guns?autoReconnect=true&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=CONVERT_TO_NULL&useSSL=false&serverTimezone=CTT");
// generateParams.setGeneratorInterface(false);
// generateParams.setParentPackage("cn.stylefeng.guns.modular.system");
// generateParams.setGeneratorInterface(false);
//
// SimpleGenerator.doGeneration(generateParams);
}
}
}
}
src/main/java/cn/stylefeng/guns/core/common/constant/DefaultAvatar.java
View file @
0119ac9e
/**
* Copyright 2018-2020 stylefeng & fengshuonan (sn93@qq.com)
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
cn
.
stylefeng
.
guns
.
core
.
common
.
constant
;
package
cn
.
stylefeng
.
guns
.
core
.
common
.
constant
;
/**
/**
...
...
src/main/java/cn/stylefeng/guns/core/common/constant/factory/ConstantFactory.java
View file @
0119ac9e
...
@@ -56,12 +56,6 @@ public class ConstantFactory implements IConstantFactory {
...
@@ -56,12 +56,6 @@ public class ConstantFactory implements IConstantFactory {
return
SpringContextHolder
.
getBean
(
"constantFactory"
);
return
SpringContextHolder
.
getBean
(
"constantFactory"
);
}
}
/**
* 根据用户id获取用户名称
*
* @author stylefeng
* @Date 2017/5/9 23:41
*/
@Override
@Override
public
String
getUserNameById
(
Long
userId
)
{
public
String
getUserNameById
(
Long
userId
)
{
User
user
=
userMapper
.
selectById
(
userId
);
User
user
=
userMapper
.
selectById
(
userId
);
...
@@ -72,12 +66,6 @@ public class ConstantFactory implements IConstantFactory {
...
@@ -72,12 +66,6 @@ public class ConstantFactory implements IConstantFactory {
}
}
}
}
/**
* 根据用户id获取用户账号
*
* @author stylefeng
* @date 2017年5月16日21:55:371
*/
@Override
@Override
public
String
getUserAccountById
(
Long
userId
)
{
public
String
getUserAccountById
(
Long
userId
)
{
User
user
=
userMapper
.
selectById
(
userId
);
User
user
=
userMapper
.
selectById
(
userId
);
...
@@ -88,9 +76,6 @@ public class ConstantFactory implements IConstantFactory {
...
@@ -88,9 +76,6 @@ public class ConstantFactory implements IConstantFactory {
}
}
}
}
/**
* 通过角色ids获取角色名称
*/
@Override
@Override
@Cacheable
(
value
=
Cache
.
CONSTANT
,
key
=
"'"
+
CacheKey
.
ROLES_NAME
+
"'+#roleIds"
)
@Cacheable
(
value
=
Cache
.
CONSTANT
,
key
=
"'"
+
CacheKey
.
ROLES_NAME
+
"'+#roleIds"
)
public
String
getRoleName
(
String
roleIds
)
{
public
String
getRoleName
(
String
roleIds
)
{
...
@@ -108,9 +93,6 @@ public class ConstantFactory implements IConstantFactory {
...
@@ -108,9 +93,6 @@ public class ConstantFactory implements IConstantFactory {
return
StrUtil
.
removeSuffix
(
sb
.
toString
(),
","
);
return
StrUtil
.
removeSuffix
(
sb
.
toString
(),
","
);
}
}
/**
* 通过角色id获取角色名称
*/
@Override
@Override
@Cacheable
(
value
=
Cache
.
CONSTANT
,
key
=
"'"
+
CacheKey
.
SINGLE_ROLE_NAME
+
"'+#roleId"
)
@Cacheable
(
value
=
Cache
.
CONSTANT
,
key
=
"'"
+
CacheKey
.
SINGLE_ROLE_NAME
+
"'+#roleId"
)
public
String
getSingleRoleName
(
Long
roleId
)
{
public
String
getSingleRoleName
(
Long
roleId
)
{
...
@@ -124,9 +106,6 @@ public class ConstantFactory implements IConstantFactory {
...
@@ -124,9 +106,6 @@ public class ConstantFactory implements IConstantFactory {
return
""
;
return
""
;
}
}
/**
* 通过角色id获取角色英文名称
*/
@Override
@Override
@Cacheable
(
value
=
Cache
.
CONSTANT
,
key
=
"'"
+
CacheKey
.
SINGLE_ROLE_TIP
+
"'+#roleId"
)
@Cacheable
(
value
=
Cache
.
CONSTANT
,
key
=
"'"
+
CacheKey
.
SINGLE_ROLE_TIP
+
"'+#roleId"
)
public
String
getSingleRoleTip
(
Long
roleId
)
{
public
String
getSingleRoleTip
(
Long
roleId
)
{
...
@@ -140,9 +119,6 @@ public class ConstantFactory implements IConstantFactory {
...
@@ -140,9 +119,6 @@ public class ConstantFactory implements IConstantFactory {
return
""
;
return
""
;
}
}
/**
* 获取部门名称
*/
@Override
@Override
@Cacheable
(
value
=
Cache
.
CONSTANT
,
key
=
"'"
+
CacheKey
.
DEPT_NAME
+
"'+#deptId"
)
@Cacheable
(
value
=
Cache
.
CONSTANT
,
key
=
"'"
+
CacheKey
.
DEPT_NAME
+
"'+#deptId"
)
public
String
getDeptName
(
Long
deptId
)
{
public
String
getDeptName
(
Long
deptId
)
{
...
@@ -159,9 +135,6 @@ public class ConstantFactory implements IConstantFactory {
...
@@ -159,9 +135,6 @@ public class ConstantFactory implements IConstantFactory {
}
}
}
}
/**
* 获取菜单的名称们(多个)
*/
@Override
@Override
public
String
getMenuNames
(
String
menuIds
)
{
public
String
getMenuNames
(
String
menuIds
)
{
Integer
[]
menus
=
Convert
.
toIntArray
(
menuIds
);
Integer
[]
menus
=
Convert
.
toIntArray
(
menuIds
);
...
@@ -175,9 +148,6 @@ public class ConstantFactory implements IConstantFactory {
...
@@ -175,9 +148,6 @@ public class ConstantFactory implements IConstantFactory {
return
StrUtil
.
removeSuffix
(
sb
.
toString
(),
","
);
return
StrUtil
.
removeSuffix
(
sb
.
toString
(),
","
);
}
}
/**
* 获取菜单名称
*/
@Override
@Override
public
String
getMenuName
(
Long
menuId
)
{
public
String
getMenuName
(
Long
menuId
)
{
if
(
ToolUtil
.
isEmpty
(
menuId
))
{
if
(
ToolUtil
.
isEmpty
(
menuId
))
{
...
@@ -192,13 +162,12 @@ public class ConstantFactory implements IConstantFactory {
...
@@ -192,13 +162,12 @@ public class ConstantFactory implements IConstantFactory {
}
}
}
}
/**
* 获取菜单名称通过编号
*/
@Override
@Override
public
String
getMenuNameByCode
(
String
code
)
{
public
String
getMenuNameByCode
(
String
code
)
{
if
(
ToolUtil
.
isEmpty
(
code
))
{
if
(
ToolUtil
.
isEmpty
(
code
))
{
return
""
;
return
""
;
}
else
if
(
code
.
equals
(
"0"
))
{
return
"顶级"
;
}
else
{
}
else
{
Menu
param
=
new
Menu
();
Menu
param
=
new
Menu
();
param
.
setCode
(
code
);
param
.
setCode
(
code
);
...
@@ -211,9 +180,20 @@ public class ConstantFactory implements IConstantFactory {
...
@@ -211,9 +180,20 @@ public class ConstantFactory implements IConstantFactory {
}
}
}
}
/**
@Override
* 获取字典名称
public
Long
getMenuIdByCode
(
String
code
)
{
*/
if
(
ToolUtil
.
isEmpty
(
code
))
{
return
0L
;
}
else
if
(
code
.
equals
(
"0"
))
{
return
0L
;
}
else
{
Menu
menu
=
new
Menu
();
menu
.
setCode
(
code
);
Menu
tempMenu
=
this
.
menuMapper
.
selectOne
(
menu
);
return
tempMenu
.
getMenuId
();
}
}
@Override
@Override
public
String
getDictName
(
Long
dictId
)
{
public
String
getDictName
(
Long
dictId
)
{
if
(
ToolUtil
.
isEmpty
(
dictId
))
{
if
(
ToolUtil
.
isEmpty
(
dictId
))
{
...
@@ -228,9 +208,6 @@ public class ConstantFactory implements IConstantFactory {
...
@@ -228,9 +208,6 @@ public class ConstantFactory implements IConstantFactory {
}
}
}
}
/**
* 获取通知标题
*/
@Override
@Override
public
String
getNoticeTitle
(
Long
dictId
)
{
public
String
getNoticeTitle
(
Long
dictId
)
{
if
(
ToolUtil
.
isEmpty
(
dictId
))
{
if
(
ToolUtil
.
isEmpty
(
dictId
))
{
...
@@ -245,9 +222,6 @@ public class ConstantFactory implements IConstantFactory {
...
@@ -245,9 +222,6 @@ public class ConstantFactory implements IConstantFactory {
}
}
}
}
/**
* 根据字典名称和字典中的值获取对应的名称
*/
@Override
@Override
public
String
getDictsByName
(
String
name
,
String
code
)
{
public
String
getDictsByName
(
String
name
,
String
code
)
{
Dict
temp
=
new
Dict
();
Dict
temp
=
new
Dict
();
...
@@ -268,33 +242,21 @@ public class ConstantFactory implements IConstantFactory {
...
@@ -268,33 +242,21 @@ public class ConstantFactory implements IConstantFactory {
}
}
}
}
/**
* 获取性别名称
*/
@Override
@Override
public
String
getSexName
(
String
sexCode
)
{
public
String
getSexName
(
String
sexCode
)
{
return
getDictsByName
(
"性别"
,
sexCode
);
return
getDictsByName
(
"性别"
,
sexCode
);
}
}
/**
* 获取用户登录状态
*/
@Override
@Override
public
String
getStatusName
(
String
status
)
{
public
String
getStatusName
(
String
status
)
{
return
ManagerStatus
.
getDescription
(
status
);
return
ManagerStatus
.
getDescription
(
status
);
}
}
/**
* 获取菜单状态
*/
@Override
@Override
public
String
getMenuStatusName
(
String
status
)
{
public
String
getMenuStatusName
(
String
status
)
{
return
MenuStatus
.
getDescription
(
status
);
return
MenuStatus
.
getDescription
(
status
);
}
}
/**
* 查询字典
*/
@Override
@Override
public
List
<
Dict
>
findInDict
(
Long
id
)
{
public
List
<
Dict
>
findInDict
(
Long
id
)
{
if
(
ToolUtil
.
isEmpty
(
id
))
{
if
(
ToolUtil
.
isEmpty
(
id
))
{
...
@@ -310,17 +272,11 @@ public class ConstantFactory implements IConstantFactory {
...
@@ -310,17 +272,11 @@ public class ConstantFactory implements IConstantFactory {
}
}
}
}
/**
* 获取被缓存的对象(用户删除业务)
*/
@Override
@Override
public
String
getCacheObject
(
String
para
)
{
public
String
getCacheObject
(
String
para
)
{
return
LogObjectHolder
.
me
().
get
().
toString
();
return
LogObjectHolder
.
me
().
get
().
toString
();
}
}
/**
* 获取子部门id
*/
@Override
@Override
public
List
<
Long
>
getSubDeptId
(
Long
deptId
)
{
public
List
<
Long
>
getSubDeptId
(
Long
deptId
)
{
Wrapper
<
Dept
>
wrapper
=
new
EntityWrapper
<>();
Wrapper
<
Dept
>
wrapper
=
new
EntityWrapper
<>();
...
@@ -338,9 +294,6 @@ public class ConstantFactory implements IConstantFactory {
...
@@ -338,9 +294,6 @@ public class ConstantFactory implements IConstantFactory {
return
deptids
;
return
deptids
;
}
}
/**
* 获取所有父部门id
*/
@Override
@Override
public
List
<
Long
>
getParentDeptIds
(
Long
deptId
)
{
public
List
<
Long
>
getParentDeptIds
(
Long
deptId
)
{
Dept
dept
=
deptMapper
.
selectById
(
deptId
);
Dept
dept
=
deptMapper
.
selectById
(
deptId
);
...
...
src/main/java/cn/stylefeng/guns/core/common/constant/factory/IConstantFactory.java
View file @
0119ac9e
...
@@ -79,6 +79,11 @@ public interface IConstantFactory {
...
@@ -79,6 +79,11 @@ public interface IConstantFactory {
String
getMenuNameByCode
(
String
code
);
String
getMenuNameByCode
(
String
code
);
/**
/**
* 获取菜单名称通过编号
*/
Long
getMenuIdByCode
(
String
code
);
/**
* 获取字典名称
* 获取字典名称
*/
*/
String
getDictName
(
Long
dictId
);
String
getDictName
(
Long
dictId
);
...
...
src/main/java/cn/stylefeng/guns/core/metadata/GunsMpFieldHandler.java
View file @
0119ac9e
/**
* Copyright 2018-2020 stylefeng & fengshuonan (sn93@qq.com)
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
cn
.
stylefeng
.
guns
.
core
.
metadata
;
package
cn
.
stylefeng
.
guns
.
core
.
metadata
;
import
cn.stylefeng.guns.core.shiro.ShiroKit
;
import
cn.stylefeng.guns.core.shiro.ShiroKit
;
...
...
src/main/java/cn/stylefeng/guns/core/util/DefaultImages.java
View file @
0119ac9e
/**
* Copyright 2018-2020 stylefeng & fengshuonan (sn93@qq.com)
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
cn
.
stylefeng
.
guns
.
core
.
util
;
package
cn
.
stylefeng
.
guns
.
core
.
util
;
import
cn.stylefeng.guns.core.listener.ConfigListener
;
import
cn.stylefeng.guns.core.listener.ConfigListener
;
...
...
src/main/java/cn/stylefeng/guns/modular/system/controller/MenuController.java
View file @
0119ac9e
...
@@ -37,13 +37,11 @@ import com.baomidou.mybatisplus.mapper.EntityWrapper;
...
@@ -37,13 +37,11 @@ import com.baomidou.mybatisplus.mapper.EntityWrapper;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.ui.Model
;
import
org.springframework.ui.Model
;
import
org.springframework.validation.BindingResult
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
javax.validation.Valid
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
...
@@ -116,14 +114,12 @@ public class MenuController extends BaseController {
...
@@ -116,14 +114,12 @@ public class MenuController extends BaseController {
@RequestMapping
(
value
=
"/edit"
)
@RequestMapping
(
value
=
"/edit"
)
@BussinessLog
(
value
=
"修改菜单"
,
key
=
"name"
,
dict
=
MenuDict
.
class
)
@BussinessLog
(
value
=
"修改菜单"
,
key
=
"name"
,
dict
=
MenuDict
.
class
)
@ResponseBody
@ResponseBody
public
ResponseData
edit
(
@Valid
Menu
menu
,
BindingResult
result
)
{
public
ResponseData
edit
(
MenuDto
menu
)
{
if
(
result
.
hasErrors
())
{
throw
new
ServiceException
(
BizExceptionEnum
.
REQUEST_NULL
);
}
//设置父级菜单编号
//设置父级菜单编号
menuSetPcode
(
menu
);
Menu
resultMenu
=
menuSetPcode
(
menu
);
this
.
menuService
.
updateById
(
m
enu
);
this
.
menuService
.
updateById
(
resultM
enu
);
return
SUCCESS_TIP
;
return
SUCCESS_TIP
;
}
}
...
@@ -145,10 +141,7 @@ public class MenuController extends BaseController {
...
@@ -145,10 +141,7 @@ public class MenuController extends BaseController {
@RequestMapping
(
value
=
"/add"
)
@RequestMapping
(
value
=
"/add"
)
@BussinessLog
(
value
=
"菜单新增"
,
key
=
"name"
,
dict
=
MenuDict
.
class
)
@BussinessLog
(
value
=
"菜单新增"
,
key
=
"name"
,
dict
=
MenuDict
.
class
)
@ResponseBody
@ResponseBody
public
ResponseData
add
(
@Valid
Menu
menu
,
BindingResult
result
)
{
public
ResponseData
add
(
MenuDto
menu
)
{
if
(
result
.
hasErrors
())
{
throw
new
ServiceException
(
BizExceptionEnum
.
REQUEST_NULL
);
}
//判断是否存在该编号
//判断是否存在该编号
String
existedMenuName
=
ConstantFactory
.
me
().
getMenuNameByCode
(
menu
.
getCode
());
String
existedMenuName
=
ConstantFactory
.
me
().
getMenuNameByCode
(
menu
.
getCode
());
...
@@ -157,10 +150,10 @@ public class MenuController extends BaseController {
...
@@ -157,10 +150,10 @@ public class MenuController extends BaseController {
}
}
//设置父级菜单编号
//设置父级菜单编号
menuSetPcode
(
menu
);
Menu
resultMenu
=
menuSetPcode
(
menu
);
m
enu
.
setStatus
(
MenuStatus
.
ENABLE
.
getCode
());
resultM
enu
.
setStatus
(
MenuStatus
.
ENABLE
.
getCode
());
this
.
menuService
.
insert
(
m
enu
);
this
.
menuService
.
insert
(
resultM
enu
);
return
SUCCESS_TIP
;
return
SUCCESS_TIP
;
}
}
...
@@ -192,8 +185,8 @@ public class MenuController extends BaseController {
...
@@ -192,8 +185,8 @@ public class MenuController extends BaseController {
if
(
ToolUtil
.
isEmpty
(
menuId
))
{
if
(
ToolUtil
.
isEmpty
(
menuId
))
{
throw
new
ServiceException
(
BizExceptionEnum
.
REQUEST_NULL
);
throw
new
ServiceException
(
BizExceptionEnum
.
REQUEST_NULL
);
}
}
this
.
menuService
.
selectById
(
menuId
);
Menu
menu
=
this
.
menuService
.
selectById
(
menuId
);
return
SUCCESS_TIP
;
return
ResponseData
.
success
(
menu
)
;
}
}
/**
/**
...
@@ -208,7 +201,8 @@ public class MenuController extends BaseController {
...
@@ -208,7 +201,8 @@ public class MenuController extends BaseController {
Menu
menu
=
this
.
menuService
.
selectById
(
menuId
);
Menu
menu
=
this
.
menuService
.
selectById
(
menuId
);
MenuDto
menuDto
=
new
MenuDto
();
MenuDto
menuDto
=
new
MenuDto
();
BeanUtil
.
copyProperties
(
menu
,
menuDto
);
BeanUtil
.
copyProperties
(
menu
,
menuDto
);
menuDto
.
setPid
(
ConstantFactory
.
me
().
getMenuIdByCode
(
menuDto
.
getPcode
()));
menuDto
.
setPcodeName
(
ConstantFactory
.
me
().
getMenuNameByCode
(
menuDto
.
getPcode
()));
menuDto
.
setPcodeName
(
ConstantFactory
.
me
().
getMenuNameByCode
(
menuDto
.
getPcode
()));
return
ResponseData
.
success
(
menuDto
);
return
ResponseData
.
success
(
menuDto
);
...
@@ -251,25 +245,31 @@ public class MenuController extends BaseController {
...
@@ -251,25 +245,31 @@ public class MenuController extends BaseController {
/**
/**
* 根据请求的父级菜单编号设置pcode和层级
* 根据请求的父级菜单编号设置pcode和层级
*/
*/
private
void
menuSetPcode
(
@Valid
Menu
menu
)
{
private
Menu
menuSetPcode
(
MenuDto
menuParam
)
{
if
(
ToolUtil
.
isEmpty
(
menu
.
getPcode
())
||
menu
.
getPcode
().
equals
(
"0"
))
{
menu
.
setPcode
(
"0"
);
Menu
resultMenu
=
new
Menu
();
menu
.
setPcodes
(
"[0],"
);
BeanUtil
.
copyProperties
(
menuParam
,
resultMenu
);
menu
.
setLevels
(
1
);
if
(
ToolUtil
.
isEmpty
(
menuParam
.
getPid
())
||
menuParam
.
getPid
().
equals
(
0L
))
{
resultMenu
.
setPcode
(
"0"
);
resultMenu
.
setPcodes
(
"[0],"
);
resultMenu
.
setLevels
(
1
);
}
else
{
}
else
{
String
code
=
menu
.
getPcode
();
Long
pid
=
menuParam
.
getPid
();
Menu
pMenu
=
menuService
.
selectBy
Code
(
code
);
Menu
pMenu
=
menuService
.
selectBy
Id
(
pid
);
Integer
pLevels
=
pMenu
.
getLevels
();
Integer
pLevels
=
pMenu
.
getLevels
();
m
enu
.
setPcode
(
pMenu
.
getCode
());
resultM
enu
.
setPcode
(
pMenu
.
getCode
());
//如果编号和父编号一致会导致无限递归
//如果编号和父编号一致会导致无限递归
if
(
menu
.
getCode
().
equals
(
menu
.
getPcode
()))
{
if
(
menu
Param
.
getCode
().
equals
(
menuParam
.
getPcode
()))
{
throw
new
ServiceException
(
BizExceptionEnum
.
MENU_PCODE_COINCIDENCE
);
throw
new
ServiceException
(
BizExceptionEnum
.
MENU_PCODE_COINCIDENCE
);
}
}
m
enu
.
setLevels
(
pLevels
+
1
);
resultM
enu
.
setLevels
(
pLevels
+
1
);
m
enu
.
setPcodes
(
pMenu
.
getPcodes
()
+
"["
+
pMenu
.
getCode
()
+
"],"
);
resultM
enu
.
setPcodes
(
pMenu
.
getPcodes
()
+
"["
+
pMenu
.
getCode
()
+
"],"
);
}
}
return
resultMenu
;
}
}
}
}
src/main/java/cn/stylefeng/guns/modular/system/model/MenuDto.java
View file @
0119ac9e
...
@@ -26,6 +26,10 @@ public class MenuDto implements Serializable {
...
@@ -26,6 +26,10 @@ public class MenuDto implements Serializable {
*/
*/
private
String
code
;
private
String
code
;
/**
/**
* 菜单父级id
*/
private
Long
pid
;
/**
* 菜单父编号
* 菜单父编号
*/
*/
private
String
pcode
;
private
String
pcode
;
...
...
src/main/webapp/WEB-INF/system/menu/menu_add.html
View file @
0119ac9e
...
@@ -19,7 +19,7 @@
...
@@ -19,7 +19,7 @@
<h5>
父级编号
<span
class=
"text-danger"
>
*
</span></h5>
<h5>
父级编号
<span
class=
"text-danger"
>
*
</span></h5>
<div
class=
"controls"
>
<div
class=
"controls"
>
<input
v-model=
"pcodeName"
id=
"detpName"
\@
click=
"showMenuSelectTree"
type=
"text"
class=
"form-control"
autocomplete=
"off"
>
<input
v-model=
"pcodeName"
id=
"detpName"
\@
click=
"showMenuSelectTree"
type=
"text"
class=
"form-control"
autocomplete=
"off"
>
<input
v-model=
"p
code
"
type=
"hidden"
class=
"form-control"
>
<input
v-model=
"p
id
"
type=
"hidden"
class=
"form-control"
>
</div>
</div>
</div>
</div>
<div
class=
"form-group"
>
<div
class=
"form-group"
>
...
...
src/main/webapp/WEB-INF/system/menu/menu_edit.html
View file @
0119ac9e
...
@@ -19,7 +19,7 @@
...
@@ -19,7 +19,7 @@
<h5>
父级编号
<span
class=
"text-danger"
>
*
</span></h5>
<h5>
父级编号
<span
class=
"text-danger"
>
*
</span></h5>
<div
class=
"controls"
>
<div
class=
"controls"
>
<input
v-model=
"pcodeName"
id=
"detpName"
\@
click=
"showMenuSelectTree"
type=
"text"
class=
"form-control"
autocomplete=
"off"
>
<input
v-model=
"pcodeName"
id=
"detpName"
\@
click=
"showMenuSelectTree"
type=
"text"
class=
"form-control"
autocomplete=
"off"
>
<input
v-model=
"p
code
"
type=
"hidden"
class=
"form-control"
>
<input
v-model=
"p
id
"
type=
"hidden"
class=
"form-control"
>
</div>
</div>
</div>
</div>
<div
class=
"form-group"
>
<div
class=
"form-group"
>
...
...
src/main/webapp/assets/modular/system/menu/menu_add.js
View file @
0119ac9e
...
@@ -6,7 +6,7 @@ var MenuInfoDlg = {
...
@@ -6,7 +6,7 @@ var MenuInfoDlg = {
menuId
:
""
,
menuId
:
""
,
name
:
""
,
name
:
""
,
code
:
""
,
code
:
""
,
p
code
:
""
,
p
id
:
""
,
pcodeName
:
""
,
pcodeName
:
""
,
url
:
""
,
url
:
""
,
sort
:
""
,
sort
:
""
,
...
@@ -36,7 +36,7 @@ MenuInfoDlg.validateForm = function () {
...
@@ -36,7 +36,7 @@ MenuInfoDlg.validateForm = function () {
if
(
!
data
.
code
)
{
if
(
!
data
.
code
)
{
return
"请输入菜单编号"
;
return
"请输入菜单编号"
;
}
}
if
(
!
data
.
p
code
)
{
if
(
!
data
.
p
id
)
{
return
"请输入菜单上级"
;
return
"请输入菜单上级"
;
}
}
if
(
!
data
.
menuFlag
)
{
if
(
!
data
.
menuFlag
)
{
...
@@ -74,7 +74,7 @@ $(function () {
...
@@ -74,7 +74,7 @@ $(function () {
},
},
showMenuSelectTree
:
function
()
{
showMenuSelectTree
:
function
()
{
var
formName
=
encodeURIComponent
(
"parent.MenuInfoDlg.app.pcodeName"
);
var
formName
=
encodeURIComponent
(
"parent.MenuInfoDlg.app.pcodeName"
);
var
formId
=
encodeURIComponent
(
"parent.MenuInfoDlg.app.p
code
"
);
var
formId
=
encodeURIComponent
(
"parent.MenuInfoDlg.app.p
id
"
);
var
treeUrl
=
encodeURIComponent
(
Feng
.
ctxPath
+
"/menu/selectMenuTreeList"
);
var
treeUrl
=
encodeURIComponent
(
Feng
.
ctxPath
+
"/menu/selectMenuTreeList"
);
layer
.
open
({
layer
.
open
({
...
...
src/main/webapp/assets/modular/system/menu/menu_edit.js
View file @
0119ac9e
...
@@ -6,7 +6,7 @@ var MenuInfoDlg = {
...
@@ -6,7 +6,7 @@ var MenuInfoDlg = {
menuId
:
""
,
menuId
:
""
,
name
:
""
,
name
:
""
,
code
:
""
,
code
:
""
,
p
code
:
""
,
p
id
:
""
,
pcodeName
:
""
,
pcodeName
:
""
,
url
:
""
,
url
:
""
,
sort
:
""
,
sort
:
""
,
...
@@ -36,7 +36,7 @@ MenuInfoDlg.validateForm = function () {
...
@@ -36,7 +36,7 @@ MenuInfoDlg.validateForm = function () {
if
(
!
data
.
code
)
{
if
(
!
data
.
code
)
{
return
"请输入菜单编号"
;
return
"请输入菜单编号"
;
}
}
if
(
!
data
.
p
code
)
{
if
(
!
data
.
p
id
)
{
return
"请输入菜单上级"
;
return
"请输入菜单上级"
;
}
}
if
(
!
data
.
menuFlag
)
{
if
(
!
data
.
menuFlag
)
{
...
@@ -80,7 +80,7 @@ $(function () {
...
@@ -80,7 +80,7 @@ $(function () {
},
},
showMenuSelectTree
:
function
()
{
showMenuSelectTree
:
function
()
{
var
formName
=
encodeURIComponent
(
"parent.MenuInfoDlg.app.pcodeName"
);
var
formName
=
encodeURIComponent
(
"parent.MenuInfoDlg.app.pcodeName"
);
var
formId
=
encodeURIComponent
(
"parent.MenuInfoDlg.app.p
code
"
);
var
formId
=
encodeURIComponent
(
"parent.MenuInfoDlg.app.p
id
"
);
var
treeUrl
=
encodeURIComponent
(
Feng
.
ctxPath
+
"/menu/selectMenuTreeList"
);
var
treeUrl
=
encodeURIComponent
(
Feng
.
ctxPath
+
"/menu/selectMenuTreeList"
);
layer
.
open
({
layer
.
open
({
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment