|
@@ -0,0 +1,118 @@
|
|
|
+package com.dt.common.service.impl;
|
|
|
+
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.dt.care.dto.AgesNameDto;
|
|
|
+import com.dt.care.dto.VaccinesDto;
|
|
|
+import com.dt.common.domain.*;
|
|
|
+import com.dt.common.mapper.*;
|
|
|
+import com.dt.common.service.HxwVaccinesService;
|
|
|
+import com.dt.user.mapper.UserMapper;
|
|
|
+import com.dt.user.pojo.User;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import javax.annotation.Resource;
|
|
|
+import java.util.Collections;
|
|
|
+import java.util.List;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+/**
|
|
|
+* @author sunday
|
|
|
+* @description 针对表【hxw_vaccines(hxw_疫苗信息表:存储所有疫苗的基本信息)】的数据库操作Service实现
|
|
|
+* @createDate 2025-07-03 09:45:44
|
|
|
+*/
|
|
|
+@Service
|
|
|
+public class HxwVaccinesServiceImpl extends ServiceImpl<HxwVaccinesMapper, HxwVaccines>
|
|
|
+ implements HxwVaccinesService{
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private HxwVaccineCategoriesMapper hxwVaccineCategoriesMapper;
|
|
|
+ @Resource
|
|
|
+ private HxwVaccineExpertRelationsMapper hxwVaccineExpertRelationsMapper;
|
|
|
+ @Resource
|
|
|
+ private HxwVaccineExpertsMapper hxwVaccineExpertsMapper;
|
|
|
+ @Resource
|
|
|
+ private HxwVaccineDetailsMapper hxwVaccineDetailsMapper;
|
|
|
+ @Resource
|
|
|
+ private HxwVaccineDiscussionsMapper hxwVaccineDiscussionsMapper;
|
|
|
+ @Resource
|
|
|
+ private HxwVaccineContentModulesMapper hxwVaccineContentModulesMapper;
|
|
|
+ @Resource
|
|
|
+ private UserMapper userMapper;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private HxwKnowledgeArticlesMapper hxwKnowledgeArticlesMapper;
|
|
|
+ @Override
|
|
|
+ public List<HxwVaccines> findByVaccinesByCategory(VaccinesDto dto) {
|
|
|
+ QueryWrapper<HxwVaccineCategories> wrapper=new QueryWrapper<>();
|
|
|
+ wrapper.eq("name",dto.getName());
|
|
|
+ HxwVaccineCategories hxwVaccineCategories = hxwVaccineCategoriesMapper.selectOne(wrapper);
|
|
|
+ QueryWrapper<HxwVaccines> hxwVaccinesQueryWrapper=new QueryWrapper<>();
|
|
|
+ hxwVaccinesQueryWrapper.eq("category_id",hxwVaccineCategories.getId());
|
|
|
+ List<HxwVaccines> vaccinesList = this.baseMapper.selectList(hxwVaccinesQueryWrapper);
|
|
|
+ return vaccinesList;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public HxwVaccines findByVaccinesDetails(AgesNameDto dto) {
|
|
|
+ QueryWrapper<HxwVaccines> wrapper=new QueryWrapper<>();
|
|
|
+ wrapper.eq("name",dto.getVaccinesName());
|
|
|
+ HxwVaccines hxwVaccines = this.baseMapper.selectOne(wrapper);//疫苗基本信息
|
|
|
+ Integer id = hxwVaccines.getId();//疫苗id
|
|
|
+ if (id!=null){
|
|
|
+ QueryWrapper<HxwVaccineExpertRelations> wrapper1=new QueryWrapper<>();
|
|
|
+ wrapper1.eq("vaccine_id",id);
|
|
|
+ HxwVaccineExpertRelations hxwVaccineExpertRelations = hxwVaccineExpertRelationsMapper.selectOne(wrapper1);
|
|
|
+ Integer expertId = hxwVaccineExpertRelations.getExpertId();//医生 id
|
|
|
+ QueryWrapper<HxwVaccineExperts> wrapper2=new QueryWrapper<>();
|
|
|
+ wrapper2.eq("id",expertId);
|
|
|
+ HxwVaccineExperts hxwVaccineExperts = hxwVaccineExpertsMapper.selectOne(wrapper2);
|
|
|
+ hxwVaccines.setExperts(hxwVaccineExperts);//设置医生信息
|
|
|
+ QueryWrapper<HxwVaccineDetails> wrapper3=new QueryWrapper<>();
|
|
|
+ wrapper3.eq("vaccine_id",id);
|
|
|
+ HxwVaccineDetails hxwVaccineDetails = hxwVaccineDetailsMapper.selectOne(wrapper3);
|
|
|
+ hxwVaccines.setDetails(hxwVaccineDetails);//设置疫苗详情信息
|
|
|
+ QueryWrapper<HxwVaccineDiscussions> wrapper4=new QueryWrapper<>();
|
|
|
+ wrapper4.eq("vaccine_id",id);
|
|
|
+ List<HxwVaccineDiscussions> hxwVaccineDiscussions = hxwVaccineDiscussionsMapper.selectList(wrapper4);
|
|
|
+ for (HxwVaccineDiscussions discussion : hxwVaccineDiscussions){
|
|
|
+ Integer userId = discussion.getUserId();
|
|
|
+ QueryWrapper<User> wrapper5=new QueryWrapper<>();
|
|
|
+ wrapper5.eq("id",userId);
|
|
|
+ User user = userMapper.selectOne(wrapper5);
|
|
|
+ discussion.setUser(user);
|
|
|
+ }
|
|
|
+ hxwVaccines.setDiscussions(hxwVaccineDiscussions);//设置讨论信息
|
|
|
+ QueryWrapper<HxwVaccineContentModules> wrapper5=new QueryWrapper<>();
|
|
|
+ wrapper5.eq("vaccine_id",id);
|
|
|
+ List<HxwVaccineContentModules> hxwVaccineContentModules = hxwVaccineContentModulesMapper.selectList(wrapper5);
|
|
|
+ hxwVaccines.setContentModules(hxwVaccineContentModules);//设置内容模块信息
|
|
|
+ QueryWrapper<HxwKnowledgeArticles> wrapper6=new QueryWrapper<>();
|
|
|
+ wrapper6.eq("related_vaccine_id",id);
|
|
|
+ List<HxwKnowledgeArticles> hxwKnowledgeArticles = hxwKnowledgeArticlesMapper.selectList(wrapper6);
|
|
|
+ hxwVaccines.setArticles(hxwKnowledgeArticles);
|
|
|
+ return hxwVaccines;
|
|
|
+ }else {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<HxwVaccines> findByAdultAll(AgesNameDto dto) {
|
|
|
+ QueryWrapper<HxwVaccineCategories> wrapper = new QueryWrapper<>();
|
|
|
+ wrapper.eq("name",dto.getAgesName());
|
|
|
+ HxwVaccineCategories hxwVaccineCategories = hxwVaccineCategoriesMapper.selectOne(wrapper);
|
|
|
+ if (hxwVaccineCategories != null) {
|
|
|
+ QueryWrapper<HxwVaccines> wrapper1 = new QueryWrapper<>();
|
|
|
+ wrapper1.eq("category_id",hxwVaccineCategories.getId());
|
|
|
+ List<HxwVaccines> list = this.baseMapper.selectList(wrapper1);
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+ return Collections.emptyList();
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|