Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
C
cms_sys
Project
Project
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
西魏
cms_sys
Commits
d7e4019b
Commit
d7e4019b
authored
Nov 07, 2020
by
sgjj
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
去除多余斜杠,添加拼音验证
parent
f23d238c
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
51 additions
and
3 deletions
+51
-3
CategoryAction.java
src/main/java/net/mingsoft/cms/action/CategoryAction.java
+14
-0
CategoryBizImpl.java
src/main/java/net/mingsoft/cms/biz/impl/CategoryBizImpl.java
+17
-1
application.yml
src/main/resources/application.yml
+0
-2
form.ftl
src/main/webapp/WEB-INF/manager/cms/category/form.ftl
+20
-0
No files found.
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
Error
(
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
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