|
@@ -4,6 +4,7 @@ import (
|
|
|
"eta/eta_mini_api/models"
|
|
|
"eta/eta_mini_api/models/response"
|
|
|
"eta/eta_mini_api/services"
|
|
|
+ "eta/eta_mini_api/utils"
|
|
|
)
|
|
|
|
|
|
type ChartController struct {
|
|
@@ -27,7 +28,7 @@ func (this *ChartController) List() {
|
|
|
pageSize, _ := this.GetInt("PageSize")
|
|
|
currentIndex, _ := this.GetInt("CurrentIndex")
|
|
|
|
|
|
- result, err := services.GetChartList(pageSize, currentIndex)
|
|
|
+ result, err := services.GetChartList(currentIndex, pageSize)
|
|
|
if err != nil {
|
|
|
br.Msg = "查询图表失败"
|
|
|
br.ErrMsg = "查询图表失败,系统异常,Err:" + err.Error()
|
|
@@ -47,3 +48,113 @@ func (this *ChartController) List() {
|
|
|
br.Success = true
|
|
|
br.Ret = 200
|
|
|
}
|
|
|
+
|
|
|
+// @Title Detail
|
|
|
+// @Description 图表详情
|
|
|
+// @Param ChartInfoId query int true "图表详情id"
|
|
|
+// @Success 200 {object} models.BaseResponse
|
|
|
+// @router /detail [get]
|
|
|
+func (this *ChartController) Detail() {
|
|
|
+ br := new(models.BaseResponse).Init()
|
|
|
+ defer func() {
|
|
|
+ this.Data["json"] = br
|
|
|
+ this.ServeJSON()
|
|
|
+ }()
|
|
|
+ if this.User.Status != utils.UserStatusFormal {
|
|
|
+ br.Msg = "用户没有权限查看图表"
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ chartInfoId, _ := this.GetInt("ChartInfoId")
|
|
|
+ if chartInfoId <= 0 {
|
|
|
+ br.Msg = "图表id错误"
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ result, err := services.GetChartDetail(chartInfoId)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取图表详情失败"
|
|
|
+ br.ErrMsg = "获取图表详情失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if result.Ret != 200 {
|
|
|
+ br.Msg = result.Msg
|
|
|
+ br.ErrMsg = result.ErrMsg
|
|
|
+ return
|
|
|
+ }
|
|
|
+ br.Data = result.Data
|
|
|
+ br.Msg = "查询成功"
|
|
|
+ br.Success = true
|
|
|
+ br.Ret = 200
|
|
|
+}
|
|
|
+
|
|
|
+// @Title Locate
|
|
|
+// @Description create users
|
|
|
+// @Param PageSize query int true "每页数据条数"
|
|
|
+// @Param CurrentIndex query int true "当前页页码,从1开始"
|
|
|
+// @Success 200 {object} models.BaseResponse
|
|
|
+// @router /locate [get]
|
|
|
+func (this *ChartController) Locate() {
|
|
|
+ br := new(models.BaseResponse).Init()
|
|
|
+ defer func() {
|
|
|
+ this.Data["json"] = br
|
|
|
+ this.ServeJSON()
|
|
|
+ }()
|
|
|
+ pageSize, _ := this.GetInt("PageSize")
|
|
|
+ currentIndex, _ := this.GetInt("CurrentIndex")
|
|
|
+ if currentIndex <= 0 {
|
|
|
+ currentIndex = 1
|
|
|
+ }
|
|
|
+ if pageSize <= 0 {
|
|
|
+ pageSize = 2
|
|
|
+ }
|
|
|
+ result, err := services.GetChartList(currentIndex, pageSize)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "查询图表失败"
|
|
|
+ br.ErrMsg = "查询图表失败,系统异常,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if result.Ret != 200 {
|
|
|
+ br.Msg = result.Msg
|
|
|
+ br.ErrMsg = result.ErrMsg
|
|
|
+ return
|
|
|
+ }
|
|
|
+ total := len(result.Data.List)
|
|
|
+ charts := make([]*response.ChartLocateItem, 0)
|
|
|
+
|
|
|
+ items := result.Data.List
|
|
|
+ for k, v := range items {
|
|
|
+ var prevChartInfoId, nextChartInfoId int
|
|
|
+ switch k {
|
|
|
+ case 0:
|
|
|
+ prevChartInfoId = -1
|
|
|
+ if k < total-1 {
|
|
|
+ nextChartInfoId = items[k+1].ChartInfoId
|
|
|
+ } else {
|
|
|
+ nextChartInfoId = -1
|
|
|
+ }
|
|
|
+ case total - 1:
|
|
|
+ nextChartInfoId = -1
|
|
|
+ if k > 0 {
|
|
|
+ prevChartInfoId = items[k-1].ChartInfoId
|
|
|
+ }
|
|
|
+ default:
|
|
|
+ prevChartInfoId = items[k-1].ChartInfoId
|
|
|
+ nextChartInfoId = items[k+1].ChartInfoId
|
|
|
+
|
|
|
+ }
|
|
|
+ tmpLocate := &response.ChartLocateItem{
|
|
|
+ ChartInfoId: v.ChartInfoId,
|
|
|
+ ChartName: v.ChartName,
|
|
|
+ UniqueCode: v.UniqueCode,
|
|
|
+ PrevChartInfoId: prevChartInfoId,
|
|
|
+ NextChartInfoId: nextChartInfoId,
|
|
|
+ }
|
|
|
+ charts = append(charts, tmpLocate)
|
|
|
+ }
|
|
|
+
|
|
|
+ br.Data = charts
|
|
|
+ br.Msg = "查询成功"
|
|
|
+ br.Success = true
|
|
|
+ br.Ret = 200
|
|
|
+}
|