|
|
@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollUtil;
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
import com.ruoyi.common.core.constant.Constants;
|
|
|
|
import com.ruoyi.common.core.constant.Constants;
|
|
|
|
import com.ruoyi.common.core.domain.R;
|
|
|
|
import com.ruoyi.common.core.domain.R;
|
|
|
|
import com.ruoyi.common.redis.service.RedisService;
|
|
|
|
import com.ruoyi.common.redis.service.RedisService;
|
|
|
@ -16,6 +17,7 @@ import com.xjs.word.domain.EnglishWord;
|
|
|
|
import com.xjs.word.mapper.EnglishWordMapper;
|
|
|
|
import com.xjs.word.mapper.EnglishWordMapper;
|
|
|
|
import com.xjs.word.service.IEnglishWordService;
|
|
|
|
import com.xjs.word.service.IEnglishWordService;
|
|
|
|
import lombok.extern.log4j.Log4j2;
|
|
|
|
import lombok.extern.log4j.Log4j2;
|
|
|
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
|
|
@ -31,11 +33,11 @@ import static com.xjs.consts.RedisConst.TRAN_DICT_EXPIRE;
|
|
|
|
* 英语单词Service业务层处理
|
|
|
|
* 英语单词Service业务层处理
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @author xjs
|
|
|
|
* @author xjs
|
|
|
|
* @since 2021-12-29
|
|
|
|
* @since 2021-12-29
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@Service
|
|
|
|
@Service
|
|
|
|
@Log4j2
|
|
|
|
@Log4j2
|
|
|
|
public class EnglishWordServiceImpl implements IEnglishWordService {
|
|
|
|
public class EnglishWordServiceImpl extends ServiceImpl<EnglishWordMapper, EnglishWord> implements IEnglishWordService {
|
|
|
|
@Resource
|
|
|
|
@Resource
|
|
|
|
private EnglishWordMapper englishWordMapper;
|
|
|
|
private EnglishWordMapper englishWordMapper;
|
|
|
|
@Autowired
|
|
|
|
@Autowired
|
|
|
@ -52,7 +54,8 @@ public class EnglishWordServiceImpl implements IEnglishWordService {
|
|
|
|
.eq("is_collect", COLLECT)
|
|
|
|
.eq("is_collect", COLLECT)
|
|
|
|
.orderByDesc("top")
|
|
|
|
.orderByDesc("top")
|
|
|
|
.orderByDesc("create_time");
|
|
|
|
.orderByDesc("create_time");
|
|
|
|
return englishWordMapper.selectPage(page,wr);
|
|
|
|
|
|
|
|
|
|
|
|
return englishWordMapper.selectPage(page, wr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
@ -73,7 +76,7 @@ public class EnglishWordServiceImpl implements IEnglishWordService {
|
|
|
|
String hkey = englishWord.getEnglishWord() + ":" + id;
|
|
|
|
String hkey = englishWord.getEnglishWord() + ":" + id;
|
|
|
|
Object value = redisService.getCacheMapValue(TRAN_DICT, hkey);
|
|
|
|
Object value = redisService.getCacheMapValue(TRAN_DICT, hkey);
|
|
|
|
if (Objects.nonNull(value)) {
|
|
|
|
if (Objects.nonNull(value)) {
|
|
|
|
return (EnglishWord)value;
|
|
|
|
return (EnglishWord) value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
R<TranslationVo> r = remoteTranDIctFeign.tranDict(englishWord.getEnglishWord());
|
|
|
|
R<TranslationVo> r = remoteTranDIctFeign.tranDict(englishWord.getEnglishWord());
|
|
|
|
if (r.getCode() != R.FAIL) {
|
|
|
|
if (r.getCode() != R.FAIL) {
|
|
|
@ -110,7 +113,7 @@ public class EnglishWordServiceImpl implements IEnglishWordService {
|
|
|
|
.eq("english_word", englishWord.getContent()));
|
|
|
|
.eq("english_word", englishWord.getContent()));
|
|
|
|
List<EnglishWord> chineseWordList = englishWordMapper.selectList(new QueryWrapper<EnglishWord>()
|
|
|
|
List<EnglishWord> chineseWordList = englishWordMapper.selectList(new QueryWrapper<EnglishWord>()
|
|
|
|
.eq("chinese_word", englishWord.getContent()));
|
|
|
|
.eq("chinese_word", englishWord.getContent()));
|
|
|
|
if (CollUtil.isNotEmpty(englishWordList)|| CollUtil.isNotEmpty(chineseWordList)) {
|
|
|
|
if (CollUtil.isNotEmpty(englishWordList) || CollUtil.isNotEmpty(chineseWordList)) {
|
|
|
|
throw new BusinessException("该词汇已存在!!!!");
|
|
|
|
throw new BusinessException("该词汇已存在!!!!");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -172,8 +175,6 @@ public class EnglishWordServiceImpl implements IEnglishWordService {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//------------------------代码自动生成-----------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 查询英语单词列表
|
|
|
|
* 查询英语单词列表
|
|
|
|
*
|
|
|
|
*
|
|
|
@ -185,6 +186,22 @@ public class EnglishWordServiceImpl implements IEnglishWordService {
|
|
|
|
return englishWordMapper.selectEnglishWordList(englishWord);
|
|
|
|
return englishWordMapper.selectEnglishWordList(englishWord);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public IPage<EnglishWord> selectEnglishWordList(Page<EnglishWord> page, EnglishWord englishWord) {
|
|
|
|
|
|
|
|
String condition = englishWord.getCondition();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QueryWrapper<EnglishWord> wr = new QueryWrapper<>();
|
|
|
|
|
|
|
|
wr.and(StringUtils.isNotEmpty(condition), obj -> {
|
|
|
|
|
|
|
|
obj.like("english_word", condition).or().like("chinese_word", condition);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//wr.like("english_word", condition).or().like("chinese_word", condition);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return this.page(page, wr);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//------------------------代码自动生成-----------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|