接收上报的定位信息
This commit is contained in:
parent
e53ca6a47f
commit
e376b160ce
@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="CodeStream">
|
||||
<option name="webViewContext" value="{"chatProviderAccess":"strict","currentTeamId":"","currentStreamId":"","pullRequestCheckoutBranch":false,"isRepositioning":false,"onboardStep":0,"panelStack":["landing-redirect"],"hasFocus":false,"channelFilter":"all","channelsMuteAll":false,"codemarkFileFilter":"all","codemarkTypeFilter":"all","codemarkTagFilter":"all","codemarkBranchFilter":"all","codemarkAuthorFilter":"all","codemarksFileViewStyle":"inline","codemarksShowArchived":false,"codemarksShowResolved":false,"codemarksWrapComments":false,"showFeedbackSmiley":true,"route":{"name":"newUserEntry","params":{}},"spatialViewShowPRComments":false,"currentPullRequestNeedsRefresh":{"needsRefresh":false,"providerId":"","pullRequestId":""},"__teamless__":{"selectedRegion":"us"},"sessionStart":1677493609591}" />
|
||||
<option name="webViewContext" value="{"chatProviderAccess":"strict","currentTeamId":"","currentStreamId":"","pullRequestCheckoutBranch":false,"isRepositioning":false,"onboardStep":0,"panelStack":["landing-redirect"],"hasFocus":false,"channelFilter":"all","channelsMuteAll":false,"codemarkFileFilter":"all","codemarkTypeFilter":"all","codemarkTagFilter":"all","codemarkBranchFilter":"all","codemarkAuthorFilter":"all","codemarksFileViewStyle":"inline","codemarksShowArchived":false,"codemarksShowResolved":false,"codemarksWrapComments":false,"showFeedbackSmiley":true,"route":{"name":"newUserEntry","params":{}},"spatialViewShowPRComments":false,"currentPullRequestNeedsRefresh":{"needsRefresh":false,"providerId":"","pullRequestId":""},"__teamless__":{"selectedRegion":"us"},"sessionStart":1678789557448}" />
|
||||
</component>
|
||||
</project>
|
@ -168,6 +168,35 @@ const docTemplate = `{
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/record/location/post": {
|
||||
"post": {
|
||||
"description": "上报定位信息",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"Record"
|
||||
],
|
||||
"summary": "上报定位信息",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/resp.Response"
|
||||
}
|
||||
},
|
||||
"default": {
|
||||
"description": "",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/errorx.CodeErrorResponse"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"definitions": {
|
||||
|
@ -161,6 +161,35 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/record/location/post": {
|
||||
"post": {
|
||||
"description": "上报定位信息",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"Record"
|
||||
],
|
||||
"summary": "上报定位信息",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/resp.Response"
|
||||
}
|
||||
},
|
||||
"default": {
|
||||
"description": "",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/errorx.CodeErrorResponse"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"definitions": {
|
||||
|
@ -149,4 +149,23 @@ paths:
|
||||
summary: 获取 bot 类型列表
|
||||
tags:
|
||||
- BotType
|
||||
/record/location/post:
|
||||
post:
|
||||
consumes:
|
||||
- application/json
|
||||
description: 上报定位信息
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
schema:
|
||||
$ref: '#/definitions/resp.Response'
|
||||
default:
|
||||
description: ""
|
||||
schema:
|
||||
$ref: '#/definitions/errorx.CodeErrorResponse'
|
||||
summary: 上报定位信息
|
||||
tags:
|
||||
- Record
|
||||
swagger: "2.0"
|
||||
|
@ -0,0 +1,61 @@
|
||||
package location
|
||||
|
||||
import (
|
||||
"github.com/gofiber/fiber/v2"
|
||||
"matrix-middle-service/pkg/logger"
|
||||
response "matrix-middle-service/pkg/resp"
|
||||
"matrix-middle-service/pkg/resp/errorx"
|
||||
utils "matrix-middle-service/pkg/utils/json"
|
||||
"matrix-middle-service/pkg/utils/time"
|
||||
)
|
||||
|
||||
func SetupLocation(r fiber.Router) {
|
||||
api := r.Group("/location")
|
||||
postLocation(api)
|
||||
}
|
||||
|
||||
type Data struct {
|
||||
CallbackTime time.Time `json:"callbackTime"`
|
||||
LocationTime time.Time `json:"locationTime"`
|
||||
LocationType int `json:"locationType,omitempty"`
|
||||
Latitude float64 `json:"latitude,omitempty"`
|
||||
Longitude float64 `json:"longitude,omitempty"`
|
||||
Accuracy float64 `json:"accuracy,omitempty"`
|
||||
Altitude float64 `json:"altitude,omitempty"`
|
||||
Bearing float64 `json:"bearing,omitempty"`
|
||||
Speed float64 `json:"speed,omitempty"`
|
||||
Country string `json:"country,omitempty"`
|
||||
Province string `json:"province,omitempty"`
|
||||
City string `json:"city,omitempty"`
|
||||
District string `json:"district,omitempty"`
|
||||
Street string `json:"street,omitempty"`
|
||||
StreetNumber string `json:"streetNumber,omitempty"`
|
||||
CityCode string `json:"cityCode,omitempty"`
|
||||
AdCode string `json:"adCode,omitempty"`
|
||||
Address string `json:"address,omitempty"`
|
||||
Description string `json:"description,omitempty"`
|
||||
}
|
||||
|
||||
// postLocation
|
||||
// @Summary 上报定位信息
|
||||
// @Description 上报定位信息
|
||||
// @Tags Record
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Success 200 {object} response.Response
|
||||
// @Failure default {object} errorx.CodeErrorResponse
|
||||
// @Router /record/location/post [post]
|
||||
func postLocation(api fiber.Router) {
|
||||
api.Post("/post", func(ctx *fiber.Ctx) error {
|
||||
data := &Data{}
|
||||
err := ctx.BodyParser(data)
|
||||
if err != nil {
|
||||
logger.Log().Error(err)
|
||||
return ctx.JSON(errorx.ParseError(err))
|
||||
}
|
||||
|
||||
logger.Log().Debug(utils.Json(data))
|
||||
|
||||
return ctx.JSON(response.NewResponse(data))
|
||||
})
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
package record
|
||||
|
||||
import (
|
||||
"github.com/gofiber/fiber/v2"
|
||||
"matrix-middle-service/internel/controller/record/location"
|
||||
)
|
||||
|
||||
func SetupRecordController(r fiber.Router) {
|
||||
api := r.Group("/record")
|
||||
location.SetupLocation(api)
|
||||
}
|
@ -3,6 +3,7 @@ package route
|
||||
import (
|
||||
"github.com/gofiber/fiber/v2"
|
||||
"matrix-middle-service/internel/controller/bot"
|
||||
"matrix-middle-service/internel/controller/record"
|
||||
"matrix-middle-service/pkg/config"
|
||||
)
|
||||
|
||||
@ -12,4 +13,5 @@ func SetupRoute(app *fiber.App, conf *config.Conf) {
|
||||
}
|
||||
|
||||
bot.SetupBotController(app)
|
||||
record.SetupRecordController(app)
|
||||
}
|
||||
|
31
backend/golang/matrix-middle-service/pkg/utils/time/time.go
Normal file
31
backend/golang/matrix-middle-service/pkg/utils/time/time.go
Normal file
@ -0,0 +1,31 @@
|
||||
package time
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
)
|
||||
|
||||
type Time time.Time
|
||||
|
||||
const (
|
||||
timeFormat = "2006-01-02 15:04:05"
|
||||
)
|
||||
|
||||
// MarshalJSON on Json Time format Time field with %Y-%m-%d %H:%M:%S
|
||||
func (t *Time) MarshalJSON() ([]byte, error) {
|
||||
// 重写time转换成json之后的格式
|
||||
var tmp = fmt.Sprintf("\"%s\"", time.Time(*t).Format(timeFormat))
|
||||
return []byte(tmp), nil
|
||||
}
|
||||
|
||||
func (t *Time) UnmarshalJSON(data []byte) error {
|
||||
// Ignore null, like in the main JSON package.
|
||||
if string(data) == "null" {
|
||||
return nil
|
||||
}
|
||||
// Fractional seconds are handled implicitly by Parse.
|
||||
var err error
|
||||
rawT, err := time.Parse(`"`+timeFormat+`"`, string(data))
|
||||
*t = Time(rawT)
|
||||
return err
|
||||
}
|
Loading…
Reference in New Issue
Block a user