|
|
|
@ -1,20 +1,111 @@
|
|
|
|
|
package com.example.venue_reservation_service.service.impl;
|
|
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
|
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.mapper.QuestionMapper;
|
|
|
|
|
import com.example.venue_reservation_service.service.QuestionService;
|
|
|
|
|
import com.example.venue_reservation_service.vo.QueryVO;
|
|
|
|
|
import com.example.venue_reservation_service.vo.Result;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
|
import java.time.LocalDateTime;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @author 31586
|
|
|
|
|
* @description 针对表【venue_question(用户答疑记录表)】的数据库操作Service实现
|
|
|
|
|
* @createDate 2025-06-21 14:15:36
|
|
|
|
|
*/
|
|
|
|
|
@Service
|
|
|
|
|
@Slf4j
|
|
|
|
|
public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question>
|
|
|
|
|
implements QuestionService{
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Result create(QuestionDTO dto) {
|
|
|
|
|
|
|
|
|
|
String word = dto.getDescription().trim();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Question question = lambdaQuery()
|
|
|
|
|
.eq(Question::getDescription, word)
|
|
|
|
|
.one();
|
|
|
|
|
|
|
|
|
|
if(question != null) {
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
return Result.ok().message("保存问题成功");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Result userPage(QuestionQueryDTO dto) {
|
|
|
|
|
Page<Question> page = Page.of(dto.getCurrent(), dto.getSize());
|
|
|
|
|
|
|
|
|
|
page.addOrder(OrderItem.desc("created_time"));
|
|
|
|
|
|
|
|
|
|
LambdaQueryWrapper<Question> wrapper = new LambdaQueryWrapper<>();
|
|
|
|
|
|
|
|
|
|
if (dto.getStatus() != null) {
|
|
|
|
|
wrapper.eq(Question::getStatus, dto.getStatus());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (dto.getType() != null) {
|
|
|
|
|
wrapper.eq(Question::getType, dto.getType());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Page<Question> resultPage = page(page, wrapper);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QueryVO<Question> vo = new QueryVO<>();
|
|
|
|
|
vo.setList(resultPage.getRecords());
|
|
|
|
|
vo.setTotal(resultPage.getTotal());
|
|
|
|
|
|
|
|
|
|
return Result.ok(vo).message("查询成功");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Result adminPage(QuestionQueryDTO dto) {
|
|
|
|
|
|
|
|
|
|
Page<Question> page = Page.of(dto.getCurrent(), dto.getSize());
|
|
|
|
|
|
|
|
|
|
page.addOrder(OrderItem.desc("created_time"));
|
|
|
|
|
|
|
|
|
|
LambdaQueryWrapper<Question> wrapper = new LambdaQueryWrapper<>();
|
|
|
|
|
|
|
|
|
|
if (dto.getStatus() != null) {
|
|
|
|
|
wrapper.eq(Question::getStatus, dto.getStatus());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Page<Question> resultPage = page(page, wrapper);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QueryVO<Question> vo = new QueryVO<>();
|
|
|
|
|
vo.setList(resultPage.getRecords());
|
|
|
|
|
vo.setTotal(resultPage.getTotal());
|
|
|
|
|
|
|
|
|
|
return Result.ok(vo).message("查询成功");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|