zxl
2025-03-14 23b688e436a89845e92d861adb5875e625e90d9f
business/src/main/java/com/ycl/service/impl/ProjectInvestmentFundingServiceImpl.java
@@ -1,7 +1,12 @@
package com.ycl.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
import com.ycl.common.utils.SecurityUtils;
import com.ycl.domain.entity.ProjectInvestmentFunding;
import com.ycl.domain.entity.ProjectInvestmentInfo;
import com.ycl.domain.vo.ProjectInvestmentInfoVO;
import com.ycl.mapper.ProjectInvestmentFundingMapper;
import com.ycl.service.ProjectInvestmentFundingService;
import com.ycl.common.base.Result;
@@ -38,8 +43,12 @@
    @Override
    public Result add(ProjectInvestmentFundingForm form) {
        ProjectInvestmentFunding entity = ProjectInvestmentFundingForm.getEntityByForm(form, null);
        Long userId = SecurityUtils.getUserId();
        entity.setCreateBy(userId);
        entity.setUpdateBy(userId);
        baseMapper.insert(entity);
        return Result.ok("添加成功");
        //避免新增一个后重复新增返回id给前端判断
        return Result.ok("添加成功").data(entity.getId());
    }
    /**
@@ -54,6 +63,8 @@
        // 为空抛IllegalArgumentException,做全局异常处理
        Assert.notNull(entity, "记录不存在");
        BeanUtils.copyProperties(form, entity);
        Long userId = SecurityUtils.getUserId();
        entity.setUpdateBy(userId);
        baseMapper.updateById(entity);
        return Result.ok("修改成功");
    }
@@ -99,8 +110,13 @@
     */
    @Override
    public Result detail(Integer id) {
        ProjectInvestmentFundingVO vo = baseMapper.getById(id);
        Assert.notNull(vo, "记录不存在");
        ProjectInvestmentFunding entity = new LambdaQueryChainWrapper<>(baseMapper)
                .eq(ProjectInvestmentFunding::getProjectId, id)
                .one();
        ProjectInvestmentFundingVO vo =new ProjectInvestmentFundingVO();
        if(entity!=null){
            vo = ProjectInvestmentFundingVO.getVoByEntity(entity, null);
        }
        return Result.ok().data(vo);
    }