1、增加数据集
This commit is contained in:
parent
3f3c36750e
commit
a2c95fe43f
|
@ -0,0 +1,65 @@
|
|||
package handler
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/gin-gonic/gin"
|
||||
"hpds-iot-web/internal/proto"
|
||||
"hpds-iot-web/internal/service"
|
||||
"hpds-iot-web/model"
|
||||
e "hpds-iot-web/pkg/err"
|
||||
)
|
||||
|
||||
func (s HandlerService) GetOwnerProjectList(c *gin.Context) (data interface{}, err error) {
|
||||
repo := service.NewDatasetService(s.AppConfig, s.Engine, s.Logger)
|
||||
us, _ := c.Get("operatorUser")
|
||||
userInfo := us.(*model.SystemUser)
|
||||
var req proto.OwnerProjectRequest
|
||||
err = c.ShouldBindJSON(&req)
|
||||
if err != nil {
|
||||
go s.SaveLog("GetOwnerProjectList", "Dataset", "", "", req.ToString(), fmt.Sprintf("%d", userInfo.UserId), c.Request.RemoteAddr, "")
|
||||
return nil, e.NewValidErr(err)
|
||||
}
|
||||
data, err = repo.GetOwnerProjectList(c, req)
|
||||
go s.SaveLog("获取业主及项目列表", "Dataset", "", "", "", fmt.Sprintf("%d", userInfo.UserId), c.Request.RemoteAddr, "")
|
||||
return
|
||||
}
|
||||
|
||||
func (s HandlerService) DatasetList(c *gin.Context) (data interface{}, err error) {
|
||||
repo := service.NewDatasetService(s.AppConfig, s.Engine, s.Logger)
|
||||
us, _ := c.Get("operatorUser")
|
||||
userInfo := us.(*model.SystemUser)
|
||||
var req proto.DatasetRequest
|
||||
err = c.ShouldBindJSON(&req)
|
||||
if err != nil {
|
||||
go s.SaveLog("DatasetList", "Dataset", "", "", req.ToString(), fmt.Sprintf("%d", userInfo.UserId), c.Request.RemoteAddr, "")
|
||||
return nil, e.NewValidErr(err)
|
||||
}
|
||||
if req.Size < 1 {
|
||||
req.Size = 20
|
||||
}
|
||||
if req.Size > 1000 {
|
||||
req.Size = 1000
|
||||
}
|
||||
if req.Page < 1 {
|
||||
req.Page = 1
|
||||
}
|
||||
data, err = repo.DatasetList(c, req)
|
||||
go s.SaveLog("获取数据集列表", "Dataset", "", "", ToString(data), fmt.Sprintf("%d", userInfo.UserId), c.Request.RemoteAddr, "")
|
||||
return
|
||||
}
|
||||
|
||||
func (s HandlerService) ImportDataset(c *gin.Context) (data interface{}, err error) {
|
||||
repo := service.NewDatasetService(s.AppConfig, s.Engine, s.Logger)
|
||||
us, _ := c.Get("operatorUser")
|
||||
userInfo := us.(*model.SystemUser)
|
||||
var req proto.ImportDatasetRequest
|
||||
err = c.ShouldBindJSON(&req)
|
||||
if err != nil {
|
||||
go s.SaveLog("ImportDataset", "Dataset", "", "", req.ToString(), fmt.Sprintf("%d", userInfo.UserId), c.Request.RemoteAddr, "")
|
||||
return nil, e.NewValidErr(err)
|
||||
}
|
||||
req.Creator = userInfo.UserId
|
||||
data, err = repo.ImportDataset(c, req)
|
||||
go s.SaveLog("导入数据集", "Dataset", "", "", ToString(data), fmt.Sprintf("%d", userInfo.UserId), c.Request.RemoteAddr, "")
|
||||
return
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
package handler
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"git.hpds.cc/Component/logging"
|
||||
"github.com/gin-gonic/gin"
|
||||
"go.uber.org/zap"
|
||||
|
@ -47,3 +48,11 @@ func (s HandlerService) SaveLog(action, category, targetId, oldValue, newValue,
|
|||
).Error(err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
func ToString(data interface{}) string {
|
||||
b, err := json.Marshal(data)
|
||||
if err != nil {
|
||||
return ""
|
||||
}
|
||||
return string(b)
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ import (
|
|||
)
|
||||
|
||||
func (s HandlerService) OwnerList(c *gin.Context) (data interface{}, err error) {
|
||||
repo := service.NewManageService(s.Engine, s.Logger)
|
||||
repo := service.NewManageService(s.AppConfig, s.Engine, s.Logger)
|
||||
us, _ := c.Get("operatorUser")
|
||||
userInfo := us.(*model.SystemUser)
|
||||
var req proto.OwnerRequest
|
||||
|
@ -35,7 +35,7 @@ func (s HandlerService) OwnerList(c *gin.Context) (data interface{}, err error)
|
|||
}
|
||||
|
||||
func (s HandlerService) OwnerInfo(c *gin.Context) (data interface{}, err error) {
|
||||
repo := service.NewManageService(s.Engine, s.Logger)
|
||||
repo := service.NewManageService(s.AppConfig, s.Engine, s.Logger)
|
||||
us, _ := c.Get("operatorUser")
|
||||
userInfo := us.(*model.SystemUser)
|
||||
//var req proto.OwnerItemReq
|
||||
|
@ -51,7 +51,7 @@ func (s HandlerService) OwnerInfo(c *gin.Context) (data interface{}, err error)
|
|||
}
|
||||
|
||||
func (s HandlerService) AddOwner(c *gin.Context) (data interface{}, err error) {
|
||||
repo := service.NewManageService(s.Engine, s.Logger)
|
||||
repo := service.NewManageService(s.AppConfig, s.Engine, s.Logger)
|
||||
us, _ := c.Get("operatorUser")
|
||||
userInfo := us.(*model.SystemUser)
|
||||
var req proto.OwnerItemReq
|
||||
|
@ -67,7 +67,7 @@ func (s HandlerService) AddOwner(c *gin.Context) (data interface{}, err error) {
|
|||
}
|
||||
|
||||
func (s HandlerService) EditOwner(c *gin.Context) (data interface{}, err error) {
|
||||
repo := service.NewManageService(s.Engine, s.Logger)
|
||||
repo := service.NewManageService(s.AppConfig, s.Engine, s.Logger)
|
||||
us, _ := c.Get("operatorUser")
|
||||
userInfo := us.(*model.SystemUser)
|
||||
var req proto.OwnerItemReq
|
||||
|
@ -83,7 +83,7 @@ func (s HandlerService) EditOwner(c *gin.Context) (data interface{}, err error)
|
|||
}
|
||||
|
||||
func (s HandlerService) DelOwner(c *gin.Context) (data interface{}, err error) {
|
||||
repo := service.NewManageService(s.Engine, s.Logger)
|
||||
repo := service.NewManageService(s.AppConfig, s.Engine, s.Logger)
|
||||
us, _ := c.Get("operatorUser")
|
||||
userInfo := us.(*model.SystemUser)
|
||||
var req proto.OwnerItemReq
|
||||
|
@ -99,7 +99,7 @@ func (s HandlerService) DelOwner(c *gin.Context) (data interface{}, err error) {
|
|||
}
|
||||
|
||||
func (s HandlerService) ProjectList(c *gin.Context) (data interface{}, err error) {
|
||||
repo := service.NewManageService(s.Engine, s.Logger)
|
||||
repo := service.NewManageService(s.AppConfig, s.Engine, s.Logger)
|
||||
us, _ := c.Get("operatorUser")
|
||||
userInfo := us.(*model.SystemUser)
|
||||
var req proto.ProjectRequest
|
||||
|
@ -123,7 +123,7 @@ func (s HandlerService) ProjectList(c *gin.Context) (data interface{}, err error
|
|||
}
|
||||
|
||||
func (s HandlerService) AddProject(c *gin.Context) (data interface{}, err error) {
|
||||
repo := service.NewManageService(s.Engine, s.Logger)
|
||||
repo := service.NewManageService(s.AppConfig, s.Engine, s.Logger)
|
||||
us, _ := c.Get("operatorUser")
|
||||
userInfo := us.(*model.SystemUser)
|
||||
var req proto.ProjectItemRequest
|
||||
|
@ -139,7 +139,7 @@ func (s HandlerService) AddProject(c *gin.Context) (data interface{}, err error)
|
|||
}
|
||||
|
||||
func (s HandlerService) EditProject(c *gin.Context) (data interface{}, err error) {
|
||||
repo := service.NewManageService(s.Engine, s.Logger)
|
||||
repo := service.NewManageService(s.AppConfig, s.Engine, s.Logger)
|
||||
us, _ := c.Get("operatorUser")
|
||||
userInfo := us.(*model.SystemUser)
|
||||
var req proto.ProjectItemRequest
|
||||
|
@ -154,7 +154,7 @@ func (s HandlerService) EditProject(c *gin.Context) (data interface{}, err error
|
|||
return
|
||||
}
|
||||
func (s HandlerService) DelProject(c *gin.Context) (data interface{}, err error) {
|
||||
repo := service.NewManageService(s.Engine, s.Logger)
|
||||
repo := service.NewManageService(s.AppConfig, s.Engine, s.Logger)
|
||||
us, _ := c.Get("operatorUser")
|
||||
userInfo := us.(*model.SystemUser)
|
||||
var req proto.ProjectItemRequest
|
||||
|
@ -170,7 +170,7 @@ func (s HandlerService) DelProject(c *gin.Context) (data interface{}, err error)
|
|||
}
|
||||
|
||||
func (s HandlerService) ProductList(c *gin.Context) (data interface{}, err error) {
|
||||
repo := service.NewManageService(s.Engine, s.Logger)
|
||||
repo := service.NewManageService(s.AppConfig, s.Engine, s.Logger)
|
||||
us, _ := c.Get("operatorUser")
|
||||
userInfo := us.(*model.SystemUser)
|
||||
var req proto.ProductRequest
|
||||
|
@ -194,7 +194,7 @@ func (s HandlerService) ProductList(c *gin.Context) (data interface{}, err error
|
|||
}
|
||||
|
||||
func (s HandlerService) GetProductInfo(c *gin.Context) (data interface{}, err error) {
|
||||
repo := service.NewManageService(s.Engine, s.Logger)
|
||||
repo := service.NewManageService(s.AppConfig, s.Engine, s.Logger)
|
||||
us, _ := c.Get("operatorUser")
|
||||
userInfo := us.(*model.SystemUser)
|
||||
var req proto.ProductItemRequest
|
||||
|
@ -208,7 +208,7 @@ func (s HandlerService) GetProductInfo(c *gin.Context) (data interface{}, err er
|
|||
return
|
||||
}
|
||||
func (s HandlerService) AddProduct(c *gin.Context) (data interface{}, err error) {
|
||||
repo := service.NewManageService(s.Engine, s.Logger)
|
||||
repo := service.NewManageService(s.AppConfig, s.Engine, s.Logger)
|
||||
us, _ := c.Get("operatorUser")
|
||||
userInfo := us.(*model.SystemUser)
|
||||
var req proto.ProductItemRequest
|
||||
|
@ -222,7 +222,7 @@ func (s HandlerService) AddProduct(c *gin.Context) (data interface{}, err error)
|
|||
return
|
||||
}
|
||||
func (s HandlerService) EditProduct(c *gin.Context) (data interface{}, err error) {
|
||||
repo := service.NewManageService(s.Engine, s.Logger)
|
||||
repo := service.NewManageService(s.AppConfig, s.Engine, s.Logger)
|
||||
us, _ := c.Get("operatorUser")
|
||||
userInfo := us.(*model.SystemUser)
|
||||
var req proto.ProductItemRequest
|
||||
|
@ -236,7 +236,7 @@ func (s HandlerService) EditProduct(c *gin.Context) (data interface{}, err error
|
|||
return
|
||||
}
|
||||
func (s HandlerService) DelProduct(c *gin.Context) (data interface{}, err error) {
|
||||
repo := service.NewManageService(s.Engine, s.Logger)
|
||||
repo := service.NewManageService(s.AppConfig, s.Engine, s.Logger)
|
||||
us, _ := c.Get("operatorUser")
|
||||
userInfo := us.(*model.SystemUser)
|
||||
var req proto.ProductItemRequest
|
||||
|
@ -250,7 +250,7 @@ func (s HandlerService) DelProduct(c *gin.Context) (data interface{}, err error)
|
|||
return
|
||||
}
|
||||
func (s HandlerService) CategoryList(c *gin.Context) (data interface{}, err error) {
|
||||
repo := service.NewManageService(s.Engine, s.Logger)
|
||||
repo := service.NewManageService(s.AppConfig, s.Engine, s.Logger)
|
||||
us, _ := c.Get("operatorUser")
|
||||
userInfo := us.(*model.SystemUser)
|
||||
var req proto.ProductCategoryRequest
|
||||
|
@ -273,7 +273,7 @@ func (s HandlerService) CategoryList(c *gin.Context) (data interface{}, err erro
|
|||
return
|
||||
}
|
||||
func (s HandlerService) AddCategory(c *gin.Context) (data interface{}, err error) {
|
||||
repo := service.NewManageService(s.Engine, s.Logger)
|
||||
repo := service.NewManageService(s.AppConfig, s.Engine, s.Logger)
|
||||
us, _ := c.Get("operatorUser")
|
||||
userInfo := us.(*model.SystemUser)
|
||||
var req proto.ProductCategoryItemRequest
|
||||
|
@ -287,7 +287,7 @@ func (s HandlerService) AddCategory(c *gin.Context) (data interface{}, err error
|
|||
return
|
||||
}
|
||||
func (s HandlerService) EditCategory(c *gin.Context) (data interface{}, err error) {
|
||||
repo := service.NewManageService(s.Engine, s.Logger)
|
||||
repo := service.NewManageService(s.AppConfig, s.Engine, s.Logger)
|
||||
us, _ := c.Get("operatorUser")
|
||||
userInfo := us.(*model.SystemUser)
|
||||
var req proto.ProductCategoryItemRequest
|
||||
|
@ -301,7 +301,7 @@ func (s HandlerService) EditCategory(c *gin.Context) (data interface{}, err erro
|
|||
return
|
||||
}
|
||||
func (s HandlerService) DelCategory(c *gin.Context) (data interface{}, err error) {
|
||||
repo := service.NewManageService(s.Engine, s.Logger)
|
||||
repo := service.NewManageService(s.AppConfig, s.Engine, s.Logger)
|
||||
us, _ := c.Get("operatorUser")
|
||||
userInfo := us.(*model.SystemUser)
|
||||
var req proto.ProductCategoryItemRequest
|
||||
|
@ -316,7 +316,7 @@ func (s HandlerService) DelCategory(c *gin.Context) (data interface{}, err error
|
|||
}
|
||||
|
||||
func (s HandlerService) AttributeList(c *gin.Context) (data interface{}, err error) {
|
||||
repo := service.NewManageService(s.Engine, s.Logger)
|
||||
repo := service.NewManageService(s.AppConfig, s.Engine, s.Logger)
|
||||
us, _ := c.Get("operatorUser")
|
||||
userInfo := us.(*model.SystemUser)
|
||||
var req proto.AttributeRequest
|
||||
|
@ -339,7 +339,7 @@ func (s HandlerService) AttributeList(c *gin.Context) (data interface{}, err err
|
|||
return
|
||||
}
|
||||
func (s HandlerService) AddAttribute(c *gin.Context) (data interface{}, err error) {
|
||||
repo := service.NewManageService(s.Engine, s.Logger)
|
||||
repo := service.NewManageService(s.AppConfig, s.Engine, s.Logger)
|
||||
us, _ := c.Get("operatorUser")
|
||||
userInfo := us.(*model.SystemUser)
|
||||
var req proto.AttributeItemRequest
|
||||
|
@ -353,7 +353,7 @@ func (s HandlerService) AddAttribute(c *gin.Context) (data interface{}, err erro
|
|||
return
|
||||
}
|
||||
func (s HandlerService) EditAttribute(c *gin.Context) (data interface{}, err error) {
|
||||
repo := service.NewManageService(s.Engine, s.Logger)
|
||||
repo := service.NewManageService(s.AppConfig, s.Engine, s.Logger)
|
||||
us, _ := c.Get("operatorUser")
|
||||
userInfo := us.(*model.SystemUser)
|
||||
var req proto.AttributeItemRequest
|
||||
|
@ -367,7 +367,7 @@ func (s HandlerService) EditAttribute(c *gin.Context) (data interface{}, err err
|
|||
return
|
||||
}
|
||||
func (s HandlerService) DelAttribute(c *gin.Context) (data interface{}, err error) {
|
||||
repo := service.NewManageService(s.Engine, s.Logger)
|
||||
repo := service.NewManageService(s.AppConfig, s.Engine, s.Logger)
|
||||
us, _ := c.Get("operatorUser")
|
||||
userInfo := us.(*model.SystemUser)
|
||||
var req proto.AttributeItemRequest
|
||||
|
@ -381,7 +381,7 @@ func (s HandlerService) DelAttribute(c *gin.Context) (data interface{}, err erro
|
|||
return
|
||||
}
|
||||
func (s HandlerService) EventList(c *gin.Context) (data interface{}, err error) {
|
||||
repo := service.NewManageService(s.Engine, s.Logger)
|
||||
repo := service.NewManageService(s.AppConfig, s.Engine, s.Logger)
|
||||
us, _ := c.Get("operatorUser")
|
||||
userInfo := us.(*model.SystemUser)
|
||||
var req proto.AttributeRequest
|
||||
|
@ -404,7 +404,7 @@ func (s HandlerService) EventList(c *gin.Context) (data interface{}, err error)
|
|||
return
|
||||
}
|
||||
func (s HandlerService) AddEvent(c *gin.Context) (data interface{}, err error) {
|
||||
repo := service.NewManageService(s.Engine, s.Logger)
|
||||
repo := service.NewManageService(s.AppConfig, s.Engine, s.Logger)
|
||||
us, _ := c.Get("operatorUser")
|
||||
userInfo := us.(*model.SystemUser)
|
||||
var req proto.EventItemRequest
|
||||
|
@ -418,7 +418,7 @@ func (s HandlerService) AddEvent(c *gin.Context) (data interface{}, err error) {
|
|||
return
|
||||
}
|
||||
func (s HandlerService) EditEvent(c *gin.Context) (data interface{}, err error) {
|
||||
repo := service.NewManageService(s.Engine, s.Logger)
|
||||
repo := service.NewManageService(s.AppConfig, s.Engine, s.Logger)
|
||||
us, _ := c.Get("operatorUser")
|
||||
userInfo := us.(*model.SystemUser)
|
||||
var req proto.EventItemRequest
|
||||
|
@ -432,7 +432,7 @@ func (s HandlerService) EditEvent(c *gin.Context) (data interface{}, err error)
|
|||
return
|
||||
}
|
||||
func (s HandlerService) DelEvent(c *gin.Context) (data interface{}, err error) {
|
||||
repo := service.NewManageService(s.Engine, s.Logger)
|
||||
repo := service.NewManageService(s.AppConfig, s.Engine, s.Logger)
|
||||
us, _ := c.Get("operatorUser")
|
||||
userInfo := us.(*model.SystemUser)
|
||||
var req proto.EventItemRequest
|
||||
|
@ -447,7 +447,7 @@ func (s HandlerService) DelEvent(c *gin.Context) (data interface{}, err error) {
|
|||
}
|
||||
|
||||
func (s HandlerService) EventParamsList(c *gin.Context) (data interface{}, err error) {
|
||||
repo := service.NewManageService(s.Engine, s.Logger)
|
||||
repo := service.NewManageService(s.AppConfig, s.Engine, s.Logger)
|
||||
us, _ := c.Get("operatorUser")
|
||||
userInfo := us.(*model.SystemUser)
|
||||
var req proto.EventParamsRequest
|
||||
|
@ -471,7 +471,7 @@ func (s HandlerService) EventParamsList(c *gin.Context) (data interface{}, err e
|
|||
}
|
||||
|
||||
func (s HandlerService) AddEventParams(c *gin.Context) (data interface{}, err error) {
|
||||
repo := service.NewManageService(s.Engine, s.Logger)
|
||||
repo := service.NewManageService(s.AppConfig, s.Engine, s.Logger)
|
||||
us, _ := c.Get("operatorUser")
|
||||
userInfo := us.(*model.SystemUser)
|
||||
var req proto.EventParamItem
|
||||
|
@ -486,7 +486,7 @@ func (s HandlerService) AddEventParams(c *gin.Context) (data interface{}, err er
|
|||
}
|
||||
|
||||
func (s HandlerService) EditEventParams(c *gin.Context) (data interface{}, err error) {
|
||||
repo := service.NewManageService(s.Engine, s.Logger)
|
||||
repo := service.NewManageService(s.AppConfig, s.Engine, s.Logger)
|
||||
us, _ := c.Get("operatorUser")
|
||||
userInfo := us.(*model.SystemUser)
|
||||
var req proto.EventParamItem
|
||||
|
@ -501,7 +501,7 @@ func (s HandlerService) EditEventParams(c *gin.Context) (data interface{}, err e
|
|||
}
|
||||
|
||||
func (s HandlerService) DelEventParams(c *gin.Context) (data interface{}, err error) {
|
||||
repo := service.NewManageService(s.Engine, s.Logger)
|
||||
repo := service.NewManageService(s.AppConfig, s.Engine, s.Logger)
|
||||
us, _ := c.Get("operatorUser")
|
||||
userInfo := us.(*model.SystemUser)
|
||||
var req proto.EventParamItem
|
||||
|
@ -516,7 +516,7 @@ func (s HandlerService) DelEventParams(c *gin.Context) (data interface{}, err er
|
|||
}
|
||||
|
||||
func (s HandlerService) ServiceList(c *gin.Context) (data interface{}, err error) {
|
||||
repo := service.NewManageService(s.Engine, s.Logger)
|
||||
repo := service.NewManageService(s.AppConfig, s.Engine, s.Logger)
|
||||
us, _ := c.Get("operatorUser")
|
||||
userInfo := us.(*model.SystemUser)
|
||||
var req proto.AttributeRequest
|
||||
|
@ -539,7 +539,7 @@ func (s HandlerService) ServiceList(c *gin.Context) (data interface{}, err error
|
|||
return
|
||||
}
|
||||
func (s HandlerService) AddService(c *gin.Context) (data interface{}, err error) {
|
||||
repo := service.NewManageService(s.Engine, s.Logger)
|
||||
repo := service.NewManageService(s.AppConfig, s.Engine, s.Logger)
|
||||
us, _ := c.Get("operatorUser")
|
||||
userInfo := us.(*model.SystemUser)
|
||||
var req proto.ServiceItemRequest
|
||||
|
@ -553,7 +553,7 @@ func (s HandlerService) AddService(c *gin.Context) (data interface{}, err error)
|
|||
return
|
||||
}
|
||||
func (s HandlerService) EditService(c *gin.Context) (data interface{}, err error) {
|
||||
repo := service.NewManageService(s.Engine, s.Logger)
|
||||
repo := service.NewManageService(s.AppConfig, s.Engine, s.Logger)
|
||||
us, _ := c.Get("operatorUser")
|
||||
userInfo := us.(*model.SystemUser)
|
||||
var req proto.ServiceItemRequest
|
||||
|
@ -567,7 +567,7 @@ func (s HandlerService) EditService(c *gin.Context) (data interface{}, err error
|
|||
return
|
||||
}
|
||||
func (s HandlerService) DelService(c *gin.Context) (data interface{}, err error) {
|
||||
repo := service.NewManageService(s.Engine, s.Logger)
|
||||
repo := service.NewManageService(s.AppConfig, s.Engine, s.Logger)
|
||||
us, _ := c.Get("operatorUser")
|
||||
userInfo := us.(*model.SystemUser)
|
||||
var req proto.ServiceItemRequest
|
||||
|
@ -582,7 +582,7 @@ func (s HandlerService) DelService(c *gin.Context) (data interface{}, err error)
|
|||
}
|
||||
|
||||
func (s HandlerService) ServiceParamsList(c *gin.Context) (data interface{}, err error) {
|
||||
repo := service.NewManageService(s.Engine, s.Logger)
|
||||
repo := service.NewManageService(s.AppConfig, s.Engine, s.Logger)
|
||||
us, _ := c.Get("operatorUser")
|
||||
userInfo := us.(*model.SystemUser)
|
||||
var req proto.ServiceParamsRequest
|
||||
|
@ -605,7 +605,7 @@ func (s HandlerService) ServiceParamsList(c *gin.Context) (data interface{}, err
|
|||
return
|
||||
}
|
||||
func (s HandlerService) AddServiceParams(c *gin.Context) (data interface{}, err error) {
|
||||
repo := service.NewManageService(s.Engine, s.Logger)
|
||||
repo := service.NewManageService(s.AppConfig, s.Engine, s.Logger)
|
||||
us, _ := c.Get("operatorUser")
|
||||
userInfo := us.(*model.SystemUser)
|
||||
var req proto.ServiceParamItem
|
||||
|
@ -619,7 +619,7 @@ func (s HandlerService) AddServiceParams(c *gin.Context) (data interface{}, err
|
|||
return
|
||||
}
|
||||
func (s HandlerService) EditServiceParams(c *gin.Context) (data interface{}, err error) {
|
||||
repo := service.NewManageService(s.Engine, s.Logger)
|
||||
repo := service.NewManageService(s.AppConfig, s.Engine, s.Logger)
|
||||
us, _ := c.Get("operatorUser")
|
||||
userInfo := us.(*model.SystemUser)
|
||||
var req proto.ServiceParamItem
|
||||
|
@ -633,7 +633,7 @@ func (s HandlerService) EditServiceParams(c *gin.Context) (data interface{}, err
|
|||
return
|
||||
}
|
||||
func (s HandlerService) DelServiceParams(c *gin.Context) (data interface{}, err error) {
|
||||
repo := service.NewManageService(s.Engine, s.Logger)
|
||||
repo := service.NewManageService(s.AppConfig, s.Engine, s.Logger)
|
||||
us, _ := c.Get("operatorUser")
|
||||
userInfo := us.(*model.SystemUser)
|
||||
var req proto.ServiceParamItem
|
||||
|
@ -648,7 +648,7 @@ func (s HandlerService) DelServiceParams(c *gin.Context) (data interface{}, err
|
|||
}
|
||||
|
||||
func (s HandlerService) DeviceList(c *gin.Context) (data interface{}, err error) {
|
||||
repo := service.NewManageService(s.Engine, s.Logger)
|
||||
repo := service.NewManageService(s.AppConfig, s.Engine, s.Logger)
|
||||
us, _ := c.Get("operatorUser")
|
||||
userInfo := us.(*model.SystemUser)
|
||||
var req proto.DeviceRequest
|
||||
|
@ -662,7 +662,7 @@ func (s HandlerService) DeviceList(c *gin.Context) (data interface{}, err error)
|
|||
return
|
||||
}
|
||||
func (s HandlerService) DeviceInfo(c *gin.Context) (data interface{}, err error) {
|
||||
repo := service.NewManageService(s.Engine, s.Logger)
|
||||
repo := service.NewManageService(s.AppConfig, s.Engine, s.Logger)
|
||||
us, _ := c.Get("operatorUser")
|
||||
userInfo := us.(*model.SystemUser)
|
||||
var req proto.DeviceItemRequest
|
||||
|
@ -676,7 +676,7 @@ func (s HandlerService) DeviceInfo(c *gin.Context) (data interface{}, err error)
|
|||
return
|
||||
}
|
||||
func (s HandlerService) AddDevice(c *gin.Context) (data interface{}, err error) {
|
||||
repo := service.NewManageService(s.Engine, s.Logger)
|
||||
repo := service.NewManageService(s.AppConfig, s.Engine, s.Logger)
|
||||
us, _ := c.Get("operatorUser")
|
||||
userInfo := us.(*model.SystemUser)
|
||||
var req proto.DeviceItemRequest
|
||||
|
@ -690,7 +690,7 @@ func (s HandlerService) AddDevice(c *gin.Context) (data interface{}, err error)
|
|||
return
|
||||
}
|
||||
func (s HandlerService) EditDevice(c *gin.Context) (data interface{}, err error) {
|
||||
repo := service.NewManageService(s.Engine, s.Logger)
|
||||
repo := service.NewManageService(s.AppConfig, s.Engine, s.Logger)
|
||||
us, _ := c.Get("operatorUser")
|
||||
userInfo := us.(*model.SystemUser)
|
||||
var req proto.DeviceItemRequest
|
||||
|
@ -704,7 +704,7 @@ func (s HandlerService) EditDevice(c *gin.Context) (data interface{}, err error)
|
|||
return
|
||||
}
|
||||
func (s HandlerService) DeleteDevice(c *gin.Context) (data interface{}, err error) {
|
||||
repo := service.NewManageService(s.Engine, s.Logger)
|
||||
repo := service.NewManageService(s.AppConfig, s.Engine, s.Logger)
|
||||
us, _ := c.Get("operatorUser")
|
||||
userInfo := us.(*model.SystemUser)
|
||||
var req proto.DeviceItemRequest
|
||||
|
|
|
@ -68,18 +68,16 @@ func (p ProjectRequest) ToString() string {
|
|||
}
|
||||
|
||||
type ProjectItemRequest struct {
|
||||
ProjectId int `json:"projectId"`
|
||||
ProjectName string `json:"projectName"`
|
||||
OwnerId int `json:"ownerId"`
|
||||
LineName string `json:"lineName"`
|
||||
StartName string `json:"startName"`
|
||||
EndName string `json:"endName"`
|
||||
FixedDeviceNum int `json:"fixedDeviceNum"`
|
||||
Direction string `json:"direction"`
|
||||
LaneNum int `json:"laneNum"`
|
||||
Lng float64 `json:"lng"`
|
||||
Lat float64 `json:"lat"`
|
||||
Creator int64 `json:"creator"`
|
||||
ProjectId int64 `json:"projectId"`
|
||||
ProjectName string `json:"projectName"`
|
||||
OwnerId int64 `json:"ownerId"`
|
||||
LineName string `json:"lineName"`
|
||||
StartName string `json:"startName"`
|
||||
EndName string `json:"endName"`
|
||||
FixedDeviceNum int `json:"fixedDeviceNum"`
|
||||
Direction string `json:"direction"`
|
||||
LaneNum int `json:"laneNum"`
|
||||
Creator int64 `json:"creator"`
|
||||
}
|
||||
|
||||
func (p ProjectItemRequest) ToString() string {
|
||||
|
@ -433,3 +431,50 @@ func (p DiseaseTypeItemRequest) ToString() string {
|
|||
}
|
||||
return string(data)
|
||||
}
|
||||
|
||||
type OwnerProjectRequest struct {
|
||||
Key string `json:"key"`
|
||||
}
|
||||
|
||||
func (p OwnerProjectRequest) ToString() string {
|
||||
data, err := json.Marshal(p)
|
||||
if err != nil {
|
||||
return ""
|
||||
}
|
||||
return string(data)
|
||||
}
|
||||
|
||||
type DatasetRequest struct {
|
||||
OwnerId int64 `json:"ownerId"`
|
||||
ProjectId int64 `json:"projectId"`
|
||||
DatasetName string `json:"datasetName"`
|
||||
StartTime string `json:"startTime"`
|
||||
EndTime string `json:"endTime"`
|
||||
BasePageList
|
||||
}
|
||||
|
||||
func (p DatasetRequest) ToString() string {
|
||||
data, err := json.Marshal(p)
|
||||
if err != nil {
|
||||
return ""
|
||||
}
|
||||
return string(data)
|
||||
}
|
||||
|
||||
type ImportDatasetRequest struct {
|
||||
DatasetId int64 `json:"datasetId"`
|
||||
CategoryId int `json:"categoryId"`
|
||||
DatasetName string `json:"datasetName"`
|
||||
DatasetDesc string `json:"datasetDesc"`
|
||||
ProjectId int64 `json:"projectId"`
|
||||
OwnerId int64 `json:"ownerId"`
|
||||
Creator int64 `json:"creator"`
|
||||
}
|
||||
|
||||
func (p ImportDatasetRequest) ToString() string {
|
||||
data, err := json.Marshal(p)
|
||||
if err != nil {
|
||||
return ""
|
||||
}
|
||||
return string(data)
|
||||
}
|
||||
|
|
|
@ -40,3 +40,26 @@ type OwnerItem struct {
|
|||
type UploadResponse struct {
|
||||
Url string `json:"url"`
|
||||
}
|
||||
|
||||
type OwnerProjectItem struct {
|
||||
OwnerId int `json:"key"`
|
||||
OwnerName string `json:"title"`
|
||||
ProjectList []ProjectItem `json:"children"`
|
||||
}
|
||||
|
||||
type ProjectItem struct {
|
||||
ProjectId string `json:"key"`
|
||||
ProjectName string `json:"title"`
|
||||
}
|
||||
|
||||
type DatasetItem struct {
|
||||
DatasetId int64 `json:"datasetId"`
|
||||
DatasetName string `json:"datasetName"`
|
||||
DatasetDesc string `json:"datasetDesc"`
|
||||
CategoryId int `json:"categoryId"`
|
||||
ProjectId int64 `json:"projectId"`
|
||||
OwnerId int64 `json:"ownerId"`
|
||||
Creator int64 `json:"creator"`
|
||||
CreateAt int64 `json:"createAt"`
|
||||
DatasetCount int64 `json:"datasetCount"`
|
||||
}
|
||||
|
|
|
@ -141,6 +141,7 @@ func InitRouter(cfg *config.WebConfig, logger *logging.Logger, engine *xorm.Engi
|
|||
}
|
||||
disease := r.Group("/disease")
|
||||
{
|
||||
disease.Use(middleware.JwtAuthMiddleware(logger.Logger))
|
||||
diseaseType := disease.Group("/type")
|
||||
{
|
||||
diseaseType.POST("/list", e.ErrorWrapper(hs.DiseaseTypeList))
|
||||
|
@ -149,6 +150,14 @@ func InitRouter(cfg *config.WebConfig, logger *logging.Logger, engine *xorm.Engi
|
|||
diseaseType.POST("/delete", e.ErrorWrapper(hs.DeleteDiseaseType))
|
||||
}
|
||||
}
|
||||
dataset := r.Group("/dataset")
|
||||
{
|
||||
dataset.Use(middleware.JwtAuthMiddleware(logger.Logger))
|
||||
dataset.POST("/ownerList", e.ErrorWrapper(hs.GetOwnerProjectList))
|
||||
|
||||
dataset.POST("/list", e.ErrorWrapper(hs.DatasetList))
|
||||
dataset.POST("/import", e.ErrorWrapper(hs.ImportDataset))
|
||||
}
|
||||
}
|
||||
return root
|
||||
}
|
||||
|
|
|
@ -0,0 +1,175 @@
|
|||
package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"git.hpds.cc/Component/logging"
|
||||
"hpds-iot-web/config"
|
||||
"hpds-iot-web/internal/proto"
|
||||
"hpds-iot-web/model"
|
||||
"net/http"
|
||||
"time"
|
||||
"xorm.io/xorm"
|
||||
)
|
||||
|
||||
type DatasetService interface {
|
||||
GetOwnerProjectList(ctx context.Context, req proto.OwnerProjectRequest) (rsp *proto.BaseResponse, err error)
|
||||
DatasetList(ctx context.Context, req proto.DatasetRequest) (rsp *proto.BaseResponse, err error)
|
||||
ImportDataset(ctx context.Context, req proto.ImportDatasetRequest) (rsp *proto.BaseResponse, err error)
|
||||
}
|
||||
|
||||
func NewDatasetService(cfg *config.WebConfig, engine *xorm.Engine, logger *logging.Logger) DatasetService {
|
||||
return &repo{
|
||||
AppConfig: cfg,
|
||||
engine: engine,
|
||||
logger: logger,
|
||||
}
|
||||
}
|
||||
|
||||
func (rp *repo) GetOwnerProjectList(ctx context.Context, req proto.OwnerProjectRequest) (rsp *proto.BaseResponse, err error) {
|
||||
rsp = new(proto.BaseResponse)
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
err = fmt.Errorf("超时/取消")
|
||||
rsp.Code = http.StatusInternalServerError
|
||||
rsp.Status = http.StatusText(http.StatusInternalServerError)
|
||||
rsp.Message = "超时/取消"
|
||||
rsp.Err = ctx.Err()
|
||||
return rsp, ctx.Err()
|
||||
default:
|
||||
ownerList := make([]model.Owner, 0)
|
||||
err := rp.engine.Where("(? = '' or owner_name like ?)", req.Key, "%"+req.Key+"%").
|
||||
And("status = 1").Find(&ownerList)
|
||||
if err != nil {
|
||||
goto ReturnPoint
|
||||
}
|
||||
data := make([]proto.OwnerProjectItem, len(ownerList))
|
||||
for k, v := range ownerList {
|
||||
projectList := make([]proto.ProjectItem, 0)
|
||||
err = rp.engine.Table("project").Cols("concat('"+fmt.Sprintf("%d", v.OwnerId)+"-', project_id) as project_id", "project_name").
|
||||
Where("owner_id = ?", v.OwnerId).And("status = 1").Find(&projectList)
|
||||
if err != nil {
|
||||
goto ReturnPoint
|
||||
}
|
||||
data[k] = proto.OwnerProjectItem{
|
||||
OwnerId: v.OwnerId,
|
||||
OwnerName: fmt.Sprintf("%s[%s]", v.OwnerName, v.ChargeUser),
|
||||
ProjectList: projectList,
|
||||
}
|
||||
}
|
||||
rsp.Code = http.StatusOK
|
||||
rsp.Status = http.StatusText(http.StatusOK)
|
||||
rsp.Message = "成功"
|
||||
rsp.Data = data
|
||||
rsp.Err = err
|
||||
return rsp, err
|
||||
}
|
||||
ReturnPoint:
|
||||
if err != nil {
|
||||
rsp.Code = http.StatusInternalServerError
|
||||
rsp.Status = http.StatusText(http.StatusInternalServerError)
|
||||
rsp.Err = err
|
||||
rsp.Message = "失败"
|
||||
}
|
||||
return rsp, err
|
||||
}
|
||||
|
||||
func (rp *repo) DatasetList(ctx context.Context, req proto.DatasetRequest) (rsp *proto.BaseResponse, err error) {
|
||||
rsp = new(proto.BaseResponse)
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
err = fmt.Errorf("超时/取消")
|
||||
rsp.Code = http.StatusInternalServerError
|
||||
rsp.Status = http.StatusText(http.StatusInternalServerError)
|
||||
rsp.Message = "超时/取消"
|
||||
rsp.Err = ctx.Err()
|
||||
return rsp, ctx.Err()
|
||||
default:
|
||||
list := make([]model.Dataset, 0)
|
||||
count, err := rp.engine.Where("(? = '' or dataset_name like ?)", req.DatasetName, "%"+req.DatasetName+"%").
|
||||
And("(? = '' or create_at >= ?)", req.StartTime, req.StartTime).
|
||||
And("(? = '' or create_at < ?)", req.EndTime, req.EndTime).
|
||||
And("(? = 0 or owner_id = ?)", req.OwnerId, req.OwnerId).
|
||||
And("(? = 0 or project_id = ?)", req.ProjectId, req.ProjectId).
|
||||
And("status = 1").FindAndCount(&list)
|
||||
if err != nil {
|
||||
goto ReturnPoint
|
||||
}
|
||||
data := make([]proto.DatasetItem, len(list))
|
||||
for k, v := range list {
|
||||
detailList := make([]model.DatasetDetail, 0)
|
||||
datasetCount, err := rp.engine.Where("dataset_id = ?", v.DatasetId).FindAndCount(&detailList)
|
||||
if err != nil {
|
||||
goto ReturnPoint
|
||||
}
|
||||
data[k] = proto.DatasetItem{
|
||||
DatasetId: v.DatasetId,
|
||||
DatasetName: v.DatasetName,
|
||||
DatasetDesc: v.DatasetDesc,
|
||||
CategoryId: v.CategoryId,
|
||||
ProjectId: v.ProjectId,
|
||||
OwnerId: v.OwnerId,
|
||||
Creator: v.Creator,
|
||||
CreateAt: v.CreateAt,
|
||||
DatasetCount: datasetCount,
|
||||
}
|
||||
}
|
||||
rsp.Code = http.StatusOK
|
||||
rsp.Status = http.StatusText(http.StatusOK)
|
||||
rsp.Message = "成功"
|
||||
rsp = FillPaging(count, req.Page, req.Size, data, rsp)
|
||||
rsp.Err = err
|
||||
return rsp, err
|
||||
}
|
||||
ReturnPoint:
|
||||
if err != nil {
|
||||
rsp.Code = http.StatusInternalServerError
|
||||
rsp.Status = http.StatusText(http.StatusInternalServerError)
|
||||
rsp.Err = err
|
||||
rsp.Message = "失败"
|
||||
}
|
||||
return rsp, err
|
||||
}
|
||||
|
||||
func (rp *repo) ImportDataset(ctx context.Context, req proto.ImportDatasetRequest) (rsp *proto.BaseResponse, err error) {
|
||||
rsp = new(proto.BaseResponse)
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
err = fmt.Errorf("超时/取消")
|
||||
rsp.Code = http.StatusInternalServerError
|
||||
rsp.Status = http.StatusText(http.StatusInternalServerError)
|
||||
rsp.Message = "超时/取消"
|
||||
rsp.Err = ctx.Err()
|
||||
return rsp, ctx.Err()
|
||||
default:
|
||||
item := &model.Dataset{
|
||||
DatasetName: req.DatasetName,
|
||||
DatasetDesc: req.DatasetDesc,
|
||||
CategoryId: req.CategoryId,
|
||||
ProjectId: req.ProjectId,
|
||||
OwnerId: req.OwnerId,
|
||||
Creator: req.Creator,
|
||||
Status: 1,
|
||||
CreateAt: time.Now().Unix(),
|
||||
UpdateAt: time.Now().Unix(),
|
||||
}
|
||||
_, err = rp.engine.Insert(item)
|
||||
if err != nil {
|
||||
goto ReturnPoint
|
||||
}
|
||||
rsp.Code = http.StatusOK
|
||||
rsp.Status = http.StatusText(http.StatusOK)
|
||||
rsp.Message = "成功"
|
||||
rsp.Data = item
|
||||
rsp.Err = err
|
||||
return rsp, err
|
||||
}
|
||||
ReturnPoint:
|
||||
if err != nil {
|
||||
rsp.Code = http.StatusInternalServerError
|
||||
rsp.Status = http.StatusText(http.StatusInternalServerError)
|
||||
rsp.Err = err
|
||||
rsp.Message = "失败"
|
||||
}
|
||||
return rsp, err
|
||||
}
|
|
@ -4,9 +4,13 @@ import (
|
|||
"context"
|
||||
"fmt"
|
||||
"git.hpds.cc/Component/logging"
|
||||
"hpds-iot-web/config"
|
||||
"hpds-iot-web/internal/proto"
|
||||
"hpds-iot-web/model"
|
||||
"hpds-iot-web/pkg/minedata"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
"xorm.io/xorm"
|
||||
)
|
||||
|
@ -17,7 +21,9 @@ type ManageService interface {
|
|||
AddOwner(ctx context.Context, req proto.OwnerItemReq) (rsp *proto.BaseResponse, err error)
|
||||
EditOwner(ctx context.Context, req proto.OwnerItemReq) (rsp *proto.BaseResponse, err error)
|
||||
DelOwner(ctx context.Context, req proto.OwnerItemReq) (rsp *proto.BaseResponse, err error)
|
||||
|
||||
ProjectList(ctx context.Context, req proto.ProjectRequest) (rsp *proto.BaseResponse, err error)
|
||||
GetLngLat(ctx context.Context, mileagePile string) (lng, lat float64, err error)
|
||||
AddProject(ctx context.Context, req proto.ProjectItemRequest) (rsp *proto.BaseResponse, err error)
|
||||
EditProject(ctx context.Context, req proto.ProjectItemRequest) (rsp *proto.BaseResponse, err error)
|
||||
DelProject(ctx context.Context, req proto.ProjectItemRequest) (rsp *proto.BaseResponse, err error)
|
||||
|
@ -65,10 +71,11 @@ type ManageService interface {
|
|||
DeleteDevice(ctx context.Context, req proto.DeviceItemRequest) (rsp *proto.BaseResponse, err error)
|
||||
}
|
||||
|
||||
func NewManageService(engine *xorm.Engine, logger *logging.Logger) ManageService {
|
||||
func NewManageService(cfg *config.WebConfig, engine *xorm.Engine, logger *logging.Logger) ManageService {
|
||||
return &repo{
|
||||
engine: engine,
|
||||
logger: logger,
|
||||
AppConfig: cfg,
|
||||
engine: engine,
|
||||
logger: logger,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -291,6 +298,7 @@ func (rp *repo) ProjectList(ctx context.Context, req proto.ProjectRequest) (rsp
|
|||
count, err := rp.engine.Where("(? = '' or project_name like ?) ", req.ProjectName, "%"+req.ProjectName+"%").
|
||||
And("(? = '' or line_name like ?)", req.LineName, "%"+req.LineName+"%").
|
||||
And("(? = 0 or owner_id = ?)", req.OwnerId, req.OwnerId).
|
||||
And("status = 1").
|
||||
Limit(int(req.Size), int(((req.Page)-1)*req.Size)).
|
||||
FindAndCount(&data)
|
||||
if err != nil {
|
||||
|
@ -333,11 +341,24 @@ func (rp *repo) AddProject(ctx context.Context, req proto.ProjectItemRequest) (r
|
|||
FixedDeviceNum: req.FixedDeviceNum,
|
||||
Direction: req.Direction,
|
||||
LaneNum: req.LaneNum,
|
||||
Lng: req.Lng,
|
||||
Lat: req.Lat,
|
||||
Status: 1,
|
||||
Creator: req.Creator,
|
||||
}
|
||||
|
||||
slng, slat, err := rp.GetLngLat(ctx, fmt.Sprintf("%s+%s", req.LineName, req.StartName))
|
||||
if err != nil {
|
||||
goto ReturnPoint
|
||||
}
|
||||
item.StartPointLng = slng
|
||||
item.StartPointLat = slat
|
||||
|
||||
elng, elat, err := rp.GetLngLat(ctx, fmt.Sprintf("%s+%s", req.LineName, req.EndName))
|
||||
if err != nil {
|
||||
goto ReturnPoint
|
||||
}
|
||||
item.EndPointLng = elng
|
||||
item.EndPointLat = elat
|
||||
|
||||
_, err = rp.engine.Insert(item)
|
||||
if err != nil {
|
||||
goto ReturnPoint
|
||||
|
@ -357,6 +378,27 @@ ReturnPoint:
|
|||
}
|
||||
return rsp, err
|
||||
}
|
||||
func (rp *repo) GetLngLat(ctx context.Context, mileagePile string) (lng, lat float64, err error) {
|
||||
mine := minedata.NewMineData(rp.AppConfig.MineData.AccessKey)
|
||||
//正里程桩
|
||||
res, err := mine.MilepostService(mileagePile)
|
||||
if err != nil {
|
||||
return 0, 0, err
|
||||
}
|
||||
if len(res.Items) > 0 {
|
||||
location := strings.Split(res.Items[0].Location, ",")
|
||||
lng, err := strconv.ParseFloat(location[0], 64)
|
||||
if err != nil {
|
||||
return 0, 0, err
|
||||
}
|
||||
lat, err := strconv.ParseFloat(location[1], 64)
|
||||
if err != nil {
|
||||
return 0, 0, err
|
||||
}
|
||||
return lng, lat, err
|
||||
}
|
||||
return 0, 0, fmt.Errorf("未能取到经纬度信息")
|
||||
}
|
||||
|
||||
func (rp *repo) EditProject(ctx context.Context, req proto.ProjectItemRequest) (rsp *proto.BaseResponse, err error) {
|
||||
rsp = new(proto.BaseResponse)
|
||||
|
@ -391,9 +433,21 @@ func (rp *repo) EditProject(ctx context.Context, req proto.ProjectItemRequest) (
|
|||
}
|
||||
if len(req.StartName) > 0 {
|
||||
item.StartName = req.StartName
|
||||
slng, slat, err := rp.GetLngLat(ctx, fmt.Sprintf("%s+%s", req.LineName, req.StartName))
|
||||
if err != nil {
|
||||
goto ReturnPoint
|
||||
}
|
||||
item.StartPointLng = slng
|
||||
item.StartPointLat = slat
|
||||
}
|
||||
if len(req.EndName) > 0 {
|
||||
item.EndName = req.EndName
|
||||
elng, elat, err := rp.GetLngLat(ctx, fmt.Sprintf("%s+%s", req.LineName, req.EndName))
|
||||
if err != nil {
|
||||
goto ReturnPoint
|
||||
}
|
||||
item.EndPointLng = elng
|
||||
item.EndPointLat = elat
|
||||
}
|
||||
if req.FixedDeviceNum > 0 {
|
||||
item.FixedDeviceNum = req.FixedDeviceNum
|
||||
|
@ -404,12 +458,6 @@ func (rp *repo) EditProject(ctx context.Context, req proto.ProjectItemRequest) (
|
|||
if req.LaneNum > 0 {
|
||||
item.LaneNum = req.LaneNum
|
||||
}
|
||||
if req.Lng > 0 {
|
||||
item.Lng = req.Lng
|
||||
}
|
||||
if req.Lat > 0 {
|
||||
item.Lat = req.Lat
|
||||
}
|
||||
_, err = rp.engine.ID(req.ProjectId).AllCols().Update(item)
|
||||
if err != nil {
|
||||
goto ReturnPoint
|
||||
|
@ -704,6 +752,7 @@ func (rp *repo) CategoryList(ctx context.Context, req proto.ProductCategoryReque
|
|||
default:
|
||||
data := make([]model.MatterCategory, 0)
|
||||
count, err := rp.engine.Where("(? = '' or category_name like ?) ", req.CategoryName, req.CategoryName).
|
||||
And("status = 1").
|
||||
Limit(int(req.Size), int(((req.Page)-1)*req.Size)).
|
||||
FindAndCount(&data)
|
||||
if err != nil {
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
package model
|
||||
|
||||
type DatasetDetail struct {
|
||||
DetailId int64 `xorm:"not null pk autoincr INT(11)" json:"detailId"` //编号
|
||||
DatasetId int64 `xorm:"INT(11) not null default 0 index" json:"datasetId"` //数据集编号
|
||||
AccessUrl string `xorm:"varchar(200)" json:"accessUrl"` //访问地址
|
||||
FileSize int64 `xorm:"BIGINT" json:"fileSize"` //文件大小
|
||||
FileMd5 string `xorm:"VARCHAR(64)" json:"fileMd5"` //文件MD5
|
||||
CreateAt int64 `xorm:"created" json:"createAt"`
|
||||
UpdateAt int64 `xorm:"updated" json:"updateAt"`
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
package model
|
||||
|
||||
type Dataset struct {
|
||||
DatasetId int64 `xorm:"not null pk autoincr INT(11)" json:"datasetId"`
|
||||
DatasetName string `xorm:"varchar(200) not null" json:"datasetName"`
|
||||
DatasetDesc string `xorm:"varchar(200)" json:"datasetDesc"`
|
||||
CategoryId int `xorm:"not null SMALLINT default 1" json:"categoryId"` //业务分类, 1:道路 2:桥梁 3:隧道 4:边坡
|
||||
ProjectId int64 `xorm:"INT(11) not null default 0 index" json:"projectId"`
|
||||
OwnerId int64 `xorm:"INT(11) not null default 0 index" json:"ownerId"`
|
||||
Creator int64 `xorm:"INT(11) not null default 0 index" json:"creator"`
|
||||
Status int `xorm:"SMALLINT not null default 1" json:"status"`
|
||||
CreateAt int64 `xorm:"created" json:"createAt"`
|
||||
UpdateAt int64 `xorm:"updated" json:"updateAt"`
|
||||
}
|
|
@ -23,6 +23,8 @@ func New(driveName, dsn string) {
|
|||
DB.Dialect().SetQuotePolicy(dialects.QuotePolicyReserved)
|
||||
err := DB.Sync2(
|
||||
&Brand{},
|
||||
&Dataset{},
|
||||
&DatasetDetail{},
|
||||
&DetectionTask{},
|
||||
&Device{},
|
||||
&DeviceType{},
|
||||
|
|
|
@ -1,17 +1,19 @@
|
|||
package model
|
||||
|
||||
type Project struct {
|
||||
ProjectId int `xorm:"not null pk autoincr INT(11)" json:"projectId"`
|
||||
ProjectId int64 `xorm:"not null pk autoincr INT(11)" json:"projectId"`
|
||||
ProjectName string `xorm:"varchar(200) not null " json:"projectName"`
|
||||
OwnerId int `xorm:"not null INT(11) default 0" json:"ownerId"`
|
||||
OwnerId int64 `xorm:"not null INT(11) default 0" json:"ownerId"`
|
||||
LineName string `xorm:"varchar(200) not null " json:"lineName"`
|
||||
StartName string `xorm:"varchar(200) not null " json:"startName"`
|
||||
EndName string `xorm:"varchar(200) not null " json:"endName"`
|
||||
FixedDeviceNum int `xorm:"not null INT(11) default 0" json:"fixedDeviceNum"`
|
||||
Direction string `xorm:"varchar(200) not null " json:"direction"`
|
||||
LaneNum int `xorm:"not null INT(4) default 0" json:"laneNum"`
|
||||
Lng float64 `xorm:"decimal(18,6)" json:"lng"`
|
||||
Lat float64 `xorm:"decimal(18,6)" json:"lat"`
|
||||
StartPointLng float64 `xorm:"decimal(18,6)" json:"startPointLng"`
|
||||
StartPointLat float64 `xorm:"decimal(18,6)" json:"startPointLat"`
|
||||
EndPointLng float64 `xorm:"decimal(18,6)" json:"endPointLng"`
|
||||
EndPointLat float64 `xorm:"decimal(18,6)" json:"endPointLat"`
|
||||
Status int `xorm:"SMALLINT default 1" json:"status"`
|
||||
Creator int64 `xorm:"INT(11) default 0" json:"creator"`
|
||||
Modifier int64 `xorm:"INT(11) default 0" json:"modifier"`
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package minedata
|
||||
|
||||
import (
|
||||
"crypto/tls"
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
|
@ -17,11 +18,21 @@ func HttpDo(reqUrl, method string, params map[string]string, header map[string]s
|
|||
paramStr = fmt.Sprintf("%s&%s=%s", paramStr, k, url.QueryEscape(v))
|
||||
}
|
||||
}
|
||||
client := &http.Client{}
|
||||
req, err := http.NewRequest(strings.ToUpper(method), reqUrl, strings.NewReader(paramStr))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
client := &http.Client{
|
||||
Transport: &http.Transport{ //对客户端进行一些配置
|
||||
TLSClientConfig: &tls.Config{
|
||||
InsecureSkipVerify: true,
|
||||
},
|
||||
},
|
||||
}
|
||||
var req *http.Request
|
||||
if strings.ToUpper(method) == "GET" {
|
||||
reqUrl += "?" + paramStr
|
||||
req, err = http.NewRequest(strings.ToUpper(method), reqUrl, nil)
|
||||
} else {
|
||||
req, err = http.NewRequest(strings.ToUpper(method), reqUrl, strings.NewReader(paramStr))
|
||||
}
|
||||
|
||||
req.Header.Set("content-type", "X-WWW-FORM-URLENCODED")
|
||||
for k, v := range header {
|
||||
req.Header.Set(k, v)
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
|
||||
### 正里程桩
|
||||
GET https://service.minedata.cn/service/lbs/kpiles/v1/keywords?key=f0bda738033e47ffbfbd5d3f865c19e1&format_name=G6021%2BK157%2B890
|
||||
Content-Type: X-WWW-FORM-URLENCODED
|
||||
|
Loading…
Reference in New Issue