基础版本完成

This commit is contained in:
2023-08-14 22:45:38 +08:00
commit 5c8439cb7f
28 changed files with 689 additions and 0 deletions

View 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);
}
}

View File

@@ -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);
}
}

View 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);
}

View 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);
}

View File

@@ -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);
}
}

View 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