基础版本完成
This commit is contained in:
		
							
								
								
									
										19
									
								
								book-service/src/main/java/com/test/BookApplication.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								book-service/src/main/java/com/test/BookApplication.java
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,19 @@
 | 
			
		||||
package com.test;
 | 
			
		||||
 | 
			
		||||
import com.apple.eawt.Application;
 | 
			
		||||
import org.springframework.boot.SpringApplication;
 | 
			
		||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * ClassName: BookApplication
 | 
			
		||||
 * Package: com.test
 | 
			
		||||
 *
 | 
			
		||||
 * @author yovinchen
 | 
			
		||||
 * @Create 2023/8/14 16:23
 | 
			
		||||
 */
 | 
			
		||||
@SpringBootApplication
 | 
			
		||||
public class BookApplication {
 | 
			
		||||
    public static void main(String[] args) {
 | 
			
		||||
        SpringApplication.run(BookApplication.class,args);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,28 @@
 | 
			
		||||
package com.test.controller;
 | 
			
		||||
 | 
			
		||||
import com.test.service.BookService;
 | 
			
		||||
import org.springframework.web.bind.annotation.PathVariable;
 | 
			
		||||
import org.springframework.web.bind.annotation.RequestMapping;
 | 
			
		||||
import org.springframework.web.bind.annotation.RestController;
 | 
			
		||||
 | 
			
		||||
import javax.annotation.Resource;
 | 
			
		||||
import java.awt.print.Book;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * ClassName: BookController
 | 
			
		||||
 * Package: com.test.controller
 | 
			
		||||
 *
 | 
			
		||||
 * @author yovinchen
 | 
			
		||||
 * @Create 2023/8/14 17:11
 | 
			
		||||
 */
 | 
			
		||||
@RestController
 | 
			
		||||
public class BookController {
 | 
			
		||||
 | 
			
		||||
    @Resource
 | 
			
		||||
    BookService service;
 | 
			
		||||
 | 
			
		||||
    @RequestMapping("/book/{bid}")
 | 
			
		||||
    Book findBookById(@PathVariable("bid") int bid){
 | 
			
		||||
        return service.getBookById(bid);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										20
									
								
								book-service/src/main/java/com/test/mapper/BookMapper.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										20
									
								
								book-service/src/main/java/com/test/mapper/BookMapper.java
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,20 @@
 | 
			
		||||
package com.test.mapper;
 | 
			
		||||
 | 
			
		||||
import org.apache.ibatis.annotations.Mapper;
 | 
			
		||||
import org.apache.ibatis.annotations.Select;
 | 
			
		||||
 | 
			
		||||
import java.awt.print.Book;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * ClassName: BookMapper
 | 
			
		||||
 * Package: com.test.mapper
 | 
			
		||||
 *
 | 
			
		||||
 * @author yovinchen
 | 
			
		||||
 * @Create 2023/8/14 17:02
 | 
			
		||||
 */
 | 
			
		||||
@Mapper
 | 
			
		||||
public interface BookMapper {
 | 
			
		||||
 | 
			
		||||
    @Select("select * from DB_BOOK where bid = #{bid}")
 | 
			
		||||
    Book getBookById(int bid);
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										14
									
								
								book-service/src/main/java/com/test/service/BookService.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										14
									
								
								book-service/src/main/java/com/test/service/BookService.java
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,14 @@
 | 
			
		||||
package com.test.service;
 | 
			
		||||
 | 
			
		||||
import java.awt.print.Book;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * ClassName: BookService
 | 
			
		||||
 * Package: com.test.service
 | 
			
		||||
 *
 | 
			
		||||
 * @author yovinchen
 | 
			
		||||
 * @Create 2023/8/14 17:03
 | 
			
		||||
 */
 | 
			
		||||
public interface BookService {
 | 
			
		||||
    Book getBookById(int bid);
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,27 @@
 | 
			
		||||
package com.test.service.impl;
 | 
			
		||||
 | 
			
		||||
import com.test.mapper.BookMapper;
 | 
			
		||||
import com.test.service.BookService;
 | 
			
		||||
import org.springframework.stereotype.Service;
 | 
			
		||||
 | 
			
		||||
import javax.annotation.Resource;
 | 
			
		||||
import java.awt.print.Book;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * ClassName: BookServiceImpl
 | 
			
		||||
 * Package: com.test.service.impl
 | 
			
		||||
 *
 | 
			
		||||
 * @author yovinchen
 | 
			
		||||
 * @Create 2023/8/14 17:09
 | 
			
		||||
 */
 | 
			
		||||
@Service
 | 
			
		||||
public class BookServiceImpl implements BookService {
 | 
			
		||||
 | 
			
		||||
    @Resource
 | 
			
		||||
    BookMapper mapper;
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public Book getBookById(int bid) {
 | 
			
		||||
        return mapper.getBookById(bid);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										8
									
								
								book-service/src/main/resources/application.yml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								book-service/src/main/resources/application.yml
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,8 @@
 | 
			
		||||
server:
 | 
			
		||||
  port: 8201
 | 
			
		||||
spring:
 | 
			
		||||
  datasource:
 | 
			
		||||
    driver-class-name: com.mysql.cj.jdbc.Driver
 | 
			
		||||
    url: jdbc:mysql://43.143.164.194:3306/mac
 | 
			
		||||
    username: mac
 | 
			
		||||
    password: mactest
 | 
			
		||||
		Reference in New Issue
	
	Block a user