123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- //
- // IHPermissionService.swift
- // Inhealth
- //
- // Created by weclouds on 2019/12/23.
- // Copyright © 2019 weclouds. All rights reserved.
- //
- import UIKit
- import SwiftyJSON
- class IHPermissionService: NSObject {
- static let share: IHPermissionService = {
- let share = IHPermissionService()
- return share
- }()
-
- override init() {
-
- }
- func getUserPermissInfo() {
- log.debug("getUserPermissInfo")
- var deviceArr = [String]()
- let username = AppShare.username
- let token = AppShare.token
- let os = AppShare.os
- let version = AppShare.version
- let client_key = AppShare.client_key
- let userId = AppShare.mLoginData?.id
- g_user_get_user_permissionHttpRequest(username, client_key: client_key, os: os, version: version, token: token, userId: userId!, success: { (json) -> (Void) in
- let mPermissionInfo = Permission_Info.fromJSON(json)
- let result = mPermissionInfo?.result
- if let rootNodes = result?.rootNodes,let airPurifierAuth = result?.airPurifierAuth,let sensorAuth = result?.sensorAuth,let lightAuth = result?.lightAuth,let cirLight = result?.cirLight{
- log.debug("rootNodes - \(rootNodes)")
- if airPurifierAuth == "0" {
- deviceArr.append("Air Purifier")
- }
- if sensorAuth == "0" {
- deviceArr.append("Sensor")
- }
- if lightAuth == "0" {
- deviceArr.append("Light")
- }
-
- if cirLight == "0" {
- deviceArr.append("Circadian light")
- }
-
-
- // requestSuccess!(rootNodes,deviceArr)
- }
-
-
- }) { () -> (Void) in
- // requestFail()
- }
- }
-
-
- func getUserPermissInfo(_ requestSuccess:(([IHTreeTableViewNode],[String]?)->Void)?,requestFail:@escaping (()->Void)) {
- log.debug("getUserPermissInfo")
- var deviceArr = [String]()
- let username = AppShare.username
- let token = AppShare.token
- let os = AppShare.os
- let version = AppShare.version
- let client_key = AppShare.client_key
- let userId = AppShare.mLoginData?.id
- g_user_get_user_permissionHttpRequest(username, client_key: client_key, os: os, version: version, token: token, userId: userId!, success: { (json) -> (Void) in
- let mPermissionInfo = Permission_Info.fromJSON(json)
- let result = mPermissionInfo?.result
- if let rootNodes = result?.rootNodes,let airPurifierAuth = result?.airPurifierAuth,let sensorAuth = result?.sensorAuth,let lightAuth = result?.lightAuth,let cirLight = result?.cirLight{
- log.debug("rootNodes - \(rootNodes)")
- if airPurifierAuth == "0" {
- deviceArr.append("Air Purifier")
- }
- if sensorAuth == "0" {
- deviceArr.append("Sensor")
- }
- if lightAuth == "0" {
- deviceArr.append("Light")
- }
-
- if cirLight == "0" {
- deviceArr.append("Circadian light")
- }
- requestSuccess!(rootNodes,deviceArr)
- }
-
-
- }) { () -> (Void) in
- requestFail()
- }
- }
-
-
-
- }
|