本文整理汇总了Java中org.springframework.beans.BeanUtils.copyProperties方法的典型用法代码示例。如果您正苦于以下问题:Java BeanUtils.copyProperties方法的具体用法?Java BeanUtils.copyProperties怎么用?Java BeanUtils.copyProperties使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.beans.BeanUtils
的用法示例。
在下文中一共展示了BeanUtils.copyProperties方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getLinkList
import org.springframework.beans.BeanUtils; //导入方法依赖的package包/类
/**
* @desc 分页查询所有链路列表
*
* @author liuliang
*
* @param pageIndex 当前页
* @param pageSize 每页条数
* @return List<LinkBO> 链路BO集合
* @throws Exception
*/
@Override
public List<LinkBO> getLinkList(String linkName,int pageIndex, int pageSize) throws Exception{
//1、查询
List<Link> linkList = null;
if(StringUtils.isBlank(linkName)){
linkList = linkDao.queryLinkByPage(pageIndex, pageSize);
}else{
linkList = linkDao.queryLinkByPage(linkName,pageIndex, pageSize);
}
//2、转换
List<LinkBO> linkBOList = new ArrayList<LinkBO>();
if((null != linkList) && (0 < linkList.size())){
LinkBO linkBO = null;
for(Link link:linkList){
linkBO = new LinkBO();
BeanUtils.copyProperties(link, linkBO);
linkBOList.add(linkBO);
}
}
//3、返回
return linkBOList;
}
示例2: getAuthority
import org.springframework.beans.BeanUtils; //导入方法依赖的package包/类
/**
* 通过用户名获取菜单和元素的权限
* @return
* @throws RuntimeException
*/
@ApiOperation(value = "通过用户名获取菜单和元素的权限" )
@RequestMapping(value = "getAuthority/{username}", method = RequestMethod.GET)
public JSONObject getAuthority(@PathVariable String username)throws Exception{
JSONObject result = new JSONObject();
List<TMenuTree> tMenuTreeList = new ArrayList<>();
List<TMenu> tMenus = tMenuService.getAuthorityMenusByUsername(username);
for(TMenu tMenu:tMenus){
TMenuTree tMenuTree = new TMenuTree();
BeanUtils.copyProperties(tMenu,tMenuTree);
tMenuTreeList.add(tMenuTree);
}
List<TMenuTree> tMenuTrees = TreeUtil.buildByRecursive(tMenuTreeList,-1);
List<TElement> tElements = tElementService.getAuthorityElementsByUsername(username);
result.put("tMenuTrees",tMenuTrees);
result.put("tElements",tElements);
return JsonUtil.getSuccessJsonObject(result);
}
示例3: add
import org.springframework.beans.BeanUtils; //导入方法依赖的package包/类
/**
* Add restaurant with the specified information.
*
* @param restaurantVO
* @return A non-null restaurant.
*/
@RequestMapping(method = RequestMethod.POST)
public ResponseEntity<Restaurant> add(@RequestBody RestaurantVO restaurantVO) {
logger.info(String.format("restaurant-service add() invoked: %s for %s", restaurantService.getClass().getName(), restaurantVO.getName()));
System.out.println(restaurantVO);
Restaurant restaurant = new Restaurant(null, null, null, null);
BeanUtils.copyProperties(restaurantVO, restaurant);
try {
restaurantService.add(restaurant);
} catch (Exception ex) {
logger.log(Level.WARNING, "Exception raised add Restaurant 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,代码来源:RestaurantController.java
示例4: buildMenuTree
import org.springframework.beans.BeanUtils; //导入方法依赖的package包/类
/**
* 生成树形菜单 菜单
*/
public static List<MenuTreeBean> buildMenuTree(List<MenuEntity> items) {
List<MenuTreeBean> result = new ArrayList<>();
// 临时的扁平化树
HashMap<Integer, MenuTreeBean> tempMap = new HashMap<>();
// 扁平化数据
for (MenuEntity me : items) {
MenuTreeBean menuTreeBean = new MenuTreeBean();
BeanUtils.copyProperties(me, menuTreeBean);
menuTreeBean.setId(me.getMid());
tempMap.put(me.getMid(), menuTreeBean);
}
// 处理父子引用关系
for (MenuEntity tb : items) {
if (tempMap.get(tb.getPid()) != null) {
tempMap.get(tb.getPid()).getChildren().add(tempMap.get(tb.getMid()));
} else {
result.add(tempMap.get(tb.getMid()));
}
}
return result;
}
示例5: add
import org.springframework.beans.BeanUtils; //导入方法依赖的package包/类
/**
* 注意:@RequestBody需要把所有请求参数作为json解析,因此,不能包含key=value这样的写法在请求url中,所有的请求参数都是一个json
*
*/
@RequiresPermissions("job:index")
@ResponseBody
@RequestMapping(value = "job", method = RequestMethod.POST)
public ResponseDTO add(@RequestBody JobAddAO jobAddAO) {
try {
//cron表达式合法性校验
CronExpression exp = new CronExpression(jobAddAO.getCron());
JobDetailDO jobDetailDO = new JobDetailDO();
BeanUtils.copyProperties(jobAddAO, jobDetailDO);
jobDetailService.addJobDetail(jobDetailDO);
} catch (ParseException e) {
e.printStackTrace();
return new ResponseDTO(0, "failed", null);
}
return new ResponseDTO(1, "success", null);
}
示例6: refreshAuthToken
import org.springframework.beans.BeanUtils; //导入方法依赖的package包/类
@GetMapping("/refresh")
public Result refreshAuthToken(HttpServletRequest request) {
String authToken = jwtHelper.getToken(request);
TokenUserInfo tokenUserInfo = null;
if (authToken != null && jwtHelper.canRefreshToken(authToken)) {
//刷新token
String refreshedToken = jwtHelper.refreshToken(authToken);
User user = userRepository.findByUsername(jwtHelper.getUsernameFromToken(authToken));
UserDTO userDTO = null;
if (user != null) {
userDTO = new UserDTO();
BeanUtils.copyProperties(user, userDTO);
}
tokenUserInfo = new TokenUserInfo(refreshedToken, userDTO, jwtProperties.getExpiredIn() );
}
return Result.ok(tokenUserInfo);
}
示例7: getByUsername
import org.springframework.beans.BeanUtils; //导入方法依赖的package包/类
/**
* 通过用户名获取用户的基本信息
* @param username
* @return
*/
@RequestMapping(value = "/user/username/{username}", method = RequestMethod.POST)
public TUserVo getByUsername(@PathVariable("username") String username) {
TUserVo tUserVo = null;
try {
TUser tUser1 = tUserService.getByUsername(username);
if (tUser1 != null) {
tUserVo=new TUserVo();
BeanUtils.copyProperties(tUser1,tUserVo);
String[] roles = tGroupService.getCodeByUsername(username);
tUserVo.setRoleList(Arrays.asList(roles));
}
} catch (Exception e) {
e.printStackTrace();
}
return tUserVo;
}
示例8: loadData
import org.springframework.beans.BeanUtils; //导入方法依赖的package包/类
@Override
protected void loadData() {
if (articleno == 0) {
addActionError(getText("errors.required.input",
new String[] { getText("label.admin.chapter.list.articleno") }));
}
article = articleService.getByNo(articleno);
ChapterSearchBean searchBean = new ChapterSearchBean();
BeanUtils.copyProperties(this, searchBean);
searchBean.setPagination(null);
chapterList = chapterService.find(searchBean);
}
示例9: COPY
import org.springframework.beans.BeanUtils; //导入方法依赖的package包/类
static IGroup COPY(final IGroup from, final IGroup to) {
if(from == null) {
return null;
}
if(to == null) {
return null;
}
BeanUtils.copyProperties(from, to);
if(from.isEnabled() != null) {
to.setEnabled(from.isEnabled());
}
return to;
}
示例10: update
import org.springframework.beans.BeanUtils; //导入方法依赖的package包/类
@Override
@CacheEvict( value = GlobalCacheConstant.USER_DETAILS_SERVICE_NAMESPACE, allEntries = true, condition = "#result != null" )
public boolean update ( PermissionResourceForm form ) {
PermissionResource permissionResource = new PermissionResource();
BeanUtils.copyProperties( form , permissionResource );
apiHandle( form , permissionResource );
return super.updateById( permissionResource );
}
示例11: execute
import org.springframework.beans.BeanUtils; //导入方法依赖的package包/类
@Override
@RequestMapping(value = "/stock/v1/create", method = RequestMethod.POST)
public EventKey execute(@RequestBody CreateStockCommandDto dto) throws Exception {
StockCreatedEvent stockCreatedEvent = new StockCreatedEvent();
BeanUtils.copyProperties(dto,stockCreatedEvent);
return eventRepository.recordAndPublish(stockCreatedEvent);
}
示例12: add
import org.springframework.beans.BeanUtils; //导入方法依赖的package包/类
/**
* Add booking with the specified information.
*
* @param bookingVO
* @return A non-null booking.
*/
@RequestMapping(method = RequestMethod.POST)
public ResponseEntity<Booking> add(@RequestBody BookingVO bookingVO) {
logger.info(String.format("booking-service add() invoked: %s for %s", bookingService.getClass().getName(), bookingVO.getName()));
System.out.println(bookingVO);
Booking booking = new Booking(null, null, null, null, null, null, null);
BeanUtils.copyProperties(bookingVO, booking);
try {
bookingService.add(booking);
} 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,代码来源:BookingController.java
示例13: finish
import org.springframework.beans.BeanUtils; //导入方法依赖的package包/类
@Override
@Transactional
public OrderDto finish(OrderDto orderDto) {
// 判断订单状态
if (!orderDto.getOrderStatus().equals(OrderStatusEnum.NEW.getCode())) {
log.error("【完结订单】订单状态不正确,orderId={}, orderStatus={}", orderDto.getOrderId(), orderDto.getOrderStatus());
throw new SellException(ResultEnum.ORDER_STATUS_ERROR);
}
// 修改订单状态
orderDto.setOrderStatus(OrderStatusEnum.FINISHED.getCode());
OrderMaster orderMaster = new OrderMaster();
BeanUtils.copyProperties(orderDto, orderMaster);
OrderMaster updateResult = orderMasterRepository.save(orderMaster);
if (updateResult == null) {
log.error("【完结订单】更新失败,orderMaster={}", orderMaster);
throw new SellException(ResultEnum.ORDER_UPDATE_FAIL);
}
return orderDto;
}
示例14: COPY
import org.springframework.beans.BeanUtils; //导入方法依赖的package包/类
static IBlogPost COPY(final IBlogPost from, final IBlogPost to) {
if(from == null) return null;
if(to == null) return null;
BeanUtils.copyProperties(from, to);
return to;
}
示例15: getCurrentUser
import org.springframework.beans.BeanUtils; //导入方法依赖的package包/类
@GetMapping("/currentUser")
public Result getCurrentUser(HttpServletRequest request) {
UserDTO currentUser = null;
String authToken = jwtHelper.getToken(request);
if (authToken != null) {
User user = userRepository.findByUsername(jwtHelper.getUsernameFromToken(authToken));
if (user != null) {
currentUser = new UserDTO();
BeanUtils.copyProperties(user, currentUser);
}
}
return Result.ok(currentUser);
}