Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -50,12 +50,13 @@
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.belerweb</groupId>
|
||||
<artifactId>pinyin4j</artifactId>
|
||||
<version>2.5.1</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.github.stuxuhai</groupId>
|
||||
<artifactId>jpinyin</artifactId>
|
||||
<version>1.1.8</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
||||
|
||||
+24
-28
@@ -22,6 +22,7 @@ import com.jero.modules.system.model.TreeSelectModel;
|
||||
import com.jero.modules.system.service.ISysDictItemService;
|
||||
import com.jero.modules.system.service.ISysDictService;
|
||||
import com.jero.modules.system.vo.SysDictPage;
|
||||
import com.jero.modules.utils.HanYuPinYinUtil;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -356,23 +357,21 @@ public class SysDictController {
|
||||
public Result<SysDict> add(@RequestBody SysDict sysDict) {
|
||||
Result<SysDict> result = new Result<SysDict>();
|
||||
try {
|
||||
if(StringUtils.isEmpty(sysDict.getDictName())){
|
||||
String pinYin = sysDictService.getAllPinyin(sysDict.getDictName());
|
||||
Integer count = sysDictService.queryExitData(sysDict);
|
||||
System.out.println("count="+count);
|
||||
if (count > 0) {
|
||||
sysDict.setDelFlag(CommonConstant.DEL_FLAG_0);
|
||||
System.out.println();
|
||||
} else {
|
||||
String pinYin = HanYuPinYinUtil.changeToNumberPinYin(sysDict.getDictName());
|
||||
sysDict.setDictCode(pinYin);
|
||||
|
||||
}else {
|
||||
Integer count = sysDictService.queryExitData(sysDict);
|
||||
if (count > 0) {
|
||||
sysDict.setDelFlag(CommonConstant.DEL_FLAG_0);
|
||||
} else {
|
||||
sysDict.setCreateTime(new Date());
|
||||
sysDictService.save(sysDict);
|
||||
}
|
||||
result.success("保存成功!");
|
||||
//添加成功后需要刷新缓存
|
||||
sysDictService.refreshCache();
|
||||
sysDict.setCreateTime(new Date());
|
||||
sysDict.setDelFlag(CommonConstant.DEL_FLAG_0);
|
||||
sysDictService.save(sysDict);
|
||||
}
|
||||
|
||||
result.success("保存成功!");
|
||||
//添加成功后需要刷新缓存
|
||||
sysDictService.refreshCache();
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(),e);
|
||||
result.error500("操作失败");
|
||||
@@ -380,7 +379,6 @@ public class SysDictController {
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @功能:编辑
|
||||
* @param sysDict
|
||||
@@ -395,11 +393,13 @@ public class SysDictController {
|
||||
if (sysdict == null) {
|
||||
result.error500("未找到对应实体");
|
||||
}else {
|
||||
if (org.apache.commons.lang3.StringUtils.isNotBlank(String.valueOf(sysDict.getIsReadOnly()))) {
|
||||
if (StringUtils.isNotBlank(String.valueOf(sysDict.getIsReadOnly()))) {
|
||||
if (FixedFieldEnum.FIXED_FIELD_ENUM.getValue().equals(sysDict.getIsReadOnly())) {
|
||||
result.error500("固定字段,不可删除");
|
||||
result.error500("固定字段,不可修改");
|
||||
}else{
|
||||
sysDict.setUpdateTime(new Date());
|
||||
String pinYin = HanYuPinYinUtil.changeToNumberPinYin(sysDict.getDictName());
|
||||
sysDict.setDictCode(pinYin);
|
||||
boolean ok = sysDictService.updateById(sysDict);
|
||||
if (ok) {
|
||||
result.success("编辑成功!");
|
||||
@@ -441,7 +441,7 @@ public class SysDictController {
|
||||
}
|
||||
|
||||
/**
|
||||
* @功能:删除
|
||||
* @功能:逻辑删除
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@@ -454,15 +454,11 @@ public class SysDictController {
|
||||
Result<SysDict> result = new Result<SysDict>();
|
||||
try{
|
||||
SysDict sysDict = sysDictService.queryById(id);
|
||||
if (StringUtils.isNotBlank(String.valueOf(sysDict.getIsReadOnly()))) {
|
||||
if (FixedFieldEnum.FIXED_FIELD_ENUM.getValue().equals(sysDict.getIsReadOnly())) {
|
||||
result.error500("固定字段,不可删除");
|
||||
} else {
|
||||
sysDict.setDelFlag(CommonConstant.DEL_FLAG_1);
|
||||
result.success("删除成功!");
|
||||
//添加成功后需要刷新缓存
|
||||
sysDictService.refreshCache();
|
||||
}
|
||||
if (FixedFieldEnum.FIXED_FIELD_ENUM.getValue().equals(sysDict.getIsReadOnly())) {
|
||||
result.error500("固定字段,不可删除");
|
||||
} else {
|
||||
sysDictService.updateDictDelFlag(CommonConstant.DEL_FLAG_1,id);
|
||||
result.success("删除成功!");
|
||||
}
|
||||
}catch (Exception e) {
|
||||
log.error(e.getMessage(),e);
|
||||
|
||||
-2
@@ -159,6 +159,4 @@ public interface ISysDictService extends IService<SysDict> {
|
||||
*/
|
||||
Integer queryExitData(SysDict sysDict);
|
||||
|
||||
|
||||
String getAllPinyin(String dictName);
|
||||
}
|
||||
|
||||
+2
-62
@@ -18,12 +18,6 @@ import com.jero.modules.system.mapper.SysDictMapper;
|
||||
import com.jero.modules.system.model.TreeSelectModel;
|
||||
import com.jero.modules.system.service.ISysDictService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.sourceforge.pinyin4j.PinyinHelper;
|
||||
import net.sourceforge.pinyin4j.format.HanyuPinyinCaseType;
|
||||
import net.sourceforge.pinyin4j.format.HanyuPinyinOutputFormat;
|
||||
import net.sourceforge.pinyin4j.format.HanyuPinyinToneType;
|
||||
import net.sourceforge.pinyin4j.format.HanyuPinyinVCharType;
|
||||
import net.sourceforge.pinyin4j.format.exception.BadHanyuPinyinOutputFormatCombination;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
@@ -367,7 +361,7 @@ public class SysDictServiceImpl extends ServiceImpl<SysDictMapper, SysDict> impl
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据标签名称,标签类型一致还原数据
|
||||
* 根据标签名称,字典Code值,标签类型一致还原数据
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@@ -375,65 +369,11 @@ public class SysDictServiceImpl extends ServiceImpl<SysDictMapper, SysDict> impl
|
||||
public Integer queryExitData(SysDict sysDict) {
|
||||
LambdaQueryWrapper<SysDict> queryWrapper = new LambdaQueryWrapper<>();
|
||||
if (StringUtils.isNotBlank(sysDict.getDictName())) {
|
||||
queryWrapper.eq(SysDict::getDictName, sysDict.getDictName()).and(wq -> wq.eq(SysDict::getAttributeType, sysDict.getAttributeType()));
|
||||
queryWrapper.eq(SysDict::getDictName, sysDict.getDictName()).eq(SysDict::getDictCode,sysDict.getDictCode()).eq(SysDict::getAttributeType, sysDict.getAttributeType());
|
||||
}
|
||||
Integer count = sysDictMapper.selectCount(queryWrapper);
|
||||
return count;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将Code值设为字典名称的中文拼音
|
||||
*/
|
||||
public String getAllPinyin(String hanzi) {
|
||||
//输出格式设置
|
||||
HanyuPinyinOutputFormat format = new HanyuPinyinOutputFormat();
|
||||
/**
|
||||
* 输出大小写设置
|
||||
*
|
||||
* LOWERCASE:输出小写
|
||||
* UPPERCASE:输出大写
|
||||
*/
|
||||
format.setCaseType(HanyuPinyinCaseType.LOWERCASE);
|
||||
|
||||
/**
|
||||
* 输出音标设置
|
||||
*
|
||||
* WITH_TONE_MARK:直接用音标符(必须设置WITH_U_UNICODE,否则会抛出异常)
|
||||
* WITH_TONE_NUMBER:1-4数字表示音标
|
||||
* WITHOUT_TONE:没有音标
|
||||
*/
|
||||
format.setToneType(HanyuPinyinToneType.WITH_TONE_MARK);
|
||||
|
||||
/**
|
||||
* 特殊音标ü设置
|
||||
*
|
||||
* WITH_V:用v表示ü
|
||||
* WITH_U_AND_COLON:用"u:"表示ü
|
||||
* WITH_U_UNICODE:直接用ü
|
||||
*/
|
||||
format.setVCharType(HanyuPinyinVCharType.WITH_U_UNICODE);
|
||||
|
||||
char[] hanYuArr = hanzi.trim().toCharArray();
|
||||
StringBuilder pinYin = new StringBuilder();
|
||||
|
||||
try {
|
||||
for (int i = 0, len = hanYuArr.length; i < len; i++) {
|
||||
//匹配是否是汉字
|
||||
if (Character.toString(hanYuArr[i]).matches("[\\u4E00-\\u9FA5]+")) {
|
||||
//如果是多音字,返回多个拼音,这里只取第一个
|
||||
String[] pys = PinyinHelper.toHanyuPinyinStringArray(hanYuArr[i], format);
|
||||
pinYin.append(pys[0]).append(" ");
|
||||
} else {
|
||||
pinYin.append(hanYuArr[i]).append(" ");
|
||||
}
|
||||
}
|
||||
} catch (BadHanyuPinyinOutputFormatCombination badHanyuPinyinOutputFormatCombination) {
|
||||
badHanyuPinyinOutputFormatCombination.printStackTrace();
|
||||
}
|
||||
return pinYin.toString();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
+145
@@ -0,0 +1,145 @@
|
||||
package com.jero.modules.utils;
|
||||
|
||||
import com.github.stuxuhai.jpinyin.ChineseHelper;
|
||||
import com.github.stuxuhai.jpinyin.PinyinFormat;
|
||||
import com.github.stuxuhai.jpinyin.PinyinHelper;
|
||||
|
||||
public class HanYuPinYinUtil {
|
||||
/**
|
||||
* 转换为有声调的拼音字符串
|
||||
* @param pinYinStr 汉字
|
||||
* @return 有声调的拼音字符串
|
||||
*/
|
||||
public String changeToMarkPinYin(String pinYinStr){
|
||||
|
||||
String tempStr = null;
|
||||
|
||||
try
|
||||
{
|
||||
tempStr = PinyinHelper.convertToPinyinString(pinYinStr, " ", PinyinFormat.WITH_TONE_MARK);
|
||||
|
||||
} catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
return tempStr;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 转换为数字声调字符串
|
||||
* @param pinYinStr 需转换的汉字
|
||||
* @return 转换完成的拼音字符串
|
||||
*/
|
||||
public static String changeToNumberPinYin(String pinYinStr){
|
||||
|
||||
String tempStr = null;
|
||||
|
||||
try
|
||||
{
|
||||
tempStr = PinyinHelper.convertToPinyinString(pinYinStr, " ", PinyinFormat.WITH_TONE_NUMBER);
|
||||
} catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return tempStr;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为不带音调的拼音字符串
|
||||
* @param pinYinStr 需转换的汉字
|
||||
* @return 拼音字符串
|
||||
*/
|
||||
public static String changeToTonePinYin(String pinYinStr){
|
||||
|
||||
String tempStr = null;
|
||||
|
||||
try{
|
||||
tempStr = PinyinHelper.convertToPinyinString(pinYinStr, " ", PinyinFormat.WITHOUT_TONE);
|
||||
} catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
return tempStr;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为每个汉字对应拼音首字母字符串
|
||||
* @param pinYinStr 需转换的汉字
|
||||
* @return 拼音字符串
|
||||
*/
|
||||
public String changeToGetShortPinYin(String pinYinStr){
|
||||
|
||||
String tempStr = null;
|
||||
|
||||
try
|
||||
{
|
||||
tempStr = PinyinHelper.getShortPinyin(pinYinStr);
|
||||
} catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
return tempStr;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查汉字是否为多音字
|
||||
* @param pinYinStr 需检查的汉字
|
||||
* @return true 多音字,false 不是多音字
|
||||
*/
|
||||
public boolean checkPinYin(char pinYinStr){
|
||||
|
||||
boolean check = false;
|
||||
try
|
||||
{
|
||||
check = PinyinHelper.hasMultiPinyin(pinYinStr);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return check;
|
||||
}
|
||||
|
||||
/**
|
||||
* 简体转换为繁体
|
||||
* @param pinYinStr
|
||||
* @return
|
||||
*/
|
||||
public String changeToTraditional(String pinYinStr){
|
||||
|
||||
String tempStr = null;
|
||||
try
|
||||
{
|
||||
tempStr = ChineseHelper.convertToTraditionalChinese(pinYinStr);
|
||||
} catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
return tempStr;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 繁体转换为简体
|
||||
* @param pinYinSt
|
||||
* @return
|
||||
*/
|
||||
public String changeToSimplified(String pinYinSt){
|
||||
|
||||
String tempStr = null;
|
||||
|
||||
try
|
||||
{
|
||||
tempStr = ChineseHelper.convertToSimplifiedChinese(pinYinSt);
|
||||
} catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return tempStr;
|
||||
}
|
||||
}
|
||||
@@ -107,11 +107,6 @@
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-openfeign</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.belerweb</groupId>
|
||||
<artifactId>pinyin4j</artifactId>
|
||||
<version>2.5.1</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
<template>
|
||||
<div class="diolag-area">
|
||||
<a-button type="primary" @click="showModal">新增</a-button>
|
||||
<a-modal class="area-module" v-model="newVisible" title="新增" ok-text="保存" cancel-text="取消" @ok="hideModal" @cancel="cancelModel" v-if="newVisible">
|
||||
<div class="table-operator">
|
||||
<div class="operator-text" @click="showModal">
|
||||
<a-icon type="plus" />
|
||||
{{$t('add')}}
|
||||
</div>
|
||||
</div>
|
||||
<!-- <a-button type="primary" @click="showModal">新增</a-button>-->
|
||||
<a-modal class="area-module" v-model="newVisible" :title="$t('add')" :ok-text="$t('preservation')" :cancel-text="$t('cancel')" @ok="hideModal" @cancel="cancelModel" v-if="newVisible">
|
||||
<a-form-model
|
||||
class="tag-module"
|
||||
ref="ruleForm"
|
||||
@@ -53,12 +59,11 @@
|
||||
<a-table
|
||||
class="table-area"
|
||||
ref="table"
|
||||
bordered
|
||||
size="middle"
|
||||
rowKey="id"
|
||||
:columns="columns"
|
||||
:dataSource="areaTable"
|
||||
:pagination="ipagination"
|
||||
:pagination="false"
|
||||
:loading="loading"
|
||||
:rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
|
||||
@change="handleTableChange">
|
||||
@@ -74,8 +79,20 @@
|
||||
>
|
||||
<a style="color:red" href="javascript:;">删除</a>
|
||||
</a-popconfirm>
|
||||
</span>
|
||||
</span>
|
||||
</a-table>
|
||||
<div class="page" v-if="areaTable.length > 0">
|
||||
<a-pagination
|
||||
:show-total="total => `共 ${total} 条`"
|
||||
show-quick-jumper
|
||||
show-size-changer
|
||||
:current="queryParams.pageNo"
|
||||
:page-size.sync="queryParams.pageSize"
|
||||
:total="total"
|
||||
@change="onChangePage"
|
||||
@showSizeChange="SizeChange"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -88,6 +105,11 @@
|
||||
},
|
||||
data(){
|
||||
return{
|
||||
queryParams:{
|
||||
pageNo:1,
|
||||
pageSize:10
|
||||
},
|
||||
total:0,
|
||||
selectedRowKeys: [],
|
||||
loading: false,
|
||||
ipagination:true,
|
||||
@@ -179,9 +201,7 @@
|
||||
if(this.form.id){
|
||||
putAction(`tag/onlCgformArea/edit`,this.form).then((res)=>{
|
||||
if(res.success){
|
||||
this.$notification.success({
|
||||
message: res.result,
|
||||
});
|
||||
this.$message.success(res.result);
|
||||
this.$emit('updateOk',res.result)
|
||||
this.form={
|
||||
isModel:'',
|
||||
@@ -195,9 +215,7 @@
|
||||
//新增
|
||||
postAction(`/tag/onlCgformArea/add`,this.form).then(res=>{
|
||||
if(res.success){
|
||||
this.$notification.success({
|
||||
message: res.result,
|
||||
});
|
||||
this.$message.success( res.result,);
|
||||
this.$emit('submitOk',res.result)
|
||||
this.form={
|
||||
isModel:'',
|
||||
@@ -248,6 +266,16 @@
|
||||
}
|
||||
})
|
||||
},
|
||||
//点击页数
|
||||
onChangePage(page,pageSize){
|
||||
this.queryParams.pageNo = page
|
||||
this.$emit('Ok')
|
||||
},
|
||||
//一页显示条数
|
||||
SizeChange(page,pageSize){
|
||||
this.queryParams.pageSize = pageSize
|
||||
this.$emit('Ok')
|
||||
},
|
||||
//正则替换小数点
|
||||
limitNumber(value) {
|
||||
if (typeof value === 'string') {
|
||||
@@ -263,6 +291,7 @@
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
@import '~@assets/less/common.less';
|
||||
.diolag-area{
|
||||
.table-area{
|
||||
margin: 20px 0;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<div class="list-table">
|
||||
<a-table bordered :data-source="tableData" :columns="columns" :row-selection="{ selectedRowKeys: selectedRowKeys, onChange: onSelectChange }" :pagination="false" class="tag-con-table">
|
||||
<a-table :data-source="tableData" :columns="columns" :row-selection="{ selectedRowKeys: selectedRowKeys, onChange: onSelectChange }" :pagination="false" class="tag-con-table">
|
||||
|
||||
<template slot="action" slot-scope="text, record">
|
||||
<a class="action-edit" href="javascript:;" @click="actionEdit(record)">编辑</a>
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
<div class="tree-table">
|
||||
<div class="tree-table-content">
|
||||
<a-table
|
||||
bordered
|
||||
class="tree-table-con"
|
||||
:columns="columns"
|
||||
:data-source="tabData"
|
||||
|
||||
@@ -47,7 +47,7 @@
|
||||
<new-drawer v-if="drawerVisible&&editFlag" :drawerVisible="drawerVisible" :isTagContent="isTagContent" :editData="editData" :editId="editId" :submitEdit="submitEdit" @closeTag="closeTag" ></new-drawer>
|
||||
</a-drawer>
|
||||
<a-modal class="show-area" v-model="areaVisible" :title="$t('ExhibitionAreaManagement')" :footer="null" @cancel="hideModal">
|
||||
<area-manage v-if="areaVisible" @diaHide="diaHide" :areaTable="areaTable" @submitOk="submitOk" @deleteOk="deleteOk" @updateOk="updateOk"></area-manage>
|
||||
<area-manage v-if="areaVisible" @diaHide="diaHide" :total="areaTotal" :areaTable="areaTable" @submitOk="submitOk" @deleteOk="deleteOk" @updateOk="updateOk"></area-manage>
|
||||
</a-modal>
|
||||
<div class="tag-doc-tab">
|
||||
<a-spin :spinning="spinning" tip="Loading...">
|
||||
@@ -203,6 +203,7 @@
|
||||
],
|
||||
areaVisible:false,
|
||||
areaTable:[],
|
||||
areaTotal:0,
|
||||
drawerVisible:false,
|
||||
value:1,
|
||||
editId:'',
|
||||
@@ -240,6 +241,7 @@
|
||||
getAction(`/tag/onlCgformArea/list`,{}).then(res=>{
|
||||
if(res.success){
|
||||
this.areaTable=res.result
|
||||
this.areaTotal=res.total
|
||||
}
|
||||
})
|
||||
},
|
||||
@@ -403,6 +405,14 @@
|
||||
width: 800px!important;
|
||||
}
|
||||
}
|
||||
.diolag-area{
|
||||
.table-operator{
|
||||
text-align: right;
|
||||
}
|
||||
.page{
|
||||
text-align: right;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
</style>
|
||||
Reference in New Issue
Block a user