Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mancheng
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
mancheng
Commits
f2220281
Commit
f2220281
authored
Dec 09, 2022
by
dong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix20221209
parent
c37b36f4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
202 additions
and
134 deletions
+202
-134
apps/util.py
+1
-1
apps/view_atlas/view.py
+72
-5
apps/view_user/view.py
+24
-24
apps/view_user/view_other.py
+105
-104
No files found.
apps/util.py
View file @
f2220281
...
...
@@ -5,7 +5,7 @@ from itsdangerous import SignatureExpired, BadSignature
from
flask
import
request
,
jsonify
,
current_app
from
config
import
Config
# from apps.models import User, Bstage
from
apps.models
import
User
from
apps.models
import
User
,
Bstage
import
functools
...
...
apps/view_atlas/view.py
View file @
f2220281
...
...
@@ -81,9 +81,14 @@ def get_cluster():
data
=
{
"cluster"
:
[
{
"id"
:
i
.
nid
,
'industry_level'
:
1
,
'name'
:
i
.
name
,
"subNodeList"
:
[{
'id'
:
j
.
nid
,
'industry_level'
:
2
,
"name"
:
j
.
name
}
for
j
in
Industry
.
query
.
filter_by
(
fid
=
i
.
nid
)]}
for
i
in
cluster_obj
]
{
"id"
:
i
.
nid
,
'industry_level'
:
1
,
'name'
:
i
.
name
,
"subNodeList"
:
[
{
'id'
:
j
.
nid
,
'industry_level'
:
2
,
"name"
:
j
.
name
}
for
j
in
Industry
.
query
.
filter_by
(
fid
=
i
.
nid
)
]}
for
i
in
cluster_obj
]
}
return
jsonify
(
code
=
RET
.
OK
,
msg
=
'产业集群名称获取成功!'
,
data
=
data
)
except
Exception
as
e
:
...
...
@@ -874,9 +879,9 @@ def inducollect():
# 行业业收藏与取消
@api_atlas.route
(
'/
industry/c
ollect'
,
methods
=
[
'POST'
])
@api_atlas.route
(
'/
IndustryC
ollect'
,
methods
=
[
'POST'
])
@login_required
def
indu_collect
():
def
indu
stry
_collect
():
'''企业收藏与状态取消'''
token
=
request
.
headers
[
"token"
]
user
=
verify_token
(
token
)
...
...
@@ -908,6 +913,68 @@ def indu_collect():
return
jsonify
(
code
=
RET
.
DBERR
,
msg
=
"数据库查询错误"
)
# 企业收藏与取消
@api_atlas.route
(
'/EnterpriseCollect'
,
methods
=
[
'POST'
])
# @login_required
def
enterprise_collect
():
'''
企业收藏与取消
:return:
'''
# 获取用户id
try
:
token
=
request
.
headers
[
"token"
]
user
=
verify_token
(
token
)
user_id
=
user
.
id
# 用户id
except
Exception
as
e
:
current_app
.
logger
.
error
(
e
)
return
jsonify
(
code
=
RET
.
SESSIONERR
,
msg
=
"token过期,请重新登录!"
)
req_dict
=
request
.
get_json
()
_id
=
req_dict
.
get
(
"id"
)
# 企业id
choice
=
req_dict
.
get
(
"choice"
)
# 1太原企业,2全国企业
collect
=
req_dict
.
get
(
"collect"
)
# 关注状态(1是,2否)
# 校验参数完整性
if
not
all
([
_id
,
choice
,
collect
]):
return
jsonify
(
code
=
RET
.
PARAMERR
,
msg
=
"参数不完整"
)
try
:
if
choice
==
1
:
# 太原企业
if
collect
==
2
:
# 未关注,我要关注
user
=
User
.
query
.
get
(
user_id
)
coms
=
Company
.
query
.
get
(
_id
)
user
.
company
.
append
(
coms
)
db
.
session
.
commit
()
return
jsonify
(
code
=
RET
.
OK
,
msg
=
"收藏成功"
,
collect
=
"1"
)
elif
collect
==
1
:
# 已关注,我要取关
user
=
User
.
query
.
get
(
user_id
)
coms
=
Company
.
query
.
get
(
_id
)
user
.
company
.
remove
(
coms
)
db
.
session
.
commit
()
return
jsonify
(
code
=
RET
.
OK
,
msg
=
"取消收藏"
,
collect
=
"2"
)
else
:
return
jsonify
(
code
=
RET
.
DATAERR
,
msg
=
"参数异常"
)
if
choice
==
2
:
# 全国企业
if
collect
==
2
:
# 未关注,我要关注
user
=
User
.
query
.
get
(
user_id
)
enters
=
Enterprise
.
query
.
get
(
_id
)
user
.
enterprise
.
append
(
enters
)
db
.
session
.
commit
()
return
jsonify
(
code
=
RET
.
OK
,
msg
=
"收藏成功"
,
collect
=
"1"
)
elif
collect
==
1
:
# 已关注,我要取关
user
=
User
.
query
.
get
(
user_id
)
enters
=
Enterprise
.
query
.
get
(
_id
)
user
.
enterprise
.
remove
(
enters
)
db
.
session
.
commit
()
return
jsonify
(
code
=
RET
.
OK
,
msg
=
"取消收藏"
,
collect
=
"2"
)
else
:
return
jsonify
(
code
=
RET
.
DATAERR
,
msg
=
"状态参数异常"
)
else
:
return
jsonify
(
code
=
RET
.
DATAERR
,
msg
=
"企业类别参数异常"
)
except
Exception
as
e
:
current_app
.
logger
.
error
(
e
)
return
jsonify
(
code
=
RET
.
DBERR
,
msg
=
"数据库查询错误"
)
"""骨干企业散点图色块图"""
...
...
apps/view_user/view.py
View file @
f2220281
...
...
@@ -460,13 +460,13 @@ def register():
position
=
req_dict
.
get
(
"position"
)
# 职务
name
=
req_dict
.
get
(
"name"
)
# 用户名
#
name = req_dict.get("name") # 用户名
password
=
req_dict
.
get
(
"password"
)
# 密码
password_again
=
req_dict
.
get
(
"password_again"
)
# 密码2
sms_code
=
req_dict
.
get
(
"sms_code"
)
# 验证码
# 校验参数完整性
if
not
all
([
real_name
,
mobile
,
name
,
belong_organization
,
belong_department
,
if
not
all
([
real_name
,
mobile
,
belong_organization
,
belong_department
,
sms_code
,
position
,
password
,
password_again
]):
return
jsonify
(
code
=
RET
.
PARAMERR
,
msg
=
"参数不完整"
)
...
...
@@ -498,17 +498,17 @@ def register():
return
jsonify
(
code
=
RET
.
DATAERR
,
msg
=
"短信验证码错误"
)
# 用户名唯一(字母开头,长度4-15)
try
:
patten
=
"^[a-zA-Z][
\
w]*[
\
w]*$"
if
re
.
match
(
patten
,
name
)
and
re
.
match
(
patten
,
name
)
.
string
==
name
:
user
=
User
.
query
.
filter_by
(
name
=
name
)
.
first
()
if
user
:
return
jsonify
(
code
=
RET
.
DATAEXIST
,
msg
=
"用户名已存在"
)
else
:
return
jsonify
(
code
=
RET
.
DATAERR
,
msg
=
"用户名格式错误"
)
except
Exception
as
e
:
current_app
.
logger
.
error
(
e
)
return
jsonify
(
code
=
RET
.
DBERR
,
msg
=
"用户名格式错误"
)
#
try:
#
patten = "^[a-zA-Z][\w]*[\w]*$"
#
if re.match(patten, name) and re.match(patten, name).string == name:
#
user = User.query.filter_by(name=name).first()
#
if user:
#
return jsonify(code=RET.DATAEXIST, msg="用户名已存在")
#
else:
#
return jsonify(code=RET.DATAERR, msg="用户名格式错误")
#
except Exception as e:
#
current_app.logger.error(e)
#
return jsonify(code=RET.DBERR, msg="用户名格式错误")
# 校验密码
if
password
!=
password_again
:
...
...
@@ -524,8 +524,8 @@ def register():
r'[.!@#$
%
^&*()_+=-]+'
,
password
)):
return
jsonify
(
code
=
RET
.
DATAERR
,
msg
=
"密码应设置为包含大小写字母、数字、特殊符号'!@#$
%
^&*()_+=-'"
)
# 密码不能使用用户名
if
password
==
name
:
return
jsonify
(
code
=
RET
.
DATAERR
,
msg
=
"密码存在风险,不能与用户名相同!"
)
#
if password == name:
#
return jsonify(code=RET.DATAERR, msg="密码存在风险,不能与用户名相同!")
# 判断并添加用户信息
try
:
...
...
@@ -552,7 +552,7 @@ def register():
# ouser.charge_department = charge_department # 是部门负责人的话,所负责的部门
ouser
.
position
=
position
# 职务
ouser
.
name
=
name
# 用户名
#
ouser.name = name # 用户名
ouser
.
flag
=
2
# 外部访问为1,内部人员为2
# ouser.status = 1 #
ouser
.
password
=
password
...
...
@@ -566,7 +566,7 @@ def register():
# is_department_manager=is_department_manager,
# charge_department=charge_department,
position
=
position
,
name
=
name
,
#
name=name,
flag
=
2
,
status
=
1
,
password
=
password
)
db
.
session
.
add
(
user
)
...
...
@@ -600,7 +600,7 @@ def detail():
"age"
:
user_info
.
age
,
# 年龄
"sex"
:
user_info
.
sex
,
# 性别
"mobile"
:
user_info
.
mobile
,
# 手机号
"username"
:
user_info
.
name
,
# 用户名
#
"username": user_info.name, # 用户名
# "email": user_info.email, # 邮箱
"belong_organization"
:
user_info
.
belong_organization
if
user_info
.
belong_organization
else
"-"
,
# 机构
"belong_department"
:
user_info
.
belong_department
if
user_info
.
belong_department
else
"-"
,
# 部门
...
...
@@ -794,7 +794,7 @@ def fix_user_info():
real_name
=
req_dict
.
get
(
"real_name"
)
age
=
req_dict
.
get
(
"age"
)
sex
=
req_dict
.
get
(
"sex"
)
name
=
req_dict
.
get
(
"name"
)
#
name = req_dict.get("name")
position
=
req_dict
.
get
(
"position"
)
belong_organization
=
req_dict
.
get
(
"belong_organization"
)
# 202212新增
...
...
@@ -821,11 +821,11 @@ def fix_user_info():
if
position
:
user_information
.
position
=
position
# 用户名
if
name
:
user
=
User
.
query
.
filter_by
(
name
=
name
)
.
filter
(
User
.
id
!=
user_id
)
.
first
()
if
user
:
return
jsonify
(
code
=
RET
.
DATAEXIST
,
msg
=
"用户名已经存在"
)
user_information
.
name
=
name
#
if name:
#
user = User.query.filter_by(name=name).filter(User.id != user_id).first()
#
if user:
#
return jsonify(code=RET.DATAEXIST, msg="用户名已经存在")
#
user_information.name = name
db
.
session
.
commit
()
except
Exception
as
e
:
db
.
session
.
rollback
()
# 回滚数据库
...
...
apps/view_user/view_other.py
View file @
f2220281
...
...
@@ -219,112 +219,113 @@ def change_email():
# return jsonify(code=RET.OK, msg="修改成功")
# 企业的收藏加个下拉列表来判断来自哪个表--是全国企业还是山西企业。返回值里面要带有status还未添加
# 企业的收藏加个下拉列表来判断来自哪个表--是全国企业还是山西企业。
# 返回值里面要带有status还未添加
# 查看收藏----页数,分类
@api_user.route
(
"/c
ollect"
,
methods
=
[
"POST"
])
@login_required
def
collect_com
():
token
=
request
.
headers
[
"token"
]
user
=
verify_token
(
token
)
user_id
=
user
.
id
req_dict
=
request
.
get_json
()
page
=
req_dict
.
get
(
"page"
)
per_page
=
req_dict
.
get
(
"per_page"
)
classify
=
req_dict
.
get
(
"classify"
)
choice
=
req_dict
.
get
(
"choice"
)
if
not
page
:
page
=
1
if
not
per_page
:
per_page
=
10
if
not
all
([
classify
,
choice
]):
return
jsonify
(
code
=
RET
.
PARAMERR
,
msg
=
"数据不全"
)
# 判断是企业还是行业关注,企业1,行业0
if
classify
==
1
:
company
=
[]
try
:
user
=
User
.
query
.
get
(
user_id
)
except
Exception
as
e
:
current_app
.
logger
.
error
(
e
)
return
jsonify
(
code
=
RET
.
DBERR
,
msg
=
"数据库错误"
)
if
choice
==
"2"
:
try
:
maxnum
=
len
(
user
.
enterprise
)
company_list
=
user
.
enterprise
[(
page
-
1
)
*
per_page
:
page
*
per_page
]
for
i
in
company_list
:
create_time
=
UserEnterprise
.
query
.
filter_by
(
enterprise_id
=
i
.
id
,
user_id
=
user_id
)
.
first
()
company
.
append
({
"id"
:
i
.
id
,
"company_name"
:
i
.
company_name
,
"create_time"
:
create_time
.
create_time
.
strftime
(
'
%
Y-
%
m-
%
d'
),
"build_date"
:
i
.
build_date
.
strftime
(
"
%
Y-
%
m-
%
d"
)
if
i
.
build_date
else
"-"
})
except
Exception
as
e
:
current_app
.
logger
.
error
(
e
)
return
jsonify
(
code
=
RET
.
DBERR
,
msg
=
"数据库错误"
)
data
=
{
"ob_list"
:
company
,
"maxnum"
:
maxnum
}
return
jsonify
(
code
=
RET
.
OK
,
msg
=
"查找成功"
,
data
=
data
)
else
:
maxnum
=
len
(
user
.
company
)
company_list
=
user
.
company
[(
page
-
1
)
*
per_page
:
page
*
per_page
]
try
:
for
i
in
company_list
:
create_time
=
UserCompany
.
query
.
filter_by
(
company_id
=
i
.
id
,
user_id
=
user_id
)
.
first
()
company
.
append
({
"id"
:
i
.
id
,
"company_name"
:
i
.
company_name
,
"create_time"
:
create_time
.
create_time
.
strftime
(
'
%
Y-
%
m-
%
d'
),
"build_date"
:
i
.
build_date
.
strftime
(
"
%
Y-
%
m-
%
d"
)
if
i
.
build_date
else
"-"
})
except
Exception
as
e
:
current_app
.
logger
.
error
(
e
)
return
jsonify
(
code
=
RET
.
DBERR
,
msg
=
"数据库错误"
)
data
=
{
"ob_list"
:
company
,
"maxnum"
:
maxnum
}
return
jsonify
(
code
=
RET
.
OK
,
msg
=
"查找成功"
,
data
=
data
)
# 行业
try
:
user
=
User
.
query
.
get
(
user_id
)
except
Exception
as
e
:
current_app
.
logger
.
error
(
e
)
return
jsonify
(
code
=
RET
.
DBERR
,
msg
=
"数据库错误"
)
maxnum
=
len
(
user
.
industry
)
industry
=
[]
industry_list
=
user
.
industry
[(
page
-
1
)
*
per_page
:
page
*
per_page
]
for
i
in
industry_list
:
# 查询关注时间
try
:
indu
=
UserIndustry
.
query
.
filter_by
(
industry_id
=
i
.
id
,
user_id
=
user_id
)
.
first
()
except
Exception
as
e
:
current_app
.
logger
.
error
(
e
)
return
jsonify
(
code
=
RET
.
DBERR
,
msg
=
"数据库错误"
)
# count = Company.query.filter_by(company_industry = i.name)
industry
.
append
({
"id"
:
i
.
id
,
"industry_name"
:
i
.
name
,
"create_time"
:
indu
.
create_time
.
strftime
(
"
%
Y-
%
m-
%
d"
),
"count"
:
i
.
entities
if
i
.
entities
else
0
})
data
=
{
"ob_list"
:
industry
,
"maxnum"
:
maxnum
}
return
jsonify
(
code
=
RET
.
OK
,
msg
=
"查找成功"
,
data
=
data
)
# @api_user.route("/EnterpriseC
ollect", methods=["POST"])
#
@login_required
# def enterprise_collect
():
#
token = request.headers["token"]
#
user = verify_token(token)
#
user_id = user.id
#
#
req_dict = request.get_json()
#
page = req_dict.get("page")
#
per_page = req_dict.get("per_page")
#
classify = req_dict.get("classify")
#
choice = req_dict.get("choice")
#
if not page:
#
page = 1
#
#
if not per_page:
#
per_page = 10
#
#
if not all([classify, choice]):
#
return jsonify(code=RET.PARAMERR, msg="数据不全")
#
#
# 判断是企业还是行业关注,企业1,行业0
#
if classify == 1:
#
company = []
#
try:
#
user = User.query.get(user_id)
#
except Exception as e:
#
current_app.logger.error(e)
#
return jsonify(code=RET.DBERR, msg="数据库错误")
# if choice == 2
:
#
try:
#
maxnum = len(user.enterprise)
#
company_list = user.enterprise[(page - 1) * per_page:page * per_page]
#
for i in company_list:
#
create_time = UserEnterprise.query.filter_by(enterprise_id=i.id, user_id=user_id).first()
#
company.append({
#
"id": i.id,
#
"company_name": i.company_name,
#
"create_time": create_time.create_time.strftime('%Y-%m-%d'),
#
"build_date": i.build_date.strftime("%Y-%m-%d") if i.build_date else "-"
#
})
#
except Exception as e:
#
current_app.logger.error(e)
#
return jsonify(code=RET.DBERR, msg="数据库错误")
#
#
data = {
#
"ob_list": company,
#
"maxnum": maxnum
#
}
#
return jsonify(code=RET.OK, msg="查找成功", data=data)
#
else:
#
maxnum = len(user.company)
#
company_list = user.company[(page - 1) * per_page:page * per_page]
#
try:
#
for i in company_list:
#
create_time = UserCompany.query.filter_by(company_id=i.id, user_id=user_id).first()
#
company.append({
#
"id": i.id,
#
"company_name": i.company_name,
#
"create_time": create_time.create_time.strftime('%Y-%m-%d'),
#
"build_date": i.build_date.strftime("%Y-%m-%d") if i.build_date else "-"
#
})
#
except Exception as e:
#
current_app.logger.error(e)
#
return jsonify(code=RET.DBERR, msg="数据库错误")
#
#
data = {
#
"ob_list": company,
#
"maxnum": maxnum
#
}
#
return jsonify(code=RET.OK, msg="查找成功", data=data)
#
# 行业
#
try:
#
user = User.query.get(user_id)
#
except Exception as e:
#
current_app.logger.error(e)
#
return jsonify(code=RET.DBERR, msg="数据库错误")
#
#
maxnum = len(user.industry)
#
industry = []
#
industry_list = user.industry[(page - 1) * per_page:page * per_page]
#
#
for i in industry_list:
#
# 查询关注时间
#
try:
#
indu = UserIndustry.query.filter_by(industry_id=i.id, user_id=user_id).first()
#
except Exception as e:
#
current_app.logger.error(e)
#
return jsonify(code=RET.DBERR, msg="数据库错误")
#
#
# count = Company.query.filter_by(company_industry = i.name)
#
industry.append({
#
"id": i.id,
#
"industry_name": i.name,
#
"create_time": indu.create_time.strftime("%Y-%m-%d"),
#
"count": i.entities if i.entities else 0
#
})
#
#
data = {
#
"ob_list": industry,
#
"maxnum": maxnum
#
}
#
return jsonify(code=RET.OK, msg="查找成功", data=data)
# 取消收藏
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment