【修改api异常打印,删除多余文件】
This commit is contained in:
parent
c8e005a639
commit
e84db3a9bf
@ -8,10 +8,10 @@ import (
|
|||||||
jwt "github.com/appleboy/gin-jwt/v2"
|
jwt "github.com/appleboy/gin-jwt/v2"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"joylink.club/bj-rtsts-server/db/model"
|
"joylink.club/bj-rtsts-server/db/model"
|
||||||
"joylink.club/bj-rtsts-server/dto"
|
|
||||||
"joylink.club/bj-rtsts-server/dto/publishedGi"
|
"joylink.club/bj-rtsts-server/dto/publishedGi"
|
||||||
"joylink.club/bj-rtsts-server/middleware"
|
"joylink.club/bj-rtsts-server/middleware"
|
||||||
"joylink.club/bj-rtsts-server/service"
|
"joylink.club/bj-rtsts-server/service"
|
||||||
|
"joylink.club/bj-rtsts-server/sys_error"
|
||||||
)
|
)
|
||||||
|
|
||||||
func InitPublishedGiRouter(api *gin.RouterGroup, authMiddleware *jwt.GinJWTMiddleware) {
|
func InitPublishedGiRouter(api *gin.RouterGroup, authMiddleware *jwt.GinJWTMiddleware) {
|
||||||
@ -41,13 +41,10 @@ func InitPublishedGiRouter(api *gin.RouterGroup, authMiddleware *jwt.GinJWTMiddl
|
|||||||
// @Failure 500 {object} dto.ErrorDto
|
// @Failure 500 {object} dto.ErrorDto
|
||||||
// @Router /api/v1/publishedGi/paging [get]
|
// @Router /api/v1/publishedGi/paging [get]
|
||||||
func pageQueryPublishedGi(c *gin.Context) {
|
func pageQueryPublishedGi(c *gin.Context) {
|
||||||
user, _ := c.Get(middleware.IdentityKey)
|
|
||||||
slog.Debug("分页查询发布的图形数据", user)
|
|
||||||
req := publishedGi.PublishedGiReqDto{}
|
req := publishedGi.PublishedGiReqDto{}
|
||||||
if err := c.ShouldBind(&req); err != nil {
|
if err := c.ShouldBind(&req); err != nil {
|
||||||
panic(dto.ErrorDto{Code: dto.ArgumentParseError, Message: err.Error()})
|
panic(sys_error.New("查询失败,查询参数格式错误", err))
|
||||||
}
|
}
|
||||||
slog.Debug("分页查询发布的图形数据", req)
|
|
||||||
page := service.PageQueryPublishedGi(&req)
|
page := service.PageQueryPublishedGi(&req)
|
||||||
c.JSON(http.StatusOK, page)
|
c.JSON(http.StatusOK, page)
|
||||||
}
|
}
|
||||||
@ -68,13 +65,10 @@ func pageQueryPublishedGi(c *gin.Context) {
|
|||||||
// @Failure 500 {object} dto.ErrorDto
|
// @Failure 500 {object} dto.ErrorDto
|
||||||
// @Router /api/v1/publishedGi/list [get]
|
// @Router /api/v1/publishedGi/list [get]
|
||||||
func listQueryPublishedGi(c *gin.Context) {
|
func listQueryPublishedGi(c *gin.Context) {
|
||||||
user, _ := c.Get(middleware.IdentityKey)
|
|
||||||
slog.Debug("列表查询发布的图形数据", user)
|
|
||||||
req := publishedGi.PublishedGiListReqDto{}
|
req := publishedGi.PublishedGiListReqDto{}
|
||||||
if err := c.ShouldBindQuery(&req); err != nil {
|
if err := c.ShouldBindQuery(&req); err != nil {
|
||||||
panic(dto.ErrorDto{Code: dto.ArgumentParseError, Message: err.Error()})
|
panic(sys_error.New("查询失败,查询参数格式错误", err))
|
||||||
}
|
}
|
||||||
slog.Debug("列表查询发布的图形数据", req)
|
|
||||||
list := service.ListQueryPublishedGi(&req)
|
list := service.ListQueryPublishedGi(&req)
|
||||||
c.JSON(http.StatusOK, list)
|
c.JSON(http.StatusOK, list)
|
||||||
}
|
}
|
||||||
@ -95,18 +89,12 @@ func listQueryPublishedGi(c *gin.Context) {
|
|||||||
// @Failure 500 {object} dto.ErrorDto
|
// @Failure 500 {object} dto.ErrorDto
|
||||||
// @Router /api/v1/publishedGi/{id} [get]
|
// @Router /api/v1/publishedGi/{id} [get]
|
||||||
func getPublishedGiById(c *gin.Context) {
|
func getPublishedGiById(c *gin.Context) {
|
||||||
user, _ := c.Get(middleware.IdentityKey)
|
|
||||||
slog.Debug("id查询发布的图形数据", user)
|
|
||||||
idStr := c.Param("id")
|
idStr := c.Param("id")
|
||||||
id, err := strconv.Atoi(idStr)
|
id, err := strconv.Atoi(idStr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(dto.ErrorDto{Code: dto.ArgumentParseError, Message: err.Error()})
|
panic(sys_error.New("查询失败,传入参数格式错误", err))
|
||||||
}
|
|
||||||
slog.Debug("id查询发布的图形数据", id)
|
|
||||||
entity, err := service.GetPublishedGiById(id)
|
|
||||||
if err != nil {
|
|
||||||
panic(dto.ErrorDto{Code: dto.DataOperationError, Message: err.Error()})
|
|
||||||
}
|
}
|
||||||
|
entity := service.GetPublishedGiById(id)
|
||||||
c.JSON(http.StatusOK, entity)
|
c.JSON(http.StatusOK, entity)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -130,10 +118,8 @@ func publishFromDraft(c *gin.Context) {
|
|||||||
slog.Debug("发布图形数据", user)
|
slog.Debug("发布图形数据", user)
|
||||||
req := publishedGi.PublishReqDto{}
|
req := publishedGi.PublishReqDto{}
|
||||||
if err := c.ShouldBind(&req); err != nil {
|
if err := c.ShouldBind(&req); err != nil {
|
||||||
panic(dto.ErrorDto{Code: dto.ArgumentParseError, Message: err.Error()})
|
panic(sys_error.New("发布失败,参数格式错误", err))
|
||||||
}
|
}
|
||||||
//todo
|
|
||||||
slog.Debug("发布图形数据请求参数", req)
|
|
||||||
service.PublishFormDraft(&req, user.(*model.User))
|
service.PublishFormDraft(&req, user.(*model.User))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -153,14 +139,11 @@ func publishFromDraft(c *gin.Context) {
|
|||||||
// @Failure 500 {object} dto.ErrorDto
|
// @Failure 500 {object} dto.ErrorDto
|
||||||
// @Router /api/v1/publishedGi/{id} [delete]
|
// @Router /api/v1/publishedGi/{id} [delete]
|
||||||
func deletePublishedGiById(c *gin.Context) {
|
func deletePublishedGiById(c *gin.Context) {
|
||||||
user, _ := c.Get(middleware.IdentityKey)
|
|
||||||
slog.Debug("id删除发布的图形数据", user)
|
|
||||||
idStr := c.Param("id")
|
idStr := c.Param("id")
|
||||||
id, err := strconv.Atoi(idStr)
|
id, err := strconv.Atoi(idStr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(dto.ErrorDto{Code: dto.ArgumentParseError, Message: err.Error()})
|
panic(sys_error.New("删除失败,传入参数格式错误", err))
|
||||||
}
|
}
|
||||||
slog.Debug("id查询发布的图形数据", id)
|
|
||||||
service.DeletePublishedGiById(id)
|
service.DeletePublishedGiById(id)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -186,11 +169,11 @@ func saveAsDraftingFromPublish(c *gin.Context) {
|
|||||||
slog.Debug("用户拉取发布图形数据", "userId", user, "发布图数据id", idStr)
|
slog.Debug("用户拉取发布图形数据", "userId", user, "发布图数据id", idStr)
|
||||||
id, err := strconv.Atoi(idStr)
|
id, err := strconv.Atoi(idStr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(dto.ErrorDto{Code: dto.ArgumentParseError, Message: err.Error()})
|
panic(sys_error.New("另存为草稿失败,传入参数格式错误", err))
|
||||||
}
|
}
|
||||||
req := publishedGi.PublishReqDto{}
|
req := publishedGi.PublishReqDto{}
|
||||||
if err := c.ShouldBind(&req); err != nil {
|
if err := c.ShouldBind(&req); err != nil {
|
||||||
panic(dto.ErrorDto{Code: dto.ArgumentParseError, Message: err.Error()})
|
panic(sys_error.New("另存为草稿失败,传入参数格式错误", err))
|
||||||
}
|
}
|
||||||
service.SaveAsDraftingFromPublish(int32(id), user.(*model.User), req.Name)
|
service.SaveAsDraftingFromPublish(int32(id), user.(*model.User), req.Name)
|
||||||
}
|
}
|
||||||
@ -211,16 +194,11 @@ func saveAsDraftingFromPublish(c *gin.Context) {
|
|||||||
// @Failure 500 {object} dto.ErrorDto
|
// @Failure 500 {object} dto.ErrorDto
|
||||||
// @Router /api/v1/publishedGi/name [get]
|
// @Router /api/v1/publishedGi/name [get]
|
||||||
func getPublishedGiByName(c *gin.Context) {
|
func getPublishedGiByName(c *gin.Context) {
|
||||||
user, _ := c.Get(middleware.IdentityKey)
|
|
||||||
slog.Debug("name查询发布的图形数据", user)
|
|
||||||
param := &publishedGi.PublishedGiSingleQueryDto{}
|
param := &publishedGi.PublishedGiSingleQueryDto{}
|
||||||
if err := c.ShouldBind(param); err != nil {
|
if err := c.ShouldBind(param); err != nil {
|
||||||
panic(dto.ErrorDto{Code: dto.ArgumentParseError, Message: err.Error()})
|
panic(sys_error.New("查询失败,查询参数格式错误", err))
|
||||||
}
|
}
|
||||||
slog.Debug("name查询发布的图形数据", param.Name)
|
slog.Debug("name查询发布的图形数据", param.Name)
|
||||||
entity, err := service.GetPublishedGiByName(param)
|
entity := service.GetPublishedGiByName(param)
|
||||||
if err != nil {
|
|
||||||
panic(dto.ErrorDto{Code: dto.DataOperationError, Message: err.Error()})
|
|
||||||
}
|
|
||||||
c.JSON(http.StatusOK, entity)
|
c.JSON(http.StatusOK, entity)
|
||||||
}
|
}
|
||||||
|
@ -1 +1 @@
|
|||||||
Subproject commit 89dd583d1990729e1925e31b7bb5da3c6aeb3a94
|
Subproject commit 365f5a50d94b1ad1462d58d1e555d4fb1fd2bc7e
|
@ -53,8 +53,12 @@ func ListAllPublishedGi() ([]*model.PublishedGi, error) {
|
|||||||
return dbquery.PublishedGi.Debug().Where(dbquery.PublishedGi.Status.Eq(1)).Find()
|
return dbquery.PublishedGi.Debug().Where(dbquery.PublishedGi.Status.Eq(1)).Find()
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetPublishedGiById(id int) (*model.PublishedGi, error) {
|
func GetPublishedGiById(id int) *model.PublishedGi {
|
||||||
return dbquery.PublishedGi.Where(dbquery.PublishedGi.ID.Eq(int32(id))).Debug().First()
|
data, err := dbquery.PublishedGi.Where(dbquery.PublishedGi.ID.Eq(int32(id))).Debug().First()
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return data
|
||||||
}
|
}
|
||||||
|
|
||||||
func PublishFormDraft(req *publishedGi.PublishReqDto, user *model.User) {
|
func PublishFormDraft(req *publishedGi.PublishReqDto, user *model.User) {
|
||||||
@ -151,12 +155,16 @@ func QueryProjectPublishedGi(id int32) []*model.PublishedGi {
|
|||||||
return publishedGis
|
return publishedGis
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetPublishedGiByName(param *publishedGi.PublishedGiSingleQueryDto) (*model.PublishedGi, error) {
|
func GetPublishedGiByName(param *publishedGi.PublishedGiSingleQueryDto) *model.PublishedGi {
|
||||||
where := dbquery.PublishedGi.
|
where := dbquery.PublishedGi.
|
||||||
Where(dbquery.PublishedGi.Name.Eq(param.Name)).
|
Where(dbquery.PublishedGi.Name.Eq(param.Name)).
|
||||||
Where(dbquery.PublishedGi.Status.Eq(1))
|
Where(dbquery.PublishedGi.Status.Eq(1))
|
||||||
if !param.Detail {
|
if !param.Detail {
|
||||||
where = where.Omit(dbquery.PublishedGi.Proto)
|
where = where.Omit(dbquery.PublishedGi.Proto)
|
||||||
}
|
}
|
||||||
return where.Debug().First()
|
data, err := where.Debug().First()
|
||||||
|
if err != nil {
|
||||||
|
panic(dto.ErrorDto{Code: dto.DataOperationError, Message: err.Error()})
|
||||||
|
}
|
||||||
|
return data
|
||||||
}
|
}
|
||||||
|
@ -1,18 +0,0 @@
|
|||||||
package service
|
|
||||||
|
|
||||||
import (
|
|
||||||
"google.golang.org/protobuf/proto"
|
|
||||||
"joylink.club/bj-rtsts-server/ats/verify/protos/graphicData"
|
|
||||||
"joylink.club/bj-rtsts-server/dto"
|
|
||||||
)
|
|
||||||
|
|
||||||
// 查询地图数据
|
|
||||||
func QueryRtssGraphicStorage(mapId int32) *graphicData.RtssGraphicStorage {
|
|
||||||
publishdata, err := GetPublishedGiById(int(mapId))
|
|
||||||
if err != nil {
|
|
||||||
panic(dto.ErrorDto{Code: dto.QueryDBError, Message: err.Error()})
|
|
||||||
}
|
|
||||||
graphicStorage := &graphicData.RtssGraphicStorage{}
|
|
||||||
proto.Unmarshal(publishdata.Proto, graphicStorage)
|
|
||||||
return graphicStorage
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user