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
4df04de6
Commit
4df04de6
authored
Dec 23, 2018
by
fengshuonan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
整理字典业务
parent
c4b61475
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
67 additions
and
34 deletions
+67
-34
src/main/java/cn/stylefeng/guns/modular/system/controller/DictController.java
+22
-15
src/main/java/cn/stylefeng/guns/modular/system/mapper/mapping/DictMapper.xml
+1
-1
src/main/java/cn/stylefeng/guns/modular/system/service/DictService.java
+42
-2
src/main/java/cn/stylefeng/guns/modular/system/warpper/DictWarpper.java
+2
-16
No files found.
src/main/java/cn/stylefeng/guns/modular/system/controller/DictController.java
View file @
4df04de6
...
@@ -20,14 +20,12 @@ import cn.stylefeng.guns.core.common.annotion.Permission;
...
@@ -20,14 +20,12 @@ import cn.stylefeng.guns.core.common.annotion.Permission;
import
cn.stylefeng.guns.core.common.constant.Const
;
import
cn.stylefeng.guns.core.common.constant.Const
;
import
cn.stylefeng.guns.core.common.constant.dictmap.DictMap
;
import
cn.stylefeng.guns.core.common.constant.dictmap.DictMap
;
import
cn.stylefeng.guns.core.common.constant.factory.ConstantFactory
;
import
cn.stylefeng.guns.core.common.constant.factory.ConstantFactory
;
import
cn.stylefeng.guns.core.common.exception.BizExceptionEnum
;
import
cn.stylefeng.guns.core.log.LogObjectHolder
;
import
cn.stylefeng.guns.core.log.LogObjectHolder
;
import
cn.stylefeng.guns.modular.system.model.DictDto
;
import
cn.stylefeng.guns.modular.system.model.DictDto
;
import
cn.stylefeng.guns.modular.system.service.DictService
;
import
cn.stylefeng.guns.modular.system.service.DictService
;
import
cn.stylefeng.guns.modular.system.warpper.DictWarpper
;
import
cn.stylefeng.guns.modular.system.warpper.DictWarpper
;
import
cn.stylefeng.roses.core.base.controller.BaseController
;
import
cn.stylefeng.roses.core.base.controller.BaseController
;
import
cn.stylefeng.roses.core.util.ToolUtil
;
import
cn.stylefeng.roses.core.reqres.response.ResponseData
;
import
cn.stylefeng.roses.kernel.model.exception.ServiceException
;
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
;
...
@@ -55,6 +53,9 @@ public class DictController extends BaseController {
...
@@ -55,6 +53,9 @@ public class DictController extends BaseController {
/**
/**
* 跳转到字典管理首页
* 跳转到字典管理首页
*
* @author fengshuonan
* @Date 2018/12/23 5:21 PM
*/
*/
@RequestMapping
(
""
)
@RequestMapping
(
""
)
public
String
index
()
{
public
String
index
()
{
...
@@ -63,6 +64,9 @@ public class DictController extends BaseController {
...
@@ -63,6 +64,9 @@ public class DictController extends BaseController {
/**
/**
* 跳转到添加字典类型
* 跳转到添加字典类型
*
* @author fengshuonan
* @Date 2018/12/23 5:21 PM
*/
*/
@RequestMapping
(
"/dict_add_type"
)
@RequestMapping
(
"/dict_add_type"
)
public
String
deptAddType
()
{
public
String
deptAddType
()
{
...
@@ -71,6 +75,9 @@ public class DictController extends BaseController {
...
@@ -71,6 +75,9 @@ public class DictController extends BaseController {
/**
/**
* 跳转到添加字典条目
* 跳转到添加字典条目
*
* @author fengshuonan
* @Date 2018/12/23 5:22 PM
*/
*/
@RequestMapping
(
"/dict_add_item"
)
@RequestMapping
(
"/dict_add_item"
)
public
String
deptAddItem
(
@RequestParam
(
"dictId"
)
Long
dictId
,
Model
model
)
{
public
String
deptAddItem
(
@RequestParam
(
"dictId"
)
Long
dictId
,
Model
model
)
{
...
@@ -81,26 +88,23 @@ public class DictController extends BaseController {
...
@@ -81,26 +88,23 @@ public class DictController extends BaseController {
/**
/**
* 新增字典
* 新增字典
*
* @author fengshuonan
* @Date 2018/12/23 5:22 PM
*/
*/
@RequestMapping
(
value
=
"/add"
)
@RequestMapping
(
value
=
"/add"
)
@Permission
(
Const
.
ADMIN_NAME
)
@Permission
(
Const
.
ADMIN_NAME
)
@ResponseBody
@ResponseBody
public
Object
add
(
DictDto
dictDto
)
{
public
ResponseData
add
(
DictDto
dictDto
)
{
if
(
ToolUtil
.
isOneEmpty
(
dictDto
,
dictDto
.
getCode
(),
dictDto
.
getName
()))
{
this
.
dictService
.
addDict
(
dictDto
);
throw
new
ServiceException
(
BizExceptionEnum
.
REQUEST_NULL
);
}
if
(
ToolUtil
.
isEmpty
(
dictDto
.
getDictTypeId
()))
{
this
.
dictService
.
addDictType
(
dictDto
);
}
else
{
this
.
dictService
.
addDictItem
(
dictDto
);
}
return
SUCCESS_TIP
;
return
SUCCESS_TIP
;
}
}
/**
/**
* 获取所有字典列表
* 获取所有字典列表
*
* @author fengshuonan
* @Date 2018/12/23 5:22 PM
*/
*/
@RequestMapping
(
value
=
"/list"
)
@RequestMapping
(
value
=
"/list"
)
@Permission
(
Const
.
ADMIN_NAME
)
@Permission
(
Const
.
ADMIN_NAME
)
...
@@ -112,12 +116,15 @@ public class DictController extends BaseController {
...
@@ -112,12 +116,15 @@ public class DictController extends BaseController {
/**
/**
* 删除字典记录
* 删除字典记录
*
* @author fengshuonan
* @Date 2018/12/23 5:22 PM
*/
*/
@BussinessLog
(
value
=
"删除字典记录"
,
key
=
"dictId"
,
dict
=
DictMap
.
class
)
@BussinessLog
(
value
=
"删除字典记录"
,
key
=
"dictId"
,
dict
=
DictMap
.
class
)
@RequestMapping
(
value
=
"/delete"
)
@RequestMapping
(
value
=
"/delete"
)
@Permission
(
Const
.
ADMIN_NAME
)
@Permission
(
Const
.
ADMIN_NAME
)
@ResponseBody
@ResponseBody
public
Object
delete
(
@RequestParam
Long
dictId
)
{
public
ResponseData
delete
(
@RequestParam
Long
dictId
)
{
//缓存被删除的名称
//缓存被删除的名称
LogObjectHolder
.
me
().
set
(
ConstantFactory
.
me
().
getDictName
(
dictId
));
LogObjectHolder
.
me
().
set
(
ConstantFactory
.
me
().
getDictName
(
dictId
));
...
...
src/main/java/cn/stylefeng/guns/modular/system/mapper/mapping/DictMapper.xml
View file @
4df04de6
...
@@ -43,6 +43,6 @@
...
@@ -43,6 +43,6 @@
<if
test=
"condition != null and condition != ''"
>
<if
test=
"condition != null and condition != ''"
>
AND NAME like CONCAT('%',#{condition},'%')
AND NAME like CONCAT('%',#{condition},'%')
</if>
</if>
order by
DICT_ID
ASC
order by
SORT
ASC
</select>
</select>
</mapper>
</mapper>
src/main/java/cn/stylefeng/guns/modular/system/service/DictService.java
View file @
4df04de6
package
cn
.
stylefeng
.
guns
.
modular
.
system
.
service
;
package
cn
.
stylefeng
.
guns
.
modular
.
system
.
service
;
import
cn.hutool.core.bean.BeanUtil
;
import
cn.hutool.core.bean.BeanUtil
;
import
cn.stylefeng.guns.core.common.exception.BizExceptionEnum
;
import
cn.stylefeng.guns.modular.system.entity.Dict
;
import
cn.stylefeng.guns.modular.system.entity.Dict
;
import
cn.stylefeng.guns.modular.system.mapper.DictMapper
;
import
cn.stylefeng.guns.modular.system.mapper.DictMapper
;
import
cn.stylefeng.guns.modular.system.model.DictDto
;
import
cn.stylefeng.guns.modular.system.model.DictDto
;
import
cn.stylefeng.roses.core.util.ToolUtil
;
import
cn.stylefeng.roses.kernel.model.exception.ServiceException
;
import
com.baomidou.mybatisplus.mapper.EntityWrapper
;
import
com.baomidou.mybatisplus.mapper.EntityWrapper
;
import
com.baomidou.mybatisplus.mapper.Wrapper
;
import
com.baomidou.mybatisplus.mapper.Wrapper
;
import
com.baomidou.mybatisplus.service.impl.ServiceImpl
;
import
com.baomidou.mybatisplus.service.impl.ServiceImpl
;
...
@@ -29,9 +32,31 @@ public class DictService extends ServiceImpl<DictMapper, Dict> {
...
@@ -29,9 +32,31 @@ public class DictService extends ServiceImpl<DictMapper, Dict> {
private
DictMapper
dictMapper
;
private
DictMapper
dictMapper
;
/**
/**
* 添加字典
*
* @author fengshuonan
* @Date 2018/12/23 5:25 PM
*/
public
void
addDict
(
DictDto
dictDto
)
{
if
(
ToolUtil
.
isOneEmpty
(
dictDto
,
dictDto
.
getCode
(),
dictDto
.
getName
()))
{
throw
new
ServiceException
(
BizExceptionEnum
.
REQUEST_NULL
);
}
if
(
ToolUtil
.
isEmpty
(
dictDto
.
getDictTypeId
()))
{
this
.
addDictType
(
dictDto
);
}
else
{
this
.
addDictItem
(
dictDto
);
}
}
/**
* 添加字典类型
* 添加字典类型
*
* @author fengshuonan
* @Date 2018/12/23 5:25 PM
*/
*/
p
ublic
void
addDictType
(
DictDto
dictDto
)
{
p
rivate
void
addDictType
(
DictDto
dictDto
)
{
Dict
dict
=
new
Dict
();
Dict
dict
=
new
Dict
();
BeanUtil
.
copyProperties
(
dictDto
,
dict
);
BeanUtil
.
copyProperties
(
dictDto
,
dict
);
...
@@ -43,8 +68,11 @@ public class DictService extends ServiceImpl<DictMapper, Dict> {
...
@@ -43,8 +68,11 @@ public class DictService extends ServiceImpl<DictMapper, Dict> {
/**
/**
* 添加字典子类型
* 添加字典子类型
*
* @author fengshuonan
* @Date 2018/12/23 5:25 PM
*/
*/
p
ublic
void
addDictItem
(
DictDto
dictDto
)
{
p
rivate
void
addDictItem
(
DictDto
dictDto
)
{
Dict
dict
=
new
Dict
();
Dict
dict
=
new
Dict
();
BeanUtil
.
copyProperties
(
dictDto
,
dict
);
BeanUtil
.
copyProperties
(
dictDto
,
dict
);
...
@@ -56,6 +84,9 @@ public class DictService extends ServiceImpl<DictMapper, Dict> {
...
@@ -56,6 +84,9 @@ public class DictService extends ServiceImpl<DictMapper, Dict> {
/**
/**
* 删除字典
* 删除字典
*
* @author fengshuonan
* @Date 2018/12/23 5:25 PM
*/
*/
@Transactional
@Transactional
public
void
delteDict
(
Long
dictId
)
{
public
void
delteDict
(
Long
dictId
)
{
...
@@ -71,6 +102,9 @@ public class DictService extends ServiceImpl<DictMapper, Dict> {
...
@@ -71,6 +102,9 @@ public class DictService extends ServiceImpl<DictMapper, Dict> {
/**
/**
* 根据编码获取词典列表
* 根据编码获取词典列表
*
* @author fengshuonan
* @Date 2018/12/23 5:25 PM
*/
*/
public
List
<
Dict
>
selectByCode
(
String
code
)
{
public
List
<
Dict
>
selectByCode
(
String
code
)
{
return
this
.
baseMapper
.
selectByCode
(
code
);
return
this
.
baseMapper
.
selectByCode
(
code
);
...
@@ -78,6 +112,9 @@ public class DictService extends ServiceImpl<DictMapper, Dict> {
...
@@ -78,6 +112,9 @@ public class DictService extends ServiceImpl<DictMapper, Dict> {
/**
/**
* 根据父类编码获取词典列表
* 根据父类编码获取词典列表
*
* @author fengshuonan
* @Date 2018/12/23 5:26 PM
*/
*/
public
List
<
Dict
>
selectByParentCode
(
String
code
)
{
public
List
<
Dict
>
selectByParentCode
(
String
code
)
{
return
this
.
baseMapper
.
selectByParentCode
(
code
);
return
this
.
baseMapper
.
selectByParentCode
(
code
);
...
@@ -85,6 +122,9 @@ public class DictService extends ServiceImpl<DictMapper, Dict> {
...
@@ -85,6 +122,9 @@ public class DictService extends ServiceImpl<DictMapper, Dict> {
/**
/**
* 查询字典列表
* 查询字典列表
*
* @author fengshuonan
* @Date 2018/12/23 5:26 PM
*/
*/
public
List
<
Map
<
String
,
Object
>>
list
(
String
conditiion
)
{
public
List
<
Map
<
String
,
Object
>>
list
(
String
conditiion
)
{
return
this
.
baseMapper
.
list
(
conditiion
);
return
this
.
baseMapper
.
list
(
conditiion
);
...
...
src/main/java/cn/stylefeng/guns/modular/system/warpper/DictWarpper.java
View file @
4df04de6
...
@@ -19,8 +19,6 @@ import cn.hutool.core.util.StrUtil;
...
@@ -19,8 +19,6 @@ import cn.hutool.core.util.StrUtil;
import
cn.stylefeng.guns.core.common.constant.factory.ConstantFactory
;
import
cn.stylefeng.guns.core.common.constant.factory.ConstantFactory
;
import
cn.stylefeng.guns.modular.system.entity.Dict
;
import
cn.stylefeng.guns.modular.system.entity.Dict
;
import
cn.stylefeng.roses.core.base.warpper.BaseControllerWrapper
;
import
cn.stylefeng.roses.core.base.warpper.BaseControllerWrapper
;
import
cn.stylefeng.roses.kernel.model.page.PageResult
;
import
com.baomidou.mybatisplus.plugins.Page
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
...
@@ -33,30 +31,18 @@ import java.util.Map;
...
@@ -33,30 +31,18 @@ import java.util.Map;
*/
*/
public
class
DictWarpper
extends
BaseControllerWrapper
{
public
class
DictWarpper
extends
BaseControllerWrapper
{
public
DictWarpper
(
Map
<
String
,
Object
>
single
)
{
super
(
single
);
}
public
DictWarpper
(
List
<
Map
<
String
,
Object
>>
multi
)
{
public
DictWarpper
(
List
<
Map
<
String
,
Object
>>
multi
)
{
super
(
multi
);
super
(
multi
);
}
}
public
DictWarpper
(
Page
<
Map
<
String
,
Object
>>
page
)
{
super
(
page
);
}
public
DictWarpper
(
PageResult
<
Map
<
String
,
Object
>>
pageResult
)
{
super
(
pageResult
);
}
@Override
@Override
protected
void
wrapTheMap
(
Map
<
String
,
Object
>
map
)
{
protected
void
wrapTheMap
(
Map
<
String
,
Object
>
map
)
{
StringBu
ffer
detail
=
new
StringBuff
er
();
StringBu
ilder
detail
=
new
StringBuild
er
();
Long
id
=
Long
.
valueOf
(
map
.
get
(
"dictId"
).
toString
());
Long
id
=
Long
.
valueOf
(
map
.
get
(
"dictId"
).
toString
());
List
<
Dict
>
dicts
=
ConstantFactory
.
me
().
findInDict
(
id
);
List
<
Dict
>
dicts
=
ConstantFactory
.
me
().
findInDict
(
id
);
if
(
dicts
!=
null
)
{
if
(
dicts
!=
null
)
{
for
(
Dict
dict
:
dicts
)
{
for
(
Dict
dict
:
dicts
)
{
detail
.
append
(
dict
.
getCode
()
+
":"
+
dict
.
getName
()
+
","
);
detail
.
append
(
dict
.
getCode
()
).
append
(
":"
).
append
(
dict
.
getName
()).
append
(
","
);
}
}
map
.
put
(
"detail"
,
StrUtil
.
removeSuffix
(
detail
.
toString
(),
","
));
map
.
put
(
"detail"
,
StrUtil
.
removeSuffix
(
detail
.
toString
(),
","
));
}
}
...
...
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