Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
X
xplot_server
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
digit_plot
xplot_server
Commits
f700eb60
Commit
f700eb60
authored
Nov 10, 2024
by
dliangx
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修复返回状态
parent
8000990b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
59 additions
and
21 deletions
+59
-21
handler/http_handler.go
+59
-21
No files found.
handler/http_handler.go
View file @
f700eb60
...
...
@@ -20,19 +20,24 @@ func SaveGeometry(ctx context.Context, c *app.RequestContext) {
err
:=
c
.
BindAndValidate
(
&
req
)
if
err
!=
nil
{
c
.
JSON
(
consts
.
StatusBadRequest
,
utils
.
H
{
"message"
:
"geojson required"
})
return
}
if
req
.
Opt
==
1
||
req
.
Opt
==
2
{
resp
,
err
:=
geo
.
SaveRoute
(
req
)
if
err
!=
nil
{
c
.
JSON
(
consts
.
StatusInternalServerError
,
err
.
Error
())
c
.
JSON
(
consts
.
StatusOK
,
utils
.
H
{
"code"
:
10001
,
"message"
:
err
.
Error
()})
return
}
c
.
JSON
(
consts
.
StatusOK
,
resp
)
return
}
else
if
req
.
Opt
==
3
{
resp
,
err
:=
geo
.
SaveOptArea
(
req
)
if
err
!=
nil
{
c
.
JSON
(
consts
.
StatusInternalServerError
,
err
.
Error
())
c
.
JSON
(
consts
.
StatusOK
,
utils
.
H
{
"code"
:
10002
,
"message"
:
err
.
Error
()})
return
}
c
.
JSON
(
consts
.
StatusOK
,
resp
)
return
}
}
...
...
@@ -42,71 +47,93 @@ func UpdateGeometry(ctx context.Context, c *app.RequestContext) {
err
:=
c
.
BindAndValidate
(
&
req
)
if
err
!=
nil
{
c
.
JSON
(
consts
.
StatusBadRequest
,
utils
.
H
{
"message"
:
"geojson required"
})
return
}
if
req
.
Opt
==
1
||
req
.
Opt
==
2
{
resp
,
err
:=
geo
.
UpdateRoute
(
req
)
if
err
!=
nil
{
c
.
JSON
(
consts
.
StatusInternalServerError
,
err
.
Error
())
c
.
JSON
(
consts
.
StatusOK
,
utils
.
H
{
"code"
:
10003
,
"message"
:
err
.
Error
()})
return
}
c
.
JSON
(
consts
.
StatusOK
,
resp
)
return
}
else
if
req
.
Opt
==
3
{
resp
,
err
:=
geo
.
UpdateOptArea
(
req
)
if
err
!=
nil
{
c
.
JSON
(
consts
.
StatusInternalServerError
,
err
.
Error
())
c
.
JSON
(
consts
.
StatusOK
,
utils
.
H
{
"code"
:
10004
,
"message"
:
err
.
Error
()})
return
}
c
.
JSON
(
consts
.
StatusOK
,
resp
)
return
}
}
func
GetGeometry
(
ctx
context
.
Context
,
c
*
app
.
RequestContext
)
{
id
,
err
:=
strconv
.
Atoi
(
c
.
Params
.
ByName
(
"id"
))
check_str
:=
""
id
,
err
:=
strconv
.
Atoi
(
c
.
Query
(
"id"
))
if
err
!=
nil
{
c
.
JSON
(
consts
.
StatusBadRequest
,
utils
.
H
{
"message"
:
"id required"
})
c
heck_str
+=
"param id required;"
}
opt
,
err
:=
strconv
.
Atoi
(
c
.
Params
.
ByName
(
"opt"
))
opt
,
err
:=
strconv
.
Atoi
(
c
.
Query
(
"opt"
))
if
err
!=
nil
{
c
.
JSON
(
consts
.
StatusBadRequest
,
utils
.
H
{
"message"
:
"opt required"
})
check_str
+=
"param opt required;"
}
if
check_str
!=
""
{
c
.
JSON
(
consts
.
StatusBadRequest
,
utils
.
H
{
"message"
:
check_str
})
return
}
if
opt
==
1
||
opt
==
2
{
resp
,
err
:=
geo
.
GetRoute
(
id
,
opt
)
if
err
!=
nil
{
c
.
JSON
(
consts
.
StatusInternalServerError
,
err
.
Error
())
c
.
JSON
(
consts
.
StatusOK
,
utils
.
H
{
"code"
:
10005
,
"message"
:
err
.
Error
()})
return
}
c
.
JSON
(
consts
.
StatusOK
,
resp
)
return
}
else
if
opt
==
3
{
resp
,
err
:=
geo
.
GetOptArea
(
id
,
opt
)
if
err
!=
nil
{
c
.
JSON
(
consts
.
StatusInternalServerError
,
err
.
Error
())
c
.
JSON
(
consts
.
StatusOK
,
utils
.
H
{
"code"
:
10006
,
"message"
:
err
.
Error
()})
return
}
c
.
JSON
(
consts
.
StatusOK
,
resp
)
return
}
}
func
DeleteGeometry
(
ctx
context
.
Context
,
c
*
app
.
RequestContext
)
{
id
,
err
:=
strconv
.
Atoi
(
c
.
Params
.
ByName
(
"id"
))
check_str
:=
""
id
,
err
:=
strconv
.
Atoi
(
c
.
Query
(
"id"
))
if
err
!=
nil
{
c
.
JSON
(
consts
.
StatusBadRequest
,
utils
.
H
{
"message"
:
"id required"
})
c
heck_str
+=
"param id required;"
}
opt
,
err
:=
strconv
.
Atoi
(
c
.
Params
.
ByName
(
"opt"
))
opt
,
err
:=
strconv
.
Atoi
(
c
.
Query
(
"opt"
))
if
err
!=
nil
{
c
.
JSON
(
consts
.
StatusBadRequest
,
utils
.
H
{
"message"
:
"opt required"
})
check_str
+=
"param opt required;"
}
if
check_str
!=
""
{
c
.
JSON
(
consts
.
StatusBadRequest
,
utils
.
H
{
"message"
:
check_str
})
return
}
if
opt
==
1
||
opt
==
2
{
resp
,
err
:=
geo
.
DeleteRoute
(
id
,
opt
)
if
err
!=
nil
{
c
.
JSON
(
consts
.
StatusInternalServerError
,
err
.
Error
())
c
.
JSON
(
consts
.
StatusOK
,
utils
.
H
{
"code"
:
10007
,
"message"
:
err
.
Error
()})
return
}
c
.
JSON
(
consts
.
StatusOK
,
resp
)
return
}
else
if
opt
==
3
{
resp
,
err
:=
geo
.
DeleteOptArea
(
id
,
opt
)
if
err
!=
nil
{
c
.
JSON
(
consts
.
StatusInternalServerError
,
err
.
Error
())
c
.
JSON
(
consts
.
StatusOK
,
utils
.
H
{
"code"
:
10008
,
"message"
:
err
.
Error
()})
return
}
c
.
JSON
(
consts
.
StatusOK
,
resp
)
return
}
}
...
...
@@ -115,19 +142,24 @@ func FindRelatedGeometry(ctx context.Context, c *app.RequestContext) {
err
:=
c
.
BindAndValidate
(
&
req
)
if
err
!=
nil
{
c
.
JSON
(
consts
.
StatusBadRequest
,
utils
.
H
{
"message"
:
"geojson required"
})
return
}
if
req
.
Opt
==
1
||
req
.
Opt
==
2
{
resp
,
err
:=
geo
.
GetRelatedRoute
(
req
)
if
err
!=
nil
{
c
.
JSON
(
consts
.
StatusInternalServerError
,
err
.
Error
())
c
.
JSON
(
consts
.
StatusOK
,
utils
.
H
{
"code"
:
10009
,
"message"
:
err
.
Error
()})
return
}
c
.
JSON
(
consts
.
StatusOK
,
resp
)
return
}
else
if
req
.
Opt
==
3
{
resp
,
err
:=
geo
.
GetRelatedOptArea
(
req
)
if
err
!=
nil
{
c
.
JSON
(
consts
.
StatusInternalServerError
,
err
.
Error
())
c
.
JSON
(
consts
.
StatusOK
,
utils
.
H
{
"code"
:
10010
,
"message"
:
err
.
Error
()})
return
}
c
.
JSON
(
consts
.
StatusOK
,
resp
)
return
}
}
...
...
@@ -137,22 +169,28 @@ func CheckTwoOptAreaIsCross(ctx context.Context, c *app.RequestContext) {
err
:=
c
.
BindAndValidate
(
&
req
)
if
err
!=
nil
{
c
.
JSON
(
consts
.
StatusBadRequest
,
utils
.
H
{
"message"
:
"geojson required"
})
return
}
if
len
(
req
)
!=
2
{
c
.
JSON
(
consts
.
StatusBadRequest
,
utils
.
H
{
"message"
:
"need tow geojson body"
})
return
}
if
req
[
0
]
.
ID
==
0
||
req
[
1
]
.
ID
==
0
{
res
,
err
:=
geo
.
CheckAreasCross
(
req
[
0
],
req
[
1
])
if
err
!=
nil
{
c
.
JSON
(
consts
.
StatusInternalServerError
,
err
.
Error
())
c
.
JSON
(
consts
.
StatusOK
,
utils
.
H
{
"code"
:
10011
,
"message"
:
err
.
Error
()})
return
}
c
.
JSON
(
consts
.
StatusOK
,
res
)
return
}
else
{
res
,
err
:=
geo
.
CheckOptAreasCrossById
(
req
[
0
]
.
ID
,
req
[
1
]
.
ID
)
if
err
!=
nil
{
c
.
JSON
(
consts
.
StatusInternalServerError
,
err
.
Error
())
c
.
JSON
(
consts
.
StatusOK
,
utils
.
H
{
"code"
:
10012
,
"message"
:
err
.
Error
()})
return
}
c
.
JSON
(
consts
.
StatusOK
,
res
)
return
}
}
...
...
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