add
554325746@qq.com
2020-02-19 17b8325233d7bf3276a55bf0937bb76a5c88d67e
add
1个文件已添加
59 ■■■■■ 已修改文件
controllers/gb28181.go 59 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
controllers/gb28181.go
New file
@@ -0,0 +1,59 @@
package controllers
import (
   "basic.com/valib/logger.git"
   "basic.com/dbapi.git"
   "webserver/extend/code"
   "webserver/extend/util"
   "github.com/gin-gonic/gin"
)
type Gb28181Controller struct {
}
// @Summary 获取国标区域列表
// @Description  获取国标区域列表
// @Produce json
// @Tags gb28181
// @Param parentId query int true "parentId"
// @Success 200 {string} json "{"code":200, success:true, msg:"", data:"成功信息"}"
// @Failure 500 {string} json "{"code":500, success:false, msg:"",data:"错误信息内容"}"
// @Router /data/api-v/gb28181/findAreaByParentId [get]
func (gbc Gb28181Controller) FindAreaByParentId(c *gin.Context) {
   parentIdStr := c.Query("parentId")
   if parentIdStr == "" {
       parentIdStr = "0"
   }
   logger.Debug("FindAreaByParentId pid:",parentIdStr)
   var api dbapi.Gb28181Api
   b, d := api.FindAreaByParentId(parentIdStr)
   if !b {
       util.ResponseFormat(c,code.ComError,"")
       return
   }
   util.ResponseFormat(c,code.Success,d)
}
// @Summary 生成新的国标id
// @Description 生成新的国标id
// @Produce json
// @Tags gb28181
// @Param code query string true "行政区域编码"
// @Success 200 {string} json "{"code":200, success:true, msg:"", data:"成功信息"}"
// @Failure 500 {string} json "{"code":500, success:false, msg:"",data:"错误信息内容"}"
// @Router /data/api-v/gb28181/newGbId [get]
func (gbc Gb28181Controller) NewGbId(c *gin.Context) {
  areaCode := c.Query("code")
  if areaCode == "" || len(areaCode) != 6{
      util.ResponseFormat(c, code.RequestParamError, "参数有误")
      return
  }
  var api dbapi.Gb28181Api
  b, d := api.NewGbId(areaCode)
  if !b {
     util.ResponseFormat(c,code.ComError,"")
     return
  }
  util.ResponseFormat(c,code.Success,d)
}