发表于: 2019-12-07 20:17:57
1 1074
一、今天完成的事
后台-用户管理
package com.jnshu.student.controller;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.jnshu.model.Student;
import com.jnshu.student.service.WebStudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* @author Admin
* @PackageName com.jnshu.academyctrlwebclient.controller
* @ClassName ctrl
* @Description
* @create 2019-11-30 17:58
*/
@RestController
@RequestMapping("/student/a")
public class WebStudentController {
@Autowired
WebStudentService webStudentService;
/**
* 学生列表
* @param start
* @param size
* @return
*/
@GetMapping(value = "/u/studentList")
private PageInfo<Student> getStudentList(@RequestParam(value = "start", defaultValue = "0") int start,
@RequestParam(value = "size", defaultValue = "10") int size, Student student){
PageHelper.startPage(start,size);
List<Student> studentList = webStudentService.studentList(student);
return new PageInfo<>(studentList);
}
/**
* 学生详情
* @return
* @throws Exception
*/
@GetMapping(value = "/u/student")
private Student getStudent(Long id)throws Exception {
return webStudentService.selectStudent(id);
}
/**
* 修改状态
* @param status
* @param id
* @return
*/
@PutMapping(value = "/u/setStatus")
private boolean setStatus(int status,Long id){
return webStudentService.setStatus(status, id);
}
}
数据库修改了几个字段
area现在不分area_province和area_city
通过模糊查询获取信息
二、遇到的问题
三、收获
<scirpt>
select id,name,email,phone,beans_amount,grade,area_province,area_city,status from student where 1=1
<if test="id != null">and id=#{id}</if>
<if test="name != null">and name=#{name}</if>
<if test="email != null">and email=#{email}</if>
<if test="phone != null">and phone=#{phone}</if>
<if test="beans_amout_min">and beans_amout_min=#{beans_amout_min}</if>
<if test="beans_amout_max">and beans_amout_max=#{beans_amout_max}</if>
<if test="area != null">and area like #{area}</if>
<if test="grade != null">and grade=#{grade}</if>
<if test="status != nulll">and status=#{status}</if>
</script>
模糊查询(sql拼接字符串)
标准模糊查询
select * from student where area like '%湖北省%'
模糊查询test
select * from student where area like CONCAT(CONCAT('%',#{area},'%'))
程序中动态模糊查询
<if test=\"area != null\">and area like CONCAT(CONCAT('%',#{area},'%'))</if>\n
四、明天的计划
修改程序,排除可能出现的bug
评论