| package com.panzhihua.service_community.service.impl; | 
|   | 
| import java.util.ArrayList; | 
| import java.util.List; | 
|   | 
| import org.springframework.beans.BeanUtils; | 
| import org.springframework.stereotype.Service; | 
|   | 
| import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | 
| import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | 
| import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; | 
| import com.panzhihua.common.model.dtos.vaccines.VaccinesByAdminDTO; | 
| import com.panzhihua.common.model.vos.R; | 
| import com.panzhihua.common.model.vos.vaccines.VaccinesByAppVO; | 
| import com.panzhihua.common.utlis.StringUtils; | 
| import com.panzhihua.service_community.dao.ComMngVaccinesDAO; | 
| import com.panzhihua.service_community.model.dos.ComMngVaccinesDO; | 
| import com.panzhihua.service_community.service.ComMngVaccinesService; | 
|   | 
| import lombok.extern.slf4j.Slf4j; | 
|   | 
| /** | 
|  * @auther lyq | 
|  * @create 2021-05-19 14:17:46 | 
|  * @describe 疫苗分类表服务实现类 | 
|  */ | 
| @Slf4j | 
| @Service | 
| public class ComMngVaccinesServiceImpl extends ServiceImpl<ComMngVaccinesDAO, ComMngVaccinesDO> | 
|     implements ComMngVaccinesService { | 
|   | 
|     /** | 
|      * 小程序-查询疫苗分类列表 | 
|      *  | 
|      * @return 疫苗分类列表 | 
|      */ | 
|     @Override | 
|     public R getVaccinesListByApp() { | 
|         List<ComMngVaccinesDO> vaccinesDOList = this.baseMapper.selectList( | 
|             new QueryWrapper<ComMngVaccinesDO>().lambda().eq(ComMngVaccinesDO::getStatus, ComMngVaccinesDO.status.yes)); | 
|         List<VaccinesByAppVO> vaccinesList = new ArrayList<>(); | 
|         if (!vaccinesDOList.isEmpty()) { | 
|             vaccinesDOList.forEach(vaccines -> { | 
|                 VaccinesByAppVO vaccinesVO = new VaccinesByAppVO(); | 
|                 BeanUtils.copyProperties(vaccines, vaccinesVO); | 
|                 vaccinesList.add(vaccinesVO); | 
|             }); | 
|         } | 
|         return R.ok(vaccinesList); | 
|     } | 
|   | 
|     /** | 
|      * 后台管理-查询疫苗分类列表 | 
|      *  | 
|      * @param vaccinesByAdminDTO | 
|      *            请求参数 | 
|      * @return 疫苗分类列表 | 
|      */ | 
|     @Override | 
|     public R getVaccinesListByAdmin(VaccinesByAdminDTO vaccinesByAdminDTO) { | 
|         return R.ok(this.baseMapper.getVaccinesByName( | 
|             new Page<ComMngVaccinesDO>(vaccinesByAdminDTO.getPageNum(), vaccinesByAdminDTO.getPageSize()), | 
|             vaccinesByAdminDTO)); | 
|     } | 
|   | 
|     /** | 
|      * 修改疫苗分类信息 | 
|      *  | 
|      * @param vaccinesByAdminDTO | 
|      *            请求参数 | 
|      * @return 修改结果 | 
|      */ | 
|     @Override | 
|     public R editVaccinesByAdmin(VaccinesByAdminDTO vaccinesByAdminDTO) { | 
|         ComMngVaccinesDO vaccinesDO = this.baseMapper.selectById(vaccinesByAdminDTO.getId()); | 
|         if (vaccinesDO == null) { | 
|             return R.fail("未找到疫苗分类记录"); | 
|         } | 
|         if (StringUtils.isNotEmpty(vaccinesByAdminDTO.getName())) { | 
|             vaccinesDO.setName(vaccinesByAdminDTO.getName()); | 
|         } | 
|         if (StringUtils.isNotEmpty(vaccinesByAdminDTO.getDescribe())) { | 
|             vaccinesDO.setDescribe(vaccinesByAdminDTO.getDescribe()); | 
|         } | 
|         if (this.baseMapper.updateById(vaccinesDO) > 0) { | 
|             return R.ok(); | 
|         } else { | 
|             return R.fail(); | 
|         } | 
|     } | 
|   | 
|     /** | 
|      * 新增疫苗分类信息 | 
|      *  | 
|      * @param vaccinesByAdminDTO | 
|      *            请求参数 | 
|      * @return 新增结果 | 
|      */ | 
|     @Override | 
|     public R addVaccinesByAdmin(VaccinesByAdminDTO vaccinesByAdminDTO) { | 
|         ComMngVaccinesDO vaccinesDO = new ComMngVaccinesDO(); | 
|         BeanUtils.copyProperties(vaccinesByAdminDTO, vaccinesDO); | 
|         if (this.baseMapper.insert(vaccinesDO) > 0) { | 
|             return R.ok(); | 
|         } else { | 
|             return R.fail(); | 
|         } | 
|     } | 
|   | 
|     /** | 
|      * 删除疫苗分类信息 | 
|      *  | 
|      * @param id | 
|      *            疫苗分类id | 
|      * @return 删除结果 | 
|      */ | 
|     @Override | 
|     public R deleteVaccinesByAdmin(Long id) { | 
|         ComMngVaccinesDO vaccinesDO = this.baseMapper.selectById(id); | 
|         if (vaccinesDO == null) { | 
|             return R.fail("未找到疫苗分类记录"); | 
|         } | 
|   | 
|         if (this.baseMapper.deleteById(id) > 0) { | 
|             return R.ok(); | 
|         } else { | 
|             return R.fail(); | 
|         } | 
|     } | 
|   | 
|     /** | 
|      * 疫苗分类列表 | 
|      *  | 
|      * @return 疫苗分类列表 | 
|      */ | 
|     public R getEnrollTypeListByAdmin() { | 
|         List<ComMngVaccinesDO> vaccinesDOList = this.baseMapper | 
|             .selectList(new QueryWrapper<ComMngVaccinesDO>().lambda().eq(ComMngVaccinesDO::getStatus, 1)); | 
|         return R.ok(vaccinesDOList); | 
|     } | 
|   | 
| } |