zqy
2025-06-22 148e5c84e87e594c0711bdf8476f5b8b2cc3170b
zhang-content/src/main/java/com/ruoyi/service/impl/MarrySelfServiceImpl.java
@@ -8,11 +8,14 @@
import com.ruoyi.common.utils.bean.BeanUtils;
import com.ruoyi.domain.MarrySelf;
import com.ruoyi.domain.MarryUser;
import com.ruoyi.domain.ZInfoUser;
import com.ruoyi.domain.dto.MarryInfoDto;
import com.ruoyi.domain.dto.MarryUserDto;
import com.ruoyi.mapper.MarrySelfMapper;
import com.ruoyi.service.MarrySelfService;
import com.ruoyi.service.MarryUserService;
import com.ruoyi.service.ZInfoUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
@@ -31,8 +34,12 @@
    @Resource
    MarryUserService marryUserService;
//    @Resource
//    MarrySelfService marrySelfService;
    @Override
    public AjaxResult getInfo() {
@@ -46,9 +53,6 @@
        MarrySelf myself = getOne(marrySelfLQW);
        if(myself == null){
            MarrySelf marryInfoDto=new MarrySelf();
            marryInfoDto.setUid(userId);
            save(marryInfoDto);
            throw new RuntimeException("请先编辑信息");
        }
@@ -72,30 +76,35 @@
    }
    @Override
    public AjaxResult updateData(MarryInfoDto marryInfoDto) {
    public Boolean updateData(MarryInfoDto marryInfoDto) {
        SysUser user = SecurityUtils.getLoginUser().getUser();
        Long userId = user.getUserId();
//        SysUser user = SecurityUtils.getLoginUser().getUser();
//        Long userId = user.getUserId();
        MarrySelf marrySelf = new MarrySelf();
        BeanUtils.copyProperties(marryInfoDto,marrySelf);
        marrySelf.setUid(userId);
        marrySelf.setUid(marryInfoDto.getUid());
        //先查询数据库中有没有本用户的数据
        LambdaQueryWrapper<MarrySelf> lqw = new LambdaQueryWrapper<>();
        lqw.eq(MarrySelf::getUid,userId);
        lqw.eq(MarrySelf::getUid,marryInfoDto.getUid());
        List<MarrySelf> list = list(lqw);
        if(list.isEmpty()){
            //如果是空的,那就是新增
            save(marrySelf);
        }else {
            //否则就是修改
            marrySelf.setId(list.get(0).getId());
            updateById(marrySelf);
        }
        return AjaxResult.success();
        return true;
    }
}