package mobile import ( "gin-vue-admin/global" "gin-vue-admin/model/request" "gin-vue-admin/model/response" "gin-vue-admin/service" "gin-vue-admin/utils" "github.com/gin-gonic/gin" "go.uber.org/zap" ) // @Tags ReportComment // @Summary 查询书列表 // @Security ApiKeyAuth // @accept application/json // @Produce application/json // @Param data body request.GetReadBooks true "查询书列表" // @Success 200 {string} string "{"success":true,"data":{},"msg":"查询成功"}" // @Router /read/getReadBooks [get] func GetReadBooks(c *gin.Context) { if err, readBooks := service.GetReadBooks(); err != nil { global.GVA_LOG.Error("查询失败!", zap.Any("err", err)) response.FailWithMessage("查询失败", c) } else { response.OkWithData(gin.H{"readBooks": readBooks}, c) } return } // @Tags ReportComment // @Summary 用bookId查询书目录 // @Security ApiKeyAuth // @accept application/json // @Produce application/json // @Param data body request.GetReadCatalog true "查询书目录" // @Success 200 {string} string "{"success":true,"data":{},"msg":"查询成功"}" // @Router /read/getReadCatalog [post] func GetReadCatalog(c *gin.Context) { var req request.GetReadCatalog _ = c.ShouldBindJSON(&req) if err, catalogs := service.GetReadCatalog(req.Id); err != nil { global.GVA_LOG.Error("查询失败!", zap.Any("err", err)) response.FailWithMessage("查询失败", c) } else { reply := utils.GetBookCatalogs(catalogs, 0) response.OkWithData(gin.H{"catalogs": reply}, c) } return } // @Tags ReportComment // @Summary 用cataId查询文章 // @Security ApiKeyAuth // @accept application/json // @Produce application/json // @Param data body request.GetReadBooks true "查询文章" // @Success 200 {string} string "{"success":true,"data":{},"msg":"查询成功"}" // @Router /read/getReadBooks [post] func GetReadContent(c *gin.Context) { var req request.GetReadContent _ = c.ShouldBindJSON(&req) if err, content := service.GetReadContent(req.Id); err != nil { global.GVA_LOG.Error("查询失败!", zap.Any("err", err)) response.FailWithMessage("查询失败", c) } else { response.OkWithData(content, c) } return } // @Tags ReportComment // @Summary 查询用户浏览历史 // @Security ApiKeyAuth // @accept application/json // @Produce application/json // @Param data body request.GetReadHistoryReq true "查询浏览历史" // @Success 200 {string} string "{"success":true,"data":{},"msg":"查询成功"}" // @Router /read/getReadHistory [post] func GetReadHistory(c *gin.Context) { var req request.GetReadHistoryReq _ = c.ShouldBindJSON(&req) if err, content := service.GetReadHistory(req); err != nil { global.GVA_LOG.Error("查询失败!", zap.Any("err", err)) response.FailWithMessage("查询失败", c) } else { response.OkWithData(content, c) } return } // @Tags ReportComment // @Summary 新增浏览记录 // @Security ApiKeyAuth // @accept application/json // @Produce application/json // @Param data body request.CreateReadHistory true "新增浏览记录" // @Success 200 {string} string "{"success":true,"data":{},"msg":"新增成功"}" // @Router /read/addReadHistory [post] func AddReadHistory(c *gin.Context) { var req request.CreateReadHistory _ = c.ShouldBindJSON(&req) service.CreateReadHistory(req) response.OkWithMessage("创建成功", c) } // @Tags ReportComment // @Summary 更新浏览记录 // @Security ApiKeyAuth // @accept application/json // @Produce application/json // @Param data body request.CreateReadHistory true "更新浏览记录" // @Success 200 {string} string "{"success":true,"data":{},"msg":"更新成功"}" // @Router /read/updateReadHistory [post] func UpdateReadHistory(c *gin.Context) { var req request.CreateReadHistory _ = c.ShouldBindJSON(&req) service.UpdateReadHistory(req) response.OkWithMessage("更新成功", c) }