mybatis-plus的EntityWrapper拼接sql并按照设置的column返回对应的字段

程序框架spring-boot

拼接sql,注意or语句的写法

@Service
public class StudentsMainServiceImpl extends ServiceImpl<StudentsMainDao, StudentsMain> implements StudentsMainService {
	@Autowired
	StudentsMainDao studentsMainDao;
	@Override
	public List<Map<String,Object>> matchStudents(Map<String, Object> params) {
		String phone = params.get("fdUserCode").toString();
		EntityWrapper<StudentsMain> wrapper = new EntityWrapper();
		wrapper.setSqlSelect("FD_NO","STUDENT_NAME","NOW_GRADE","FD_ID");
		wrapper.like("FATHER_MOBILE", phone).or().like("MOTHER_MOBILE", phone);
		List<Map<String,Object>> reList = this.selectMaps(wrapper);
		return reList;
	}

接口测试返回的结果

{
    "msg": "查询成功",
    "code": 0,
    "data": "[{\"NOW_GRADE\":\"初中三年级                \",\"FD_ID\":\"1\",\"FD_NO\":\"00001\",\"STUDENT_NAME\":\"张晓\"},{\"NOW_GRADE\":\"高中一年级\",\"FD_ID\":\"2\",\"FD_NO\":null,\"STUDENT_NAME\":\"萨克森\"}]"
}

后台打印的sql

但是之前经历了一点我还没有搞明白

@Service
public class StudentsMainServiceImpl extends ServiceImpl<StudentsMainDao, StudentsMain> implements StudentsMainService {
	@Autowired
	StudentsMainDao studentsMainDao;
	@Override
	public List<StudentsMain> matchStudents(Map<String, Object> params) {
		String phone = params.get("fdUserCode").toString();
		EntityWrapper<StudentsMain> wrapper = new EntityWrapper();
		wrapper.setSqlSelect("FD_NO","STUDENT_NAME","NOW_GRADE","FD_ID");
		wrapper.like("FATHER_MOBILE", phone).or().like("MOTHER_MOBILE", phone);
		List<StudentsMain> reList = this.selectList(wrapper);
		return reList;
	}

	
}

虽然设置了要返回的字段属性

但是接口测试返回的是:

{
    "msg": "查询成功",
    "code": 0,
    "data": "[{\"fatherName\":\"\",\"fdTeacherChargeId\":\"\",\"fdSex\":\"\",\"fdGrade\":\"\",\"fdRemark\":\"\",\"fdStatus\":0,\"fdCreateTime\":null,\"fdBirthday\":\"\",\"fatherMobile\":\"\",\"fdCustId\":\"\",\"fdCreateId\":\"\",\"fdId\":\"1\",\"fdSchoolidId\":\"\",\"fdPublicClass\":\"\",\"nowGrade\":\"初中三年级\",\"fdPublicSchool\":\"\",\"motherMobile\":\"\",\"motherName\":\"\",\"fdAge\":0,\"fdAlterTime\":null,\"fdNo\":\"00001\",\"informationOrigin\":\"\",\"fdCustMobile\":\"\",\"fdCustName\":\"\",\"studentName\":\"张晓\",\"fdAlterId\":\"\"},{\"fatherName\":\"\",\"fdTeacherChargeId\":\"\",\"fdSex\":\"\",\"fdGrade\":\"\",\"fdRemark\":\"\",\"fdStatus\":0,\"fdCreateTime\":null,\"fdBirthday\":\"\",\"fatherMobile\":\"\",\"fdCustId\":\"\",\"fdCreateId\":\"\",\"fdId\":\"2\",\"fdSchoolidId\":\"\",\"fdPublicClass\":\"\",\"nowGrade\":\"高中一年级\",\"fdPublicSchool\":\"\",\"motherMobile\":\"\",\"motherName\":\"\",\"fdAge\":0,\"fdAlterTime\":null,\"fdNo\":\"\",\"informationOrigin\":\"\",\"fdCustMobile\":\"\",\"fdCustName\":\"\",\"studentName\":\"萨克森\",\"fdAlterId\":\"\"}]"
}

也就是说它把所有字段都返回了,后台打印的sql

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

菜鸟茜

随多随少随你心意^-^

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值