|
@@ -2,24 +2,35 @@ package com.gis.cms.service.impl;
|
|
|
|
|
|
import com.gis.cms.entity.dto.BarrageDto;
|
|
import com.gis.cms.entity.dto.BarrageDto;
|
|
import com.gis.cms.entity.po.BarrageEntity;
|
|
import com.gis.cms.entity.po.BarrageEntity;
|
|
|
|
+import com.gis.cms.entity.vo.BarrageVoExcel;
|
|
|
|
+import com.gis.cms.entity.vo.CommentVoExcel;
|
|
import com.gis.cms.mapper.BarrageMapper;
|
|
import com.gis.cms.mapper.BarrageMapper;
|
|
import com.gis.cms.service.SensitiveService;
|
|
import com.gis.cms.service.SensitiveService;
|
|
|
|
+import com.gis.common.base.entity.dto.DateDto;
|
|
import com.gis.common.base.entity.dto.PageDateDto;
|
|
import com.gis.common.base.entity.dto.PageDateDto;
|
|
|
|
+import com.gis.common.base.exception.BaseRuntimeException;
|
|
import com.gis.common.base.mapper.IBaseMapper;
|
|
import com.gis.common.base.mapper.IBaseMapper;
|
|
import com.gis.common.base.service.impl.IBaseServiceImpl;
|
|
import com.gis.common.base.service.impl.IBaseServiceImpl;
|
|
|
|
+import com.gis.common.util.ExcelUtils;
|
|
|
|
+import com.gis.common.util.MyStrUtil;
|
|
import com.gis.common.util.Result;
|
|
import com.gis.common.util.Result;
|
|
import com.gis.cms.service.BarrageService;
|
|
import com.gis.cms.service.BarrageService;
|
|
import com.github.pagehelper.PageInfo;
|
|
import com.github.pagehelper.PageInfo;
|
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.time.LocalDateTime;
|
|
import java.time.LocalDateTime;
|
|
|
|
+import java.util.HashMap;
|
|
|
|
+import java.util.List;
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
* Created by owen on 2020/3/11 0011 16:16
|
|
* Created by owen on 2020/3/11 0011 16:16
|
|
*/
|
|
*/
|
|
|
|
+@Slf4j
|
|
@Service
|
|
@Service
|
|
public class BarrageServiceImpl extends IBaseServiceImpl<BarrageEntity, Long> implements BarrageService {
|
|
public class BarrageServiceImpl extends IBaseServiceImpl<BarrageEntity, Long> implements BarrageService {
|
|
|
|
|
|
@@ -39,15 +50,6 @@ public class BarrageServiceImpl extends IBaseServiceImpl<BarrageEntity, Long> im
|
|
public Result<PageInfo<BarrageEntity>> search(PageDateDto param, Integer display) {
|
|
public Result<PageInfo<BarrageEntity>> search(PageDateDto param, Integer display) {
|
|
startPage(param);
|
|
startPage(param);
|
|
PageInfo<BarrageEntity> page = new PageInfo<>(entityMapper.search(param, display));
|
|
PageInfo<BarrageEntity> page = new PageInfo<>(entityMapper.search(param, display));
|
|
-// List<BarrageVo> list = page.getList();
|
|
|
|
-// Set<Object> filterKey = sensitiveService.getFilterKey();
|
|
|
|
-// for (BarrageVo vo : list) {
|
|
|
|
-// String content = vo.getContent();
|
|
|
|
-// if (content != null){
|
|
|
|
-// vo.setContent(MyStrUtil.getFilterMsg(filterKey, content));
|
|
|
|
-// }
|
|
|
|
-// }
|
|
|
|
-
|
|
|
|
|
|
|
|
return Result.success(page);
|
|
return Result.success(page);
|
|
}
|
|
}
|
|
@@ -82,4 +84,45 @@ public class BarrageServiceImpl extends IBaseServiceImpl<BarrageEntity, Long> im
|
|
return Result.success(entity);
|
|
return Result.success(entity);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public Result exportExcel(DateDto param) {
|
|
|
|
+ List<BarrageVoExcel> rows = findByDate(param);
|
|
|
|
+
|
|
|
|
+ // 保存地址
|
|
|
|
+ String filePath = "/excel/" + MyStrUtil.getTimeStr() + ".xlsx";
|
|
|
|
+ String savePath = configConstant.serverBasePath + filePath;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ HashMap<String, String> rowTitle = new HashMap<>();
|
|
|
|
+ rowTitle.put("createTime", "提交时间");
|
|
|
|
+ rowTitle.put("content", "内容");
|
|
|
|
+
|
|
|
|
+ ExcelUtils.createExcel(rows, savePath, rowTitle);
|
|
|
|
+ HashMap<String, Object> result = new HashMap<>();
|
|
|
|
+ result.put("size", rows.size());
|
|
|
|
+ result.put("path", filePath);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ return Result.success(result);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private List<BarrageVoExcel> findByDate(DateDto param){
|
|
|
|
+
|
|
|
|
+ String startTime = param.getStartTime();
|
|
|
|
+ String endTime = param.getEndTime();
|
|
|
|
+ if (StringUtils.isBlank(startTime) || StringUtils.isBlank(endTime)){
|
|
|
|
+ throw new BaseRuntimeException("日期不能为空");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ StringBuffer sql = new StringBuffer();
|
|
|
|
+ sql.append("select * from tb_barrage where is_delete=0 ");
|
|
|
|
+ sql.append(" and create_time >= ").append("'").append(startTime).append("'");
|
|
|
|
+ sql.append(" and create_time <= ").append("'").append(endTime).append("'");
|
|
|
|
+ sql.append(" order by create_time desc");
|
|
|
|
+ String sqlStr = sql.toString();
|
|
|
|
+ log.info("sql: {}", sqlStr);
|
|
|
|
+ return entityMapper.expertSql(sqlStr);
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|