LambdaQueryWrapper<ProjectBean> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.ne(ProjectBean::getProjectId, projectId);
queryWrapper.eq(ProjectBean::getProjectOrgId, orgId);
List<String> fieldList = new ArrayList<>();
fieldList.add("PROJECT_NAME");
queryWrapper.select(ProjectBean.class,i -> fieldList.contains(i.getColumn()));
List<ProjectBean> projectBeanList = projectMapper.selectList(queryWrapper);
log.info("projectBeanList = {}",JSON.toJSONString(projectBeanList));
[
{
"projectId": "1004",
"projectName": "aaaa"
},
{
"projectId": "10166",
"projectName": "bbbb"
},
{
"projectId": "10170",
"projectName": "cccc"
}
]
结论:
1、主键应该不需要指定,默认返回
2、指定列时,使用的是数据库的字段名称,而非属性名称,例如PROJECT_NAME