| | |
| | | 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.ProjectInvestmentInfo; |
| | | import com.ycl.domain.entity.ProjectUnitRegistrationInfo; |
| | | import com.ycl.domain.vo.ProjectInvestmentInfoVO; |
| | | import com.ycl.mapper.ProjectUnitRegistrationInfoMapper; |
| | | import com.ycl.service.ProjectUnitRegistrationInfoService; |
| | | import com.ycl.common.base.Result; |
| | |
| | | |
| | | /** |
| | | * 添加 |
| | | * |
| | | * @param form |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Result add(ProjectUnitRegistrationInfoForm form) { |
| | | ProjectUnitRegistrationInfo entity = ProjectUnitRegistrationInfoForm.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()); |
| | | } |
| | | |
| | | /** |
| | | * 修改 |
| | | * |
| | | * @param form |
| | | * @return |
| | | */ |
| | |
| | | // 为空抛IllegalArgumentException,做全局异常处理 |
| | | Assert.notNull(entity, "记录不存在"); |
| | | BeanUtils.copyProperties(form, entity); |
| | | Long userId = SecurityUtils.getUserId(); |
| | | entity.setUpdateBy(userId); |
| | | baseMapper.updateById(entity); |
| | | return Result.ok("修改成功"); |
| | | } |
| | | |
| | | /** |
| | | * 批量删除 |
| | | * |
| | | * @param ids |
| | | * @return |
| | | */ |
| | |
| | | |
| | | /** |
| | | * id删除 |
| | | * |
| | | * @param id |
| | | * @return |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 分页查询 |
| | | * |
| | | * @param query |
| | | * @return |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 根据id查找 |
| | | * |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Result detail(Integer id) { |
| | | ProjectUnitRegistrationInfoVO vo = baseMapper.getById(id); |
| | | Assert.notNull(vo, "记录不存在"); |
| | | ProjectUnitRegistrationInfo entity = new LambdaQueryChainWrapper<>(baseMapper) |
| | | .eq(ProjectUnitRegistrationInfo::getProjectId, id) |
| | | .one(); |
| | | ProjectUnitRegistrationInfoVO vo = new ProjectUnitRegistrationInfoVO(); |
| | | if (entity != null) { |
| | | vo = ProjectUnitRegistrationInfoVO.getVoByEntity(entity, null); |
| | | } |
| | | return Result.ok().data(vo); |
| | | } |
| | | |
| | | /** |
| | | * 列表 |
| | | * |
| | | * @return |
| | | */ |
| | | @Override |
| | |
| | | .collect(Collectors.toList()); |
| | | return Result.ok().data(vos); |
| | | } |
| | | |
| | | @Override |
| | | public Result getUnitRegistrationInfoByName(String name) { |
| | | List<ProjectUnitRegistrationInfo> entity = new LambdaQueryChainWrapper<>(baseMapper) |
| | | .like(ProjectUnitRegistrationInfo::getProjectUnit,name) |
| | | .list(); |
| | | return Result.ok().data(entity); |
| | | } |
| | | } |