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
...
@@ -5,7 +5,7 @@ from itsdangerous import SignatureExpired, BadSignature
from
flask
import
request
,
jsonify
,
current_app
from
flask
import
request
,
jsonify
,
current_app
from
config
import
Config
from
config
import
Config
# from apps.models import User, Bstage
# from apps.models import User, Bstage
from
apps.models
import
User
from
apps.models
import
User
,
Bstage
import
functools
import
functools
...
...
apps/view_atlas/view.py
View file @
f2220281
...
@@ -81,9 +81,14 @@ def get_cluster():
...
@@ -81,9 +81,14 @@ def get_cluster():
data
=
{
data
=
{
"cluster"
:
[
"cluster"
:
[
{
"id"
:
i
.
nid
,
'industry_level'
:
1
,
'name'
:
i
.
name
,
{
"id"
:
i
.
nid
,
'industry_level'
:
1
,
"subNodeList"
:
[{
'id'
:
j
.
nid
,
'industry_level'
:
2
,
"name"
:
j
.
name
}
for
j
in
'name'
:
i
.
name
,
Industry
.
query
.
filter_by
(
fid
=
i
.
nid
)]}
for
i
in
cluster_obj
]
"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
)
return
jsonify
(
code
=
RET
.
OK
,
msg
=
'产业集群名称获取成功!'
,
data
=
data
)
except
Exception
as
e
:
except
Exception
as
e
:
...
@@ -874,9 +879,9 @@ def inducollect():
...
@@ -874,9 +879,9 @@ def inducollect():
# 行业业收藏与取消
# 行业业收藏与取消
@api_atlas.route
(
'/
industry/c
ollect'
,
methods
=
[
'POST'
])
@api_atlas.route
(
'/
IndustryC
ollect'
,
methods
=
[
'POST'
])
@login_required
@login_required
def
indu_collect
():
def
indu
stry
_collect
():
'''企业收藏与状态取消'''
'''企业收藏与状态取消'''
token
=
request
.
headers
[
"token"
]
token
=
request
.
headers
[
"token"
]
user
=
verify_token
(
token
)
user
=
verify_token
(
token
)
...
@@ -908,6 +913,68 @@ def indu_collect():
...
@@ -908,6 +913,68 @@ def indu_collect():
return
jsonify
(
code
=
RET
.
DBERR
,
msg
=
"数据库查询错误"
)
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():
...
@@ -460,13 +460,13 @@ def register():
position
=
req_dict
.
get
(
"position"
)
# 职务
position
=
req_dict
.
get
(
"position"
)
# 职务
name
=
req_dict
.
get
(
"name"
)
# 用户名
#
name = req_dict.get("name") # 用户名
password
=
req_dict
.
get
(
"password"
)
# 密码
password
=
req_dict
.
get
(
"password"
)
# 密码
password_again
=
req_dict
.
get
(
"password_again"
)
# 密码2
password_again
=
req_dict
.
get
(
"password_again"
)
# 密码2
sms_code
=
req_dict
.
get
(
"sms_code"
)
# 验证码
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
]):
sms_code
,
position
,
password
,
password_again
]):
return
jsonify
(
code
=
RET
.
PARAMERR
,
msg
=
"参数不完整"
)
return
jsonify
(
code
=
RET
.
PARAMERR
,
msg
=
"参数不完整"
)
...
@@ -498,17 +498,17 @@ def register():
...
@@ -498,17 +498,17 @@ def register():
return
jsonify
(
code
=
RET
.
DATAERR
,
msg
=
"短信验证码错误"
)
return
jsonify
(
code
=
RET
.
DATAERR
,
msg
=
"短信验证码错误"
)
# 用户名唯一(字母开头,长度4-15)
# 用户名唯一(字母开头,长度4-15)
try
:
#
try:
patten
=
"^[a-zA-Z][
\
w]*[
\
w]*$"
#
patten = "^[a-zA-Z][\w]*[\w]*$"
if
re
.
match
(
patten
,
name
)
and
re
.
match
(
patten
,
name
)
.
string
==
name
:
#
if re.match(patten, name) and re.match(patten, name).string == name:
user
=
User
.
query
.
filter_by
(
name
=
name
)
.
first
()
#
user = User.query.filter_by(name=name).first()
if
user
:
#
if user:
return
jsonify
(
code
=
RET
.
DATAEXIST
,
msg
=
"用户名已存在"
)
#
return jsonify(code=RET.DATAEXIST, msg="用户名已存在")
else
:
#
else:
return
jsonify
(
code
=
RET
.
DATAERR
,
msg
=
"用户名格式错误"
)
#
return jsonify(code=RET.DATAERR, msg="用户名格式错误")
except
Exception
as
e
:
#
except Exception as e:
current_app
.
logger
.
error
(
e
)
#
current_app.logger.error(e)
return
jsonify
(
code
=
RET
.
DBERR
,
msg
=
"用户名格式错误"
)
#
return jsonify(code=RET.DBERR, msg="用户名格式错误")
# 校验密码
# 校验密码
if
password
!=
password_again
:
if
password
!=
password_again
:
...
@@ -524,8 +524,8 @@ def register():
...
@@ -524,8 +524,8 @@ def register():
r'[.!@#$
%
^&*()_+=-]+'
,
password
)):
r'[.!@#$
%
^&*()_+=-]+'
,
password
)):
return
jsonify
(
code
=
RET
.
DATAERR
,
msg
=
"密码应设置为包含大小写字母、数字、特殊符号'!@#$
%
^&*()_+=-'"
)
return
jsonify
(
code
=
RET
.
DATAERR
,
msg
=
"密码应设置为包含大小写字母、数字、特殊符号'!@#$
%
^&*()_+=-'"
)
# 密码不能使用用户名
# 密码不能使用用户名
if
password
==
name
:
#
if password == name:
return
jsonify
(
code
=
RET
.
DATAERR
,
msg
=
"密码存在风险,不能与用户名相同!"
)
#
return jsonify(code=RET.DATAERR, msg="密码存在风险,不能与用户名相同!")
# 判断并添加用户信息
# 判断并添加用户信息
try
:
try
:
...
@@ -552,7 +552,7 @@ def register():
...
@@ -552,7 +552,7 @@ def register():
# ouser.charge_department = charge_department # 是部门负责人的话,所负责的部门
# ouser.charge_department = charge_department # 是部门负责人的话,所负责的部门
ouser
.
position
=
position
# 职务
ouser
.
position
=
position
# 职务
ouser
.
name
=
name
# 用户名
#
ouser.name = name # 用户名
ouser
.
flag
=
2
# 外部访问为1,内部人员为2
ouser
.
flag
=
2
# 外部访问为1,内部人员为2
# ouser.status = 1 #
# ouser.status = 1 #
ouser
.
password
=
password
ouser
.
password
=
password
...
@@ -566,7 +566,7 @@ def register():
...
@@ -566,7 +566,7 @@ def register():
# is_department_manager=is_department_manager,
# is_department_manager=is_department_manager,
# charge_department=charge_department,
# charge_department=charge_department,
position
=
position
,
position
=
position
,
name
=
name
,
#
name=name,
flag
=
2
,
status
=
1
,
password
=
password
)
flag
=
2
,
status
=
1
,
password
=
password
)
db
.
session
.
add
(
user
)
db
.
session
.
add
(
user
)
...
@@ -600,7 +600,7 @@ def detail():
...
@@ -600,7 +600,7 @@ def detail():
"age"
:
user_info
.
age
,
# 年龄
"age"
:
user_info
.
age
,
# 年龄
"sex"
:
user_info
.
sex
,
# 性别
"sex"
:
user_info
.
sex
,
# 性别
"mobile"
:
user_info
.
mobile
,
# 手机号
"mobile"
:
user_info
.
mobile
,
# 手机号
"username"
:
user_info
.
name
,
# 用户名
#
"username": user_info.name, # 用户名
# "email": user_info.email, # 邮箱
# "email": user_info.email, # 邮箱
"belong_organization"
:
user_info
.
belong_organization
if
user_info
.
belong_organization
else
"-"
,
# 机构
"belong_organization"
:
user_info
.
belong_organization
if
user_info
.
belong_organization
else
"-"
,
# 机构
"belong_department"
:
user_info
.
belong_department
if
user_info
.
belong_department
else
"-"
,
# 部门
"belong_department"
:
user_info
.
belong_department
if
user_info
.
belong_department
else
"-"
,
# 部门
...
@@ -794,7 +794,7 @@ def fix_user_info():
...
@@ -794,7 +794,7 @@ def fix_user_info():
real_name
=
req_dict
.
get
(
"real_name"
)
real_name
=
req_dict
.
get
(
"real_name"
)
age
=
req_dict
.
get
(
"age"
)
age
=
req_dict
.
get
(
"age"
)
sex
=
req_dict
.
get
(
"sex"
)
sex
=
req_dict
.
get
(
"sex"
)
name
=
req_dict
.
get
(
"name"
)
#
name = req_dict.get("name")
position
=
req_dict
.
get
(
"position"
)
position
=
req_dict
.
get
(
"position"
)
belong_organization
=
req_dict
.
get
(
"belong_organization"
)
# 202212新增
belong_organization
=
req_dict
.
get
(
"belong_organization"
)
# 202212新增
...
@@ -821,11 +821,11 @@ def fix_user_info():
...
@@ -821,11 +821,11 @@ def fix_user_info():
if
position
:
if
position
:
user_information
.
position
=
position
user_information
.
position
=
position
# 用户名
# 用户名
if
name
:
#
if name:
user
=
User
.
query
.
filter_by
(
name
=
name
)
.
filter
(
User
.
id
!=
user_id
)
.
first
()
#
user = User.query.filter_by(name=name).filter(User.id != user_id).first()
if
user
:
#
if user:
return
jsonify
(
code
=
RET
.
DATAEXIST
,
msg
=
"用户名已经存在"
)
#
return jsonify(code=RET.DATAEXIST, msg="用户名已经存在")
user_information
.
name
=
name
#
user_information.name = name
db
.
session
.
commit
()
db
.
session
.
commit
()
except
Exception
as
e
:
except
Exception
as
e
:
db
.
session
.
rollback
()
# 回滚数据库
db
.
session
.
rollback
()
# 回滚数据库
...
...
apps/view_user/view_other.py
View file @
f2220281
...
@@ -219,112 +219,113 @@ def change_email():
...
@@ -219,112 +219,113 @@ def change_email():
# return jsonify(code=RET.OK, msg="修改成功")
# return jsonify(code=RET.OK, msg="修改成功")
# 企业的收藏加个下拉列表来判断来自哪个表--是全国企业还是山西企业。返回值里面要带有status还未添加
# 企业的收藏加个下拉列表来判断来自哪个表--是全国企业还是山西企业。
# 返回值里面要带有status还未添加
# 查看收藏----页数,分类
# 查看收藏----页数,分类
@api_user.route
(
"/c
ollect"
,
methods
=
[
"POST"
])
# @api_user.route("/EnterpriseC
ollect", methods=["POST"])
@login_required
#
@login_required
def
collect_com
():
# def enterprise_collect
():
token
=
request
.
headers
[
"token"
]
#
token = request.headers["token"]
user
=
verify_token
(
token
)
#
user = verify_token(token)
user_id
=
user
.
id
#
user_id = user.id
#
req_dict
=
request
.
get_json
()
#
req_dict = request.get_json()
page
=
req_dict
.
get
(
"page"
)
#
page = req_dict.get("page")
per_page
=
req_dict
.
get
(
"per_page"
)
#
per_page = req_dict.get("per_page")
classify
=
req_dict
.
get
(
"classify"
)
#
classify = req_dict.get("classify")
choice
=
req_dict
.
get
(
"choice"
)
#
choice = req_dict.get("choice")
if
not
page
:
#
if not page:
page
=
1
#
page = 1
#
if
not
per_page
:
#
if not per_page:
per_page
=
10
#
per_page = 10
#
if
not
all
([
classify
,
choice
]):
#
if not all([classify, choice]):
return
jsonify
(
code
=
RET
.
PARAMERR
,
msg
=
"数据不全"
)
#
return jsonify(code=RET.PARAMERR, msg="数据不全")
#
# 判断是企业还是行业关注,企业1,行业0
#
# 判断是企业还是行业关注,企业1,行业0
if
classify
==
1
:
#
if classify == 1:
company
=
[]
#
company = []
try
:
#
try:
user
=
User
.
query
.
get
(
user_id
)
#
user = User.query.get(user_id)
except
Exception
as
e
:
#
except Exception as e:
current_app
.
logger
.
error
(
e
)
#
current_app.logger.error(e)
return
jsonify
(
code
=
RET
.
DBERR
,
msg
=
"数据库错误"
)
#
return jsonify(code=RET.DBERR, msg="数据库错误")
if
choice
==
"2"
:
# if choice == 2
:
try
:
#
try:
maxnum
=
len
(
user
.
enterprise
)
#
maxnum = len(user.enterprise)
company_list
=
user
.
enterprise
[(
page
-
1
)
*
per_page
:
page
*
per_page
]
#
company_list = user.enterprise[(page - 1) * per_page:page * per_page]
for
i
in
company_list
:
#
for i in company_list:
create_time
=
UserEnterprise
.
query
.
filter_by
(
enterprise_id
=
i
.
id
,
user_id
=
user_id
)
.
first
()
#
create_time = UserEnterprise.query.filter_by(enterprise_id=i.id, user_id=user_id).first()
company
.
append
({
#
company.append({
"id"
:
i
.
id
,
#
"id": i.id,
"company_name"
:
i
.
company_name
,
#
"company_name": i.company_name,
"create_time"
:
create_time
.
create_time
.
strftime
(
'
%
Y-
%
m-
%
d'
),
#
"create_time": create_time.create_time.strftime('%Y-%m-%d'),
"build_date"
:
i
.
build_date
.
strftime
(
"
%
Y-
%
m-
%
d"
)
if
i
.
build_date
else
"-"
#
"build_date": i.build_date.strftime("%Y-%m-%d") if i.build_date else "-"
})
#
})
except
Exception
as
e
:
#
except Exception as e:
current_app
.
logger
.
error
(
e
)
#
current_app.logger.error(e)
return
jsonify
(
code
=
RET
.
DBERR
,
msg
=
"数据库错误"
)
#
return jsonify(code=RET.DBERR, msg="数据库错误")
#
data
=
{
#
data = {
"ob_list"
:
company
,
#
"ob_list": company,
"maxnum"
:
maxnum
#
"maxnum": maxnum
}
#
}
return
jsonify
(
code
=
RET
.
OK
,
msg
=
"查找成功"
,
data
=
data
)
#
return jsonify(code=RET.OK, msg="查找成功", data=data)
else
:
#
else:
maxnum
=
len
(
user
.
company
)
#
maxnum = len(user.company)
company_list
=
user
.
company
[(
page
-
1
)
*
per_page
:
page
*
per_page
]
#
company_list = user.company[(page - 1) * per_page:page * per_page]
try
:
#
try:
for
i
in
company_list
:
#
for i in company_list:
create_time
=
UserCompany
.
query
.
filter_by
(
company_id
=
i
.
id
,
user_id
=
user_id
)
.
first
()
#
create_time = UserCompany.query.filter_by(company_id=i.id, user_id=user_id).first()
company
.
append
({
#
company.append({
"id"
:
i
.
id
,
#
"id": i.id,
"company_name"
:
i
.
company_name
,
#
"company_name": i.company_name,
"create_time"
:
create_time
.
create_time
.
strftime
(
'
%
Y-
%
m-
%
d'
),
#
"create_time": create_time.create_time.strftime('%Y-%m-%d'),
"build_date"
:
i
.
build_date
.
strftime
(
"
%
Y-
%
m-
%
d"
)
if
i
.
build_date
else
"-"
#
"build_date": i.build_date.strftime("%Y-%m-%d") if i.build_date else "-"
})
#
})
except
Exception
as
e
:
#
except Exception as e:
current_app
.
logger
.
error
(
e
)
#
current_app.logger.error(e)
return
jsonify
(
code
=
RET
.
DBERR
,
msg
=
"数据库错误"
)
#
return jsonify(code=RET.DBERR, msg="数据库错误")
#
data
=
{
#
data = {
"ob_list"
:
company
,
#
"ob_list": company,
"maxnum"
:
maxnum
#
"maxnum": maxnum
}
#
}
return
jsonify
(
code
=
RET
.
OK
,
msg
=
"查找成功"
,
data
=
data
)
#
return jsonify(code=RET.OK, msg="查找成功", data=data)
# 行业
#
# 行业
try
:
#
try:
user
=
User
.
query
.
get
(
user_id
)
#
user = User.query.get(user_id)
except
Exception
as
e
:
#
except Exception as e:
current_app
.
logger
.
error
(
e
)
#
current_app.logger.error(e)
return
jsonify
(
code
=
RET
.
DBERR
,
msg
=
"数据库错误"
)
#
return jsonify(code=RET.DBERR, msg="数据库错误")
#
maxnum
=
len
(
user
.
industry
)
#
maxnum = len(user.industry)
industry
=
[]
#
industry = []
industry_list
=
user
.
industry
[(
page
-
1
)
*
per_page
:
page
*
per_page
]
#
industry_list = user.industry[(page - 1) * per_page:page * per_page]
#
for
i
in
industry_list
:
#
for i in industry_list:
# 查询关注时间
#
# 查询关注时间
try
:
#
try:
indu
=
UserIndustry
.
query
.
filter_by
(
industry_id
=
i
.
id
,
user_id
=
user_id
)
.
first
()
#
indu = UserIndustry.query.filter_by(industry_id=i.id, user_id=user_id).first()
except
Exception
as
e
:
#
except Exception as e:
current_app
.
logger
.
error
(
e
)
#
current_app.logger.error(e)
return
jsonify
(
code
=
RET
.
DBERR
,
msg
=
"数据库错误"
)
#
return jsonify(code=RET.DBERR, msg="数据库错误")
#
# count = Company.query.filter_by(company_industry = i.name)
#
# count = Company.query.filter_by(company_industry = i.name)
industry
.
append
({
#
industry.append({
"id"
:
i
.
id
,
#
"id": i.id,
"industry_name"
:
i
.
name
,
#
"industry_name": i.name,
"create_time"
:
indu
.
create_time
.
strftime
(
"
%
Y-
%
m-
%
d"
),
#
"create_time": indu.create_time.strftime("%Y-%m-%d"),
"count"
:
i
.
entities
if
i
.
entities
else
0
#
"count": i.entities if i.entities else 0
})
#
})
#
data
=
{
#
data = {
"ob_list"
:
industry
,
#
"ob_list": industry,
"maxnum"
:
maxnum
#
"maxnum": maxnum
}
#
}
return
jsonify
(
code
=
RET
.
OK
,
msg
=
"查找成功"
,
data
=
data
)
#
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