package cn.stylefeng.guns.modular.business.service.impl;
|
|
import cn.stylefeng.guns.modular.business.dto.MentalTestMyTestOrderDTO;
|
import cn.stylefeng.guns.modular.business.dto.MentalTestMyTestRecordTopicDTO;
|
import cn.stylefeng.guns.modular.business.dto.MentalTestMyTestTopicDTO;
|
import cn.stylefeng.guns.modular.business.dto.MentalTestRecordPageDTO;
|
import cn.stylefeng.guns.modular.business.entity.MentalTestRecord;
|
import cn.stylefeng.guns.modular.business.mapper.MentalTestRecordMapper;
|
import cn.stylefeng.guns.modular.business.service.IMentalTestRecordService;
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import org.springframework.stereotype.Service;
|
|
import java.util.List;
|
|
/**
|
* <p>
|
* 心理测试记录 服务实现类
|
* </p>
|
*
|
* @author goupan
|
* @since 2024-01-09
|
*/
|
@Service
|
public class MentalTestRecordServiceImpl extends ServiceImpl<MentalTestRecordMapper, MentalTestRecord> implements IMentalTestRecordService {
|
|
@Override
|
public List<MentalTestMyTestTopicDTO> myTestTopic(Long userId, Long topicId) {
|
return this.baseMapper.myTestTopic(userId, topicId);
|
}
|
@Override
|
public List<MentalTestMyTestRecordTopicDTO> myTestRecordTopicByMentalAppointmentId(Long mentalAppointmentId, List<Long> mentalAppointmentIdList) {
|
return this.baseMapper.myTestRecordTopicByMentalAppointmentId(mentalAppointmentId, mentalAppointmentIdList);
|
}
|
|
@Override
|
public List<MentalTestMyTestOrderDTO> myTestOrder(Long userId, Long topicId) {
|
return this.baseMapper.myTestOrder(userId, topicId);
|
}
|
|
@Override
|
public Long getConsultWorkerIdByRecord(Long mentalTestRecordId, Long userId) {
|
// 咨询性格分析师
|
Long consultWorkerId = null;
|
if (mentalTestRecordId != null) {
|
// 从性格测试结果获取,性格分析师ID
|
MentalTestRecord mentalTestRecord = this.getById(mentalTestRecordId);
|
consultWorkerId = mentalTestRecord.getConsultWorkerId();
|
}
|
|
if (consultWorkerId == null && userId != null) {
|
// 从其他记录中获取
|
consultWorkerId = this.getObj(
|
Wrappers.<MentalTestRecord>lambdaQuery()
|
.select(MentalTestRecord::getConsultWorkerId)
|
.eq(MentalTestRecord::getUserId, userId)
|
.isNotNull(MentalTestRecord::getConsultWorkerId)
|
.last("limit 1"),
|
l -> (Long) l
|
);
|
|
if (consultWorkerId != null) {
|
// 将性格分析师分配入测试记录
|
this.update(
|
Wrappers.<MentalTestRecord>lambdaUpdate()
|
.set(MentalTestRecord::getConsultWorkerId, consultWorkerId)
|
.eq(MentalTestRecord::getId, mentalTestRecordId)
|
);
|
}
|
}
|
return consultWorkerId;
|
}
|
|
@Override
|
public Page<MentalTestRecordPageDTO> getPage(Page<Object> page, String title, String nickName, String telephone, Integer testType) {
|
return this.baseMapper.getPage(page, title, nickName, telephone, testType);
|
}
|
}
|