
一、在Java编程里, 针对其基本功能模块的日常操作与应用方式。1.单表查询GetMapping(/list) public TableDataInfo list(Student student){ LambdaQueryWrapperStudent lqw new LambdaQueryWrapperStudent(); lqw.eq(Student::getName, student.getName()); lqw.like(Student::getClass,student.getClass()); lqw.between(age,student.getAge1(),student.getAge2()); lqw.orderByAsc(age); ListStudent list studentService.list(lqw); }/list) public TableDataInfo list(Student student){ LambdaQueryWrapperStudent lqw new LambdaQueryWrapperStudent(); lqw.eq(Student::getName, student.getName()); lqw.like(Student::getClass,student.getClass()); lqw.between(age,student.getAge1(),student.getAge2()); lqw.orderByAsc(age); ListStudent list studentService.list(lqw); }对应的sql语句为select * from student where name ? and class like %?% and age between ? and ? order by ? asc* from student where name ? and class like %?% and age between ? and ? order by ? asc1.关于单表查询这一项内容, 其基本的使用方式需要进行详细的了解和分析。函数名说明例子eq等于eq“name”, “张子”这玩意儿转换成标准写法就是, name 等于单引号括起来的字符串‘张子’。ne不等于举例说明, 当执行ne函数并传入参数name以及字符串张子时, 其结果表现为字段名称为name的值不等于字符串值张子。gt大于例gt(“age”,“18”) age18lt小于将“年龄”设定为小于“十八”的条件, 结果转换为“age”。在值1到值2之间例如, 针对像“age”和数字18到30这样的内容,其结果为18。like模糊查询示例的情况是, 当输入的内容为like“name”, “张”的时候, 转换的结果就变成了name like ‘%张%’。字段为NULL当字段的值为名为“name”时, 结果会显示为name是否为空。2、多表查询//Controller GetMapping(/listAndClass) public TableDataInfo listAndClass(Student student) { QueryWrapperStudent qw new QueryWrapperStudent (); if(StringUtils.isNotBlank(student.getName())){ qw.eq(s.name,student.getName()); } if(StringUtils.isNotBlank(student.getClassName())){ qw.like(c.name,student.getClassName()); } startPage(); ListStudent list studentService.listAndClass(qw); return getDataTable(list); } //Service ListStudent listAndClass(QueryWrapperStudent qw); //Service impl Override public ListStudent listAndClass(QueryWrapperStudent qw) { return this.getBaseMapper().listAndClass(qw); } //Mapper Select(select s.*,c.name from student s left join class c on s.id c.student_id ${ew.customSqlSegment}) ListYwSpaqjgDj listAndClass(Param(Constants.WRAPPER) QueryWrapperStudent qw);GetMapping(/listAndClass) public TableDataInfo listAndClass(Student student) { QueryWrapperStudent qw new QueryWrapperStudent (); if(StringUtils.isNotBlank(student.getName())){ qw.eq(s.name,student.getName()); } if(StringUtils.isNotBlank(student.getClassName())){ qw.like(c.name,student.getClassName()); } startPage(); ListStudent list studentService.listAndClass(qw); return getDataTable(list); } //Service ListStudent listAndClass(QueryWrapperStudent qw); //Service impl Override public ListStudent listAndClass(QueryWrapperStudent qw) { return this.getBaseMapper().listAndClass(qw); } //Mapper Select(select s.*,c.name from student s left join class c on s.id c.student_id ${ew.customSqlSegment}) ListYwSpaqjgDj listAndClass(Param(Constants.WRAPPER) QueryWrapperStudent qw);