Entity、Dao、Service、Controller、application.yml、pom.xml
Entity
Dao
Service
实现接口Impl
package com.guoxinn.demo.Service.ServiceImpl;
import com.guoxinn.demo.Entity.User;
import com.guoxinn.demo.Service.UserService;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
@Service
public class UserServiceImpl implements UserService {
@Override
public boolean login(User user) {
String username = user.getUsername();
String password = user.getPassword();
if(username.equals("king") && password.equals("123")){
return true;
}
return false;
}
@Override
public List<User> getList() {
User user1= new User("king1","12345");
User user2 = new User("king2","12345");
User user3 = new User("king3","12345");
List<User> list = new ArrayList<>();
list.add(user1);
list.add(user2);
list.add(user3);
return list;
}
}
Controller
package com.guoxinn.demo.Controller;
import com.guoxinn.demo.Entity.User;
import com.guoxinn.demo.Interce.TokenUtil;
import com.guoxinn.demo.Service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import java.util.HashMap;