| | |
| | | package com.ruoyi.service.impl; |
| | | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.utils.MapUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.domain.ZfPetNote; |
| | | import com.ruoyi.mapper.ZfPetNoteMapper; |
| | | import com.ruoyi.service.ZfPetNoteService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | * @since 2023-03-12 |
| | | */ |
| | | @Service |
| | | @Slf4j |
| | | public class ZfPetNoteServiceImpl extends ServiceImpl<ZfPetNoteMapper, ZfPetNote> implements ZfPetNoteService { |
| | | |
| | | @Override |
| | | public AjaxResult selectPetNoteList(ZfPetNote zfPetNote, Integer pageNum, Integer pageSize) { |
| | | LambdaQueryWrapper<ZfPetNote> lqw = buildCondition(zfPetNote); |
| | | Page<ZfPetNote> ZfPetNotePage = new Page<>(pageNum,pageSize); |
| | | Page<ZfPetNote> pageResult = page(ZfPetNotePage, lqw); |
| | | HashMap<String, Object> data = MapUtils.getResult(pageResult); |
| | | return AjaxResult.success(data); |
| | | } |
| | | |
| | | @Override |
| | | public List<ZfPetNote> selectByCondition(ZfPetNote zfPetNote) { |
| | | LambdaQueryWrapper<ZfPetNote> lambdaQueryWrapper = buildCondition(zfPetNote); |
| | | List<ZfPetNote> list = list(lambdaQueryWrapper); |
| | | log.info("返回的数据为:{}",list); |
| | | return list; |
| | | } |
| | | |
| | | @Override |
| | | public AjaxResult getAllPetNoteByPetId(Long pid) { |
| | | LambdaQueryWrapper<ZfPetNote> lqw = new LambdaQueryWrapper<>(); |
| | | lqw.eq(ZfPetNote::getPid,pid); |
| | | List<ZfPetNote> list = list(lqw); |
| | | return AjaxResult.success(list); |
| | | } |
| | | |
| | | private LambdaQueryWrapper<ZfPetNote> buildCondition(ZfPetNote zfPetNote) { |
| | | LambdaQueryWrapper<ZfPetNote> lqw = new LambdaQueryWrapper<>(); |
| | | lqw.like(StringUtils.isNotEmpty(zfPetNote.getTitle()),ZfPetNote::getTitle,zfPetNote.getTitle()); |
| | | lqw.like(zfPetNote.getCreateTime()!=null,ZfPetNote::getCreateTime,zfPetNote.getCreateTime()); |
| | | lqw.like(zfPetNote.getRemindTime()!=null,ZfPetNote::getRemindTime,zfPetNote.getRemindTime()); |
| | | lqw.like(StringUtils.isNotEmpty(zfPetNote.getRemark()),ZfPetNote::getRemark,zfPetNote.getRemark()); |
| | | return lqw; |
| | | } |
| | | } |