|
|
|
@ -1,12 +1,15 @@
|
|
|
|
|
package com.example.venue_reservation_service.service.impl;
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.Query;
|
|
|
|
|
import com.baomidou.mybatisplus.core.metadata.OrderItem;
|
|
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
|
import com.example.venue_reservation_service.domain.Question;
|
|
|
|
|
import com.example.venue_reservation_service.dto.QuestionDTO;
|
|
|
|
|
import com.example.venue_reservation_service.dto.QuestionQueryDTO;
|
|
|
|
|
import com.example.venue_reservation_service.dto.ReservationDTO;
|
|
|
|
|
import com.example.venue_reservation_service.mapper.QuestionMapper;
|
|
|
|
|
import com.example.venue_reservation_service.service.QuestionService;
|
|
|
|
|
import com.example.venue_reservation_service.vo.QueryVO;
|
|
|
|
@ -17,6 +20,7 @@ import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
|
import java.time.LocalDateTime;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Optional;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @author 31586
|
|
|
|
@ -31,27 +35,21 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question>
|
|
|
|
|
@Override
|
|
|
|
|
public Result create(QuestionDTO dto) {
|
|
|
|
|
|
|
|
|
|
String word = dto.getDescription().trim();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String word = dto.getDescription().strip();
|
|
|
|
|
Question question = lambdaQuery()
|
|
|
|
|
.eq(Question::getDescription, word)
|
|
|
|
|
.eq(Question::getUserId, dto.getUserId())
|
|
|
|
|
.one();
|
|
|
|
|
|
|
|
|
|
if(question != null) {
|
|
|
|
|
if(Optional.ofNullable(question).isPresent()) {
|
|
|
|
|
question.setCreatedTime(LocalDateTime.now());
|
|
|
|
|
}else {
|
|
|
|
|
question = BeanUtil.copyProperties(dto, Question.class);
|
|
|
|
|
question.setStatus(0);
|
|
|
|
|
question.setCreatedTime(LocalDateTime.now());
|
|
|
|
|
updateById(question);
|
|
|
|
|
return Result.ok().message("已有相同问题,修改创建时间成功");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Question newQuestion = new Question();
|
|
|
|
|
BeanUtils.copyProperties(dto, newQuestion);
|
|
|
|
|
newQuestion.setStatus(0);
|
|
|
|
|
newQuestion.setCreatedTime(LocalDateTime.now());
|
|
|
|
|
|
|
|
|
|
save(newQuestion);
|
|
|
|
|
|
|
|
|
|
saveOrUpdate(question);
|
|
|
|
|
return Result.ok().message("保存问题成功");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -83,7 +81,7 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question>
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Result adminPage(QuestionQueryDTO dto) {
|
|
|
|
|
public Result adminPage(ReservationDTO dto) {
|
|
|
|
|
|
|
|
|
|
Page<Question> page = Page.of(dto.getCurrent(), dto.getSize());
|
|
|
|
|
|
|
|
|
|