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.StudentHonor;
|
import com.dsh.account.feignclient.other.HonorDeClient;
|
import com.dsh.account.mapper.StudentHonorMapper;
|
import com.dsh.account.model.vo.medalDetail.GongVo;
|
import com.dsh.account.model.vo.medalDetail.StuMedalVo;
|
import com.dsh.account.service.StudentHonorService;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Service;
|
|
import java.util.ArrayList;
|
import java.util.List;
|
import java.util.stream.Collectors;
|
|
/**
|
* <p>
|
* 学员-荣耀中间表 服务实现类
|
* </p>
|
*
|
* @author jqs
|
* @since 2023-07-04
|
*/
|
@Service
|
public class StudentHonorServiceImpl extends ServiceImpl<StudentHonorMapper, StudentHonor> implements StudentHonorService {
|
|
|
@Autowired
|
private HonorDeClient honorDeClient;
|
|
@Override
|
public List<GongVo> queryStuOfMedalData(Integer stuId) {
|
List<GongVo> voList = new ArrayList<>();
|
List<StudentHonor> studentHonors = this.baseMapper.selectList(new QueryWrapper<StudentHonor>()
|
.eq("stuId", stuId));
|
if (studentHonors.size() > 0){
|
studentHonors.forEach( stuoHo -> {
|
GongVo vo = new GongVo();
|
vo.setMedalType(stuoHo.getHonorType());
|
switch (stuoHo.getHonorType()){
|
case 1:
|
vo.setMedalName("俱乐部之星");
|
break;
|
case 2:
|
vo.setMedalName("运动达人");
|
break;
|
case 3:
|
vo.setMedalName("社区之王");
|
break;
|
case 4:
|
vo.setMedalName("深度玩家");
|
break;
|
default:
|
break;
|
}
|
voList.add(vo);
|
});
|
}
|
return voList;
|
}
|
|
@Override
|
public List<StuMedalVo> queryHonorDetails(Integer stuId) {
|
List<StudentHonor> studentHonors = this.baseMapper.selectList(new QueryWrapper<StudentHonor>()
|
.in("stuId",stuId));
|
List<Integer> collect = studentHonors.stream().map(StudentHonor::getHonorRuleId).collect(Collectors.toList());
|
return honorDeClient.getStuHonors(collect);
|
}
|
}
|