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


Java User类代码示例

本文整理汇总了Java中com.packtpub.mmj.user.domain.model.entity.User的典型用法代码示例。如果您正苦于以下问题:Java User类的具体用法?Java User怎么用?Java User使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


User类属于com.packtpub.mmj.user.domain.model.entity包,在下文中一共展示了User类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: findByName

import com.packtpub.mmj.user.domain.model.entity.User; //导入依赖的package包/类
/**
 * Fetch users with the specified name. A partial case-insensitive match is
 * supported. So <code>http://.../user/rest</code> will find any users with
 * upper or lower case 'rest' in their name.
 *
 * @param name
 * @return A non-null, non-empty collection of users.
 */
@HystrixCommand(fallbackMethod = "defaultUsers")
@RequestMapping(method = RequestMethod.GET)
public ResponseEntity<Collection<User>> findByName(@RequestParam("name") String name) {
    logger.info(String.format("user-service findByName() invoked:%s for %s ", userService.getClass().getName(), name));
    name = name.trim().toLowerCase();
    Collection<User> users;
    try {
        users = userService.findByName(name);
    } catch (Exception ex) {
        logger.log(Level.SEVERE, "Exception raised findByName REST Call", ex);
        return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
    }
    return users.size() > 0 ? new ResponseEntity<>(users, HttpStatus.OK)
            : new ResponseEntity<>(HttpStatus.NO_CONTENT);
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Microservices-with-Java-9-Second-Edition,代码行数:24,代码来源:UserController.java

示例2: add

import com.packtpub.mmj.user.domain.model.entity.User; //导入依赖的package包/类
/**
 * Add user with the specified information.
 *
 * @param userVO
 * @return A non-null user.
 */
@RequestMapping(method = RequestMethod.POST)
public ResponseEntity<User> add(@RequestBody UserVO userVO) {
    logger.info(String.format("user-service add() invoked: %s for %s", userService.getClass().getName(), userVO.getName()));
    System.out.println(userVO);
    User user = new User(null, null, null, null, null);
    BeanUtils.copyProperties(userVO, user);
    try {
        userService.add(user);
    } catch (Exception ex) {
        logger.log(Level.WARNING, "Exception raised add Booking REST Call {0}", ex);
        return new ResponseEntity<>(HttpStatus.UNPROCESSABLE_ENTITY);
    }
    return new ResponseEntity<>(HttpStatus.CREATED);
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Microservices-with-Java-9-Second-Edition,代码行数:21,代码来源:UserController.java

示例3: add

import com.packtpub.mmj.user.domain.model.entity.User; //导入依赖的package包/类
/**
 * Add user with the specified information.
 *
 * @param userVO
 * @return A non-null user.
 */
@RequestMapping(method = RequestMethod.POST)
public ResponseEntity<User> add(@RequestBody UserVO userVO) {
    logger.info(String.format("user-service add() invoked: %s for %s", userService.getClass().getName(), userVO.getName()));
    System.out.println(userVO);
    User user = new User(null, null, null, null, null);
    BeanUtils.copyProperties(userVO, user);
    try {
        userService.add(user);
    } catch (Exception ex) {
        logger.log(Level.WARNING, "Exception raised add User REST Call {0}", ex);
        return new ResponseEntity<>(HttpStatus.UNPROCESSABLE_ENTITY);
    }
    return new ResponseEntity<>(HttpStatus.CREATED);
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Microservices-with-Java-9-Second-Edition,代码行数:21,代码来源:UserController.java

示例4: findByName

import com.packtpub.mmj.user.domain.model.entity.User; //导入依赖的package包/类
/**
 * Fetch users with the specified name. A partial case-insensitive match is
 * supported. So <code>http://.../user/rest</code> will find any users with
 * upper or lower case 'rest' in their name.
 *
 * @param name
 * @return A non-null, non-empty collection of users.
 */
@HystrixCommand(fallbackMethod = "defaultUsers")
@RequestMapping(method = RequestMethod.GET)
public ResponseEntity<Collection<User>> findByName(@RequestParam("name") String name) {
    logger.info(String.format("user-service findByName() invoked:{} for {} ", userService.getClass().getName(), name));
    name = name.trim().toLowerCase();
    Collection<User> users;
    try {
        users = userService.findByName(name);
    } catch (Exception ex) {
        logger.log(Level.SEVERE, "Exception raised findByName REST Call", ex);
        return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
    }
    return users.size() > 0 ? new ResponseEntity<>(users, HttpStatus.OK)
            : new ResponseEntity<>(HttpStatus.NO_CONTENT);
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Microservices-with-Java,代码行数:24,代码来源:UserController.java

示例5: findByName

import com.packtpub.mmj.user.domain.model.entity.User; //导入依赖的package包/类
/**
 * Fetch users with the specified name. A partial case-insensitive match is
 * supported. So <code>http://.../user/rest</code> will find any users with
 * upper or lower case 'rest' in their name.
 *
 * @param name
 * @return A non-null, non-empty collection of users.
 */
@RequestMapping(method = RequestMethod.GET)
public ResponseEntity<Collection<User>> findByName(@RequestParam("name") String name) {
    logger.info(String.format("user-service findByName() invoked:{} for {} ", userService.getClass().getName(), name));
    name = name.trim().toLowerCase();
    Collection<User> users;
    try {
        users = userService.findByName(name);
    } catch (Exception ex) {
        logger.log(Level.SEVERE, "Exception raised findByName REST Call", ex);
        return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
    }
    return users.size() > 0 ? new ResponseEntity<>(users, HttpStatus.OK)
            : new ResponseEntity<>(HttpStatus.NO_CONTENT);
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Microservices-with-Java-9-Second-Edition,代码行数:23,代码来源:UserController.java

示例6: InMemUserRepository

import com.packtpub.mmj.user.domain.model.entity.User; //导入依赖的package包/类
/**
 * Initialize the in-memory User Repository with empty Map
 */
public InMemUserRepository() {
    entities = new HashMap();
    User user = new User("1", "User Name 1", "Address 1", "City 1", "9999911111");
    entities.put("1", user);
    User user2 = new User("1", "User Name 2", "Address 2", "City 2", "9999922222");
    entities.put("2", user2);
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Microservices-with-Java-9-Second-Edition,代码行数:11,代码来源:InMemUserRepository.java

示例7: update

import com.packtpub.mmj.user.domain.model.entity.User; //导入依赖的package包/类
/**
 *
 * @param entity
 */
@Override
public void update(User entity) {
    if (entities.containsKey(entity.getId())) {
        entities.put(entity.getId(), entity);
    }
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Microservices-with-Java-9-Second-Edition,代码行数:11,代码来源:InMemUserRepository.java

示例8: findByName

import com.packtpub.mmj.user.domain.model.entity.User; //导入依赖的package包/类
/**
 *
 * @param name
 * @return
 * @throws Exception
 */
@Override
public Collection<User> findByName(String name) throws Exception {
    Collection<User> users = new ArrayList();
    int noOfChars = name.length();
    entities.forEach((k, v) -> {
        if (v.getName().toLowerCase().contains(name.toLowerCase().subSequence(0, noOfChars))) {
            users.add(v);
        }
    });
    return users;
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Microservices-with-Java-9-Second-Edition,代码行数:18,代码来源:InMemUserRepository.java

示例9: add

import com.packtpub.mmj.user.domain.model.entity.User; //导入依赖的package包/类
@Override
public void add(User user) throws Exception {
    if (userRepository.containsName(user.getName())) {
        throw new Exception(String.format("There is already a product with the name - %s", user.getName()));
    }

    if (user.getName() == null || "".equals(user.getName())) {
        throw new Exception("Booking name cannot be null or empty string.");
    }
    super.add(user);
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Microservices-with-Java-9-Second-Edition,代码行数:12,代码来源:UserServiceImpl.java

示例10: InMemUserRepository

import com.packtpub.mmj.user.domain.model.entity.User; //导入依赖的package包/类
/**
 * Initialize the in-memory Restaurant Repository with empty Map
 */
public InMemUserRepository() {
    entities = new HashMap();
    User user = new User("1", "User Name 1", "Address 1", "City 1", "9999911111");
    entities.put("1", user);
    User user2 = new User("1", "User Name 2", "Address 2", "City 2", "9999922222");
    entities.put("2", user2);
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Microservices-with-Java-9-Second-Edition,代码行数:11,代码来源:InMemUserRepository.java


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