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
b1e60983
Commit
b1e60983
authored
Dec 09, 2018
by
fengshuonan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
删除编辑字典
parent
9ac5fda2
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
0 additions
and
279 deletions
+0
-279
src/main/java/cn/stylefeng/guns/modular/system/controller/DictController.java
+0
-42
src/main/java/cn/stylefeng/guns/modular/system/service/DictService.java
+0
-60
src/main/webapp/WEB-INF/system/dict/dict_edit.html
+0
-45
src/main/webapp/assets/modular/system/dict/dict_edit.js
+0
-118
src/test/java/cn/stylefeng/guns/system/DictTest.java
+0
-14
No files found.
src/main/java/cn/stylefeng/guns/modular/system/controller/DictController.java
View file @
b1e60983
...
...
@@ -22,18 +22,15 @@ import cn.stylefeng.guns.core.common.constant.dictmap.DictMap;
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.modular.system.entity.Dict
;
import
cn.stylefeng.guns.modular.system.model.DictDto
;
import
cn.stylefeng.guns.modular.system.service.DictService
;
import
cn.stylefeng.guns.modular.system.warpper.DictWarpper
;
import
cn.stylefeng.roses.core.base.controller.BaseController
;
import
cn.stylefeng.roses.core.util.ToolUtil
;
import
cn.stylefeng.roses.kernel.model.exception.ServiceException
;
import
com.baomidou.mybatisplus.mapper.EntityWrapper
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.ui.Model
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.ResponseBody
;
...
...
@@ -83,20 +80,6 @@ public class DictController extends BaseController {
}
/**
* 跳转到修改字典
*/
@Permission
(
Const
.
ADMIN_NAME
)
@RequestMapping
(
"/dict_edit/{dictId}"
)
public
String
deptUpdate
(
@PathVariable
Long
dictId
,
Model
model
)
{
Dict
dict
=
dictService
.
selectById
(
dictId
);
model
.
addAttribute
(
"dict"
,
dict
);
List
<
Dict
>
subDicts
=
dictService
.
selectList
(
new
EntityWrapper
<
Dict
>().
eq
(
"PID"
,
dictId
));
model
.
addAttribute
(
"subDicts"
,
subDicts
);
LogObjectHolder
.
me
().
set
(
dict
);
return
PREFIX
+
"dict_edit.html"
;
}
/**
* 新增字典
*/
@RequestMapping
(
value
=
"/add"
)
...
...
@@ -128,31 +111,6 @@ public class DictController extends BaseController {
}
/**
* 字典详情
*/
@RequestMapping
(
value
=
"/detail/{dictId}"
)
@Permission
(
Const
.
ADMIN_NAME
)
@ResponseBody
public
Object
detail
(
@PathVariable
(
"dictId"
)
Integer
dictId
)
{
return
dictService
.
selectById
(
dictId
);
}
/**
* 修改字典
*/
@BussinessLog
(
value
=
"修改字典"
,
key
=
"dictName,dictValues"
,
dict
=
DictMap
.
class
)
@RequestMapping
(
value
=
"/update"
)
@Permission
(
Const
.
ADMIN_NAME
)
@ResponseBody
public
Object
update
(
Long
dictId
,
String
dictCode
,
String
dictName
,
String
dictTips
,
String
dictValues
)
{
if
(
ToolUtil
.
isOneEmpty
(
dictId
,
dictCode
,
dictName
,
dictValues
))
{
throw
new
ServiceException
(
BizExceptionEnum
.
REQUEST_NULL
);
}
dictService
.
editDict
(
dictId
,
dictCode
,
dictName
,
dictTips
,
dictValues
);
return
SUCCESS_TIP
;
}
/**
* 删除字典记录
*/
@BussinessLog
(
value
=
"删除字典记录"
,
key
=
"dictId"
,
dict
=
DictMap
.
class
)
...
...
src/main/java/cn/stylefeng/guns/modular/system/service/DictService.java
View file @
b1e60983
package
cn
.
stylefeng
.
guns
.
modular
.
system
.
service
;
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.mapper.DictMapper
;
import
cn.stylefeng.guns.modular.system.model.DictDto
;
import
cn.stylefeng.roses.kernel.model.exception.ServiceException
;
import
com.baomidou.mybatisplus.mapper.EntityWrapper
;
import
com.baomidou.mybatisplus.mapper.Wrapper
;
import
com.baomidou.mybatisplus.service.impl.ServiceImpl
;
...
...
@@ -16,8 +14,6 @@ import javax.annotation.Resource;
import
java.util.List
;
import
java.util.Map
;
import
static
cn
.
stylefeng
.
guns
.
core
.
common
.
constant
.
factory
.
MutiStrFactory
.*;
/**
* <p>
* 字典表 服务实现类
...
...
@@ -59,62 +55,6 @@ public class DictService extends ServiceImpl<DictMapper, Dict> {
}
/**
* 添加字典
*/
@Transactional
public
void
addDict
(
String
dictCode
,
String
dictName
,
String
dictDescription
,
String
dictValues
)
{
//判断有没有该字典
List
<
Dict
>
dicts
=
dictMapper
.
selectList
(
new
EntityWrapper
<
Dict
>().
eq
(
"CODE"
,
dictCode
).
and
().
eq
(
"PID"
,
0
));
if
(
dicts
!=
null
&&
dicts
.
size
()
>
0
)
{
throw
new
ServiceException
(
BizExceptionEnum
.
DICT_EXISTED
);
}
//解析dictValues
List
<
Map
<
String
,
String
>>
items
=
parseKeyValue
(
dictValues
);
//添加字典
Dict
dict
=
new
Dict
();
dict
.
setName
(
dictName
);
dict
.
setCode
(
dictCode
);
dict
.
setDescription
(
dictDescription
);
dict
.
setSort
(
0
);
dict
.
setPid
(
0L
);
this
.
dictMapper
.
insert
(
dict
);
//添加字典条目
for
(
Map
<
String
,
String
>
item
:
items
)
{
String
code
=
item
.
get
(
MUTI_STR_CODE
);
String
name
=
item
.
get
(
MUTI_STR_NAME
);
String
num
=
item
.
get
(
MUTI_STR_NUM
);
Dict
itemDict
=
new
Dict
();
itemDict
.
setPid
(
dict
.
getDictId
());
itemDict
.
setCode
(
code
);
itemDict
.
setName
(
name
);
try
{
itemDict
.
setSort
(
Integer
.
valueOf
(
num
));
}
catch
(
NumberFormatException
e
)
{
throw
new
ServiceException
(
BizExceptionEnum
.
DICT_MUST_BE_NUMBER
);
}
this
.
dictMapper
.
insert
(
itemDict
);
}
}
/**
* 编辑字典
*/
@Transactional
public
void
editDict
(
Long
dictId
,
String
dictCode
,
String
dictName
,
String
dictTips
,
String
dicts
)
{
//删除之前的字典
this
.
delteDict
(
dictId
);
//重新添加新的字典
this
.
addDict
(
dictCode
,
dictName
,
dictTips
,
dicts
);
}
/**
* 删除字典
*/
@Transactional
...
...
src/main/webapp/WEB-INF/system/dict/dict_edit.html
deleted
100644 → 0
View file @
9ac5fda2
@layout("/common/_dialog.html",{plugins:["sweet-alert","layer"],js:["/assets/modular/system/role/role_edit.js"]}){
<div
class=
"container-fluid"
>
<form
id=
"roleForm"
\@
submit=
"submitForm"
>
<div
class=
"row"
>
<div
class=
"col-6"
>
<div
class=
"form-group"
>
<h5>
角色名称
<span
class=
"text-danger"
>
*
</span></h5>
<div
class=
"controls"
>
<input
v-model=
"name"
type=
"text"
class=
"form-control"
>
</div>
</div>
<div
class=
"form-group"
>
<h5>
上级名称
<span
class=
"text-danger"
>
*
</span></h5>
<div
class=
"controls"
>
<input
v-model=
"pName"
id=
"pName"
\@
click=
"showParentSelectTree"
type=
"text"
class=
"form-control"
autocomplete=
"off"
>
<input
v-model=
"pid"
type=
"hidden"
class=
"form-control"
>
</div>
</div>
<div
class=
"form-group"
>
<h5>
别名
<span
class=
"text-danger"
>
*
</span></h5>
<div
class=
"controls"
>
<input
v-model=
"description"
type=
"text"
class=
"form-control"
>
</div>
</div>
</div>
<div
class=
"col-6"
>
<div
class=
"form-group"
>
<h5>
排序
</h5>
<div
class=
"controls"
>
<input
v-model=
"sort"
type=
"text"
class=
"form-control"
>
</div>
</div>
</div>
</div>
<div
class=
"row"
>
<div
class=
"col-6"
>
<div
class=
"text-xs-right"
>
<button
class=
"btn btn-info normal-button-width"
\@
click=
"ensure"
>
提交
</button>
<button
class=
"btn btn-inverse normal-button-width m-l-10"
\@
click=
"close"
>
取消
</button>
</div>
</div>
</div>
</form>
</div>
@}
src/main/webapp/assets/modular/system/dict/dict_edit.js
deleted
100644 → 0
View file @
9ac5fda2
/**
* 初始化字典详情对话框
*/
var
DictInfoDlg
=
{
count
:
$
(
"#itemSize"
).
val
(),
dictName
:
''
,
//字典的名称
dictCode
:
''
,
//字典类型编码
dictTips
:
''
,
//字典备注
mutiString
:
''
,
//拼接字符串内容(拼接字典条目)
itemTemplate
:
$
(
"#itemTemplate"
).
html
()
};
/**
* item获取新的id
*/
DictInfoDlg
.
newId
=
function
()
{
if
(
this
.
count
==
undefined
){
this
.
count
=
0
;
}
this
.
count
=
this
.
count
+
1
;
return
"dictItem"
+
this
.
count
;
};
/**
* 关闭此对话框
*/
DictInfoDlg
.
close
=
function
()
{
parent
.
layer
.
close
(
window
.
parent
.
Dict
.
layerIndex
);
};
/**
* 添加条目
*/
DictInfoDlg
.
addItem
=
function
()
{
$
(
"#itemsArea"
).
append
(
this
.
itemTemplate
);
$
(
"#dictItem"
).
attr
(
"id"
,
this
.
newId
());
};
/**
* 删除item
*/
DictInfoDlg
.
deleteItem
=
function
(
event
)
{
var
obj
=
Feng
.
eventParseObject
(
event
);
obj
=
obj
.
is
(
'button'
)
?
obj
:
obj
.
parent
();
obj
.
parent
().
parent
().
remove
();
};
/**
* 清除为空的item Dom
*/
DictInfoDlg
.
clearNullDom
=
function
(){
$
(
"[name='dictItem']"
).
each
(
function
(){
var
num
=
$
(
this
).
find
(
"[name='itemNum']"
).
val
();
var
name
=
$
(
this
).
find
(
"[name='itemName']"
).
val
();
if
(
num
==
''
||
name
==
''
){
$
(
this
).
remove
();
}
});
};
/**
* 收集添加字典的数据
*/
DictInfoDlg
.
collectData
=
function
()
{
this
.
clearNullDom
();
var
mutiString
=
""
;
$
(
"[name='dictItem']"
).
each
(
function
(){
var
code
=
$
(
this
).
find
(
"[name='itemCode']"
).
val
();
var
name
=
$
(
this
).
find
(
"[name='itemName']"
).
val
();
var
num
=
$
(
this
).
find
(
"[name='itemNum']"
).
val
();
mutiString
=
mutiString
+
(
code
+
":"
+
name
+
":"
+
num
+
";"
);
});
this
.
dictName
=
$
(
"#dictName"
).
val
();
this
.
dictCode
=
$
(
"#dictCode"
).
val
();
this
.
dictTips
=
$
(
"#dictTips"
).
val
();
this
.
mutiString
=
mutiString
;
};
/**
* 提交添加字典
*/
DictInfoDlg
.
addSubmit
=
function
()
{
this
.
collectData
();
//提交信息
var
ajax
=
new
$ax
(
Feng
.
ctxPath
+
"/dict/add"
,
function
(
data
)
{
Feng
.
success
(
"添加成功!"
);
window
.
parent
.
Dict
.
table
.
refresh
();
DictInfoDlg
.
close
();
},
function
(
data
)
{
Feng
.
error
(
"添加失败!"
+
data
.
responseJSON
.
message
+
"!"
);
});
ajax
.
set
(
'dictName'
,
this
.
dictName
);
ajax
.
set
(
'dictCode'
,
this
.
dictCode
);
ajax
.
set
(
'dictTips'
,
this
.
dictTips
);
ajax
.
set
(
'dictValues'
,
this
.
mutiString
);
ajax
.
start
();
};
/**
* 提交修改
*/
DictInfoDlg
.
editSubmit
=
function
()
{
this
.
collectData
();
var
ajax
=
new
$ax
(
Feng
.
ctxPath
+
"/dict/update"
,
function
(
data
)
{
Feng
.
success
(
"修改成功!"
);
window
.
parent
.
Dict
.
table
.
refresh
();
DictInfoDlg
.
close
();
},
function
(
data
)
{
Feng
.
error
(
"修改失败!"
+
data
.
responseJSON
.
message
+
"!"
);
});
ajax
.
set
(
'dictId'
,
$
(
"#dictId"
).
val
());
ajax
.
set
(
'dictName'
,
this
.
dictName
);
ajax
.
set
(
'dictCode'
,
this
.
dictCode
);
ajax
.
set
(
'dictTips'
,
this
.
dictTips
);
ajax
.
set
(
'dictValues'
,
this
.
mutiString
);
ajax
.
start
();
};
src/test/java/cn/stylefeng/guns/system/DictTest.java
View file @
b1e60983
...
...
@@ -25,20 +25,6 @@ public class DictTest extends BaseJunit {
DictMapper
dictMapper
;
@Test
public
void
addTest
()
{
String
dictCode
=
"test"
;
String
dictName
=
"字典测试"
;
String
dictTips
=
"这是一个字典测试"
;
String
dictValues
=
"1:测试1:1;2:测试2:2"
;
dictService
.
addDict
(
dictCode
,
dictName
,
dictTips
,
dictValues
);
}
@Test
public
void
editTest
()
{
dictService
.
editDict
(
16L
,
"tes"
,
"测试"
,
"备注"
,
"1:测试1:1;2:测试2:2"
);
}
@Test
public
void
deleteTest
()
{
this
.
dictService
.
delteDict
(
16L
);
}
...
...
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