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
5b9c7b12
Commit
5b9c7b12
authored
Mar 31, 2019
by
fengshuonan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
适配sql server,改掉所有pids like语句
parent
d5e51511
Show whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
117 additions
and
19 deletions
+117
-19
src/main/java/cn/stylefeng/guns/core/common/constant/factory/ConstantFactory.java
+2
-3
src/main/java/cn/stylefeng/guns/core/common/constant/state/CommonStatus.java
+52
-0
src/main/java/cn/stylefeng/guns/modular/system/mapper/DeptMapper.java
+5
-0
src/main/java/cn/stylefeng/guns/modular/system/mapper/DictMapper.java
+4
-0
src/main/java/cn/stylefeng/guns/modular/system/mapper/MenuMapper.java
+7
-0
src/main/java/cn/stylefeng/guns/modular/system/mapper/mapping/DeptMapper.xml
+9
-0
src/main/java/cn/stylefeng/guns/modular/system/mapper/mapping/DictMapper.xml
+10
-1
src/main/java/cn/stylefeng/guns/modular/system/mapper/mapping/MenuMapper.xml
+11
-1
src/main/java/cn/stylefeng/guns/modular/system/mapper/mapping/RoleMapper.xml
+1
-1
src/main/java/cn/stylefeng/guns/modular/system/service/DeptService.java
+2
-4
src/main/java/cn/stylefeng/guns/modular/system/service/DictService.java
+6
-3
src/main/java/cn/stylefeng/guns/modular/system/service/DictTypeService.java
+5
-0
src/main/java/cn/stylefeng/guns/modular/system/service/MenuService.java
+3
-6
No files found.
src/main/java/cn/stylefeng/guns/core/common/constant/factory/ConstantFactory.java
View file @
5b9c7b12
...
@@ -300,9 +300,8 @@ public class ConstantFactory implements IConstantFactory {
...
@@ -300,9 +300,8 @@ public class ConstantFactory implements IConstantFactory {
@Override
@Override
public
List
<
Long
>
getSubDeptId
(
Long
deptId
)
{
public
List
<
Long
>
getSubDeptId
(
Long
deptId
)
{
QueryWrapper
<
Dept
>
wrapper
=
new
QueryWrapper
<>();
wrapper
=
wrapper
.
like
(
"PIDS"
,
"%["
+
deptId
+
"]%"
);
List
<
Dept
>
depts
=
this
.
deptMapper
.
likePids
(
deptId
);
List
<
Dept
>
depts
=
this
.
deptMapper
.
selectList
(
wrapper
);
ArrayList
<
Long
>
deptids
=
new
ArrayList
<>();
ArrayList
<
Long
>
deptids
=
new
ArrayList
<>();
...
...
src/main/java/cn/stylefeng/guns/core/common/constant/state/CommonStatus.java
0 → 100644
View file @
5b9c7b12
/**
* Copyright 2018-2020 stylefeng & fengshuonan (https://gitee.com/stylefeng)
* <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
.
state
;
import
lombok.Getter
;
/**
* 公共状态
*
* @author fengshuonan
* @Date 2017年1月22日 下午12:14:59
*/
@Getter
public
enum
CommonStatus
{
ENABLE
(
"ENABLE"
,
"启用"
),
DISABLE
(
"DISABLE"
,
"禁用"
);
String
code
;
String
message
;
CommonStatus
(
String
code
,
String
message
)
{
this
.
code
=
code
;
this
.
message
=
message
;
}
public
static
String
getDescription
(
String
status
)
{
if
(
status
==
null
)
{
return
""
;
}
else
{
for
(
CommonStatus
s
:
CommonStatus
.
values
())
{
if
(
s
.
getCode
().
equals
(
status
))
{
return
s
.
getMessage
();
}
}
return
""
;
}
}
}
src/main/java/cn/stylefeng/guns/modular/system/mapper/DeptMapper.java
View file @
5b9c7b12
...
@@ -34,4 +34,9 @@ public interface DeptMapper extends BaseMapper<Dept> {
...
@@ -34,4 +34,9 @@ public interface DeptMapper extends BaseMapper<Dept> {
* 获取所有部门树列表
* 获取所有部门树列表
*/
*/
List
<
TreeviewNode
>
treeviewNodes
();
List
<
TreeviewNode
>
treeviewNodes
();
/**
* where pids like ''
*/
List
<
Dept
>
likePids
(
Long
deptId
);
}
}
src/main/java/cn/stylefeng/guns/modular/system/mapper/DictMapper.java
View file @
5b9c7b12
...
@@ -21,4 +21,8 @@ public interface DictMapper extends BaseMapper<Dict> {
...
@@ -21,4 +21,8 @@ public interface DictMapper extends BaseMapper<Dict> {
*/
*/
List
<
ZTreeNode
>
dictTree
(
Long
dictTypeId
);
List
<
ZTreeNode
>
dictTree
(
Long
dictTypeId
);
/**
* where parentIds like ''
*/
List
<
Dict
>
likeParentIds
(
Long
dictId
);
}
}
src/main/java/cn/stylefeng/guns/modular/system/mapper/MenuMapper.java
View file @
5b9c7b12
...
@@ -87,5 +87,12 @@ public interface MenuMapper extends BaseMapper<Menu> {
...
@@ -87,5 +87,12 @@ public interface MenuMapper extends BaseMapper<Menu> {
*/
*/
List
<
Map
<
String
,
Object
>>
selectMenuTree
(
@Param
(
"condition"
)
String
condition
,
@Param
(
"level"
)
String
level
);
List
<
Map
<
String
,
Object
>>
selectMenuTree
(
@Param
(
"condition"
)
String
condition
,
@Param
(
"level"
)
String
level
);
/**
* 获取pcodes like某个code的菜单列表
*
* @author fengshuonan
* @Date 2019/3/31 15:51
*/
List
<
Menu
>
getMenusLikePcodes
(
@Param
(
"code"
)
String
code
);
}
}
src/main/java/cn/stylefeng/guns/modular/system/mapper/mapping/DeptMapper.xml
View file @
5b9c7b12
...
@@ -52,4 +52,13 @@
...
@@ -52,4 +52,13 @@
select DEPT_ID AS tags, PID as parentId, SIMPLE_NAME as text from sys_dept
select DEPT_ID AS tags, PID as parentId, SIMPLE_NAME as text from sys_dept
</select>
</select>
<select
id=
"likePids"
resultType=
"cn.stylefeng.guns.modular.system.entity.Dept"
>
select
<include
refid=
"Base_Column_List"
/>
from sys_dept
<where>
PIDS LIKE CONCAT('%$[',#{deptId},'$]%') escape '$'
</where>
</select>
</mapper>
</mapper>
src/main/java/cn/stylefeng/guns/modular/system/mapper/mapping/DictMapper.xml
View file @
5b9c7b12
...
@@ -32,7 +32,16 @@
...
@@ -32,7 +32,16 @@
ELSE
ELSE
'false'
'false'
END
END
) as open from sys_dict where DICT_TYPE_ID = #{dictTypeId}
) as 'open' from sys_dict where DICT_TYPE_ID = #{dictTypeId}
</select>
<select
id=
"likeParentIds"
resultType=
"cn.stylefeng.guns.modular.system.entity.Dict"
>
select
<include
refid=
"Base_Column_List"
></include>
from sys_dict as base
<where>
PARENT_IDS LIKE CONCAT('%$[',#{dictId},'$]%') escape '$'
</where>
</select>
</select>
</mapper>
</mapper>
src/main/java/cn/stylefeng/guns/modular/system/mapper/mapping/MenuMapper.xml
View file @
5b9c7b12
...
@@ -107,7 +107,7 @@
...
@@ -107,7 +107,7 @@
ELSE
ELSE
'true'
'true'
END
END
) as
`checked`
) as
'checked'
FROM
FROM
sys_menu m1
sys_menu m1
LEFT JOIN
LEFT JOIN
...
@@ -195,4 +195,14 @@
...
@@ -195,4 +195,14 @@
</if>
</if>
</select>
</select>
<select
id=
"getMenusLikePcodes"
resultType=
"cn.stylefeng.guns.modular.system.entity.Menu"
>
select
<include
refid=
"Base_Column_List"
></include>
from sys_menu
<where>
PCODES LIKE CONCAT('%$[',#{code},'$]%') escape '$'
</where>
</select>
</mapper>
</mapper>
src/main/java/cn/stylefeng/guns/modular/system/mapper/mapping/RoleMapper.xml
View file @
5b9c7b12
...
@@ -45,7 +45,7 @@
...
@@ -45,7 +45,7 @@
SELECT
SELECT
r.ROLE_ID as id,
r.ROLE_ID as id,
PID as pId,
PID as pId,
NAME AS
`name`
,
NAME AS
'name'
,
(
(
CASE
CASE
WHEN (PID = 0 OR PID IS NULL) THEN
WHEN (PID = 0 OR PID IS NULL) THEN
...
...
src/main/java/cn/stylefeng/guns/modular/system/service/DeptService.java
View file @
5b9c7b12
...
@@ -8,7 +8,6 @@ import cn.stylefeng.guns.modular.system.entity.Dept;
...
@@ -8,7 +8,6 @@ import cn.stylefeng.guns.modular.system.entity.Dept;
import
cn.stylefeng.guns.modular.system.mapper.DeptMapper
;
import
cn.stylefeng.guns.modular.system.mapper.DeptMapper
;
import
cn.stylefeng.roses.core.util.ToolUtil
;
import
cn.stylefeng.roses.core.util.ToolUtil
;
import
cn.stylefeng.roses.kernel.model.exception.ServiceException
;
import
cn.stylefeng.roses.kernel.model.exception.ServiceException
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
...
@@ -81,9 +80,8 @@ public class DeptService extends ServiceImpl<DeptMapper, Dept> {
...
@@ -81,9 +80,8 @@ public class DeptService extends ServiceImpl<DeptMapper, Dept> {
Dept
dept
=
deptMapper
.
selectById
(
deptId
);
Dept
dept
=
deptMapper
.
selectById
(
deptId
);
//根据like查询删除所有级联的部门
//根据like查询删除所有级联的部门
QueryWrapper
<
Dept
>
wrapper
=
new
QueryWrapper
<>();
List
<
Dept
>
subDepts
=
deptMapper
.
likePids
(
dept
.
getDeptId
());
wrapper
=
wrapper
.
like
(
"PIDS"
,
"%["
+
dept
.
getDeptId
()
+
"]%"
);
List
<
Dept
>
subDepts
=
deptMapper
.
selectList
(
wrapper
);
for
(
Dept
temp
:
subDepts
)
{
for
(
Dept
temp
:
subDepts
)
{
this
.
removeById
(
temp
.
getDeptId
());
this
.
removeById
(
temp
.
getDeptId
());
}
}
...
...
src/main/java/cn/stylefeng/guns/modular/system/service/DictService.java
View file @
5b9c7b12
package
cn
.
stylefeng
.
guns
.
modular
.
system
.
service
;
package
cn
.
stylefeng
.
guns
.
modular
.
system
.
service
;
import
cn.stylefeng.guns.core.common.constant.state.CommonStatus
;
import
cn.stylefeng.guns.core.common.exception.BizExceptionEnum
;
import
cn.stylefeng.guns.core.common.exception.BizExceptionEnum
;
import
cn.stylefeng.guns.core.common.node.ZTreeNode
;
import
cn.stylefeng.guns.core.common.node.ZTreeNode
;
import
cn.stylefeng.guns.core.common.page.LayuiPageFactory
;
import
cn.stylefeng.guns.core.common.page.LayuiPageFactory
;
...
@@ -54,6 +55,9 @@ public class DictService extends ServiceImpl<DictMapper, Dict> {
...
@@ -54,6 +55,9 @@ public class DictService extends ServiceImpl<DictMapper, Dict> {
//设置pids
//设置pids
dictSetPids
(
entity
);
dictSetPids
(
entity
);
//设置状态
entity
.
setStatus
(
CommonStatus
.
ENABLE
.
getCode
());
this
.
save
(
entity
);
this
.
save
(
entity
);
}
}
...
@@ -241,9 +245,8 @@ public class DictService extends ServiceImpl<DictMapper, Dict> {
...
@@ -241,9 +245,8 @@ public class DictService extends ServiceImpl<DictMapper, Dict> {
}
}
private
List
<
Long
>
getSubIds
(
Long
dictId
)
{
private
List
<
Long
>
getSubIds
(
Long
dictId
)
{
QueryWrapper
<
Dict
>
dictQueryWrapper
=
new
QueryWrapper
<>();
dictQueryWrapper
.
like
(
"PARENT_IDS"
,
"%["
+
dictId
+
"]%"
);
List
<
Dict
>
list
=
this
.
baseMapper
.
likeParentIds
(
dictId
);
List
<
Dict
>
list
=
this
.
list
(
dictQueryWrapper
);
ArrayList
<
Long
>
longs
=
new
ArrayList
<>();
ArrayList
<
Long
>
longs
=
new
ArrayList
<>();
for
(
Dict
dict
:
list
)
{
for
(
Dict
dict
:
list
)
{
...
...
src/main/java/cn/stylefeng/guns/modular/system/service/DictTypeService.java
View file @
5b9c7b12
package
cn
.
stylefeng
.
guns
.
modular
.
system
.
service
;
package
cn
.
stylefeng
.
guns
.
modular
.
system
.
service
;
import
cn.stylefeng.guns.core.common.constant.state.CommonStatus
;
import
cn.stylefeng.guns.core.common.exception.BizExceptionEnum
;
import
cn.stylefeng.guns.core.common.exception.BizExceptionEnum
;
import
cn.stylefeng.guns.core.common.page.LayuiPageFactory
;
import
cn.stylefeng.guns.core.common.page.LayuiPageFactory
;
import
cn.stylefeng.guns.core.common.page.LayuiPageInfo
;
import
cn.stylefeng.guns.core.common.page.LayuiPageInfo
;
...
@@ -46,6 +47,10 @@ public class DictTypeService extends ServiceImpl<DictTypeMapper, DictType> {
...
@@ -46,6 +47,10 @@ public class DictTypeService extends ServiceImpl<DictTypeMapper, DictType> {
}
}
DictType
entity
=
getEntity
(
param
);
DictType
entity
=
getEntity
(
param
);
//设置状态
entity
.
setStatus
(
CommonStatus
.
ENABLE
.
getCode
());
this
.
save
(
entity
);
this
.
save
(
entity
);
}
}
...
...
src/main/java/cn/stylefeng/guns/modular/system/service/MenuService.java
View file @
5b9c7b12
...
@@ -109,9 +109,7 @@ public class MenuService extends ServiceImpl<MenuMapper, Menu> {
...
@@ -109,9 +109,7 @@ public class MenuService extends ServiceImpl<MenuMapper, Menu> {
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
updateSubMenuLevels
(
Menu
oldMenu
,
Menu
newMenu
)
{
public
void
updateSubMenuLevels
(
Menu
oldMenu
,
Menu
newMenu
)
{
QueryWrapper
<
Menu
>
wrapper
=
new
QueryWrapper
<>();
List
<
Menu
>
menus
=
menuMapper
.
getMenusLikePcodes
(
oldMenu
.
getCode
());
wrapper
=
wrapper
.
like
(
"PCODES"
,
"%["
+
oldMenu
.
getCode
()
+
"]%"
);
List
<
Menu
>
menus
=
menuMapper
.
selectList
(
wrapper
);
for
(
Menu
menu
:
menus
)
{
for
(
Menu
menu
:
menus
)
{
...
@@ -166,9 +164,8 @@ public class MenuService extends ServiceImpl<MenuMapper, Menu> {
...
@@ -166,9 +164,8 @@ public class MenuService extends ServiceImpl<MenuMapper, Menu> {
delMenu
(
menuId
);
delMenu
(
menuId
);
//删除所有子菜单
//删除所有子菜单
QueryWrapper
<
Menu
>
wrapper
=
new
QueryWrapper
<>();
List
<
Menu
>
menus
=
menuMapper
.
getMenusLikePcodes
(
menu
.
getCode
());
wrapper
=
wrapper
.
like
(
"PCODES"
,
"%["
+
menu
.
getCode
()
+
"]%"
);
List
<
Menu
>
menus
=
menuMapper
.
selectList
(
wrapper
);
for
(
Menu
temp
:
menus
)
{
for
(
Menu
temp
:
menus
)
{
delMenu
(
temp
.
getMenuId
());
delMenu
(
temp
.
getMenuId
());
}
}
...
...
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