Exemplo n.º 1
0
def delete_one(category_id):
    '''删除设备类型/n/t
    如果设备已经绑定了该类型,无法删除'''
    device_category = DeviceCategory.get_or_404(id=category_id)
    if DeviceModel.get(category_id=category_id):
        raise ForbiddenException(msg='该类别下存在设备,不可删除')
    device_category.delete()
    return Success(error_code=2)
Exemplo n.º 2
0
    def handle(self) -> Response:
        """デバイス情報を取得

		:return Response: レスポンス
		"""
        device = Device.get(self.request.query('id'))
        return GetDeviceResponse(
            device.to_dict(),
            LightColors.get().to_dict() if device.has_color else {})