// Path: src/main/java/co/lilpilot/blog/model/User.java
// @Data
// @Entity
// public class User extends BaseModel {
//     @ApiModelProperty(value = "用户名")
//     private String username;
//     @ApiModelProperty(value = "密码（md5）")
//     private String passwordHashed;
//     @ApiModelProperty(value = "角色")
//     private String role;
// }
// 
// Path: src/main/java/co/lilpilot/blog/service/UserService.java
// @Service
// public class UserService {
// 
//     @Autowired
//     private UserRepository userRepository;
// 
//     public User createUser(String username, String password) {
//         if (StringUtils.isEmpty(username) || StringUtils.isEmpty(password)) {
//             throw new IllegalArgumentException("username or password is empty");
//         }
//         User user = new User();
//         user.setUsername(username);
//         user.setPasswordHashed(new BCryptPasswordEncoder().encode(password));
//         user.setRole("ADMIN");
//         return saveOrUpdate(user);
//     }
// 
//     public User saveOrUpdate(User user) {
//         if (user == null) {
//             throw new IllegalArgumentException("user is null");
//         }
//         return userRepository.save(user);
//     }
// 
//     public User getByUsername(String username) {
//         if (Strings.isNullOrEmpty(username)) {
//             throw new IllegalArgumentException("username is empty");
//         }
//         return userRepository.findByUsername(username);
//     }
// }


import co.lilpilot.blog.model.User;
import co.lilpilot.blog.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.authority.AuthorityUtils;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service;
package co.lilpilot.blog.security;


/**
 * Created by lilpilot on 2017/5/2.
 */
@Service
public class CustomUserDetailsService implements UserDetailsService {

    @Autowired
// Path: src/main/java/co/lilpilot/blog/model/User.java
// @Data
// @Entity
// public class User extends BaseModel {
//     @ApiModelProperty(value = "用户名")
//     private String username;
//     @ApiModelProperty(value = "密码（md5）")
//     private String passwordHashed;
//     @ApiModelProperty(value = "角色")
//     private String role;
// }
// 
// Path: src/main/java/co/lilpilot/blog/service/UserService.java
// @Service
// public class UserService {
// 
//     @Autowired
//     private UserRepository userRepository;
// 
//     public User createUser(String username, String password) {
//         if (StringUtils.isEmpty(username) || StringUtils.isEmpty(password)) {
//             throw new IllegalArgumentException("username or password is empty");
//         }
//         User user = new User();
//         user.setUsername(username);
//         user.setPasswordHashed(new BCryptPasswordEncoder().encode(password));
//         user.setRole("ADMIN");
//         return saveOrUpdate(user);
//     }
// 
//     public User saveOrUpdate(User user) {
//         if (user == null) {
//             throw new IllegalArgumentException("user is null");
//         }
//         return userRepository.save(user);
//     }
// 
//     public User getByUsername(String username) {
//         if (Strings.isNullOrEmpty(username)) {
//             throw new IllegalArgumentException("username is empty");
//         }
//         return userRepository.findByUsername(username);
//     }
// }


// Path: src/main/java/co/lilpilot/blog/security/CustomUserDetailsService.java
import co.lilpilot.blog.model.User;
import co.lilpilot.blog.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.authority.AuthorityUtils;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service;

package co.lilpilot.blog.security;


/**
 * Created by lilpilot on 2017/5/2.
 */
@Service
public class CustomUserDetailsService implements UserDetailsService {

    @Autowired
    private UserService userService;