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