File tree Expand file tree Collapse file tree 3 files changed +47
-0
lines changed Expand file tree Collapse file tree 3 files changed +47
-0
lines changed Original file line number Diff line number Diff line change 1+ package com .springboot .jian .controller ;
2+
3+ import com .springboot .jian .service .recordMessage ;
4+ import org .springframework .web .bind .annotation .CrossOrigin ;
5+ import org .springframework .web .bind .annotation .PostMapping ;
6+ import org .springframework .web .bind .annotation .RestController ;
7+
8+ import java .io .IOException ;
9+ import java .util .List ;
10+
11+ @ RestController
12+ public class recordBusiness {
13+ @ CrossOrigin (origins = "http://localhost:5173" )
14+ @ PostMapping (value = "recordBusiness" )
15+ public List <Object > record () throws IOException {
16+ recordMessage recordMessage =new recordMessage ();
17+ return recordMessage .record ();
18+ }
19+ }
Original file line number Diff line number Diff line change 1+ package com .springboot .jian .service ;
2+
3+ import org .apache .ibatis .io .Resources ;
4+ import org .apache .ibatis .session .SqlSession ;
5+ import org .apache .ibatis .session .SqlSessionFactory ;
6+ import org .apache .ibatis .session .SqlSessionFactoryBuilder ;
7+
8+ import java .io .IOException ;
9+ import java .io .InputStream ;
10+ import java .util .List ;
11+
12+ public class recordMessage {
13+ public List <Object > record () throws IOException {
14+ // 创建 SqlSessionFactoryBuilder 对象
15+ SqlSessionFactoryBuilder sqlSessionFactoryBuilder = new SqlSessionFactoryBuilder ();
16+ // 加载 MyBatis 配置文件
17+ InputStream is = Resources .getResourceAsStream ("mybatis-config.xml" );
18+ // 创建 SqlSessionFactory 对象
19+ SqlSessionFactory sqlSessionFactory = sqlSessionFactoryBuilder .build (is );
20+ SqlSession sqlSession = sqlSessionFactory .openSession ();
21+ // 执行查询操作
22+ return sqlSession .selectList ("SelectRecord" );
23+ }
24+ }
Original file line number Diff line number Diff line change 5252 <select id =" SelectUserName" resultType =" java.lang.String" >
5353 select (name) from user;
5454 </select >
55+ <!-- 查询借阅记录-->
56+ <select id =" SelectRecord" resultType =" com.springboot.jian.pojo.BorrowingInformation" >
57+ select * from record;
58+ </select >
5559</mapper >
You can’t perform that action at this time.
0 commit comments