基础版本完成
This commit is contained in:
		
							
								
								
									
										18
									
								
								user-service/src/main/java/com/test/UserApplication.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								user-service/src/main/java/com/test/UserApplication.java
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,18 @@
 | 
			
		||||
package com.test;
 | 
			
		||||
 | 
			
		||||
import org.springframework.boot.SpringApplication;
 | 
			
		||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * ClassName: UserApplication
 | 
			
		||||
 * Package: com.test
 | 
			
		||||
 *
 | 
			
		||||
 * @author yovinchen
 | 
			
		||||
 * @Create 2023/8/14 16:26
 | 
			
		||||
 */
 | 
			
		||||
@SpringBootApplication
 | 
			
		||||
public class UserApplication {
 | 
			
		||||
    public static void main(String[] args) {
 | 
			
		||||
        SpringApplication.run(UserApplication.class, args);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,29 @@
 | 
			
		||||
package com.test.controller;
 | 
			
		||||
 | 
			
		||||
import com.test.entity.User;
 | 
			
		||||
import com.test.service.UserService;
 | 
			
		||||
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;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * ClassName: UserController
 | 
			
		||||
 * Package: com.test.controller
 | 
			
		||||
 *
 | 
			
		||||
 * @author yovinchen
 | 
			
		||||
 * @Create 2023/8/14 17:08
 | 
			
		||||
 */
 | 
			
		||||
@RestController
 | 
			
		||||
public class UserController {
 | 
			
		||||
 | 
			
		||||
    @Resource
 | 
			
		||||
    UserService service;
 | 
			
		||||
 | 
			
		||||
    //这里以RESTFul风格为例
 | 
			
		||||
    @RequestMapping("/user/{uid}")
 | 
			
		||||
    public User findUserById(@PathVariable("uid") int uid) {
 | 
			
		||||
        return service.getUserById(uid);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										18
									
								
								user-service/src/main/java/com/test/mapper/UserMapper.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								user-service/src/main/java/com/test/mapper/UserMapper.java
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,18 @@
 | 
			
		||||
package com.test.mapper;
 | 
			
		||||
 | 
			
		||||
import com.test.entity.User;
 | 
			
		||||
import org.apache.ibatis.annotations.Mapper;
 | 
			
		||||
import org.apache.ibatis.annotations.Select;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * ClassName: UserMapper
 | 
			
		||||
 * Package: com.test.mapper
 | 
			
		||||
 *
 | 
			
		||||
 * @author yovinchen
 | 
			
		||||
 * @Create 2023/8/14 17:04
 | 
			
		||||
 */
 | 
			
		||||
@Mapper
 | 
			
		||||
public interface UserMapper {
 | 
			
		||||
    @Select("select * from DB_USER where uid = #{uid}")
 | 
			
		||||
    User getUserById(int uid);
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										14
									
								
								user-service/src/main/java/com/test/service/UserService.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										14
									
								
								user-service/src/main/java/com/test/service/UserService.java
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,14 @@
 | 
			
		||||
package com.test.service;
 | 
			
		||||
 | 
			
		||||
import com.test.entity.User;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * ClassName: UserService
 | 
			
		||||
 * Package: com.test.service
 | 
			
		||||
 *
 | 
			
		||||
 * @author yovinchen
 | 
			
		||||
 * @Create 2023/8/14 17:05
 | 
			
		||||
 */
 | 
			
		||||
public interface UserService {
 | 
			
		||||
    User getUserById(int uid);
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,27 @@
 | 
			
		||||
package com.test.service.impl;
 | 
			
		||||
 | 
			
		||||
import com.test.entity.User;
 | 
			
		||||
import com.test.mapper.UserMapper;
 | 
			
		||||
import com.test.service.UserService;
 | 
			
		||||
import org.springframework.stereotype.Service;
 | 
			
		||||
 | 
			
		||||
import javax.annotation.Resource;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * ClassName: UserServiceImpl
 | 
			
		||||
 * Package: com.test.service.impl
 | 
			
		||||
 *
 | 
			
		||||
 * @author yovinchen
 | 
			
		||||
 * @Create 2023/8/14 17:07
 | 
			
		||||
 */
 | 
			
		||||
@Service
 | 
			
		||||
public class UserServiceImpl implements UserService {
 | 
			
		||||
 | 
			
		||||
    @Resource
 | 
			
		||||
    UserMapper mapper;
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public User getUserById(int uid) {
 | 
			
		||||
        return mapper.getUserById(uid);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										8
									
								
								user-service/src/main/resources/application.yml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								user-service/src/main/resources/application.yml
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,8 @@
 | 
			
		||||
server:
 | 
			
		||||
  port: 8101
 | 
			
		||||
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