后端微服务框架初步完成(还没跑起来)
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
package com.cxyxiaomo.epp;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
// 启动类
|
||||
|
||||
@SpringBootApplication
|
||||
public class UserProvider {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(UserProvider.class, args);
|
||||
}
|
||||
}
|
@@ -0,0 +1,32 @@
|
||||
package com.cxyxiaomo.epp.controller;
|
||||
|
||||
import com.cxyxiaomo.epp.pojo.User;
|
||||
import com.cxyxiaomo.epp.service.UserServiceImpl;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
// 提供 restful 服务
|
||||
|
||||
@RestController
|
||||
public class UserController {
|
||||
|
||||
@Autowired
|
||||
private UserServiceImpl userService;
|
||||
|
||||
@PostMapping("/user/add")
|
||||
public boolean addUser(User user) {
|
||||
return userService.addUser(user);
|
||||
}
|
||||
|
||||
@GetMapping("/user/get/{id}")
|
||||
public User getUserById(@PathVariable("id") Long id) {
|
||||
return userService.getUserById(id);
|
||||
}
|
||||
|
||||
@GetMapping("/user/list")
|
||||
public List<User> addUser() {
|
||||
return userService.getUserList();
|
||||
}
|
||||
}
|
@@ -0,0 +1,18 @@
|
||||
package com.cxyxiaomo.epp.dao;
|
||||
|
||||
import com.cxyxiaomo.epp.pojo.User;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
@Repository
|
||||
public interface UserDao {
|
||||
|
||||
public boolean addUser(User user);
|
||||
|
||||
public User getUserById(Long id);
|
||||
|
||||
public List<User> getUserList();
|
||||
}
|
@@ -0,0 +1,14 @@
|
||||
package com.cxyxiaomo.epp.service;
|
||||
|
||||
import com.cxyxiaomo.epp.pojo.User;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface UserService {
|
||||
|
||||
public boolean addUser(User user);
|
||||
|
||||
public User getUserById(Long id);
|
||||
|
||||
public List<User> getUserList();
|
||||
}
|
@@ -0,0 +1,30 @@
|
||||
package com.cxyxiaomo.epp.service;
|
||||
|
||||
import com.cxyxiaomo.epp.dao.UserDao;
|
||||
import com.cxyxiaomo.epp.pojo.User;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class UserServiceImpl implements UserService {
|
||||
|
||||
@Autowired
|
||||
private UserDao userDao;
|
||||
|
||||
@Override
|
||||
public boolean addUser(User user) {
|
||||
return userDao.addUser(user);
|
||||
}
|
||||
|
||||
@Override
|
||||
public User getUserById(Long id) {
|
||||
return userDao.getUserById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<User> getUserList() {
|
||||
return userDao.getUserList();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user