Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
jinli gu
MCMS
Commits
d7e4019b
Commit
d7e4019b
authored
Nov 07, 2020
by
sgjj
Browse files
去除多余斜杠,添加拼音验证
parent
f23d238c
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/main/java/net/mingsoft/cms/action/CategoryAction.java
View file @
d7e4019b
package
net.mingsoft.cms.action
;
package
net.mingsoft.cms.action
;
import
cn.hutool.core.util.StrUtil
;
import
cn.hutool.core.util.StrUtil
;
import
com.baomidou.mybatisplus.core.toolkit.Wrappers
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiImplicitParam
;
import
io.swagger.annotations.ApiImplicitParam
;
import
io.swagger.annotations.ApiImplicitParams
;
import
io.swagger.annotations.ApiImplicitParams
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiOperation
;
import
net.mingsoft.base.entity.BaseEntity
;
import
net.mingsoft.base.entity.ResultData
;
import
net.mingsoft.base.entity.ResultData
;
import
net.mingsoft.basic.annotation.LogAnn
;
import
net.mingsoft.basic.annotation.LogAnn
;
import
net.mingsoft.basic.bean.EUListBean
;
import
net.mingsoft.basic.bean.EUListBean
;
...
@@ -282,6 +284,18 @@ public class CategoryAction extends BaseAction {
...
@@ -282,6 +284,18 @@ public class CategoryAction extends BaseAction {
return
ResultData
.
build
().
success
(
category
);
return
ResultData
.
build
().
success
(
category
);
}
}
@ApiOperation
(
value
=
"验证拼音"
)
@GetMapping
(
"/verifyPingYin"
)
@ResponseBody
public
ResultData
verifyPingYin
(
@ModelAttribute
@ApiIgnore
CategoryEntity
category
,
HttpServletResponse
response
,
HttpServletRequest
request
,
@ApiIgnore
ModelMap
model
){
int
count
=
categoryBiz
.
count
(
Wrappers
.<
CategoryEntity
>
lambdaQuery
()
.
ne
(
StrUtil
.
isNotBlank
(
category
.
getId
()),
CategoryEntity:
:
getId
,
category
.
getId
())
.
eq
(
CategoryEntity:
:
getCategoryPinyin
,
category
.
getCategoryPinyin
()));
if
(
count
>
0
){
return
ResultData
.
build
().
error
(
"存在相同拼音的栏目"
);
}
return
ResultData
.
build
().
success
();
}
}
}
src/main/java/net/mingsoft/cms/biz/impl/CategoryBizImpl.java
View file @
d7e4019b
...
@@ -108,6 +108,7 @@ public class CategoryBizImpl extends BaseBizImpl<ICategoryDao, CategoryEntity> i
...
@@ -108,6 +108,7 @@ public class CategoryBizImpl extends BaseBizImpl<ICategoryDao, CategoryEntity> i
//保存链接地址
//保存链接地址
String
path
=
ObjectUtil
.
isNotNull
(
parentCategory
)?
parentCategory
.
getCategoryPath
():
""
;
String
path
=
ObjectUtil
.
isNotNull
(
parentCategory
)?
parentCategory
.
getCategoryPath
():
""
;
categoryEntity
.
setCategoryPath
(
path
+
"/"
+
categoryEntity
.
getCategoryPinyin
());
categoryEntity
.
setCategoryPath
(
path
+
"/"
+
categoryEntity
.
getCategoryPinyin
());
removeVirgule
(
categoryEntity
);
setTopId
(
categoryEntity
);
setTopId
(
categoryEntity
);
super
.
updateById
(
categoryEntity
);
super
.
updateById
(
categoryEntity
);
}
}
...
@@ -144,6 +145,8 @@ public class CategoryBizImpl extends BaseBizImpl<ICategoryDao, CategoryEntity> i
...
@@ -144,6 +145,8 @@ public class CategoryBizImpl extends BaseBizImpl<ICategoryDao, CategoryEntity> i
String
path
=
categoryEntity
.
getCategoryPath
();
String
path
=
categoryEntity
.
getCategoryPath
();
//判断是否有parentIds
//判断是否有parentIds
x
.
setCategoryPath
(
path
+
"/"
+
x
.
getCategoryPinyin
());
x
.
setCategoryPath
(
path
+
"/"
+
x
.
getCategoryPinyin
());
//去除多余的/符号
removeVirgule
(
x
);
super
.
updateEntity
(
x
);
super
.
updateEntity
(
x
);
setChildParentId
(
x
);
setChildParentId
(
x
);
});
});
...
@@ -152,7 +155,8 @@ public class CategoryBizImpl extends BaseBizImpl<ICategoryDao, CategoryEntity> i
...
@@ -152,7 +155,8 @@ public class CategoryBizImpl extends BaseBizImpl<ICategoryDao, CategoryEntity> i
@Override
@Override
public
void
updateEntity
(
CategoryEntity
entity
)
{
public
void
updateEntity
(
CategoryEntity
entity
)
{
setParentId
(
entity
);
setParentId
(
entity
);
String
pingYin
=
PinYinUtil
.
getPingYin
(
entity
.
getCategoryTitle
());
String
pingYin
=
entity
.
getCategoryPinyin
();
if
(
StrUtil
.
isNotBlank
(
pingYin
)){
CategoryEntity
category
=
new
CategoryEntity
();
CategoryEntity
category
=
new
CategoryEntity
();
category
.
setCategoryPinyin
(
pingYin
);
category
.
setCategoryPinyin
(
pingYin
);
CategoryEntity
categoryBizEntity
=
(
CategoryEntity
)
getEntity
(
category
);
CategoryEntity
categoryBizEntity
=
(
CategoryEntity
)
getEntity
(
category
);
...
@@ -160,12 +164,24 @@ public class CategoryBizImpl extends BaseBizImpl<ICategoryDao, CategoryEntity> i
...
@@ -160,12 +164,24 @@ public class CategoryBizImpl extends BaseBizImpl<ICategoryDao, CategoryEntity> i
if
(
categoryBizEntity
!=
null
&&!
categoryBizEntity
.
getId
().
equals
(
entity
.
getId
())){
if
(
categoryBizEntity
!=
null
&&!
categoryBizEntity
.
getId
().
equals
(
entity
.
getId
())){
entity
.
setCategoryPinyin
(
pingYin
+
entity
.
getId
());
entity
.
setCategoryPinyin
(
pingYin
+
entity
.
getId
());
}
}
}
setParentLeaf
(
entity
);
setParentLeaf
(
entity
);
setTopId
(
entity
);
setTopId
(
entity
);
removeVirgule
(
entity
);
super
.
updateById
(
entity
);
super
.
updateById
(
entity
);
setChildParentId
(
entity
);
setChildParentId
(
entity
);
}
}
/**去除多余的/符号
* @param entity
*/
private
void
removeVirgule
(
CategoryEntity
entity
)
{
if
(
entity
.
getCategoryPath
().
startsWith
(
"/"
))
{
entity
.
setCategoryPath
(
entity
.
getCategoryPath
().
substring
(
1
));
}
}
@Override
@Override
public
void
update
(
CategoryEntity
entity
)
{
public
void
update
(
CategoryEntity
entity
)
{
super
.
updateEntity
(
entity
);
super
.
updateEntity
(
entity
);
...
...
src/main/resources/application.yml
View file @
d7e4019b
...
@@ -84,7 +84,6 @@ spring:
...
@@ -84,7 +84,6 @@ spring:
mybatis-plus
:
mybatis-plus
:
global-config
:
global-config
:
db-config
:
db-config
:
column-format
:
"
\"
%s
\"
"
#增加这个需要增加 ms-db
id-type
:
assign_id
id-type
:
assign_id
configuration
:
configuration
:
database-id
:
mysql
database-id
:
mysql
\ No newline at end of file
src/main/webapp/WEB-INF/manager/cms/category/form.ftl
View file @
d7e4019b
...
@@ -253,6 +253,21 @@
...
@@ -253,6 +253,21 @@
var form = new Vue(
{
var form = new Vue(
{
el
:
'#
form
'
,
el
:
'#
form
'
,
data
:
function
()
{
data
:
function
()
{
var
that
=
this
//验证拼音是否存在
var
validatorCategoryPinyin
=
function
(
rule
,
value
,
callback
)
{
//
ms
.http.get
(
ms
.manager
+'/
cms
/
category
/
verifyPingYin
.do
'
,{
id
:
that
.form.id
,
categoryPinyin
:
that
.form.categoryPinyin
,
})
.then
(
function
(
res
)
{
if
(
!
res
.result
){
callback
(
new
E
rror
(
res
.msg
))
;
}
else
{
return
callback
()
;
}
})
}
return
{
return
{
treeList
:
[
{
treeList
:
[
{
id
:
'
0
'
,
id
:
'
0
'
,
...
@@ -318,6 +333,11 @@
...
@@ -318,6 +333,11 @@
"required"
:
true
,
"required"
:
true
,
"message"
:
"请选择列表模板"
"message"
:
"请选择列表模板"
}
]
,
}
]
,
categoryPinyin
:
[
{
validator
:
validatorCategoryPinyin
,
trigger
:
'
blur
'
}
]
,
//
内容模板
//
内容模板
categoryUrl
:
[
{
categoryUrl
:
[
{
"required"
:
true
,
"required"
:
true
,
...
...
Write
Preview
Supports
Markdown
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