去除多余斜杠,添加拼音验证
This commit is contained in:
parent
f23d238cf7
commit
d7e4019b56
|
@ -1,10 +1,12 @@
|
|||
package net.mingsoft.cms.action;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import net.mingsoft.base.entity.BaseEntity;
|
||||
import net.mingsoft.base.entity.ResultData;
|
||||
import net.mingsoft.basic.annotation.LogAnn;
|
||||
import net.mingsoft.basic.bean.EUListBean;
|
||||
|
@ -282,6 +284,18 @@ public class CategoryAction extends BaseAction {
|
|||
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();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -108,6 +108,7 @@ public class CategoryBizImpl extends BaseBizImpl<ICategoryDao, CategoryEntity> i
|
|||
//保存链接地址
|
||||
String path=ObjectUtil.isNotNull(parentCategory)?parentCategory.getCategoryPath():"";
|
||||
categoryEntity.setCategoryPath( path+"/" + categoryEntity.getCategoryPinyin());
|
||||
removeVirgule(categoryEntity);
|
||||
setTopId(categoryEntity);
|
||||
super.updateById(categoryEntity);
|
||||
}
|
||||
|
@ -144,6 +145,8 @@ public class CategoryBizImpl extends BaseBizImpl<ICategoryDao, CategoryEntity> i
|
|||
String path=categoryEntity.getCategoryPath();
|
||||
//判断是否有parentIds
|
||||
x.setCategoryPath(path+"/"+x.getCategoryPinyin());
|
||||
//去除多余的/符号
|
||||
removeVirgule(x);
|
||||
super.updateEntity(x);
|
||||
setChildParentId(x);
|
||||
});
|
||||
|
@ -152,7 +155,8 @@ public class CategoryBizImpl extends BaseBizImpl<ICategoryDao, CategoryEntity> i
|
|||
@Override
|
||||
public void updateEntity(CategoryEntity entity) {
|
||||
setParentId(entity);
|
||||
String pingYin = PinYinUtil.getPingYin(entity.getCategoryTitle());
|
||||
String pingYin =entity.getCategoryPinyin();
|
||||
if(StrUtil.isNotBlank(pingYin)){
|
||||
CategoryEntity category=new CategoryEntity();
|
||||
category.setCategoryPinyin(pingYin);
|
||||
CategoryEntity categoryBizEntity = (CategoryEntity)getEntity(category);
|
||||
|
@ -160,12 +164,24 @@ public class CategoryBizImpl extends BaseBizImpl<ICategoryDao, CategoryEntity> i
|
|||
if(categoryBizEntity!=null&&!categoryBizEntity.getId().equals(entity.getId())){
|
||||
entity.setCategoryPinyin(pingYin+entity.getId());
|
||||
}
|
||||
}
|
||||
setParentLeaf(entity);
|
||||
setTopId(entity);
|
||||
removeVirgule(entity);
|
||||
super.updateById(entity);
|
||||
setChildParentId(entity);
|
||||
}
|
||||
|
||||
/**去除多余的/符号
|
||||
* @param entity
|
||||
*/
|
||||
private void removeVirgule(CategoryEntity entity) {
|
||||
|
||||
if (entity.getCategoryPath().startsWith("/")) {
|
||||
entity.setCategoryPath(entity.getCategoryPath().substring(1));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(CategoryEntity entity) {
|
||||
super.updateEntity(entity);
|
||||
|
|
|
@ -84,7 +84,6 @@ spring:
|
|||
mybatis-plus:
|
||||
global-config:
|
||||
db-config:
|
||||
column-format: "\"%s\"" #增加这个需要增加 ms-db
|
||||
id-type: assign_id
|
||||
configuration:
|
||||
database-id: mysql
|
|
@ -253,6 +253,21 @@
|
|||
var form = new Vue({
|
||||
el: '#form',
|
||||
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 {
|
||||
treeList: [{
|
||||
id: '0',
|
||||
|
@ -318,6 +333,11 @@
|
|||
"required": true,
|
||||
"message": "请选择列表模板"
|
||||
}],
|
||||
categoryPinyin:[
|
||||
{
|
||||
validator: validatorCategoryPinyin, trigger: 'blur'
|
||||
}
|
||||
],
|
||||
// 内容模板
|
||||
categoryUrl: [{
|
||||
"required": true,
|
||||
|
|
Loading…
Reference in New Issue