123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156 |
- package report
- import (
- "github.com/gin-gonic/gin"
- "hongze/hongze_yb/controller/response"
- "hongze/hongze_yb/models/request"
- "hongze/hongze_yb/models/tables/rddp/classify_menu"
- reportService "hongze/hongze_yb/services/report"
- userService "hongze/hongze_yb/services/user"
- "hongze/hongze_yb/utils"
- "strconv"
- )
- // ClassifyList 专栏列表
- func ClassifyList(c *gin.Context) {
- reqClassifyIdFirst := c.DefaultQuery("classify_id_first", "")
- if reqClassifyIdFirst == "" {
- response.Fail("请输入二级分类标识", c)
- return
- }
- classifyIdFirst, err := strconv.Atoi(reqClassifyIdFirst)
- if err != nil {
- response.Fail("请输入正确的二级分类标识", c)
- return
- }
- userinfo := userService.GetInfoByClaims(c)
- classList, err := reportService.GetClassListByClassifyId(userinfo, classifyIdFirst)
- if err != nil {
- response.Fail(err.Error(), c)
- return
- }
- response.OkData("查询成功", classList, c)
- return
- }
- // ClassifyDetail 专栏详情
- func ClassifyDetail(c *gin.Context) {
- reqClassifyIdSecond := c.DefaultQuery("classify_id_second", "")
- if reqClassifyIdSecond == "" {
- response.Fail("请输入二级分类标识", c)
- return
- }
- classifyIdSecond, err := strconv.Atoi(reqClassifyIdSecond)
- if err != nil {
- response.Fail("请输入正确的二级分类标识", c)
- return
- }
- userinfo := userService.GetInfoByClaims(c)
- detail, err := reportService.GetClassifyDetail(userinfo, classifyIdSecond)
- if err != nil {
- response.Fail(err.Error(), c)
- return
- }
- response.OkData("查询成功", detail, c)
- return
- }
- // ClassifyDetailReports 专栏目录列表
- func ClassifyDetailReports(c *gin.Context) {
- reqClassifyIdSecond := c.DefaultQuery("classify_id_second", "")
- reqPageIndex := c.DefaultQuery("current_index", "1")
- reqPageSize := c.DefaultQuery("page_size", strconv.Itoa(utils.PageSize20))
- pageIndex, err := strconv.Atoi(reqPageIndex)
- if err != nil {
- response.Fail("请输入正确的条数限制", c)
- return
- }
- pageSize, err := strconv.Atoi(reqPageSize)
- if err != nil {
- response.Fail("请输入正确的页码", c)
- return
- }
- if reqClassifyIdSecond == "" {
- response.Fail("请输入二级分类标识", c)
- return
- }
- classifyIdSecond, err := strconv.Atoi(reqClassifyIdSecond)
- if err != nil {
- response.Fail("请输入正确的二级分类标识", c)
- return
- }
- userinfo := userService.GetInfoByClaims(c)
- detail, err := reportService.GetClassifyReportList(userinfo, classifyIdSecond, pageIndex, pageSize)
- if err != nil {
- response.Fail(err.Error(), c)
- return
- }
- response.OkData("查询成功", detail, c)
- return
- }
- // ClassifySimpleList 简单查询二级分类名称列表
- func ClassifySimpleList(c *gin.Context) {
- reqClassifyIdFirst := c.DefaultQuery("classify_id_first", "")
- if reqClassifyIdFirst == "" {
- response.Fail("请输入分类ID", c)
- return
- }
- classifyIdFirst, err := strconv.Atoi(reqClassifyIdFirst)
- if err != nil {
- response.Fail("分类ID格式错误", c)
- return
- }
- userinfo := userService.GetInfoByClaims(c)
- classList, err := reportService.GetClassifySecondSimpleList(userinfo, classifyIdFirst)
- if err != nil {
- response.Fail(err.Error(), c)
- return
- }
- response.OkData("查询成功", classList, c)
- return
- }
- // ClassifyFirstList Ficc 菜单
- func ClassifyFirstList(c *gin.Context) {
- userinfo := userService.GetInfoByClaims(c)
- classList, err := reportService.GetClassifyFirstList(userinfo)
- if err != nil {
- response.Fail(err.Error(), c)
- return
- }
- response.OkData("查询成功", classList, c)
- return
- }
- // ClassifyMenuList 一级分类-子目录列表
- func ClassifyMenuList(c *gin.Context) {
- var req request.ClassifyMenuReq
- if err := c.Bind(&req); err != nil {
- response.Fail("参数有误", c)
- return
- }
- if req.ClassifyId <= 0 {
- response.Fail("参数有误", c)
- return
- }
- list, e := classify_menu.GetMenuListByClassifyId(req.ClassifyId)
- if e != nil {
- response.FailMsg("获取失败", "获取一级分类子目录列表失败, Err: "+e.Error(), c)
- return
- }
- response.OkData("获取成功", list, c)
- }
|