package com.dsh.account.service.impl; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.dsh.account.entity.Coach; import com.dsh.account.entity.EvaluateStudent; import com.dsh.account.entity.TStudent; import com.dsh.account.entity.User; import com.dsh.account.feignclient.other.SiteClient; import com.dsh.account.mapper.EvaluateStudentMapper; import com.dsh.account.mapper.TStudentMapper; import com.dsh.account.model.vo.commentDetail.StuCommentsVo; import com.dsh.account.service.CoachService; import com.dsh.account.service.EvaluateStudentService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Arrays; import java.util.List; /** *

* 评价学员记录 服务实现类 *

* * @author jqs * @since 2023-07-03 */ @Service public class EvaluateStudentServiceImpl extends ServiceImpl implements EvaluateStudentService { @Resource private TStudentMapper tstuMapper; private final SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm"); @Autowired private CoachService coachService; @Resource private SiteClient siteClient; @Override public List queryStuCommentsList(Integer stuId) { List stuCommentsVos = new ArrayList<>(); TStudent tStudent = tstuMapper.selectById(stuId); List evaluateStudents = this.list(new QueryWrapper() .eq("studentId",stuId )); if (evaluateStudents.size() > 0){ for (EvaluateStudent evaluateStudent : evaluateStudents) { StuCommentsVo vo = new StuCommentsVo(); // Coach coach = coachService.getById(evaluateStudent.getCoachId()); User user = siteClient.queryUserName(evaluateStudent.getCoachId()); // vo.setHeadImg(tStudent.getHeadImg()); vo.setHeadImg(user.getAvatar()); // vo.setStuName(tStudent.getName()); vo.setStuName(user.getName()); vo.setComTime(format.format(evaluateStudent.getInsertTime())); vo.setContents(evaluateStudent.getContent()); String imgs = evaluateStudent.getImgs(); String[] split = imgs.split(","); vo.setImgs(Arrays.asList(split)); stuCommentsVos.add(vo); } } return stuCommentsVos; } }