feature(demo): 新增查询学生表

This commit is contained in:
ClovertaTheTrilobita 2025-07-01 02:41:42 +08:00
parent d6c06d1f06
commit b2960541ba
4 changed files with 15 additions and 0 deletions

View file

@ -52,4 +52,9 @@ public class DemoController {
)); ));
} }
} }
@GetMapping("/search")
public List<Student> searchById(@RequestParam int id) {
return studentService.findById(id);
}
} }

View file

@ -11,4 +11,6 @@ public interface StudentMapper {
List<Student> findAll(); List<Student> findAll();
void insert(Student student); void insert(Student student);
List<Student> findById(int id);
} }

View file

@ -29,4 +29,8 @@ public class StudentService {
studentMapper.insert(student); studentMapper.insert(student);
return true; return true;
} }
public List<Student> findById(int id) {
return studentMapper.findById(id);
}
} }

View file

@ -14,4 +14,8 @@
#{name}, #{email}, #{phone} #{name}, #{email}, #{phone}
) )
</insert> </insert>
<select id="findById" resultType="Student" parameterType="int">
SELECT * FROM student WHERE id=#{id};
</select>
</mapper> </mapper>