| | |
| | | import com.ruoyi.common.utils.MapUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.domain.ZfDoctor; |
| | | import com.ruoyi.domain.ZfPet; |
| | | import com.ruoyi.mapper.ZfDoctorMapper; |
| | | import com.ruoyi.service.ZfDoctorService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | |
| | | @Override |
| | | public AjaxResult selectDoctorList(ZfDoctor zfDoctor, Integer pageNum, Integer pageSize) { |
| | | LambdaQueryWrapper<ZfDoctor> lqw = buildCondition(zfDoctor); |
| | | lqw.orderByDesc(ZfDoctor::getId); |
| | | lqw.orderByDesc(ZfDoctor::getCreateTime); |
| | | |
| | | Page<ZfDoctor> ZfDoctorPage = new Page<>(pageNum,pageSize); |
| | | Page<ZfDoctor> pageResult = page(ZfDoctorPage, lqw); |
| | |
| | | @Override |
| | | public List<ZfDoctor> selectByCondition(ZfDoctor zfDoctor) { |
| | | LambdaQueryWrapper<ZfDoctor> lambdaQueryWrapper = buildCondition(zfDoctor); |
| | | lambdaQueryWrapper.orderByDesc(ZfDoctor::getCreateTime); |
| | | List<ZfDoctor> list = list(lambdaQueryWrapper); |
| | | log.info("返回的数据为:{}",list); |
| | | return list; |
| | | } |
| | | |
| | | @Override |
| | | public AjaxResult mySave(ZfDoctor zfDoctor) { |
| | | //判断是否有重复数据 |
| | | LambdaQueryWrapper<ZfDoctor> lqw = uniqueCondition(zfDoctor); |
| | | List<ZfDoctor> list = list(lqw); |
| | | if(list.size()>0){ |
| | | throw new RuntimeException("请勿新增重复数据"); |
| | | } |
| | | |
| | | if(save(zfDoctor)){ |
| | | return AjaxResult.success(); |
| | | }else { |
| | | return AjaxResult.error(); |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | private LambdaQueryWrapper<ZfDoctor> uniqueCondition(ZfDoctor zfDoctor) { |
| | | LambdaQueryWrapper<ZfDoctor> lqw = new LambdaQueryWrapper<>(); |
| | | lqw.eq(StringUtils.isNotEmpty(zfDoctor.getType()),ZfDoctor::getType,zfDoctor.getType()); |
| | | lqw.eq(StringUtils.isNotEmpty(zfDoctor.getSymptom()),ZfDoctor::getSymptom,zfDoctor.getSymptom()); |
| | | lqw.eq(StringUtils.isNotEmpty(zfDoctor.getDuration()),ZfDoctor::getDuration,zfDoctor.getDuration()); |
| | | lqw.eq(StringUtils.isNotEmpty(zfDoctor.getCmedical()),ZfDoctor::getCmedical,zfDoctor.getCmedical()); |
| | | lqw.eq(StringUtils.isNotEmpty(zfDoctor.getWmedical()),ZfDoctor::getWmedical,zfDoctor.getWmedical()); |
| | | lqw.eq(StringUtils.isNotEmpty(zfDoctor.getEffect()),ZfDoctor::getEffect,zfDoctor.getEffect()); |
| | | lqw.eq(StringUtils.isNotEmpty(zfDoctor.getSuitable()),ZfDoctor::getSuitable,zfDoctor.getSuitable()); |
| | | lqw.eq(StringUtils.isNotEmpty(zfDoctor.getRemark()),ZfDoctor::getRemark,zfDoctor.getRemark()); |
| | | return lqw; |
| | | |
| | | } |
| | | |
| | | private LambdaQueryWrapper<ZfDoctor> buildCondition(ZfDoctor zfDoctor) { |
| | | LambdaQueryWrapper<ZfDoctor> lqw = new LambdaQueryWrapper<>(); |
| | | lqw.like(StringUtils.isNotEmpty(zfDoctor.getType()),ZfDoctor::getType,zfDoctor.getType()); |