mirror of
https://gitee.com/beecue/fastbee.git
synced 2025-12-19 17:35:54 +08:00
设备认证统一
This commit is contained in:
@@ -46,7 +46,7 @@ public interface IDeviceService
|
||||
* @param model 设备编号和产品ID
|
||||
* @return 设备
|
||||
*/
|
||||
public DeviceAuthenticateModel selectDeviceAuthenticate(AuthenticateInputModel model);
|
||||
public ProductAuthenticateModel selectProductAuthenticate(AuthenticateInputModel model);
|
||||
|
||||
/**
|
||||
* 查询设备和运行状态
|
||||
|
||||
@@ -67,12 +67,4 @@ public interface IProductAuthorizeService
|
||||
*/
|
||||
public int addProductAuthorizeByNum(ProductAuthorizeVO productAuthorizeVO);
|
||||
|
||||
|
||||
/**
|
||||
* 根据产品id和设备序列号绑定授权码
|
||||
* @param productAuthorize
|
||||
* @return
|
||||
*/
|
||||
public int boundProductAuthorize(ProductAuthorize productAuthorize);
|
||||
|
||||
}
|
||||
|
||||
@@ -116,8 +116,8 @@ public class DeviceServiceImpl implements IDeviceService {
|
||||
* @return 设备
|
||||
*/
|
||||
@Override
|
||||
public DeviceAuthenticateModel selectDeviceAuthenticate(AuthenticateInputModel model) {
|
||||
return deviceMapper.selectDeviceAuthenticate(model);
|
||||
public ProductAuthenticateModel selectProductAuthenticate(AuthenticateInputModel model) {
|
||||
return deviceMapper.selectProductAuthenticate(model);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -21,98 +21,92 @@ import static com.ruoyi.common.utils.SecurityUtils.getLoginUser;
|
||||
|
||||
/**
|
||||
* 产品授权码Service业务层处理
|
||||
*
|
||||
*
|
||||
* @author kami
|
||||
* @date 2022-04-11
|
||||
*/
|
||||
@Service
|
||||
public class ProductAuthorizeServiceImpl implements IProductAuthorizeService
|
||||
{
|
||||
public class ProductAuthorizeServiceImpl implements IProductAuthorizeService {
|
||||
@Autowired
|
||||
private ProductAuthorizeMapper productAuthorizeMapper;
|
||||
|
||||
/**
|
||||
* 查询产品授权码
|
||||
*
|
||||
*
|
||||
* @param authorizeId 产品授权码主键
|
||||
* @return 产品授权码
|
||||
*/
|
||||
@Override
|
||||
public ProductAuthorize selectProductAuthorizeByAuthorizeId(Long authorizeId)
|
||||
{
|
||||
public ProductAuthorize selectProductAuthorizeByAuthorizeId(Long authorizeId) {
|
||||
return productAuthorizeMapper.selectProductAuthorizeByAuthorizeId(authorizeId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询产品授权码列表
|
||||
*
|
||||
*
|
||||
* @param productAuthorize 产品授权码
|
||||
* @return 产品授权码
|
||||
*/
|
||||
@Override
|
||||
public List<ProductAuthorize> selectProductAuthorizeList(ProductAuthorize productAuthorize)
|
||||
{
|
||||
public List<ProductAuthorize> selectProductAuthorizeList(ProductAuthorize productAuthorize) {
|
||||
return productAuthorizeMapper.selectProductAuthorizeList(productAuthorize);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增产品授权码
|
||||
*
|
||||
*
|
||||
* @param productAuthorize 产品授权码
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertProductAuthorize(ProductAuthorize productAuthorize)
|
||||
{
|
||||
public int insertProductAuthorize(ProductAuthorize productAuthorize) {
|
||||
productAuthorize.setCreateTime(DateUtils.getNowDate());
|
||||
return productAuthorizeMapper.insertProductAuthorize(productAuthorize);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改产品授权码
|
||||
*
|
||||
*
|
||||
* @param productAuthorize 产品授权码
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateProductAuthorize(ProductAuthorize productAuthorize)
|
||||
{
|
||||
public int updateProductAuthorize(ProductAuthorize productAuthorize) {
|
||||
productAuthorize.setUpdateTime(DateUtils.getNowDate());
|
||||
return productAuthorizeMapper.updateProductAuthorize(productAuthorize);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除产品授权码
|
||||
*
|
||||
*
|
||||
* @param authorizeIds 需要删除的产品授权码主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteProductAuthorizeByAuthorizeIds(Long[] authorizeIds)
|
||||
{
|
||||
public int deleteProductAuthorizeByAuthorizeIds(Long[] authorizeIds) {
|
||||
return productAuthorizeMapper.deleteProductAuthorizeByAuthorizeIds(authorizeIds);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除产品授权码信息
|
||||
*
|
||||
*
|
||||
* @param authorizeId 产品授权码主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteProductAuthorizeByAuthorizeId(Long authorizeId)
|
||||
{
|
||||
public int deleteProductAuthorizeByAuthorizeId(Long authorizeId) {
|
||||
return productAuthorizeMapper.deleteProductAuthorizeByAuthorizeId(authorizeId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据数量批量新增产品授权码
|
||||
*
|
||||
* @param productAuthorizeVO
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public int addProductAuthorizeByNum(ProductAuthorizeVO productAuthorizeVO) {
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public int addProductAuthorizeByNum(ProductAuthorizeVO productAuthorizeVO) {
|
||||
Long productId = productAuthorizeVO.getProductId();
|
||||
int createNum = productAuthorizeVO.getCreateNum();
|
||||
List<ProductAuthorize> list = new ArrayList<>(createNum);
|
||||
@@ -126,31 +120,6 @@ public class ProductAuthorizeServiceImpl implements IProductAuthorizeService
|
||||
list.add(authorize);
|
||||
}
|
||||
return productAuthorizeMapper.insertBatchAuthorize(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据产品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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user