From b02beccf4567068cb47a3f1181a00039456c872d Mon Sep 17 00:00:00 2001 From: zqy <2522236926@qq.com> Date: 星期三, 06 八月 2025 15:37:20 +0800 Subject: [PATCH] 用户修改姓名和电话同步修改uaid --- zhang-content/src/main/java/com/ruoyi/service/impl/ZfMasterServiceImpl.java | 68 ++++++++++++++++++++++++++++++++++ 1 files changed, 68 insertions(+), 0 deletions(-) diff --git a/zhang-content/src/main/java/com/ruoyi/service/impl/ZfMasterServiceImpl.java b/zhang-content/src/main/java/com/ruoyi/service/impl/ZfMasterServiceImpl.java index 42e82dd..17bc7be 100644 --- a/zhang-content/src/main/java/com/ruoyi/service/impl/ZfMasterServiceImpl.java +++ b/zhang-content/src/main/java/com/ruoyi/service/impl/ZfMasterServiceImpl.java @@ -1,11 +1,18 @@ package com.ruoyi.service.impl; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +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; import org.springframework.stereotype.Service; + +import java.util.List; /** * <p> @@ -16,6 +23,67 @@ * @since 2023-03-12 */ @Service +@Slf4j public class ZfMasterServiceImpl extends ServiceImpl<ZfMasterMapper, ZfMaster> implements ZfMasterService { + @Override + public AjaxResult getMasterInfoByPetId(String pid) { + LambdaQueryWrapper<ZfMaster> lqw = new LambdaQueryWrapper<>(); + lqw.eq(ZfMaster::getPetId,pid); + ZfMaster master = getOne(lqw); + return AjaxResult.success(master); + } + + @Override + public List<ZfMaster> selectByCondition(ZfMaster zfMaster) { + LambdaQueryWrapper<ZfMaster> lambdaQueryWrapper = buildCondition(zfMaster); + List<ZfMaster> list = list(lambdaQueryWrapper); + log.info("杩斿洖鐨勬暟鎹负:{}",list); + 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.getPhoneNo()),ZfMaster::getPhoneNo,zfMaster.getPhoneNo()); + + lqw.like(StringUtils.isNotEmpty(zfMaster.getAddress()),ZfMaster::getAddress,zfMaster.getAddress()); + + return lqw; + } } -- Gitblit v1.9.1