AdminManage.py 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627
  1. # -*- coding: utf-8 -*-
  2. import time
  3. from django.db.models import Count,Q
  4. from django.views.decorators.csrf import csrf_exempt
  5. from django.views.generic import TemplateView
  6. from django.utils.decorators import method_decorator
  7. from django.contrib.auth.hashers import make_password # 对密码加密模块
  8. from Model.models import Device_Info, Role, UserExModel, User_Brand, UidSetModel, AppFrequencyYearStatisticsModel, \
  9. AppFrequencyStatisticsModel, EquipmentInfoExStatisticsModel, Equipment_Info
  10. from Service.ModelService import ModelService
  11. from django.utils import timezone
  12. from Model.models import Access_Log, Device_User
  13. from django.views.decorators.http import require_http_methods
  14. from Object.ResponseObject import ResponseObject
  15. from Object.TokenObject import TokenObject
  16. from Ansjer.config import OFF_LINE_TIME_DELTA, DEVICE_TYPE
  17. import datetime, simplejson as json
  18. from Service.CommonService import CommonService
  19. from Object.RedisObject import RedisObject
  20. '''
  21. http://192.168.136.40:8077/adminManage/manage?operation=getAllDeviceArea&token=debug
  22. http://192.168.136.40:8077/adminManage/manage?operation=getAllUserName&token=debug
  23. http://192.168.136.40:8077/adminManage/manage?operation=getAllUID&token=debug
  24. http://127.0.0.1:8000/adminManage/manage?operation=getAllOnLine&token=stest
  25. http://127.0.0.1:8000/adminManage/manage?operation=getOnLine&token=stest
  26. '''
  27. class AdminManage(TemplateView):
  28. @method_decorator(csrf_exempt)
  29. def dispatch(self, *args, **kwargs):
  30. return super(AdminManage, self).dispatch(*args, **kwargs)
  31. def get(self, request, *args, **kwargs):
  32. request.encoding = 'utf-8'
  33. return self.validation(request_dict=request.GET)
  34. def post(self, request, *args, **kwargs):
  35. request.encoding = 'utf-8'
  36. return self.validation(request_dict=request.POST)
  37. def validation(self, request_dict, *args, **kwargs):
  38. response = ResponseObject()
  39. token = request_dict.get('token', None)
  40. tko = TokenObject(token)
  41. response.lang = tko.lang
  42. if tko.code != 0:
  43. return response.json(tko.code)
  44. userID = tko.userID
  45. operation = request_dict.get('operation', None)
  46. if userID is None or operation is None:
  47. return response.json(444, 'operation')
  48. if operation == 'resetUserPwd':
  49. return self.resetUserPwd(request_dict, userID, response)
  50. if operation == 'getAllOnLine':
  51. return self.getAllOnLine(userID, response)
  52. if operation == 'getOnLine':
  53. return self.getRedisOnline(userID, response)
  54. # return self.getOnLine(userID, response)
  55. if operation == 'getAllUserName':
  56. return self.getAllUserName(userID, response)
  57. if operation == 'getStatisAccess':
  58. return self.getStatisAccess(userID, request_dict, response)
  59. if operation == 'getAllUID':
  60. return self.getAllUID(userID, response)
  61. if operation == 'getAllDeviceArea':
  62. return self.getAllDeviceArea(userID, response)
  63. if operation == 'getUserBrand':
  64. return self.getUserBrand(userID, response)
  65. if operation == 'getAreaDeviceType':
  66. return self.getAreaDeviceType(userID, response)
  67. if operation == 'getDeviceType':
  68. return self.getDeviceType(userID, response)
  69. if operation == 'getAppFrequency':
  70. return self.getAppFrequency(userID, request_dict, response)
  71. if operation == 'getHistoryAppFrequency':
  72. return self.getAllAppFrequency(userID, response)
  73. if operation == 'getPushStatistics':
  74. return self.query_push_by_level(userID, request_dict, response)
  75. def resetUserPwd(self, request_dict, userID, response):
  76. own_permission = ModelService.check_perm(userID=userID, permID=50)
  77. if not own_permission:
  78. return response.json(404)
  79. duserID = request_dict.get('duserID', None)
  80. userPwd = request_dict.get('userPwd', None)
  81. if not duserID:
  82. return response.json(444, 'duserID')
  83. UserValid = Device_User.objects.filter(userID=duserID)
  84. if UserValid:
  85. if userPwd is None:
  86. userPwd = '123456'
  87. is_update = UserValid.update(password=make_password(userPwd))
  88. if is_update:
  89. return response.json(0)
  90. else:
  91. return response.json(177)
  92. else:
  93. return response.json(104)
  94. def getAllUserName(self, userID, response):
  95. # 权限固定为30
  96. own_permission = ModelService.check_perm(userID=userID, permID=30)
  97. if own_permission is not True:
  98. return response.json(404)
  99. username_list = Device_User.objects.all().values_list('username', flat=True)
  100. if username_list:
  101. return response.json(0, {'username_list': list(username_list)})
  102. else:
  103. return response.json(0)
  104. # 获取全部用户的在线个数
  105. def getAllOnLine(self, userID, response):
  106. # 权限固定为30
  107. own_permission = ModelService.check_perm(userID=userID, permID=30)
  108. if own_permission is not True:
  109. return response.json(404)
  110. allonline = Device_User.objects.all().values('online')
  111. # 两个变量,分别是在线,离线
  112. onlinenum = 0
  113. noonlinenum = 0
  114. for q in allonline:
  115. if q['online'] == True:
  116. onlinenum += 1
  117. else:
  118. noonlinenum += 1
  119. print("在线人数:")
  120. print(onlinenum)
  121. return response.json(0, {"onlinenum": onlinenum, "no_onlinenum": noonlinenum})
  122. # 获取全部用户的在线人数
  123. def getOnLine(self, userID, response):
  124. # 权限固定为30
  125. own_permission = ModelService.check_perm(userID=userID, permID=30)
  126. if own_permission is True:
  127. online_list = Device_User.objects.all().values('online', 'last_login')
  128. # 两个变量,分别是在线,离线
  129. onlinenum = 0
  130. noonlinenum = 0
  131. for q in online_list:
  132. # print(q['last_login'] )
  133. # 最后访问时间加5分种
  134. dl_time = q['last_login'] + datetime.timedelta(minutes=OFF_LINE_TIME_DELTA)
  135. # print(dl_time)
  136. # 当前时间
  137. now_time = timezone.localtime(timezone.now())
  138. # print(now_time)
  139. # 如果当前时间大于最后访问的时间
  140. if now_time < dl_time:
  141. onlinenum += 1
  142. else:
  143. noonlinenum += 1
  144. print("在线人")
  145. print(onlinenum)
  146. return response.json(0, {"onlinenum": onlinenum, "no_onlinenum": noonlinenum})
  147. else:
  148. return response.json(404)
  149. # 获取全部用户的在线人数
  150. def getRedisOnline(self, userID, response):
  151. # 权限固定为30
  152. own_perm = ModelService.check_perm(userID, 30)
  153. if own_perm:
  154. count = int(Device_User.objects.count())
  155. redisObj = RedisObject(db=3)
  156. onlines = int(redisObj.get_size())
  157. print(onlines)
  158. return response.json(0, {"onlinenum": onlines, "no_onlinenum": count - onlines})
  159. else:
  160. return response.json(404)
  161. # 获取所有设备地区
  162. def getAllDeviceArea(self, userID, response):
  163. own_permission = ModelService.check_perm(userID=userID, permID=30)
  164. if own_permission is True:
  165. qs = Device_Info.objects.all().values('area', 'UID')
  166. uid_area_dict = {}
  167. for q in qs:
  168. if q['UID'] and q['area']:
  169. uid_area_dict[q['UID']] = q['area']
  170. if len(uid_area_dict):
  171. area_dict = {}
  172. for k, v in uid_area_dict.items():
  173. if v in area_dict:
  174. area_dict[v] += 1
  175. else:
  176. area_dict[v] = 1
  177. return response.json(0, {'area': area_dict})
  178. else:
  179. return response.json(0)
  180. else:
  181. return response.json(404)
  182. '''
  183. 统计一天访问量
  184. http://192.168.136.45:8077/adminManage/manage?token=test&operation=getStatisAccess&timestamp=1528773308
  185. '''
  186. def getStatisAccess(self, userID, request_dict, response):
  187. own_permission = ModelService.check_perm(userID=userID, permID=30)
  188. if own_permission is not True:
  189. return response.json(404)
  190. time_stamp = int(request_dict.get('timestamp', None))
  191. times = datetime.datetime.fromtimestamp(time_stamp)
  192. time_dict = CommonService.getTimeDict(times)
  193. res = {}
  194. for k, v in time_dict.items():
  195. start_date = time_dict[k]
  196. end_date = time_dict[k] + datetime.timedelta(hours=1)
  197. count = Access_Log.objects.filter(time__range=(start_date, end_date)).count()
  198. if count:
  199. res[k] = count
  200. else:
  201. res[k] = 0
  202. return response.json(0, {'count': res})
  203. def getAllUID(self, userID, response):
  204. own_permission = ModelService.check_perm(userID=userID, permID=30)
  205. if own_permission is not True:
  206. return response.json(404)
  207. uid_list = Device_Info.objects.all().values_list('UID', flat=True)
  208. res = {}
  209. if uid_list:
  210. res = {'count': uid_list.count(), 'uid_list': list(uid_list)}
  211. return response.json(0, res)
  212. def getUserBrand(self, userID, response):
  213. own_permission = ModelService.check_perm(userID=userID, permID=30)
  214. if own_permission is not True:
  215. return response.json(404)
  216. # 手机型号统计
  217. print('手机型号统计:')
  218. ub_qs = User_Brand.objects.values('deviceSupplier', 'deviceModel').annotate(value=Count('id')).order_by()
  219. res = {
  220. 'value': 0,
  221. 'data': []
  222. }
  223. data = res['data']
  224. tmpDict = {}
  225. for ub in ub_qs:
  226. deviceSupplier = ub['deviceSupplier']
  227. if not tmpDict.__contains__(deviceSupplier):
  228. tmpDict[deviceSupplier] = {
  229. 'name': deviceSupplier,
  230. 'value': 0,
  231. 'children': []
  232. }
  233. item = tmpDict[deviceSupplier]
  234. item['value'] = item['value'] + ub['value']
  235. res['value'] = res['value'] + item['value']
  236. model = {
  237. 'name': ub['deviceModel'],
  238. 'value': ub['value']
  239. }
  240. item['children'].append(model)
  241. for k, v in tmpDict.items():
  242. data.append(v)
  243. print(res)
  244. return response.json(0, res)
  245. def getAreaDeviceType(self, userID, response):
  246. own_permission = ModelService.check_perm(userID=userID, permID=30)
  247. if own_permission is not True:
  248. return response.json(404)
  249. print('区域设备类型统计:')
  250. di_qs = Device_Info.objects.values('area', 'Type').annotate(value=Count('UID', distinct=True)).order_by()
  251. res = {
  252. 'quantity': 0,
  253. 'data': []
  254. }
  255. data = res['data']
  256. tmpDict = {}
  257. tmpDict['null'] = {
  258. 'area': '未知',
  259. 'quantity': 0,
  260. 'models': []
  261. }
  262. for di in di_qs:
  263. area = di['area']
  264. if area is None or area == '':
  265. area = 'null'
  266. if not tmpDict.__contains__(area):
  267. tmpDict[area] = {
  268. 'area': area,
  269. 'quantity': 0,
  270. 'models': []
  271. }
  272. item = tmpDict[area]
  273. item['quantity'] = item['quantity'] + di['value']
  274. res['quantity'] = res['quantity'] + item['quantity']
  275. device_model = None
  276. if DEVICE_TYPE.__contains__(di['Type']):
  277. device_model = DEVICE_TYPE[di['Type']]
  278. else:
  279. device_model = DEVICE_TYPE[0]
  280. model = {
  281. 'model': device_model,
  282. 'quantity': di['value']
  283. }
  284. item['models'].append(model)
  285. for k, v in tmpDict.items():
  286. data.append(v)
  287. return response.json(0, res)
  288. def getDeviceType(self, userID, response):
  289. own_permission = ModelService.check_perm(userID=userID, permID=30)
  290. if own_permission is not True:
  291. return response.json(404)
  292. # 设备类型统计
  293. di_qs = Device_Info.objects.values('Type').annotate(quantity=Count('UID', distinct=True)).order_by()
  294. # 设备型号统计
  295. us_qs = UidSetModel.objects.values('deviceModel').annotate(quantity=Count('id')).order_by()
  296. res = {
  297. 'type_data': {
  298. 'quantity': 0,
  299. 'data': []
  300. },
  301. 'model_data': {
  302. 'quantity': 0,
  303. 'data': []
  304. }
  305. }
  306. type_data = res['type_data']
  307. data = type_data['data']
  308. quantity = 0
  309. for di in di_qs:
  310. if DEVICE_TYPE.__contains__(di['Type']):
  311. device_model = DEVICE_TYPE[di['Type']]
  312. else:
  313. device_model = DEVICE_TYPE[0]
  314. di['Type'] = device_model
  315. quantity += di['quantity']
  316. data.append(di)
  317. type_data['quantity'] = quantity
  318. model_data = res['model_data']
  319. data = model_data['data']
  320. quantity = 0
  321. for us in us_qs:
  322. data.append(us)
  323. quantity += us['quantity']
  324. model_data['quantity'] = quantity
  325. return response.json(0, res)
  326. def getAppFrequency(self, userID, request_dict, response):
  327. own_permission = ModelService.check_perm(userID=userID, permID=30)
  328. if own_permission is not True:
  329. return response.json(404)
  330. # 当前的年份
  331. current_time = int(time.time())
  332. localtime = time.localtime(current_time)
  333. current_year = localtime.tm_year
  334. current_month = localtime.tm_mon
  335. start_year = end_year = current_year
  336. end_month = current_month
  337. start_month = 1
  338. result = []
  339. if end_month != 12:
  340. start_month = end_month + 1
  341. start_year = current_year - 1
  342. time_struct = [start_year, start_month, 0, 0, 0, 0, 0, 0, 0]
  343. key_formal = '{year}{month}'
  344. for i in range(12):
  345. result.append({
  346. 'date_time': key_formal.format(year=time_struct[0], month=str(time_struct[1]).zfill(2)),
  347. 'data': None
  348. })
  349. month = time_struct[1] + 1
  350. if month > 12:
  351. time_struct[0] = time_struct[0] + 1
  352. time_struct[1] = 1
  353. else:
  354. time_struct[1] = month
  355. #
  356. afs_qs = {}
  357. if start_year == end_year:
  358. afs_qs = list(AppFrequencyStatisticsModel.objects.filter(year=start_year, month__gte=start_month, month__lte=end_month).values().order_by('-year', 'month'))
  359. else:
  360. afs_qs = list(AppFrequencyStatisticsModel.objects.filter(year=start_year, month__gte=start_month).values().order_by('-year', 'month'))
  361. tmps_qs = list(AppFrequencyStatisticsModel.objects.filter(year=end_year, month__lte=end_month).values().order_by('-year', 'month'))
  362. for tmp in tmps_qs:
  363. afs_qs.append(tmp)
  364. tmp_dict = {}
  365. for afs in afs_qs:
  366. key = key_formal.format(year=afs['year'], month=str(afs['month']).zfill(2))
  367. tmp_dict[key] = json.loads(afs['data'])
  368. for res in result:
  369. if tmp_dict.__contains__(res['date_time']):
  370. res['data'] = tmp_dict[res['date_time']]
  371. print(result)
  372. return response.json(0, result)
  373. def getAllAppFrequency(self, userID, response):
  374. own_permission = ModelService.check_perm(userID=userID, permID=30)
  375. if own_permission is not True:
  376. return response.json(404)
  377. # 取出请求年份的统计好的数据
  378. print('start')
  379. time_struct = time.localtime()
  380. current_year = time_struct.tm_year
  381. start_year = current_year - 5 + 1
  382. afs_qs = AppFrequencyYearStatisticsModel.objects.filter(year__gte=start_year, year__lt=current_year).order_by(
  383. '-year')
  384. if afs_qs.exists():
  385. afs_qs = afs_qs.values('id', 'data', 'num', 'year')
  386. res = []
  387. for afs in afs_qs:
  388. res.append({
  389. 'year': afs['year'],
  390. 'data': json.loads(afs['data'])
  391. })
  392. return response.json(0, res)
  393. else:
  394. return response.json(0, [])
  395. def query_push_by_level(self, userID, request_dict, response):
  396. own_permission = ModelService.check_perm(userID=userID, permID=30)
  397. if own_permission is not True:
  398. return response.json(404)
  399. level = request_dict.get('level', None)
  400. print(level)
  401. if level is None:
  402. return response.json(444)
  403. level = int(level)
  404. if level < 0:
  405. return response.json(444)
  406. elif level < 3:
  407. return self.query_push_day_statistics(level, response)
  408. else:
  409. return response.json(404)
  410. def query_push_day_statistics(self, level, response):
  411. start_time = 0
  412. end_time = 0
  413. localtime = time.localtime()
  414. current_day = localtime.tm_mday
  415. time_struct = [localtime.tm_year, localtime.tm_mon, current_day, 0, 0, 0, 0, 0, 0]
  416. current_time = time.mktime(tuple(time_struct))
  417. current_time = current_time - time.timezone - 8 * 60 * 60
  418. count = 0
  419. if level == 0: # 七天
  420. start_time = current_time - 6 * 24 * 60 * 60
  421. count = 6
  422. elif level == 1:
  423. start_time = current_time - 13 * 24 * 60 * 60
  424. count = 13
  425. elif level == 2:
  426. start_time = current_time - 29 * 24 * 60 * 60
  427. count = 29
  428. end_time = current_time
  429. eqx_qs = EquipmentInfoExStatisticsModel.objects.filter(statistics_date__gte=start_time, statistics_date__lte=end_time, date_type=0, push_type=-1).values()
  430. data = []
  431. for i in range(count + 1):
  432. data.append({
  433. 'date_time': time.strftime('%m-%d', time.localtime(start_time)),
  434. 'data': None
  435. })
  436. start_time += (24 * 60 * 60)
  437. tmp_dict = {}
  438. successes = 0
  439. failures = 0
  440. for eqx in eqx_qs:
  441. statistics_date = time.strftime('%m-%d', time.localtime(eqx['statistics_date']))
  442. successes += eqx['number_of_successes']
  443. failures += eqx['number_of_failures']
  444. tmp_dict[statistics_date] = {
  445. 'number_of_successes': eqx['number_of_successes'],
  446. 'number_of_failures': eqx['number_of_failures'],
  447. 'total': (eqx['number_of_successes'] + eqx['number_of_failures'])
  448. }
  449. # 取出当前的推送数据
  450. start_time = current_time
  451. current_time = int(time.time())
  452. eq_qs = Equipment_Info.objects.filter(addTime__gte=start_time, addTime__lte=current_time)
  453. print(eq_qs.values())
  454. # 0:APNS推送,1:谷歌推送,2:极光推送
  455. tmp = {
  456. 'number_of_successes': 0,
  457. 'number_of_failures': 0,
  458. 'total': 0
  459. }
  460. for eq in eq_qs:
  461. if eq.push_server_status == 200:
  462. tmp['number_of_successes'] += 1
  463. successes += 1
  464. else:
  465. tmp['number_of_failures'] += 1
  466. failures += 1
  467. tmp['total'] += 1
  468. statistics_date = time.strftime('%M-%d', time.localtime(start_time))
  469. tmp_dict[statistics_date] = tmp
  470. for item in data:
  471. if tmp_dict.__contains__(item['date_time']):
  472. item['data'] = tmp_dict[item['date_time']]
  473. success_rate = (successes / (successes + failures))
  474. arrival_rate = success_rate
  475. res = {
  476. 'data': data,
  477. 'successes': successes,
  478. 'failures': failures,
  479. 'success_rate': success_rate,
  480. 'arrival_rate': arrival_rate
  481. }
  482. return response.json(0, res)
  483. @require_http_methods(["GET"])
  484. def getUserIds(request):
  485. token = request.GET.get('token', None)
  486. response = ResponseObject()
  487. tko = TokenObject(token)
  488. response.lang = tko.lang
  489. if tko.code != 0:
  490. return response.json(tko.code)
  491. userID = tko.userID
  492. own_perm = ModelService.check_perm(userID, 30)
  493. if own_perm is not True:
  494. return response.json(404)
  495. dn = Device_User.objects.all().values('userID', 'username')
  496. return response.json(0, {"datas": list(dn)})
  497. @csrf_exempt
  498. def search_user_by_content(request):
  499. if request.method == 'GET':
  500. request_dict = request.GET
  501. if request.method == 'POST':
  502. request_dict = request.POST
  503. token = request_dict.get('token', None)
  504. page = request_dict.get('page', None)
  505. line = request_dict.get('line', None)
  506. content = request_dict.get('content', None)
  507. rstime = request_dict.get('rstime', None)
  508. retime = request_dict.get('retime', None)
  509. response = ResponseObject()
  510. if page is not None and line is not None:
  511. page = int(page)
  512. line = int(line)
  513. else:
  514. return response.json(10, 'page,line is none')
  515. tko = TokenObject(token)
  516. response.lang = tko.lang
  517. if tko.code != 0:
  518. return response.json(tko.code)
  519. userID = tko.userID
  520. own_perm = ModelService.check_perm(userID=userID, permID=20)
  521. if own_perm is not True:
  522. return response.json(404)
  523. try:
  524. content = json.loads(content)
  525. search_kwargs = CommonService.get_kwargs(data=content)
  526. queryset = Device_User.objects.filter(**search_kwargs)
  527. except Exception as e:
  528. return response.json(444, repr(e))
  529. if rstime is not None and rstime != '' and retime is not None and retime != '':
  530. startt = datetime.datetime.fromtimestamp(int(rstime))
  531. rstime = startt.strftime("%Y-%m-%d %H:%M:%S.%f")
  532. endt = datetime.datetime.fromtimestamp(int(retime))
  533. retime = endt.strftime("%Y-%m-%d %H:%M:%S.%f")
  534. queryset = queryset.filter(data_joined__range=(rstime, retime))
  535. elif rstime is not None and rstime != '':
  536. startt = datetime.datetime.fromtimestamp(int(rstime))
  537. rstime = startt.strftime("%Y-%m-%d %H:%M:%S.%f")
  538. queryset = queryset.filter(data_joined__gte=rstime)
  539. elif retime is not None and retime != '':
  540. endt = datetime.datetime.fromtimestamp(int(retime))
  541. retime = endt.strftime("%Y-%m-%d %H:%M:%S.%f")
  542. queryset = queryset.filter(data_joined__lte=retime)
  543. if queryset.exists():
  544. count = queryset.count()
  545. res = queryset[(page - 1) * line:page * line]
  546. sqlDict = CommonService.qs_to_dict(res)
  547. for k, v in enumerate(sqlDict["datas"]):
  548. if len(v['fields']['role']) > 0:
  549. role_query_set = Role.objects.get(rid=v['fields']['role'][0])
  550. sqlDict["datas"][k]['fields']['role'].append(role_query_set.roleName)
  551. for val in res:
  552. if v['pk'] == val.userID:
  553. if sqlDict["datas"][k]['fields']['online'] is True:
  554. dl_time = val.last_login + datetime.timedelta(minutes=5)
  555. now_time = timezone.localtime(timezone.now())
  556. if now_time > dl_time:
  557. sqlDict["datas"][k]['fields']['online'] = False
  558. ue = UserExModel.objects.filter(userID=v['pk'])
  559. if ue.exists():
  560. sqlDict["datas"][k]['fields']['appBundleId'] = ue[0].appBundleId
  561. else:
  562. sqlDict["datas"][k]['fields']['appBundleId'] = ''
  563. sqlDict['count'] = count
  564. return response.json(0, sqlDict)
  565. return response.json(0, {'datas': [], 'count': 0})