-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
添加借阅记录接口
- Loading branch information
Showing
3 changed files
with
47 additions
and
0 deletions.
There are no files selected for viewing
19 changes: 19 additions & 0 deletions
19
jian/src/main/java/com/springboot/jian/controller/recordBusiness.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.springboot.jian.controller; | ||
|
||
import com.springboot.jian.service.recordMessage; | ||
import org.springframework.web.bind.annotation.CrossOrigin; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import java.io.IOException; | ||
import java.util.List; | ||
|
||
@RestController | ||
public class recordBusiness { | ||
@CrossOrigin(origins = "http://localhost:5173") | ||
@PostMapping(value = "recordBusiness") | ||
public List<Object> record() throws IOException { | ||
recordMessage recordMessage=new recordMessage(); | ||
return recordMessage.record(); | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
jian/src/main/java/com/springboot/jian/service/recordMessage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.springboot.jian.service; | ||
|
||
import org.apache.ibatis.io.Resources; | ||
import org.apache.ibatis.session.SqlSession; | ||
import org.apache.ibatis.session.SqlSessionFactory; | ||
import org.apache.ibatis.session.SqlSessionFactoryBuilder; | ||
|
||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.util.List; | ||
|
||
public class recordMessage { | ||
public List<Object> record() throws IOException { | ||
// 创建 SqlSessionFactoryBuilder 对象 | ||
SqlSessionFactoryBuilder sqlSessionFactoryBuilder = new SqlSessionFactoryBuilder(); | ||
// 加载 MyBatis 配置文件 | ||
InputStream is = Resources.getResourceAsStream("mybatis-config.xml"); | ||
// 创建 SqlSessionFactory 对象 | ||
SqlSessionFactory sqlSessionFactory = sqlSessionFactoryBuilder.build(is); | ||
SqlSession sqlSession = sqlSessionFactory.openSession(); | ||
// 执行查询操作 | ||
return sqlSession.selectList("SelectRecord"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters