| | |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.domain.ZfMaster; |
| | | import com.ruoyi.domain.ZfPet; |
| | | import com.ruoyi.mapper.ZfMasterMapper; |
| | | import com.ruoyi.service.ZfMasterService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | |
| | | public class ZfMasterServiceImpl extends ServiceImpl<ZfMasterMapper, ZfMaster> implements ZfMasterService { |
| | | |
| | | @Override |
| | | public AjaxResult getMasterInfoByPetId(Long pid) { |
| | | public AjaxResult getMasterInfoByPetId(String pid) { |
| | | LambdaQueryWrapper<ZfMaster> lqw = new LambdaQueryWrapper<>(); |
| | | lqw.eq(ZfMaster::getPetId,pid); |
| | | ZfMaster master = getOne(lqw); |
| | |
| | | return list; |
| | | } |
| | | |
| | | @Override |
| | | public AjaxResult mySave(ZfMaster zfMaster) { |
| | | //判断是否有重复数据 |
| | | LambdaQueryWrapper<ZfMaster> lqw = uniqueCondition(zfMaster); |
| | | List<ZfMaster> list = list(lqw); |
| | | if(list.size()>0){ |
| | | throw new RuntimeException("请勿新增重复数据"); |
| | | } |
| | | |
| | | if(save(zfMaster)){ |
| | | return AjaxResult.success(); |
| | | }else { |
| | | return AjaxResult.error(); |
| | | } |
| | | |
| | | } |
| | | |
| | | private LambdaQueryWrapper<ZfMaster> uniqueCondition(ZfMaster zfMaster) { |
| | | LambdaQueryWrapper<ZfMaster> lqw = new LambdaQueryWrapper<>(); |
| | | lqw.eq(zfMaster.getPetId()!=null,ZfMaster::getPetId,zfMaster.getPetId()); |
| | | lqw.eq(StringUtils.isNotEmpty(zfMaster.getName()),ZfMaster::getName,zfMaster.getName()); |
| | | lqw.eq(StringUtils.isNotEmpty(zfMaster.getCertificateType()),ZfMaster::getCertificateType,zfMaster.getCertificateType()); |
| | | |
| | | lqw.eq(StringUtils.isNotEmpty(zfMaster.getPhoneNo()),ZfMaster::getPhoneNo,zfMaster.getPhoneNo()); |
| | | |
| | | lqw.eq(StringUtils.isNotEmpty(zfMaster.getAddress()),ZfMaster::getAddress,zfMaster.getAddress()); |
| | | |
| | | |
| | | return lqw; |
| | | |
| | | } |
| | | |
| | | private LambdaQueryWrapper<ZfMaster> buildCondition(ZfMaster zfMaster) { |
| | | LambdaQueryWrapper<ZfMaster> lqw = new LambdaQueryWrapper<>(); |
| | | lqw.like(zfMaster.getPetId()!=null,ZfMaster::getPetId,zfMaster.getPetId()); |
| | | lqw.like(StringUtils.isNotEmpty(zfMaster.getName()),ZfMaster::getName,zfMaster.getName()); |
| | | lqw.like(StringUtils.isNotEmpty(zfMaster.getCertificateType()),ZfMaster::getCertificateType,zfMaster.getCertificateType()); |
| | | lqw.like(StringUtils.isNotEmpty(zfMaster.getFixedNo()),ZfMaster::getFixedNo,zfMaster.getFixedNo()); |
| | | |
| | | lqw.like(StringUtils.isNotEmpty(zfMaster.getPhoneNo()),ZfMaster::getPhoneNo,zfMaster.getPhoneNo()); |
| | | lqw.eq(zfMaster.getMany()!=null,ZfMaster::getMany,zfMaster.getMany()); |
| | | |
| | | lqw.like(StringUtils.isNotEmpty(zfMaster.getAddress()),ZfMaster::getAddress,zfMaster.getAddress()); |
| | | lqw.like(StringUtils.isNotEmpty(zfMaster.getProperty()),ZfMaster::getProperty,zfMaster.getProperty()); |
| | | lqw.like(StringUtils.isNotEmpty(zfMaster.getEmail()),ZfMaster::getEmail,zfMaster.getEmail()); |
| | | |
| | | return lqw; |
| | | } |
| | | } |