|
@@ -0,0 +1,117 @@
|
|
|
+package chart
|
|
|
+
|
|
|
+import (
|
|
|
+ "github.com/gin-gonic/gin"
|
|
|
+ "hongze/hongze_yb/controller/response"
|
|
|
+ "hongze/hongze_yb/models/response/my_chart"
|
|
|
+ my_chart2 "hongze/hongze_yb/models/tables/my_chart"
|
|
|
+ "hongze/hongze_yb/services/chart"
|
|
|
+ "hongze/hongze_yb/services/user"
|
|
|
+ "strconv"
|
|
|
+ "strings"
|
|
|
+)
|
|
|
+
|
|
|
+// GetMyChartChassify 获取图表分类列表
|
|
|
+// @Tags 图库模块
|
|
|
+// @Summary 获取图表分类
|
|
|
+// @Description 获取图表分类列表
|
|
|
+// @Security ApiKeyAuth
|
|
|
+// @Param Authorization header string true "Bearer 31a165baebe6dec616b1f8f3207b4273"
|
|
|
+// @Accept json
|
|
|
+// @Product json
|
|
|
+// @Param Keywords query string false "分类名称关键词"
|
|
|
+// @Success 200 {object} my_chart.MyChartClassifyListResp
|
|
|
+// @failure 400 {string} string "分类列表获取失败"
|
|
|
+// @Router /chart/getChartChassify [get]
|
|
|
+func GetMyChartChassify(c *gin.Context) {
|
|
|
+ userInfo := user.GetInfoByClaims(c)
|
|
|
+ publicCondition := make(map[string]interface{})
|
|
|
+ privateCondition := make(map[string]interface{})
|
|
|
+ reqKeywords := c.DefaultQuery("Keywords", "")
|
|
|
+ if reqKeywords != "" {
|
|
|
+ publicCondition["my_chart_classify_name like"] = "%" + reqKeywords + "%"
|
|
|
+ privateCondition["my_chart_classify_name like"] = "%" + reqKeywords + "%"
|
|
|
+ }
|
|
|
+
|
|
|
+ publicClassify, privateClassify, err := chart.GetUserChartClassifyListByCondition(userInfo, publicCondition, privateCondition)
|
|
|
+ if err != nil {
|
|
|
+ response.Fail("获取图表分类失败, Err:" + err.Error(), c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ respData := &my_chart.MyChartClassifyListResp {
|
|
|
+ PublicClassify: publicClassify,
|
|
|
+ PrivateClassify: privateClassify,
|
|
|
+ }
|
|
|
+ response.OkData("获取成功", respData, c)
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+// GetMyChartChassify 获取图表分类列表
|
|
|
+// @Tags 图库模块
|
|
|
+// @Summary 获取图表分类
|
|
|
+// @Description 获取图表分类列表
|
|
|
+// @Security ApiKeyAuth
|
|
|
+// @Param Authorization header string true "Bearer 31a165baebe6dec616b1f8f3207b4273"
|
|
|
+// @Accept json
|
|
|
+// @Product json
|
|
|
+// @Param Keywords query string false "图表名称关键词"
|
|
|
+// @Param Page query int false "当前页页码,从1开始"
|
|
|
+// @Param Limit query int false "每页数据量"
|
|
|
+// @Success 200 {object} []my_chart.MyChartList
|
|
|
+// @failure 400 {string} string "图库列表获取失败"
|
|
|
+// @Router /chart/getChartList [get]
|
|
|
+func GetMyChartList(c *gin.Context) {
|
|
|
+ userInfo := user.GetInfoByClaims(c)
|
|
|
+
|
|
|
+ // 获取图表分类IDs
|
|
|
+ publicCondition := make(map[string]interface{})
|
|
|
+ privateCondition := make(map[string]interface{})
|
|
|
+ publicClassify, privateClassify, err := chart.GetUserChartClassifyListByCondition(userInfo, publicCondition, privateCondition)
|
|
|
+ if err != nil {
|
|
|
+ response.Fail("获取图标信息失败, Err:" + err.Error(), c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ var condition string
|
|
|
+ var pars []interface{}
|
|
|
+ // 图表分类
|
|
|
+ classifyIdsSlice := make([]string, 0)
|
|
|
+ for i := 0; i < len(publicClassify); i++ {
|
|
|
+ classifyIdsSlice = append(classifyIdsSlice, strconv.Itoa(publicClassify[i].MyChartClassifyID))
|
|
|
+ }
|
|
|
+ for i := 0; i < len(privateClassify); i++ {
|
|
|
+ classifyIdsSlice = append(classifyIdsSlice, strconv.Itoa(privateClassify[i].MyChartClassifyID))
|
|
|
+ }
|
|
|
+ classifyIdsStr := strings.Join(classifyIdsSlice, ",")
|
|
|
+ condition += " AND d.my_chart_classify_id IN (?)"
|
|
|
+ pars = append(pars, classifyIdsStr)
|
|
|
+ // 关键词
|
|
|
+ reqKeywords := c.DefaultQuery("Keywords", "")
|
|
|
+ if reqKeywords != "" {
|
|
|
+ condition += " AND b.chart_name LIKE ?"
|
|
|
+ pars = append(pars, "%" + reqKeywords + "%")
|
|
|
+ }
|
|
|
+ page, _ := strconv.Atoi(c.Query("Page"))
|
|
|
+ limit, _ := strconv.Atoi(c.Query("Limit"))
|
|
|
+ if page == 0 {
|
|
|
+ page = 1
|
|
|
+ }
|
|
|
+ if limit == 0 {
|
|
|
+ limit = 10
|
|
|
+ }
|
|
|
+
|
|
|
+ list, err := my_chart2.GetMyChartListByCondition(condition, pars, page, limit)
|
|
|
+ if err != nil {
|
|
|
+ response.Fail("获取图库列表失败, Err:" + err.Error(), c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ response.OkData("获取成功", list, c)
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+// GetChartInfo 获取图表详情
|
|
|
+func GetChartInfo(c *gin.Context) {
|
|
|
+
|
|
|
+}
|