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
0b25293c
Commit
0b25293c
authored
Jan 05, 2023
by
dong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix20230104
parent
ddeb1986
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
68 additions
and
77 deletions
+68
-77
apps/manage/view_dict.py
+14
-19
apps/manage/view_org.py
+49
-54
apps/manage/view_user.py
+1
-2
apps/models.py
+1
-0
apps/view_atlas/view.py
+2
-1
apps/view_user/view.py
+1
-1
No files found.
apps/manage/view_dict.py
View file @
0b25293c
...
...
@@ -5,28 +5,27 @@ from apps.util import login_required, verify_btoken
from
apps.utils.response_code
import
RET
#
导航目录
列表
#
产业名称
列表
@api_power.route
(
'/listField'
,
methods
=
[
'GET'
])
@login_required
def
list_fields
():
'''导航目录列表'''
try
:
field
=
Industry
.
query
.
all
()
field
=
Industry
Chain
.
query
.
filter_by
(
industry_type
=
0
)
.
all
()
data
=
[{
"id"
:
i
.
id
,
"name"
:
i
.
name
,
"statu"
:
i
.
statu
,
# 启用状态1启用,2禁用
"cate"
:
"一级产业"
if
i
.
fid
==
0
else
"二级产业"
}
for
i
in
field
]
"name"
:
i
.
industry_name
,
"status"
:
i
.
status
,
# 启用状态1启用,2禁用
# "cate": "一级产业" if i.fid == 0 else "二级产业"
}
for
i
in
field
]
except
Exception
as
e
:
current_app
.
logger
.
error
(
e
)
return
jsonify
(
code
=
RET
.
DBERR
,
msg
=
"数据异常"
)
return
jsonify
(
code
=
RET
.
OK
,
msg
=
"获取成功"
,
data
=
data
)
#
导航信息
编辑
#
产业名称
编辑
@api_power.route
(
'/modifyFields'
,
methods
=
[
'POST'
])
@login_required
def
modify_fields
():
'''导航信息修改'''
# token = request.headers["token"]
# user = verify_btoken(token)
# user_role = user.role # 用户角色
...
...
@@ -38,8 +37,8 @@ def modify_fields():
name
=
req_dict
.
get
(
"newname"
)
# 行业新名字
try
:
field
=
Industry
.
query
.
get
(
_id
)
field
.
name
=
name
field
=
Industry
Chain
.
query
.
get
(
_id
)
field
.
industry_
name
=
name
db
.
session
.
commit
()
except
Exception
as
e
:
current_app
.
logger
.
error
(
e
)
...
...
@@ -47,11 +46,10 @@ def modify_fields():
return
jsonify
(
code
=
RET
.
OK
,
msg
=
"修改成功"
)
#
导航
状态修改
@api_power.route
(
'/fieldStatu'
,
methods
=
[
'POST'
])
#
产业
状态修改
@api_power.route
(
'/fieldStatu
s
'
,
methods
=
[
'POST'
])
@login_required
def
field_statu
():
'''导航信息修改'''
# token = request.headers["token"]
# user = verify_btoken(token)
# user_role = user.role # 用户角色
...
...
@@ -60,14 +58,11 @@ def field_statu():
req_dict
=
request
.
get_json
()
_id
=
req_dict
.
get
(
'id'
)
# 行业id
statu
=
req_dict
.
get
(
"statu
"
)
# 状态值1启用,2禁用
statu
s
=
req_dict
.
get
(
"status
"
)
# 状态值1启用,2禁用
try
:
field
=
Industry
.
query
.
get
(
_id
)
if
statu
==
1
:
field
.
statu
=
2
else
:
field
.
statu
=
1
field
=
IndustryChain
.
query
.
get
(
_id
)
field
.
status
=
status
db
.
session
.
commit
()
except
Exception
as
e
:
current_app
.
logger
.
error
(
e
)
...
...
apps/manage/view_org.py
View file @
0b25293c
...
...
@@ -80,7 +80,7 @@ def add_org():
return
jsonify
(
code
=
RET
.
DBERR
,
msg
=
"数据库操作错误"
)
# 新增部门
或组
# 新增部门
@api_power.route
(
"/addSub"
,
methods
=
[
"POST"
])
@login_required
def
add_sub
():
...
...
@@ -97,7 +97,7 @@ def add_sub():
return
jsonify
(
code
=
RET
.
PARAMERR
,
msg
=
"参数不完整"
)
try
:
if
cate
==
1
:
# 增加部门
#
if cate == 1: # 增加部门
sec
=
Section
.
query
.
filter_by
(
name
=
name
,
goverment_id
=
_id
)
.
first
()
if
sec
:
# 一个机构下部门名不能重复
return
jsonify
(
code
=
RET
.
DATAERR
,
msg
=
"部门名重复"
)
...
...
@@ -112,21 +112,21 @@ def add_sub():
db
.
session
.
add
(
section
)
# 添加部门
goverment
.
sections
.
append
(
section
)
# 外键关系添加
db
.
session
.
commit
()
# 数据库提交
if
cate
==
2
:
# 增加组
gro
=
Group
.
query
.
filter_by
(
name
=
name
,
section_id
=
_id
)
.
first
()
if
gro
:
# 一个部门下组名不能重复
return
jsonify
(
code
=
RET
.
DATAERR
,
msg
=
"组名重复"
)
section
=
Section
.
query
.
get
(
_id
)
group
=
Group
(
name
=
name
,
section_id
=
_id
)
if
pnums
:
group
.
pnums
=
pnums
if
charge
:
group
.
charge
=
charge
if
charge_phone
:
group
.
charge_phone
=
charge_phone
db
.
session
.
add
(
group
)
# 添加组
section
.
groups
.
append
(
group
)
# 添加关系
db
.
session
.
commit
()
# 提交
#
if cate == 2: # 增加组
#
gro = Group.query.filter_by(name=name, section_id=_id).first()
#
if gro: # 一个部门下组名不能重复
#
return jsonify(code=RET.DATAERR, msg="组名重复")
#
section = Section.query.get(_id)
#
group = Group(name=name, section_id=_id)
#
if pnums:
#
group.pnums = pnums
#
if charge:
#
group.charge = charge
#
if charge_phone:
#
group.charge_phone = charge_phone
#
db.session.add(group) # 添加组
#
section.groups.append(group) # 添加关系
#
db.session.commit() # 提交
# if cate == 3:
# return jsonify(code=RET.OK, msg="暂无下级机构,请勿继续添加")
return
jsonify
(
code
=
RET
.
OK
,
msg
=
"添加成功"
)
...
...
@@ -153,22 +153,31 @@ def section_group():
if
cate
==
1
:
# 查询当前机构下的部门
goverment
=
Government
.
query
.
get
(
_id
)
sections
=
goverment
.
sections
# 查询当前机构下的部门list
if
sections
:
data
=
[{
"id"
:
sec
.
id
,
"name"
:
sec
.
name
,
"pnums"
:
sec
.
pnums
if
sec
.
pnums
else
0
,
"charge"
:
sec
.
charge
if
sec
.
charge
else
"-"
,
"charge_phone"
:
sec
.
charge_phone
if
sec
.
charge_phone
else
"-"
,
"cate"
:
2
}
for
sec
in
sections
]
else
:
users
=
User
.
query
.
filter_by
(
belong_organization
=
goverment
.
name
)
.
all
()
# 查询当前部门下的组list
data
=
[{
"id"
:
user
.
id
,
"name"
:
user
.
real_name
,
"pnums"
:
''
,
"charge"
:
''
,
"charge_phone"
:
user
.
mobile
if
user
.
mobile
else
"-"
,
"cate"
:
3
}
for
user
in
users
]
return
jsonify
(
code
=
RET
.
OK
,
msg
=
"查找成功"
,
data
=
data
)
if
cate
==
2
:
# 查询当前部门下的组
section
=
Section
.
query
.
get
(
_id
)
groups
=
section
.
groups
# 查询当前部门下的组list
data
=
[{
"id"
:
group
.
id
,
"name"
:
group
.
name
,
"pnums"
:
group
.
pnums
if
group
.
pnums
else
0
,
"charge"
:
group
.
charge
if
group
.
charge
else
"-"
,
"charge_phone"
:
group
.
charge_phone
if
group
.
charge_phon
e
else
"-"
,
"cate"
:
3
}
for
group
in
group
s
]
section
=
Section
.
query
.
get
(
_id
)
.
name
users
=
User
.
query
.
filter_by
(
belong_department
=
section
)
.
all
()
# 查询当前部门下的组list
data
=
[{
"id"
:
user
.
id
,
"name"
:
user
.
real_
name
,
"pnums"
:
''
,
"charge"
:
''
,
"charge_phone"
:
user
.
mobile
if
user
.
mobil
e
else
"-"
,
"cate"
:
3
}
for
user
in
user
s
]
return
jsonify
(
code
=
RET
.
OK
,
msg
=
"查找成功"
,
data
=
data
)
return
jsonify
(
code
=
RET
.
OK
,
msg
=
"暂无下级信息"
,
data
=
[])
except
Exception
as
e
:
...
...
@@ -176,14 +185,14 @@ def section_group():
return
jsonify
(
code
=
RET
.
DBERR
,
msg
=
"数据库查询错误"
,
data
=
[])
# 编辑机构,部门
或者组
详情
# 编辑机构,部门详情
@api_power.route
(
"/editDetail"
,
methods
=
[
"POST"
])
@login_required
def
edit_detail
():
req_dict
=
request
.
get_json
()
_id
=
req_dict
.
get
(
"id"
)
# 部门id
cate
=
req_dict
.
get
(
"cate"
)
# 1机构,2部门
,3组
name
=
req_dict
.
get
(
"name"
)
# 1机构,2部门
,3组
的名称
cate
=
req_dict
.
get
(
"cate"
)
# 1机构,2部门
name
=
req_dict
.
get
(
"name"
)
# 1机构,2部门 的名称
charge
=
req_dict
.
get
(
"charge"
)
# 局内领导
charge_phone
=
req_dict
.
get
(
"charge_phone"
)
# 联系方式
pnums
=
str
(
req_dict
.
get
(
"pnums"
))
# 人数
...
...
@@ -216,20 +225,6 @@ def edit_detail():
section
.
pnums
=
pnums
db
.
session
.
commit
()
return
jsonify
(
code
=
RET
.
OK
,
msg
=
"修改成功"
)
if
cate
==
3
:
# 组
group
=
Group
.
query
.
get
(
_id
)
# 当前组
sec_id
=
group
.
section_id
# 当前组的部门id
gro
=
Group
.
query
.
filter_by
(
name
=
name
,
section_id
=
sec_id
)
.
filter
(
Group
.
id
!=
_id
)
.
first
()
if
gro
:
# 当前部门下此组名已存在
return
jsonify
(
code
=
RET
.
DBERR
,
msg
=
"组名不可重复"
)
group
.
name
=
name
group
.
charge
=
charge
group
.
charge_phone
=
charge_phone
# group.function = func
group
.
pnums
=
pnums
# group.secnums = secnums
db
.
session
.
commit
()
return
jsonify
(
code
=
RET
.
OK
,
msg
=
"修改成功"
)
return
jsonify
(
code
=
RET
.
DATAERR
,
msg
=
"cate参数错误"
)
except
Exception
as
e
:
# 操作失败,回滚数据库
...
...
@@ -277,18 +272,18 @@ def deleteorg():
db
.
session
.
delete
(
section
)
# 删除
db
.
session
.
commit
()
# 提交
return
jsonify
(
code
=
RET
.
OK
,
msg
=
"删除成功"
)
if
cate
==
3
:
# 删除
组
group
=
Group
.
query
.
get
(
_id
)
# 当前组信息
section
=
group
.
section
# 组属于的部门,单个对象
gover
=
section
.
goverment
# 部门属于的机构,单个对象
unums
=
User
.
query
.
filter_by
(
belong_organization
=
gover
.
name
,
belong_department
=
section
.
name
,
group
=
group
.
name
,
status
=
1
)
.
count
()
# 已经通过审核的人数
if
unums
>
0
:
# 当前组有人,先到组详情,进行组员的删除
return
jsonify
(
code
=
RET
.
REQERR
,
msg
=
"当前组有人员存在,请清除后再操作"
)
section
.
groups
.
remove
(
group
)
# 当前组没有人,删除组之前需要先删除与之相关的部门关系
db
.
session
.
delete
(
group
)
# 删除
if
cate
==
3
:
# 删除
部门下的人员
user
=
User
.
query
.
get
(
_id
)
# 当前组信息
#
section = group.section # 组属于的部门,单个对象
#
gover = section.goverment # 部门属于的机构,单个对象
#
unums = User.query.filter_by(belong_organization=gover.name,
#
belong_department=section.name,
#
group=group.name,
#
status=1).count() # 已经通过审核的人数
#
if unums > 0: # 当前组有人,先到组详情,进行组员的删除
#
return jsonify(code=RET.REQERR, msg="当前组有人员存在,请清除后再操作")
#
section.groups.remove(group) # 当前组没有人,删除组之前需要先删除与之相关的部门关系
db
.
session
.
delete
(
user
)
# 删除
db
.
session
.
commit
()
# 提交
return
jsonify
(
code
=
RET
.
OK
,
msg
=
"删除成功"
)
else
:
...
...
apps/manage/view_user.py
View file @
0b25293c
...
...
@@ -100,7 +100,6 @@ def add_user():
user
.
password
=
password
org_obj
=
OrganizationChart
.
query
.
filter
(
# OrganizationChart.one_org == one_org,
OrganizationChart
.
three_role
==
three_role
)
.
first
()
user
.
org_id
=
org_obj
.
id
db
.
session
.
add
(
user
)
...
...
@@ -219,7 +218,7 @@ def update_user():
user
.
org_id
=
org_obj
.
id
user
.
position
=
position
user
.
belong_organization
=
one_org
user
.
two
_department
=
two_department
user
.
belong
_department
=
two_department
user
.
mobile
=
mobile
user
.
real_name
=
real_name
if
password
and
not
password1
:
...
...
apps/models.py
View file @
0b25293c
...
...
@@ -1726,6 +1726,7 @@ class IndustryChain(db.Model):
__table_args__
=
({
'comment'
:
'新版产业链数据数据表'
})
# 添加表注释
id
=
db
.
Column
(
db
.
Integer
,
primary_key
=
True
,
autoincrement
=
True
,
comment
=
'主键id'
)
industry_name
=
db
.
Column
(
db
.
String
(
20
),
comment
=
'行业名称'
)
status
=
db
.
Column
(
db
.
Integer
,
doc
=
'启用状态1启用,2禁用'
,
comment
=
'启用状态1启用,2禁用'
)
# 启用状态1启用,2禁用
industry_type
=
db
.
Column
(
db
.
Integer
,
comment
=
'行业类型(0是产业集群,1是上游行业,2是中游行业,3是下游行业)'
)
relate_id
=
db
.
Column
(
db
.
Integer
,
comment
=
'关系id(关联与哪个产业环节'
)
...
...
apps/view_atlas/view.py
View file @
0b25293c
...
...
@@ -76,7 +76,8 @@ def find_up_thr(name_query, relation):
@api_atlas.route
(
'/industry/cluster'
,
methods
=
[
'GET'
])
def
get_cluster
():
try
:
cluster_obj
=
Industry
.
query
.
filter_by
(
fid
=
0
)
.
all
()
cluster_obj
=
IndustryChain
.
query
.
filter_by
(
industry_type
=
0
,
status
=
1
)
.
all
()
# cluster_obj = Industry.query.all()
data
=
{
...
...
apps/view_user/view.py
View file @
0b25293c
...
...
@@ -454,7 +454,7 @@ def register():
sms_code
=
req_dict
.
get
(
"sms_code"
)
# 验证码
# 校验参数完整性
if
not
all
([
real_name
,
mobile
,
belong_organization
,
belong_department
,
if
not
all
([
real_name
,
mobile
,
belong_organization
,
sms_code
,
position
,
password
,
password_again
]):
return
jsonify
(
code
=
RET
.
PARAMERR
,
msg
=
"参数不完整"
)
...
...
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