use of com.ruoyi.iot.domain.ProductAuthorize in project wumei-smart by kerwincui.
the class ProductAuthorizeServiceImpl method addProductAuthorizeByNum.
/**
* 根据数量批量新增产品授权码
* @param productAuthorizeVO
* @return
*/
@Override
@Transactional
public int addProductAuthorizeByNum(ProductAuthorizeVO productAuthorizeVO) {
Long productId = productAuthorizeVO.getProductId();
int createNum = productAuthorizeVO.getCreateNum();
List<ProductAuthorize> list = new ArrayList<>(createNum);
SysUser user = getLoginUser().getUser();
for (int i = 0; i < createNum; i++) {
ProductAuthorize authorize = new ProductAuthorize();
authorize.setProductId(productId);
authorize.setCreateBy(user.getUserName());
authorize.setCreateTime(DateUtils.getNowDate());
authorize.setAuthorizeCode(IdUtils.fastSimpleUUID().toUpperCase());
list.add(authorize);
}
return productAuthorizeMapper.insertBatchAuthorize(list);
}
use of com.ruoyi.iot.domain.ProductAuthorize in project wumei-smart by kerwincui.
the class ProductAuthorizeServiceImpl method boundProductAuthorize.
/**
* 根据产品id和设备序列号绑定授权码
*
* @param productAuthorize
* @return
*/
@Override
@Transactional
public int boundProductAuthorize(ProductAuthorize productAuthorize) {
ProductAuthorize authorize = null;
if (StringUtils.isEmpty(productAuthorize.getAuthorizeCode())) {
// TODO-kami: 2022/4/11 13:34 后期无需查询,硬件调用直接传入参数,可以删除
authorize = productAuthorizeMapper.selectOneUnboundAuthorizeByProductId(productAuthorize);
productAuthorize.setAuthorizeCode(authorize.getAuthorizeCode());
} else {
authorize = productAuthorizeMapper.selectOneUnboundAuthorizeByAuthorizeCode(productAuthorize);
}
if (authorize == null) {
throw new ServiceException("授权码数据异常", HttpStatus.BAD_REQUEST);
}
productAuthorize.setAuthorizeId(authorize.getAuthorizeId());
productAuthorize.setUpdateTime(DateUtils.getNowDate());
return productAuthorizeMapper.updateProductAuthorize(productAuthorize);
}
Aggregations