tfse-admin-api-v0.2/company/db.py

65 lines
1.6 KiB
Python

import re
import pymongo
client = pymongo.MongoClient('mongodb://{}:{}@{}:{}'.format('root', 'sromitdTW569kC#M', '116.63.130.34', 27018))
def find_company_records(query):
"""
查询企业信息
Parameters:
query: 查询条件
Returns:
record: 查询结果
"""
collection = client['用户']['用户信息']
data = collection.find({"企业ID": query}, {'企业ID': True, '企业名称': True, '_id': False})
record = list(data)
if len(record) == 0:
data = collection.find({"企业名称": re.compile(query)}, {'企业ID': True, '企业名称': True, '_id': False})
record = list(data)
return record
def find_user_info(cid):
"""
查询用户信息
Parameters:
cid: 企业ID
Returns:
record: 查询结果
"""
collection = client['用户']['用户信息']
data = collection.find({"企业ID": cid}, {'企业ID': True, '企业名称': True, '已认证': True, '_id': False})
record = list(data)
return record
def find_company_basic_info(cid):
"""
查询公司基本信息
Parameters:
cid: 企业ID
Returns:
record: 查询结果
"""
collection = client['企业']['公司基本信息']
data = collection.find({"企业ID": cid}, {'_id': False})
record = list(data)
return record
def find_company_evaluate_info(cid):
"""
查询评价记录
Parameters:
cid: 企业ID
Returns:
record: 查询结果
"""
collection = client['评价']['评价记录']
data = collection.find({"企业ID": cid}, {'_id': False, '企业ID': False})
record = list(data)
return record