|
@@ -24,8 +24,11 @@ from Object.TokenObject import TokenObject
|
|
|
from Service.CommonService import CommonService
|
|
|
from collections import Counter
|
|
|
'''
|
|
|
-http://192.168.136.45:8077/userbrandinfo/query?token=test&page=1&line=10
|
|
|
-http://192.168.136.39:8000/userbrandinfo/query?token=test&page=1&line=5
|
|
|
+http://192.168.136.39:8000/userbrandinfo/queryByAdmin?token=test&page=1&line=10 全部记录
|
|
|
+http://192.168.136.39:8000/userbrandinfo/queryArea?token=test 市的区域统计
|
|
|
+http://192.168.136.39:8000/userbrandinfo/queryDeviceSupplier?token=test 品牌统计
|
|
|
+http://192.168.136.39:8000/userbrandinfo/queryAllByAdmin?token=test&page=1&line=10 全部记录中过滤查询每个用户的最新一条数据
|
|
|
+
|
|
|
http://192.168.136.39:8000/userbrandinfo/queryAll?token=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VySUQiOiIxNTQzOTA5MDUwNDEzMTM4MDAxMzgwMDAiLCJsYW5nIjoiY24iLCJ1c2VyIjoiMTM4MDAxMzgwMDEiLCJtX2NvZGUiOiIxMjM0MTMyNDMyMTQiLCJleHAiOjE1NTk4OTY4NTd9.nhK3VSghSGjyXKjel4woz7R_3bhjgqQDlX-ypYsklNU&page=1&line=5
|
|
|
'''
|
|
|
|
|
@@ -97,11 +100,30 @@ class UserBrandInfo(View):
|
|
|
longitude = request_dict.get('longitude', None)
|
|
|
latitude = request_dict.get('latitude', None)
|
|
|
appId = request_dict.get('appId', None)
|
|
|
- param_area = CommonService.get_param_flag(data=[country])
|
|
|
+
|
|
|
+ if country is None:
|
|
|
+ country=''
|
|
|
+ if province is None:
|
|
|
+ province=''
|
|
|
+ if city is None:
|
|
|
+ city = ''
|
|
|
+ if area is None:
|
|
|
+ area=''
|
|
|
+ if street is None:
|
|
|
+ street=''
|
|
|
+ if longitude is None:
|
|
|
+ longitude=''
|
|
|
+ if latitude is None:
|
|
|
+ latitude=''
|
|
|
+ param_area = CommonService.get_param_flag(data=[country,province,city,longitude,latitude])
|
|
|
must_fill_in = CommonService.get_param_flag(data=[appId,deviceSupplier,deviceModel,osType,osVersion])
|
|
|
if must_fill_in is False:
|
|
|
return response.json(444,'appId,deviceSupplier,deviceModel,osType,osVersion')
|
|
|
if param_area is True:
|
|
|
+ if '省' in province:
|
|
|
+ province = province.replace('省','')
|
|
|
+ if '市' in city:
|
|
|
+ city = city.replace('市','')
|
|
|
status = 1
|
|
|
country = country
|
|
|
province = province
|
|
@@ -112,8 +134,8 @@ class UserBrandInfo(View):
|
|
|
latitude = latitude
|
|
|
else:
|
|
|
status = 0
|
|
|
- jsonData = CommonService.getIpIpInfo(ip=self.clientIP,lang='EN')
|
|
|
- print(jsonData['city_name'])
|
|
|
+ print (self.clientIP)
|
|
|
+ jsonData = CommonService.getIpIpInfo(ip=self.clientIP,lang='CN')
|
|
|
country = jsonData['country_name']
|
|
|
province = jsonData['region_name']
|
|
|
city = jsonData['city_name']
|
|
@@ -162,17 +184,21 @@ class UserBrandInfo(View):
|
|
|
line = int(request_dict.get('line', None))
|
|
|
param_flag = CommonService.get_param_flag(data=[page, line])
|
|
|
if param_flag is True:
|
|
|
- user_brand_queryset = User_Brand.objects.all().order_by('-id')
|
|
|
- if user_brand_queryset.exists():
|
|
|
- count = user_brand_queryset.count()
|
|
|
- res = user_brand_queryset[(page - 1) * line:page * line]
|
|
|
- send_json = CommonService.qs_to_dict(res)
|
|
|
- for k, v in enumerate(send_json["datas"]):
|
|
|
- username = ModelService.get_user_name(userID=send_json["datas"][k]['fields']['userID'])
|
|
|
- send_json["datas"][k]['fields']['username']=username
|
|
|
- send_json['count'] = count
|
|
|
- return response.json(0, send_json)
|
|
|
- return response.json(0, {'datas': [], 'count': 0})
|
|
|
+ check_perm = ModelService.check_perm(userID=userID,permID=30)
|
|
|
+ if check_perm is True:
|
|
|
+ user_brand_queryset = User_Brand.objects.all().order_by('-id')
|
|
|
+ if user_brand_queryset.exists():
|
|
|
+ count = user_brand_queryset.count()
|
|
|
+ res = user_brand_queryset[(page - 1) * line:page * line]
|
|
|
+ send_json = CommonService.qs_to_dict(res)
|
|
|
+ for k, v in enumerate(send_json["datas"]):
|
|
|
+ username = ModelService.get_user_name(userID=send_json["datas"][k]['fields']['userID'])
|
|
|
+ send_json["datas"][k]['fields']['username']=username
|
|
|
+ send_json['count'] = count
|
|
|
+ return response.json(0, send_json)
|
|
|
+ return response.json(0, {'datas': [], 'count': 0})
|
|
|
+ else:
|
|
|
+ return response.json(404)
|
|
|
else:
|
|
|
return response.json(444)
|
|
|
def delete_by_admin(self, request_dict, userID,response):
|
|
@@ -246,6 +272,7 @@ class UserBrandInfo(View):
|
|
|
# 区域统计的接口
|
|
|
def query_area_info(self, request_dict, userID,response):
|
|
|
check_perm = ModelService.check_perm(userID=userID,permID=30)
|
|
|
+ district = request_dict.get('district', None)
|
|
|
if check_perm is True:
|
|
|
# 按照用户去重复查询
|
|
|
user_brand_queryset = User_Brand.objects.all().order_by('userID').values_list('userID', flat=True).distinct()
|
|
@@ -261,7 +288,7 @@ class UserBrandInfo(View):
|
|
|
send_jsons.append(user_brand_querysetlast["datas"][0])
|
|
|
deviceSupplier=[]
|
|
|
for k, v in enumerate(send_jsons):
|
|
|
- deviceSupplier.append(v['fields']['city'])
|
|
|
+ deviceSupplier.append(v['fields'][district])
|
|
|
deviceSupplier = Counter(deviceSupplier)
|
|
|
deviceSupplier = deviceSupplier
|
|
|
|