|
@@ -1,15 +1,24 @@
|
|
package cn.cslg.pas.service;
|
|
package cn.cslg.pas.service;
|
|
|
|
|
|
|
|
|
|
|
|
+import cn.cslg.pas.common.model.PersonnelVO;
|
|
|
|
+import cn.cslg.pas.common.model.dto.ScratchWordsDTO;
|
|
|
|
+import cn.cslg.pas.common.model.dto.ScratchWordsUpdateDTO;
|
|
|
|
+import cn.cslg.pas.common.utils.CacheUtils;
|
|
|
|
+import cn.cslg.pas.common.utils.SecurityUtils.LoginUtils;
|
|
import cn.cslg.pas.domain.ScratchWords;
|
|
import cn.cslg.pas.domain.ScratchWords;
|
|
|
|
|
|
|
|
+import cn.cslg.pas.exception.XiaoShiException;
|
|
import cn.cslg.pas.mapper.ScratchWordsMapper;
|
|
import cn.cslg.pas.mapper.ScratchWordsMapper;
|
|
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import lombok.RequiredArgsConstructor;
|
|
import lombok.RequiredArgsConstructor;
|
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
import org.springframework.context.annotation.Lazy;
|
|
import org.springframework.context.annotation.Lazy;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
+import java.util.List;
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -23,6 +32,64 @@ import org.springframework.stereotype.Service;
|
|
@Service
|
|
@Service
|
|
@RequiredArgsConstructor(onConstructor_ = {@Lazy})
|
|
@RequiredArgsConstructor(onConstructor_ = {@Lazy})
|
|
public class ScratchWordsService extends ServiceImpl<ScratchWordsMapper, ScratchWords> {
|
|
public class ScratchWordsService extends ServiceImpl<ScratchWordsMapper, ScratchWords> {
|
|
|
|
+ private final CacheUtils cacheUtils;
|
|
|
|
+ private final LoginUtils loginUtils;
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 新增划词高亮
|
|
|
|
+ *
|
|
|
|
+ * @param scratchWordsDTOS
|
|
|
|
+ */
|
|
|
|
+ public void add(List<ScratchWordsDTO> scratchWordsDTOS){
|
|
|
|
+ ScratchWords scratchWords = new ScratchWords();
|
|
|
|
+ //判断传入列表不为空
|
|
|
|
+ if(scratchWordsDTOS != null && scratchWordsDTOS.size() != 0){
|
|
|
|
+ //遍历传入列表
|
|
|
|
+ for(int i = 0; i < scratchWordsDTOS.size(); i++){
|
|
|
|
+ ScratchWordsDTO scratchWordsDTO = scratchWordsDTOS.get(i);
|
|
|
|
+ BeanUtils.copyProperties(scratchWordsDTO, scratchWords);
|
|
|
|
+ //获取当前登陆人信息
|
|
|
|
+ PersonnelVO personnelVO = cacheUtils.getLoginUser(loginUtils.getId());
|
|
|
|
+ //设置创建人id
|
|
|
|
+ scratchWords.setCreateId(personnelVO.getId());
|
|
|
|
+ //数据入表
|
|
|
|
+ scratchWords.insert();
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ throw new XiaoShiException("传入列表不能为空");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 更新划词高亮
|
|
|
|
+ * @param scratchWordsUpdateDTOS
|
|
|
|
+ */
|
|
|
|
+ public void update(List<ScratchWordsUpdateDTO> scratchWordsUpdateDTOS){
|
|
|
|
+ ScratchWords scratchWords = new ScratchWords();
|
|
|
|
+ //判断传入列表不为空
|
|
|
|
+ if(scratchWordsUpdateDTOS != null && scratchWordsUpdateDTOS.size() != 0){
|
|
|
|
+ //遍历传入列表
|
|
|
|
+ for(int i = 0; i < scratchWordsUpdateDTOS.size(); i++) {
|
|
|
|
+ ScratchWordsUpdateDTO scratchWordsUpdateDTO = scratchWordsUpdateDTOS.get(i);
|
|
|
|
+ BeanUtils.copyProperties(scratchWordsUpdateDTO, scratchWords);
|
|
|
|
+ scratchWordsUpdateDTO.updateById();
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ throw new XiaoShiException("传入列表不能为空");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public List<ScratchWords> queryAll(){
|
|
|
|
+ List<ScratchWords> scratchWords = this.list();
|
|
|
|
+ return scratchWords;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void delete(List<Integer> ids){
|
|
|
|
+ for(int i = 0; i < ids.size(); i++){
|
|
|
|
+ LambdaQueryWrapper<ScratchWords> LW = new LambdaQueryWrapper<>();
|
|
|
|
+ LW.eq(ScratchWords::getId, ids.get(i));
|
|
|
|
+ ScratchWords scratchWords = this.getOne(LW);
|
|
|
|
+ scratchWords.deleteById();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|