当前位置: 首页>>代码示例>>Java>>正文


Java User类代码示例

本文整理汇总了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;
    }
 
开发者ID:acsiia,项目名称:spring-rest-service-oauth-master,代码行数:18,代码来源:UserServiceImpl.java

示例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;
}
 
开发者ID:acsiia,项目名称:spring-rest-service-oauth-master,代码行数:18,代码来源:UserServiceImpl.java

示例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);
}
 
开发者ID:acsiia,项目名称:spring-rest-service-oauth-master,代码行数:9,代码来源:CustomUserDetailsService.java

示例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);
}
 
开发者ID:acsiia,项目名称:spring-rest-service-oauth-master,代码行数:14,代码来源:ProfileController.java

示例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);
}
 
开发者ID:acsiia,项目名称:spring-rest-service-oauth-master,代码行数:10,代码来源:PostController.java

示例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);
    }
}
 
开发者ID:acsiia,项目名称:spring-rest-service-oauth-master,代码行数:9,代码来源:PostController.java

示例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;
}
 
开发者ID:acsiia,项目名称:spring-rest-service-oauth-master,代码行数:16,代码来源:PostController.java

示例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;
}
 
开发者ID:acsiia,项目名称:spring-rest-service-oauth-master,代码行数:12,代码来源:CommentController.java

示例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;
}
 
开发者ID:acsiia,项目名称:spring-rest-service-oauth-master,代码行数:9,代码来源:UserController2.java

示例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);
}
 
开发者ID:aksappy,项目名称:RestSecurityOAuth,代码行数:9,代码来源:CustomUserDetailsService.java

示例11: UserRepositoryUsersDetails

import hello.data.User; //导入依赖的package包/类
private UserRepositoryUsersDetails(User user) {
	super(user);
}
 
开发者ID:acsiia,项目名称:spring-rest-service-oauth-master,代码行数:4,代码来源:CustomUserDetailsService.java

示例12: getUsers

import hello.data.User; //导入依赖的package包/类
@RequestMapping("/users")
public Iterable<User> getUsers() {
	return userRepository.findAll();
}
 
开发者ID:acsiia,项目名称:spring-rest-service-oauth-master,代码行数:5,代码来源:UserController.java

示例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;
}
 
开发者ID:acsiia,项目名称:spring-rest-service-oauth-master,代码行数:6,代码来源:ProfileController.java

示例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());
   }
 
开发者ID:acsiia,项目名称:spring-rest-service-oauth-master,代码行数:6,代码来源:PostController.java

示例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);
}
 
开发者ID:acsiia,项目名称:spring-rest-service-oauth-master,代码行数:6,代码来源:CommentController.java


注:本文中的hello.data.User类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。