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


Java BeanUtils.copyProperties方法代码示例

本文整理汇总了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;
}
 
开发者ID:yunjiweidian,项目名称:TITAN,代码行数:33,代码来源:LinkServiceImpl.java

示例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);
}
 
开发者ID:fier-liu,项目名称:FCat,代码行数:24,代码来源:TUserController.java

示例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;
    }
 
开发者ID:cx118118,项目名称:ssm-rbac,代码行数:25,代码来源:CommonUtils.java

示例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);

}
 
开发者ID:wu05281,项目名称:admin-shiro,代码行数:22,代码来源:QuartzCtl.java

示例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);
}
 
开发者ID:YupaiTS,项目名称:docs-manage,代码行数:18,代码来源:AuthController.java

示例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;
}
 
开发者ID:fier-liu,项目名称:FCat,代码行数:22,代码来源:TUserServiceFeign.java

示例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);
}
 
开发者ID:luckyyeah,项目名称:YiDu-Novel,代码行数:13,代码来源:ChapterListAction.java

示例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;
}
 
开发者ID:howma03,项目名称:sporticus,代码行数:15,代码来源:IGroup.java

示例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 );
}
 
开发者ID:yujunhao8831,项目名称:spring-boot-start-current,代码行数:9,代码来源:PermissionResourceServiceImpl.java

示例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);
}
 
开发者ID:kloiasoft,项目名称:eventapis,代码行数:8,代码来源:CreateStockCommandHandler.java

示例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;
}
 
开发者ID:FutureWL,项目名称:sell,代码行数:23,代码来源:OrderServiceImpl.java

示例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;
}
 
开发者ID:howma03,项目名称:sporticus,代码行数:8,代码来源:IBlogPost.java

示例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);
}
 
开发者ID:YupaiTS,项目名称:docs-manage,代码行数:14,代码来源:AuthController.java


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