|
@@ -4,11 +4,13 @@ import cn.hutool.core.util.StrUtil;
|
|
|
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.rnkrsoft.bopomofo4j.Bopomofo4j;
|
|
|
import com.ruoyi.common.config.RuoYiConfig;
|
|
|
import com.ruoyi.common.enums.CommentType;
|
|
|
import com.ruoyi.common.exception.BaseException;
|
|
|
import com.ruoyi.common.utils.DateUtils;
|
|
|
import com.ruoyi.common.utils.SecurityUtils;
|
|
|
+import com.ruoyi.common.utils.StringUtils;
|
|
|
import com.ruoyi.common.utils.bean.BeanUtils;
|
|
|
import com.ruoyi.system.domain.ZbFile;
|
|
|
import com.ruoyi.system.domain.grallery.ZbGallery;
|
|
@@ -73,12 +75,29 @@ public class ZbGalleryServiceImpl extends ServiceImpl<ZbGalleryMapper, ZbGallery
|
|
|
gallery.setCreateTime(nowDate);
|
|
|
String createBy = SecurityUtils.getUserId().toString();
|
|
|
gallery.setCreateBy(createBy);
|
|
|
-
|
|
|
+ //把中文名称转换为拼音存储
|
|
|
+ String cnName = gallery.getCnName();
|
|
|
+ if (StringUtils.isNotEmpty(cnName)){
|
|
|
+ Bopomofo4j.local();//启用本地模式(也就是禁用沙盒)
|
|
|
+ /**
|
|
|
+ * 将汉字句子转换拼音,支持声母带音调,数字音调,无音调三种格式
|
|
|
+ *
|
|
|
+ * @param words 句子
|
|
|
+ * @param toneType 拼音样式 0-声母带音调,1-数字音调在最后,2-无音调,默认值0
|
|
|
+ * @param upper 是否大写,默认为假(小写)
|
|
|
+ * @param cap 是否首字母大写,在upper为假时有效,默认为假(小写)
|
|
|
+ * @param split 分割符号,默认一个空格
|
|
|
+ * @return 拼音
|
|
|
+ */
|
|
|
+ String pinyin = Bopomofo4j.pinyin(cnName, 2, false, false, "");
|
|
|
+ gallery.setPyName(pinyin);
|
|
|
+ }
|
|
|
int insert = baseMapper.insert(gallery);
|
|
|
if (insert <= 0) {
|
|
|
throw new BaseException("图库保存失败");
|
|
|
}
|
|
|
|
|
|
+
|
|
|
//判断是否新增图库时,新增了图片
|
|
|
if (zbGallery.getImgInfos().size() > 0) {
|
|
|
List<ZbGalleryImg> imgList = zbGallery.getImgInfos().stream().filter(e -> e.getId() != null).map(x -> {
|
|
@@ -119,7 +138,23 @@ public class ZbGalleryServiceImpl extends ServiceImpl<ZbGalleryMapper, ZbGallery
|
|
|
gallery.setCreateTime(nowDate);
|
|
|
String createBy = SecurityUtils.getUserId().toString();
|
|
|
gallery.setCreateBy(createBy);
|
|
|
-
|
|
|
+ //把中文名称转换为拼音存储
|
|
|
+ String cnName = gallery.getCnName();
|
|
|
+ if (StringUtils.isNotEmpty(cnName)){
|
|
|
+ Bopomofo4j.local();//启用本地模式(也就是禁用沙盒)
|
|
|
+ /**
|
|
|
+ * 将汉字句子转换拼音,支持声母带音调,数字音调,无音调三种格式
|
|
|
+ *
|
|
|
+ * @param words 句子
|
|
|
+ * @param toneType 拼音样式 0-声母带音调,1-数字音调在最后,2-无音调,默认值0
|
|
|
+ * @param upper 是否大写,默认为假(小写)
|
|
|
+ * @param cap 是否首字母大写,在upper为假时有效,默认为假(小写)
|
|
|
+ * @param split 分割符号,默认一个空格
|
|
|
+ * @return 拼音
|
|
|
+ */
|
|
|
+ String pinyin = Bopomofo4j.pinyin(cnName, 2, false, false, "");
|
|
|
+ gallery.setPyName(pinyin);
|
|
|
+ }
|
|
|
int insert = baseMapper.updateById(gallery);
|
|
|
if (insert <= 0) {
|
|
|
throw new BaseException("图库保存失败");
|