|
|
@@ -31,6 +31,7 @@ import org.springframework.http.HttpStatus; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.util.CollectionUtils; |
|
|
|
|
|
|
|
import java.text.SimpleDateFormat; |
|
|
|
import java.util.*; |
|
|
|
|
|
|
|
/** |
|
|
@@ -54,23 +55,29 @@ public class QuestionServiceImpl extends BaseServiceImpl<QuestionMapper, Questio |
|
|
|
@Autowired |
|
|
|
private IQuestionTypeService questionTypeService; |
|
|
|
|
|
|
|
//private final static SimpleDateFormat dateformat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
|
|
|
private final static SimpleDateFormat dateformat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
|
|
|
|
|
|
|
@Override |
|
|
|
public IPage<Question> queryPage(QuestionQuery query) { |
|
|
|
if(null == query.getPage() || null == query.getLimit()){ |
|
|
|
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL); |
|
|
|
} |
|
|
|
// 获取分页数据 |
|
|
|
IPage<Question> page = new Page<>(query.getPage(), query.getLimit()); |
|
|
|
IPage<Question> pageData = questionMapper.selectPage(page, new LambdaQueryWrapper<Question>() |
|
|
|
.eq(ObjectUtil.isNotEmpty(query.getMissionId()), Question::getMissionId, query.getMissionId()) |
|
|
|
.like(ObjectUtil.isNotEmpty(query.getName()), Question::getMissionName, query.getName()) |
|
|
|
.between((ObjectUtil.isNotEmpty(query.getStartTime()) && ObjectUtil.isNotEmpty(query.getEndTime())),Question::getCreateTime,query.getStartTime(),query.getEndTime()) |
|
|
|
.eq(ObjectUtil.isNotEmpty(query.getType()), Question::getType, query.getType()) |
|
|
|
.eq(ObjectUtil.isNotEmpty(query.getStatus()), Question::getStatus, query.getStatus()) |
|
|
|
//.eq(Question::getTenantId, ShiroUtils.getTenantId()) |
|
|
|
.eq(Question::getMark, MarkTypeEnum.VALID.getCode()).orderByDesc(Question::getCreateTime)); |
|
|
|
IPage<Question> pageData=null; |
|
|
|
try { |
|
|
|
// 获取分页数据 |
|
|
|
IPage<Question> page = new Page<>(query.getPage(), query.getLimit()); |
|
|
|
pageData = questionMapper.selectPage(page, new LambdaQueryWrapper<Question>() |
|
|
|
.eq(ObjectUtil.isNotEmpty(query.getMissionId()), Question::getMissionId, query.getMissionId()) |
|
|
|
.like(ObjectUtil.isNotEmpty(query.getName()), Question::getMissionName, query.getName()) |
|
|
|
.between((ObjectUtil.isNotEmpty(query.getStartTime()) && ObjectUtil.isNotEmpty(query.getEndTime())), Question::getCreateTime, dateformat.parse(query.getStartTime()), dateformat.parse(query.getEndTime())) |
|
|
|
.eq(ObjectUtil.isNotEmpty(query.getType()), Question::getType, query.getType()) |
|
|
|
.eq(ObjectUtil.isNotEmpty(query.getStatus()), Question::getStatus, query.getStatus()) |
|
|
|
//.eq(Question::getTenantId, ShiroUtils.getTenantId()) |
|
|
|
.eq(Question::getMark, MarkTypeEnum.VALID.getCode()).orderByDesc(Question::getCreateTime)); |
|
|
|
}catch (Exception e){ |
|
|
|
e.printStackTrace(); |
|
|
|
log.error("查询出错!"); |
|
|
|
} |
|
|
|
return pageData; |
|
|
|
} |
|
|
|
|
|
|
@@ -87,15 +94,21 @@ public class QuestionServiceImpl extends BaseServiceImpl<QuestionMapper, Questio |
|
|
|
if(thMissions.size()==0){ |
|
|
|
return new ArrayList<>(); |
|
|
|
} |
|
|
|
return questionMapper.selectList(new LambdaQueryWrapper<Question>() |
|
|
|
//只需要取最上面的那一条 |
|
|
|
.eq(Question::getMissionId, thMissions.get(0).getId()) |
|
|
|
.like(ObjectUtil.isNotEmpty(query.getName()), Question::getMissionName, query.getName()) |
|
|
|
.between((ObjectUtil.isNotEmpty(query.getStartTime()) && ObjectUtil.isNotEmpty(query.getEndTime())), Question::getCreateTime, query.getStartTime(), query.getEndTime()) |
|
|
|
.eq(ObjectUtil.isNotEmpty(query.getType()), Question::getType, query.getType()) |
|
|
|
.eq(Question::getStatus, QuestionStatusEnum.CONFIRM.getCode()) |
|
|
|
//.eq(Question::getTenantId, ShiroUtils.getTenantId()) |
|
|
|
.eq(Question::getMark, MarkTypeEnum.VALID.getCode()).orderByDesc(Question::getCreateTime)); |
|
|
|
try { |
|
|
|
return questionMapper.selectList(new LambdaQueryWrapper<Question>() |
|
|
|
//只需要取最上面的那一条 |
|
|
|
.eq(Question::getMissionId, thMissions.get(0).getId()) |
|
|
|
.like(ObjectUtil.isNotEmpty(query.getName()), Question::getMissionName, query.getName()) |
|
|
|
.between((ObjectUtil.isNotEmpty(query.getStartTime()) && ObjectUtil.isNotEmpty(query.getEndTime())), Question::getCreateTime, dateformat.parse(query.getStartTime()), dateformat.parse(query.getEndTime())) |
|
|
|
.eq(ObjectUtil.isNotEmpty(query.getType()), Question::getType, query.getType()) |
|
|
|
.eq(Question::getStatus, QuestionStatusEnum.CONFIRM.getCode()) |
|
|
|
//.eq(Question::getTenantId, ShiroUtils.getTenantId()) |
|
|
|
.eq(Question::getMark, MarkTypeEnum.VALID.getCode()).orderByDesc(Question::getCreateTime)); |
|
|
|
}catch (Exception e){ |
|
|
|
e.printStackTrace(); |
|
|
|
log.error("查询出错!"); |
|
|
|
return null; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@Override |