|
@@ -1,9 +1,14 @@
|
|
|
package com.gis.cms.service.impl;
|
|
|
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.gis.cms.entity.dto.AuditDto;
|
|
|
import com.gis.cms.entity.dto.QuestionGroupDto;
|
|
|
import com.gis.cms.entity.dto.StatusPageDataDto;
|
|
|
import com.gis.cms.entity.po.AuditLogEntity;
|
|
|
+import com.gis.cms.entity.po.NewsEntity;
|
|
|
import com.gis.cms.entity.po.QuestionAnswerEntity;
|
|
|
import com.gis.cms.entity.po.QuestionGroupEntity;
|
|
|
import com.gis.cms.mapper.QuestionGroupMapper;
|
|
@@ -11,17 +16,18 @@ import com.gis.cms.service.AuditLogService;
|
|
|
import com.gis.cms.service.QuestionAnswerService;
|
|
|
import com.gis.cms.service.QuestionGroupService;
|
|
|
import com.gis.common.base.exception.BaseRuntimeException;
|
|
|
-import com.gis.common.base.mapper.IBaseMapper;
|
|
|
+import com.gis.common.base.service.IBaseService;
|
|
|
+import com.gis.common.constant.ConfigConstant;
|
|
|
import com.gis.common.constant.MsgCode;
|
|
|
import com.gis.common.constant.TypeCode;
|
|
|
+import com.gis.common.util.BaseUtil;
|
|
|
+import com.gis.common.util.FileUtils;
|
|
|
import com.gis.common.util.Result;
|
|
|
import com.gis.cms.service.FileService;
|
|
|
-import com.github.pagehelper.PageInfo;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
-import tk.mybatis.mapper.entity.Condition;
|
|
|
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.util.ArrayList;
|
|
@@ -34,11 +40,7 @@ import java.util.List;
|
|
|
*/
|
|
|
@Slf4j
|
|
|
@Service
|
|
|
-public class QuestionGroupServiceImpl extends ServiceImpl<QuestionGroupEntity, Long> implements QuestionGroupService {
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private QuestionGroupMapper entityMapper;
|
|
|
-
|
|
|
+public class QuestionGroupServiceImpl extends ServiceImpl<QuestionGroupMapper, QuestionGroupEntity> implements QuestionGroupService {
|
|
|
|
|
|
@Autowired
|
|
|
FileService fileService;
|
|
@@ -49,51 +51,91 @@ public class QuestionGroupServiceImpl extends ServiceImpl<QuestionGroupEntity, L
|
|
|
@Autowired
|
|
|
QuestionAnswerService questionAnswerService;
|
|
|
|
|
|
- @Override
|
|
|
- public IBaseMapper<QuestionGroupEntity, Long> getBaseMapper() {
|
|
|
- return this.entityMapper;
|
|
|
- }
|
|
|
+ @Autowired
|
|
|
+ FileUtils fileUtils;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ IBaseService iBaseService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ ConfigConstant configConstant;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+// @Override
|
|
|
+// public Result<QuestionGroupEntity> search(StatusPageDataDto param, Integer display) {
|
|
|
+// startPage(param);
|
|
|
+// Condition condition = new Condition(QuestionGroupEntity.class);
|
|
|
+// String searchKey = param.getSearchKey();
|
|
|
+// if (StringUtils.isNotBlank(searchKey)) {
|
|
|
+// searchKey = StringUtils.trim(searchKey);
|
|
|
+// condition.and().orLike("name", "%" + searchKey + "%");
|
|
|
+// }
|
|
|
+// String startTime = param.getStartTime();
|
|
|
+// String endTime = param.getEndTime();
|
|
|
+// if (StringUtils.isNotBlank(startTime) && StringUtils.isNotBlank(endTime) ) {
|
|
|
+// condition.and().andBetween("createTime", startTime, endTime);
|
|
|
+// }
|
|
|
+// Integer status = param.getStatus();
|
|
|
+// if (status != null) {
|
|
|
+// condition.and().andEqualTo("status", status);
|
|
|
+// }
|
|
|
+//
|
|
|
+// if (display != null) {
|
|
|
+// condition.and().andEqualTo("display", display);
|
|
|
+// }
|
|
|
+// condition.orderBy("createTime").desc();
|
|
|
+//
|
|
|
+// PageInfo<QuestionGroupEntity> pageInfo = findAll(condition, param.getPageNum(), param.getPageSize());
|
|
|
+// List<QuestionGroupEntity> list = pageInfo.getList();
|
|
|
+//
|
|
|
+// List<QuestionGroupEntity> result = new ArrayList<>();
|
|
|
+//
|
|
|
+// for (QuestionGroupEntity q : list) {
|
|
|
+// Integer count = getQuesitongCount(q.getId());
|
|
|
+// q.setQuestionCount(count);
|
|
|
+// result.add(q);
|
|
|
+// }
|
|
|
+//
|
|
|
+// pageInfo.setList(result);
|
|
|
+//
|
|
|
+// return Result.success(pageInfo);
|
|
|
+//
|
|
|
+//
|
|
|
+// }
|
|
|
+
|
|
|
|
|
|
@Override
|
|
|
public Result<QuestionGroupEntity> search(StatusPageDataDto param, Integer display) {
|
|
|
- startPage(param);
|
|
|
- Condition condition = new Condition(QuestionGroupEntity.class);
|
|
|
+
|
|
|
+ BaseUtil.startPage(param);
|
|
|
+ LambdaQueryWrapper<QuestionGroupEntity> wrapper = new LambdaQueryWrapper<>();
|
|
|
String searchKey = param.getSearchKey();
|
|
|
- if (StringUtils.isNotBlank(searchKey)) {
|
|
|
- searchKey = StringUtils.trim(searchKey);
|
|
|
- condition.and().orLike("name", "%" + searchKey + "%");
|
|
|
-// .orLike("userName", "%" + searchKey + "%");
|
|
|
- }
|
|
|
+ wrapper.like(StrUtil.isNotBlank(searchKey), QuestionGroupEntity::getName, searchKey);
|
|
|
+
|
|
|
String startTime = param.getStartTime();
|
|
|
String endTime = param.getEndTime();
|
|
|
- if (StringUtils.isNotBlank(startTime) && StringUtils.isNotBlank(endTime) ) {
|
|
|
- condition.and().andBetween("createTime", startTime, endTime);
|
|
|
- }
|
|
|
- Integer status = param.getStatus();
|
|
|
- if (status != null) {
|
|
|
- condition.and().andEqualTo("status", status);
|
|
|
- }
|
|
|
-
|
|
|
- if (display != null) {
|
|
|
- condition.and().andEqualTo("display", display);
|
|
|
+ if (StringUtils.isNotBlank(startTime) && StringUtils.isNotBlank(endTime)){
|
|
|
+ wrapper.between(QuestionGroupEntity::getCreateTime, startTime, endTime);
|
|
|
}
|
|
|
- condition.orderBy("createTime").desc();
|
|
|
|
|
|
- PageInfo<QuestionGroupEntity> pageInfo = findAll(condition, param.getPageNum(), param.getPageSize());
|
|
|
- List<QuestionGroupEntity> list = pageInfo.getList();
|
|
|
+ Integer status = param.getStatus();
|
|
|
+ wrapper.eq(status!= null, QuestionGroupEntity::getStatus, status);
|
|
|
+ wrapper.eq(display!= null, QuestionGroupEntity::getDisplay, display);
|
|
|
+ wrapper.orderByDesc(QuestionGroupEntity::getCreateTime);
|
|
|
+ Page<QuestionGroupEntity> page = this.page(new Page<>(param.getPageNum(), param.getPageSize()), wrapper);
|
|
|
|
|
|
+ List<QuestionGroupEntity> records = page.getRecords();
|
|
|
List<QuestionGroupEntity> result = new ArrayList<>();
|
|
|
|
|
|
- for (QuestionGroupEntity q : list) {
|
|
|
+ for (QuestionGroupEntity q : records) {
|
|
|
Integer count = getQuesitongCount(q.getId());
|
|
|
q.setQuestionCount(count);
|
|
|
result.add(q);
|
|
|
}
|
|
|
|
|
|
- pageInfo.setList(result);
|
|
|
-
|
|
|
- return Result.success(pageInfo);
|
|
|
-
|
|
|
+ page.setRecords(result);
|
|
|
+ return Result.success(page);
|
|
|
|
|
|
}
|
|
|
|
|
@@ -137,7 +179,7 @@ public class QuestionGroupServiceImpl extends ServiceImpl<QuestionGroupEntity, L
|
|
|
|
|
|
@Override
|
|
|
public Result updateDisplay(Long id, Integer display) {
|
|
|
- QuestionGroupEntity entity = this.findById(id);
|
|
|
+ QuestionGroupEntity entity = this.getById(id);
|
|
|
if (entity == null) {
|
|
|
log.error("对象id不存在 : {}", id);
|
|
|
return Result.failure("对象id不存在");
|
|
@@ -150,19 +192,19 @@ public class QuestionGroupServiceImpl extends ServiceImpl<QuestionGroupEntity, L
|
|
|
}
|
|
|
|
|
|
entity.setDisplay(display);
|
|
|
- this.update(entity);
|
|
|
+ this.updateById(entity);
|
|
|
return Result.success(entity);
|
|
|
}
|
|
|
|
|
|
|
|
|
private void updateStatus(Long id, Integer status){
|
|
|
- QuestionGroupEntity entity = this.findById(id);
|
|
|
+ QuestionGroupEntity entity = this.getById(id);
|
|
|
if (entity == null) {
|
|
|
throw new BaseRuntimeException(MsgCode.e3001, "对象不存在");
|
|
|
}
|
|
|
entity.setStatus(status);
|
|
|
entity.setUpdateTime(LocalDateTime.now());
|
|
|
- this.update(entity);
|
|
|
+ this.updateById(entity);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -173,16 +215,16 @@ public class QuestionGroupServiceImpl extends ServiceImpl<QuestionGroupEntity, L
|
|
|
entity = new QuestionGroupEntity();
|
|
|
// entity.setDisplay(1);
|
|
|
entity.setName(param.getName());
|
|
|
- entity.setUserName(getTokenUserName());
|
|
|
+ entity.setUserName(iBaseService.getUserName());
|
|
|
this.save(entity);
|
|
|
} else {
|
|
|
- entity = this.findById(id);
|
|
|
+ entity = this.getById(id);
|
|
|
if (entity == null) {
|
|
|
return Result.failure("对象不存在: " + id);
|
|
|
}
|
|
|
entity.setName(param.getName());
|
|
|
entity.setUpdateTime(LocalDateTime.now());
|
|
|
- this.update(entity);
|
|
|
+ this.updateById(entity);
|
|
|
}
|
|
|
|
|
|
Long groupId = entity.getId();
|
|
@@ -201,14 +243,15 @@ public class QuestionGroupServiceImpl extends ServiceImpl<QuestionGroupEntity, L
|
|
|
|
|
|
@Override
|
|
|
public Result remove(Long id) {
|
|
|
- QuestionGroupEntity entity = this.findById(id);
|
|
|
- if (entity == null) {
|
|
|
- return Result.success();
|
|
|
- }
|
|
|
+// QuestionGroupEntity entity = this.getById(id);
|
|
|
+// if (entity == null) {
|
|
|
+// return Result.success();
|
|
|
+// }
|
|
|
// db数据软删除, 物理数据真删除
|
|
|
- entity.setIsDelete(1);
|
|
|
- entity.setUpdateTime(LocalDateTime.now());
|
|
|
- this.update(entity);
|
|
|
+// entity.setIsDelete(1);
|
|
|
+// entity.setUpdateTime(LocalDateTime.now());
|
|
|
+// this.updateById(entity);
|
|
|
+ this.removeById(id);
|
|
|
// 相应的答案删除
|
|
|
questionAnswerService.removeByQuestionGroupId(id);
|
|
|
|
|
@@ -217,7 +260,7 @@ public class QuestionGroupServiceImpl extends ServiceImpl<QuestionGroupEntity, L
|
|
|
|
|
|
@Override
|
|
|
public Result<QuestionGroupEntity> detail(Long id) {
|
|
|
- QuestionGroupEntity entity = this.findById(id);
|
|
|
+ QuestionGroupEntity entity = this.getById(id);
|
|
|
if (entity == null) {
|
|
|
return Result.failure("对象不存在");
|
|
|
}
|