|
@@ -56,6 +56,7 @@ func (this *MyChartController) Collect() {
|
|
|
UniqueCode: req.UniqueCode,
|
|
|
ChartImage: req.ChartImage,
|
|
|
ChartName: req.ChartName,
|
|
|
+ ChartInfoId: req.ChartInfoId,
|
|
|
CreateTime: time.Now(),
|
|
|
ModifyTime: time.Now(),
|
|
|
}
|
|
@@ -180,6 +181,75 @@ func (this *MyChartController) List() {
|
|
|
br.Ret = 200
|
|
|
}
|
|
|
|
|
|
+// @Title Locate
|
|
|
+// @Description create users
|
|
|
+// @Param PageSize query int true "每页数据条数"
|
|
|
+// @Param CurrentIndex query int true "当前页页码,从1开始"
|
|
|
+// @Success 200 {object} models.BaseResponse
|
|
|
+// @Failure 403 {object} models.BaseResponse
|
|
|
+// @router /locate [get]
|
|
|
+func (this *MyChartController) Locate() {
|
|
|
+ br := new(models.BaseResponse).Init()
|
|
|
+ defer func() {
|
|
|
+ this.Data["json"] = br
|
|
|
+ this.ServeJSON()
|
|
|
+ }()
|
|
|
+ user := this.User
|
|
|
+ total, err := models.GetMyChartListCountById(user.UserId)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "查询收藏数量失败"
|
|
|
+ br.ErrMsg = "查询收藏数量失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ charts := make([]*response.MyChartLocateItem, 0)
|
|
|
+ if total == 0 {
|
|
|
+ br.Data = charts
|
|
|
+ br.Ret = 200
|
|
|
+ br.Success = true
|
|
|
+ br.Msg = "获取成功"
|
|
|
+ return
|
|
|
+ }
|
|
|
+ items, err := models.GetMyChartListById(user.UserId, 0, total)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "查询收藏失败"
|
|
|
+ br.ErrMsg = "查询收藏失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for k, v := range items {
|
|
|
+ var prevChartInfoId, nextChartInfoId int
|
|
|
+ switch k {
|
|
|
+ case 0:
|
|
|
+ prevChartInfoId = -1
|
|
|
+ if k < total {
|
|
|
+ nextChartInfoId = items[k+1].ChartInfoId
|
|
|
+ }
|
|
|
+ case total - 1:
|
|
|
+ nextChartInfoId = -1
|
|
|
+ if k > 0 {
|
|
|
+ prevChartInfoId = items[k-1].ChartInfoId
|
|
|
+ }
|
|
|
+ default:
|
|
|
+ prevChartInfoId = items[k-1].ChartInfoId
|
|
|
+ nextChartInfoId = items[k+1].ChartInfoId
|
|
|
+
|
|
|
+ }
|
|
|
+ tmpChart := &response.MyChartLocateItem{
|
|
|
+ MyChartId: v.MyChartId,
|
|
|
+ ChartInfoId: v.ChartInfoId,
|
|
|
+ ChartName: v.ChartName,
|
|
|
+ UniqueCode: v.UniqueCode,
|
|
|
+ PrevChartInfoId: prevChartInfoId,
|
|
|
+ NextChartInfoId: nextChartInfoId,
|
|
|
+ }
|
|
|
+ charts = append(charts, tmpChart)
|
|
|
+ }
|
|
|
+
|
|
|
+ br.Data = charts
|
|
|
+ br.Msg = "查询成功"
|
|
|
+ br.Success = true
|
|
|
+ br.Ret = 200
|
|
|
+}
|
|
|
+
|
|
|
// @Title IsCollect
|
|
|
// @Description create users
|
|
|
// @Param PageSize query int true "每页数据条数"
|