本文整理汇总了Java中hello.data.User类的典型用法代码示例。如果您正苦于以下问题:Java User类的具体用法?Java User怎么用?Java User使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
User类属于hello.data包,在下文中一共展示了User类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: changeEnableField
import hello.data.User; //导入依赖的package包/类
@Override
public User changeEnableField(Integer id) {
User user = repository.findById(id);
if(user.isEnable()){
user.setEnable(false);
// user.setRoles(null);
} else {
user.setEnable(true);
// Role role = roleRepository.findById(1);
// Set<Role> roles =new HashSet<Role>();
// roles.add(role);
// user.setRoles(roles);
}
updateUser(user);
return user;
}
示例2: saveUser
import hello.data.User; //导入依赖的package包/类
@Override
public User saveUser(User user) {
Role role = roleRepository.findById(1);
Set<Role> roles =new HashSet<Role>();
roles.add(role);
user.setRoles(roles);
user.setEnable(true);
User user1 = repository.save(user);
Profile profile = new Profile();
profile.setUser(user);
profileRepository.save(profile);
user1.setProfile(profile);
return user1;
}
示例3: loadUserByUsername
import hello.data.User; //导入依赖的package包/类
@Override
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
User user = userRepository.findByLogin(username);
if (user == null) {
throw new UsernameNotFoundException(String.format("User %s does not exist!", username));
}
return new UserRepositoryUsersDetails(user);
}
示例4: updateProfile
import hello.data.User; //导入依赖的package包/类
@RequestMapping(value = "/update", method = RequestMethod.POST)
public Profile updateProfile(@RequestBody Profile profile,@AuthenticationPrincipal User user) throws IOException {
Profile profile1 = user.getProfile();
profile1.setAvatar(profile.getAvatar());
profile1.setBirthday(profile.getBirthday());
profile1.setCity(profile.getCity());
profile1.setCountry(profile.getCountry());
profile1.setFirstName(profile.getFirstName());
profile1.setSecondName(profile.getSecondName());
profile1.setSurname(profile.getSurname());
profile1.setSex(profile.getSex());
return profileService.updateProfile(profile1);
}
示例5: addPost
import hello.data.User; //导入依赖的package包/类
@RequestMapping(value = "/add", method = RequestMethod.POST)
public Post addPost(@RequestBody Post post,@AuthenticationPrincipal User user){
post.setDislike(0);
post.setLike(0);
post.setOwner(user);
post.setPostTime(new java.sql.Timestamp(Calendar.getInstance().getTime().getTime()));
return postService.savePost(post);
}
示例6: removePost
import hello.data.User; //导入依赖的package包/类
@RequestMapping(value = "/delete/{id}", method = RequestMethod.GET)
public void removePost(@PathVariable("id") Integer id,@AuthenticationPrincipal User user) {
Post post = postService.getPost(id);
if (post.getOwner().getLogin().equals(user.getLogin()))
{
postService.deletePost(id);
}
}
示例7: updatePost
import hello.data.User; //导入依赖的package包/类
@RequestMapping(value = "/update", method = RequestMethod.POST)
public Post updatePost(@RequestBody Post post, @AuthenticationPrincipal User user) {
Post post1 = postService.getPost(post.getPostId());
if (post1.getOwner().getLogin().equals(user.getLogin()))
{
post1.setDislike(post.getDislike());
post1.setLike(post.getLike());
post1.setImage(post.getImage());
post1.setPostContent(post.getPostContent());
return postService.updatePost(post1);
}
return null;
}
示例8: updateComment
import hello.data.User; //导入依赖的package包/类
@RequestMapping(value = "/update", method = RequestMethod.POST)
public Comment updateComment (@RequestBody Comment comment, @AuthenticationPrincipal User user) {
Comment comment1 = commentService.getComment(comment.getId());
if (comment1.getSender().getLogin().equals(user.getLogin()))
{
comment1.setComment(comment.getComment());
return commentService.updateComment(comment1);
}
return null;
}
示例9: addUser
import hello.data.User; //导入依赖的package包/类
@RequestMapping(value = "/add",method = RequestMethod.POST)
public User addUser(@RequestBody User user){
if(userService.isLoginFree(user.getLogin()))
return userService.saveUser(user);
//not final code, course it must return not null, but a json in the else case
else
return null;
}
示例10: loadUserByUsername
import hello.data.User; //导入依赖的package包/类
@Override
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
User user = userRepository.findByLogin(username);
if (user == null) {
throw new UsernameNotFoundException(String.format("User %s does not exist!", username));
}
return new UserRepositoryUserDetails(user);
}
示例11: UserRepositoryUsersDetails
import hello.data.User; //导入依赖的package包/类
private UserRepositoryUsersDetails(User user) {
super(user);
}
示例12: getUsers
import hello.data.User; //导入依赖的package包/类
@RequestMapping("/users")
public Iterable<User> getUsers() {
return userRepository.findAll();
}
示例13: showProfileCurrent
import hello.data.User; //导入依赖的package包/类
@RequestMapping(value = "/current", method = RequestMethod.GET)
public Profile showProfileCurrent(@AuthenticationPrincipal User user) {
Profile profile = user.getProfile();
return profile;
}
示例14: showPostCurrent
import hello.data.User; //导入依赖的package包/类
@RequestMapping(value = "/current", method = RequestMethod.GET)
public List<Post> showPostCurrent(@AuthenticationPrincipal User user) {
//REMAKE!!!!!!!!!!!!!!
return postService.getListOfPostsByIdOfOwner(user.getId());
}
示例15: addComment
import hello.data.User; //导入依赖的package包/类
@RequestMapping(value = "/add", method = RequestMethod.POST)
public Comment addComment(@RequestBody Comment comment,@AuthenticationPrincipal User user) {
comment.setSender(user);
return commentService.saveComment(comment);
}