Browse Source

图片转换成base64码进行显示

tags/v1.1.0
qiujinyang 2 years ago
parent
commit
d03bda59c1
3 changed files with 44 additions and 22 deletions
  1. +9
    -0
      tuoheng-admin/src/main/java/com/tuoheng/admin/controller/QuestionController.java
  2. +2
    -2
      tuoheng-admin/src/main/java/com/tuoheng/admin/entity/request/QuestionQuery.java
  3. +33
    -20
      tuoheng-admin/src/main/java/com/tuoheng/admin/service/impl/QuestionServiceImpl.java

+ 9
- 0
tuoheng-admin/src/main/java/com/tuoheng/admin/controller/QuestionController.java View File

@@ -1,5 +1,6 @@
package com.tuoheng.admin.controller;

import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.tuoheng.admin.entity.domain.Question;
import com.tuoheng.admin.entity.request.*;
@@ -38,6 +39,10 @@ public class QuestionController {
*/
@GetMapping("/page")
public JsonResult<IPage<Question>> page(QuestionQuery questionQuery) {
if(ObjectUtil.isNotEmpty(questionQuery.getStartTime()) && ObjectUtil.isNotEmpty(questionQuery.getEndTime())){
questionQuery.setStartTime(questionQuery.getStartTime()+" 00:00:00");
questionQuery.setEndTime(questionQuery.getEndTime()+" 59:59:59");
}
return JsonResult.success(questionService.queryPage(questionQuery));
}

@@ -105,6 +110,10 @@ public class QuestionController {
*/
@GetMapping("/distributed")
public JsonResult distributed(QuestionQuery questionQuery) {
if(ObjectUtil.isNotEmpty(questionQuery.getStartTime()) && ObjectUtil.isNotEmpty(questionQuery.getEndTime())){
questionQuery.setStartTime(questionQuery.getStartTime()+" 00:00:00");
questionQuery.setEndTime(questionQuery.getEndTime()+" 23:59:59");
}
return JsonResult.success(questionService.distributed(questionQuery));
}


+ 2
- 2
tuoheng-admin/src/main/java/com/tuoheng/admin/entity/request/QuestionQuery.java View File

@@ -32,12 +32,12 @@ public class QuestionQuery extends BaseQuery implements Serializable {
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@ApiModelProperty(value = "开始时间")
private Date startTime;
private String startTime;

@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@ApiModelProperty(value = "结束时间")
private Date endTime;
private String endTime;

@ApiModelProperty(value = "任务名称")
private String name;

+ 33
- 20
tuoheng-admin/src/main/java/com/tuoheng/admin/service/impl/QuestionServiceImpl.java View File

@@ -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

Loading…
Cancel
Save