當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。