1、修改bug
This commit is contained in:
parent
7451a0cc62
commit
6a6a63793d
|
@ -229,6 +229,20 @@ func (s HandlerService) GetProjectData(c *gin.Context) (data interface{}, err er
|
|||
go s.SaveLog("获取项目数据", "Manage", "", "", "", fmt.Sprintf("%d", userInfo.UserId), c.Request.RemoteAddr, "")
|
||||
return
|
||||
}
|
||||
func (s HandlerService) GetProjectRadarData(c *gin.Context) (data interface{}, err error) {
|
||||
repo := service.NewManageService(s.AppConfig, s.Engine, s.Logger)
|
||||
us, _ := c.Get("operatorUser")
|
||||
userInfo := us.(*model.SystemUser)
|
||||
var req proto.ProjectDataByPidRequest
|
||||
err = c.ShouldBindJSON(&req)
|
||||
if err != nil {
|
||||
go s.SaveLog("GetProjectRendaData", "Manage", "", "", ToString(req), fmt.Sprintf("%d", userInfo.UserId), c.Request.RemoteAddr, "")
|
||||
return nil, e.NewValidErr(err)
|
||||
}
|
||||
data, err = repo.GetProjectRadarData(c, req)
|
||||
go s.SaveLog("获取项目数据中雷达的图像文件", "Manage", "", "", "", fmt.Sprintf("%d", userInfo.UserId), c.Request.RemoteAddr, "")
|
||||
return
|
||||
}
|
||||
|
||||
func (s HandlerService) ProductList(c *gin.Context) (data interface{}, err error) {
|
||||
repo := service.NewManageService(s.AppConfig, s.Engine, s.Logger)
|
||||
|
|
|
@ -69,12 +69,13 @@ func (us RoleRequest) ToString() string {
|
|||
}
|
||||
|
||||
type RoleItemRequest struct {
|
||||
RoleId int64 `json:"roleId"`
|
||||
RoleName string `json:"roleName"`
|
||||
RoleValue string `json:"roleValue"`
|
||||
AliasName string `json:"aliasName"`
|
||||
Description string `json:"description"`
|
||||
Status int `json:"status"`
|
||||
RoleId int64 `json:"roleId"`
|
||||
RoleName string `json:"roleName"`
|
||||
RoleValue string `json:"roleValue"`
|
||||
AliasName string `json:"aliasName"`
|
||||
Description string `json:"description"`
|
||||
Status int `json:"status"`
|
||||
DataRange []int64 `json:"dataRange"`
|
||||
}
|
||||
|
||||
func (us RoleItemRequest) ToString() string {
|
||||
|
@ -140,6 +141,11 @@ type ProjectDataRequest struct {
|
|||
BasePageList
|
||||
}
|
||||
|
||||
type ProjectDataByPidRequest struct {
|
||||
ProjectId int64 `json:"projectId"`
|
||||
Pid int64 `json:"pid"`
|
||||
}
|
||||
|
||||
type ProjectItemRequest struct {
|
||||
ProjectId int64 `json:"projectId"`
|
||||
ProjectName string `json:"projectName"`
|
||||
|
|
|
@ -287,4 +287,5 @@ type ProjectSrcFile struct {
|
|||
SrcImg string `json:"srcImg"`
|
||||
CreateAt int64 `json:"createAt"`
|
||||
UpdateAt int64 `json:"updateAt"`
|
||||
Pid int64 `json:"pid"`
|
||||
}
|
||||
|
|
|
@ -65,7 +65,7 @@ func InitRouter(cfg *config.WebConfig, logger *logging.Logger, engine *xorm.Engi
|
|||
project.POST("/delete", e.ErrorWrapper(hs.DelProject))
|
||||
project.POST("/result", e.ErrorWrapper(hs.GetProjectResult))
|
||||
project.POST("/data", e.ErrorWrapper(hs.GetProjectData))
|
||||
|
||||
project.POST("/radar", e.ErrorWrapper(hs.GetProjectRadarData))
|
||||
}
|
||||
product := manage.Group("/product")
|
||||
{
|
||||
|
|
|
@ -77,9 +77,10 @@ func (rp *repo) Login(ctx context.Context, userName, pass string) (rsp *proto.Ba
|
|||
rsp.Err = ctx.Err()
|
||||
return rsp, ctx.Err()
|
||||
default:
|
||||
var h bool
|
||||
//获取用户
|
||||
us := new(model.SystemUser)
|
||||
h, err := rp.engine.Where("phone=?", userName).Get(us)
|
||||
h, err = rp.engine.Where("phone=?", userName).Get(us)
|
||||
if err != nil {
|
||||
goto ReturnPoint
|
||||
}
|
||||
|
@ -321,7 +322,7 @@ func (rp *repo) AddUser(ctx context.Context, req proto.UserRequestItem) (rsp *pr
|
|||
return rsp, ctx.Err()
|
||||
default:
|
||||
item := new(model.SystemUser)
|
||||
b, err := rp.engine.Where("phone = ?)", req.Phone).
|
||||
b, err := rp.engine.Where("phone = ?", req.Phone).
|
||||
Get(item)
|
||||
if err != nil {
|
||||
goto ReturnPoint
|
||||
|
@ -419,7 +420,7 @@ func (rp *repo) EditUser(ctx context.Context, req proto.UserRequestItem) (rsp *p
|
|||
item.Pass = utils.GetUserSha1Pass(req.Password, item.Salt)
|
||||
}
|
||||
item.UpdateAt = time.Now().Unix()
|
||||
_, err = sess.AllCols().Update(item)
|
||||
_, err = sess.ID(item.UserId).AllCols().Update(item)
|
||||
if err != nil {
|
||||
_ = sess.Rollback()
|
||||
goto ReturnPoint
|
||||
|
@ -539,6 +540,7 @@ func (rp *repo) AddRole(ctx context.Context, req proto.RoleItemRequest) (rsp *pr
|
|||
item.RoleName = req.RoleName
|
||||
item.RoleValue = req.RoleValue
|
||||
item.Status = req.Status
|
||||
item.DataRange = req.DataRange
|
||||
item.CreateAt = time.Now().Unix()
|
||||
item.UpdateAt = time.Now().Unix()
|
||||
_, err = rp.engine.Insert(item)
|
||||
|
@ -596,6 +598,7 @@ func (rp *repo) EditRole(ctx context.Context, req proto.RoleItemRequest) (rsp *p
|
|||
if len(req.RoleValue) > 0 && item.RoleValue != req.RoleValue {
|
||||
item.RoleValue = req.RoleValue
|
||||
}
|
||||
item.DataRange = req.DataRange
|
||||
item.Status = req.Status
|
||||
item.UpdateAt = time.Now().Unix()
|
||||
_, err = rp.engine.AllCols().Update(item)
|
||||
|
|
|
@ -30,6 +30,7 @@ type ManageService interface {
|
|||
DelProject(ctx context.Context, req proto.ProjectItemRequest) (rsp *proto.BaseResponse, err error)
|
||||
GetProjectResult(ctx context.Context, req proto.ProjectRequest) (rsp *proto.BaseResponse, err error)
|
||||
GetProjectData(ctx context.Context, req proto.ProjectDataRequest) (rsp *proto.BaseResponse, err error)
|
||||
GetProjectRadarData(ctx context.Context, req proto.ProjectDataByPidRequest) (rsp *proto.BaseResponse, err error)
|
||||
|
||||
ProductList(ctx context.Context, req proto.ProductRequest) (rsp *proto.BaseResponse, err error)
|
||||
GetProductInfo(ctx context.Context, req proto.ProductItemRequest) (rsp *proto.BaseResponse, err error)
|
||||
|
@ -666,7 +667,7 @@ func (rp *repo) GetProjectData(ctx context.Context, req proto.ProjectDataRequest
|
|||
if err != nil {
|
||||
goto ReturnPoint
|
||||
}
|
||||
sess := rp.engine.In("dataset_id", dataset)
|
||||
sess := rp.engine.In("dataset_id", dataset).And("pid=0")
|
||||
if len(req.KPileStart) > 0 {
|
||||
sess = sess.And("milepost_number >= ?", req.KPileStart)
|
||||
}
|
||||
|
@ -718,6 +719,66 @@ ReturnPoint:
|
|||
}
|
||||
return rsp, err
|
||||
}
|
||||
|
||||
func (rp *repo) GetProjectRadarData(ctx context.Context, req proto.ProjectDataByPidRequest) (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:
|
||||
dataset := make([]int64, 0)
|
||||
err = rp.engine.SQL("select dataset_id from dataset where project_id = ?", req.ProjectId).Find(&dataset)
|
||||
if err != nil {
|
||||
goto ReturnPoint
|
||||
}
|
||||
srcList := make([]model.FileManager, 0)
|
||||
err = rp.engine.In("dataset_id", dataset).
|
||||
Where("pid=?", req.Pid).Find(&srcList)
|
||||
if err != nil {
|
||||
goto ReturnPoint
|
||||
}
|
||||
list := make([]proto.ProjectSrcFile, len(srcList))
|
||||
for k, v := range srcList {
|
||||
upDown := "上行"
|
||||
if v.UpDown == 1 {
|
||||
upDown = "下行"
|
||||
}
|
||||
list[k] = proto.ProjectSrcFile{
|
||||
FileId: v.FileId,
|
||||
FileName: v.FileName,
|
||||
FileType: v.FileType,
|
||||
MilepostNumber: v.MilepostNumber,
|
||||
AccessUrl: v.AccessUrl,
|
||||
UpDown: upDown,
|
||||
LineNum: v.LineNum,
|
||||
Longitude: v.Longitude,
|
||||
Latitude: v.Latitude,
|
||||
CreateAt: v.CreateAt,
|
||||
UpdateAt: v.UpdateAt,
|
||||
Pid: v.Pid,
|
||||
}
|
||||
}
|
||||
rsp.Code = http.StatusOK
|
||||
rsp.Status = http.StatusText(http.StatusOK)
|
||||
rsp.Message = "成功"
|
||||
rsp.Data = list
|
||||
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) ProductList(ctx context.Context, req proto.ProductRequest) (rsp *proto.BaseResponse, err error) {
|
||||
rsp = new(proto.BaseResponse)
|
||||
select {
|
||||
|
|
|
@ -19,4 +19,5 @@ type FileManager struct {
|
|||
UpDown int `xorm:"TINYINT default 0" json:"upDown"` //上下行, 0:上行;1:下行
|
||||
Longitude float64 `xorm:"decimal(18,6)" json:"longitude"` //经度
|
||||
Latitude float64 `xorm:"decimal(18,6)" json:"latitude"` //纬度
|
||||
Pid int64 `xorm:"INT(11) default 0 index" json:"pid"` //上级编号
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ func ErrorWrapper(handle WrapperHandle) gin.HandlerFunc {
|
|||
c.JSON(r.Status, r)
|
||||
case validator.ValidationErrors:
|
||||
msg := r.Translate(binding.ValidTrans).Error()
|
||||
c.JSON(http.StatusOK, gin.H{"code": "", "msg": msg})
|
||||
c.JSON(http.StatusOK, gin.H{"code": "400", "msg": msg})
|
||||
default:
|
||||
er := NewValidErr(err)
|
||||
c.JSON(http.StatusOK, gin.H{"code": 500, "msg": er.Error()})
|
||||
|
|
Loading…
Reference in New Issue