在service层原本要将所有的字段全部set
NursingProject nursingProject1=new NursingProject();
nursingProject1.setId(nursingProjectDto.getId());
nursingProject1.setId(nursingProjectDto.getId());
nursingProject1.setId(nursingProjectDto.getId());}
为了减少这么多set,我们使用BeanUtil.copyProperties(xxDTO,xxEntity.class)
@Override
public void add(NursingProjectDto nursingProjectDto) {
//对象转换
NursingProject nursingProject= BeanUtil.copyProperties(nursingProjectDto,NursingProject.class);
nursingProjectMapper.insert(nursingProject);
}
如此就好了