|
@@ -1,12 +1,24 @@
|
|
|
package com.sooka.jnb.information.service.impl;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Arrays;
|
|
|
import java.util.List;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
import com.ruoyi.common.utils.DateUtils;
|
|
|
+import com.ruoyi.common.utils.SecurityUtils;
|
|
|
+import com.ruoyi.common.utils.StringUtils;
|
|
|
+import com.sooka.jnb.highServer.domain.JnbHighServerImg;
|
|
|
+import com.sooka.jnb.highServer.mapper.JnbHighServerImgMapper;
|
|
|
import com.sooka.jnb.information.domain.Information;
|
|
|
+import com.sooka.jnb.information.domain.InformationVo;
|
|
|
import com.sooka.jnb.information.mapper.InformationMapper;
|
|
|
import com.sooka.jnb.information.service.InformationService;
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
+import org.springframework.util.ObjectUtils;
|
|
|
|
|
|
/**
|
|
|
* 高频服务Service业务层处理
|
|
@@ -19,11 +31,17 @@ public class InformationServiceImpl implements InformationService
|
|
|
{
|
|
|
@Autowired
|
|
|
private InformationMapper informationMapper;
|
|
|
+ @Autowired
|
|
|
+ private JnbHighServerImgMapper jnbHighServerImgMapper;
|
|
|
|
|
|
@Override
|
|
|
- public Information selectInformationById(Long id)
|
|
|
+ public InformationVo selectInformationById(Long id)
|
|
|
{
|
|
|
- return informationMapper.selectInformationById(id);
|
|
|
+ Information information = informationMapper.selectInformationById(id);
|
|
|
+ InformationVo vo = new InformationVo();
|
|
|
+ vo.setImgUrlList(StringUtils.join(jnbHighServerImgMapper.selectAll(id)));
|
|
|
+ BeanUtils.copyProperties(information,vo);
|
|
|
+ return vo;
|
|
|
}
|
|
|
|
|
|
|
|
@@ -35,30 +53,79 @@ public class InformationServiceImpl implements InformationService
|
|
|
|
|
|
|
|
|
@Override
|
|
|
- public int insertInformationServer(Information information)
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public int insertInformationServer(InformationVo information)
|
|
|
{
|
|
|
- information.setCreateTime(DateUtils.getNowDate());
|
|
|
- return informationMapper.insertInformation(information);
|
|
|
+ Information entity = new Information();
|
|
|
+ BeanUtils.copyProperties(information,entity);
|
|
|
+ entity.setCreateTime(DateUtils.getNowDate());
|
|
|
+ entity.setCreateBy(String.valueOf(SecurityUtils.getUserId()));
|
|
|
+ int i = informationMapper.insertInformation(entity);
|
|
|
+ if (i>0){
|
|
|
+ List<String> imgUrlList = Arrays.asList(information.getImgUrlList().split(","));
|
|
|
+ if (!ObjectUtils.isEmpty(imgUrlList)){
|
|
|
+ List<JnbHighServerImg> imgList = new ArrayList<>();
|
|
|
+ imgUrlList.forEach(a->{
|
|
|
+ JnbHighServerImg serverImg = new JnbHighServerImg();
|
|
|
+ serverImg.setCreateBy(String.valueOf(SecurityUtils.getUserId()));
|
|
|
+ serverImg.setCreateTime(DateUtils.getNowDate());
|
|
|
+ serverImg.setServerId(information.getId());
|
|
|
+ serverImg.setImgUrl(a);
|
|
|
+ imgList.add(serverImg);
|
|
|
+ });
|
|
|
+ jnbHighServerImgMapper.saveJnbHighServerImg(imgList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return i;
|
|
|
}
|
|
|
|
|
|
|
|
|
@Override
|
|
|
- public int updateInformation(Information information)
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public int updateInformation(InformationVo information)
|
|
|
{
|
|
|
- information.setUpdateTime(DateUtils.getNowDate());
|
|
|
- return informationMapper.updateInformation(information);
|
|
|
+ Information entity = new Information();
|
|
|
+ BeanUtils.copyProperties(information,entity);
|
|
|
+ entity.setUpdateTime(DateUtils.getNowDate());
|
|
|
+ entity.setUpdateBy(String.valueOf(SecurityUtils.getUserId()));
|
|
|
+ int i = informationMapper.updateInformation(entity);
|
|
|
+ List<String> imgUrlList = Arrays.asList(information.getImgUrlList().split(","));
|
|
|
+ if (!ObjectUtils.isEmpty(imgUrlList)){
|
|
|
+ List<JnbHighServerImg> imgList = new ArrayList<>();
|
|
|
+ jnbHighServerImgMapper.deleteJnbHighServerByServerId(information.getId());
|
|
|
+ imgUrlList.forEach(a->{
|
|
|
+ JnbHighServerImg serverImg = new JnbHighServerImg();
|
|
|
+ serverImg.setCreateBy(String.valueOf(SecurityUtils.getUserId()));
|
|
|
+ serverImg.setCreateTime(DateUtils.getNowDate());
|
|
|
+ serverImg.setServerId(information.getId());
|
|
|
+ serverImg.setImgUrl(a);
|
|
|
+ imgList.add(serverImg);
|
|
|
+ });
|
|
|
+ jnbHighServerImgMapper.saveJnbHighServerImg(imgList);
|
|
|
+ }
|
|
|
+ return i;
|
|
|
}
|
|
|
|
|
|
|
|
|
@Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
public int deleteInformationByIds(Long[] ids)
|
|
|
{
|
|
|
- return informationMapper.deleteInformationByIds(ids);
|
|
|
+ int i = informationMapper.deleteInformationByIds(ids);
|
|
|
+ if (i>0){
|
|
|
+ jnbHighServerImgMapper.deleteJnbHighServerByServerIds(ids);
|
|
|
+ }
|
|
|
+ return i;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
public int deleteInformationById(Long id)
|
|
|
{
|
|
|
- return informationMapper.deleteInformationById(id);
|
|
|
+ int i = informationMapper.deleteInformationById(id);
|
|
|
+ if (i>0){
|
|
|
+ jnbHighServerImgMapper.deleteJnbHighServerByServerId(id);
|
|
|
+ }
|
|
|
+ return i;
|
|
|
}
|
|
|
}
|