123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142 |
- package autocode
- import (
- "github.com/flipped-aurora/gin-vue-admin/server/global"
- "github.com/flipped-aurora/gin-vue-admin/server/model/autocode"
- autocodeReq "github.com/flipped-aurora/gin-vue-admin/server/model/autocode/request"
- "github.com/flipped-aurora/gin-vue-admin/server/model/common/request"
- "github.com/flipped-aurora/gin-vue-admin/server/model/common/response"
- "github.com/flipped-aurora/gin-vue-admin/server/service"
- "github.com/gin-gonic/gin"
- "go.uber.org/zap"
- )
- type ReadCountApi struct {
- }
- var readCountService = service.ServiceGroupApp.AutoCodeServiceGroup.ReadCountService
- // CreateReadCount 创建ReadCount
- // @Tags ReadCount
- // @Summary 创建ReadCount
- // @Security ApiKeyAuth
- // @accept application/json
- // @Produce application/json
- // @Param data body autocode.ReadCount true "创建ReadCount"
- // @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
- // @Router /readCount/createReadCount [post]
- func (readCountApi *ReadCountApi) CreateReadCount(c *gin.Context) {
- var readCount autocode.ReadCount
- _ = c.ShouldBindJSON(&readCount)
- if err := readCountService.CreateReadCount(readCount); err != nil {
- global.GVA_LOG.Error("创建失败!", zap.Any("err", err))
- response.FailWithMessage("创建失败", c)
- } else {
- response.OkWithMessage("创建成功", c)
- }
- }
- // DeleteReadCount 删除ReadCount
- // @Tags ReadCount
- // @Summary 删除ReadCount
- // @Security ApiKeyAuth
- // @accept application/json
- // @Produce application/json
- // @Param data body autocode.ReadCount true "删除ReadCount"
- // @Success 200 {string} string "{"success":true,"data":{},"msg":"删除成功"}"
- // @Router /readCount/deleteReadCount [delete]
- func (readCountApi *ReadCountApi) DeleteReadCount(c *gin.Context) {
- var readCount autocode.ReadCount
- _ = c.ShouldBindJSON(&readCount)
- if err := readCountService.DeleteReadCount(readCount); err != nil {
- global.GVA_LOG.Error("删除失败!", zap.Any("err", err))
- response.FailWithMessage("删除失败", c)
- } else {
- response.OkWithMessage("删除成功", c)
- }
- }
- // DeleteReadCountByIds 批量删除ReadCount
- // @Tags ReadCount
- // @Summary 批量删除ReadCount
- // @Security ApiKeyAuth
- // @accept application/json
- // @Produce application/json
- // @Param data body request.IdsReq true "批量删除ReadCount"
- // @Success 200 {string} string "{"success":true,"data":{},"msg":"批量删除成功"}"
- // @Router /readCount/deleteReadCountByIds [delete]
- func (readCountApi *ReadCountApi) DeleteReadCountByIds(c *gin.Context) {
- var IDS request.IdsReq
- _ = c.ShouldBindJSON(&IDS)
- if err := readCountService.DeleteReadCountByIds(IDS); err != nil {
- global.GVA_LOG.Error("批量删除失败!", zap.Any("err", err))
- response.FailWithMessage("批量删除失败", c)
- } else {
- response.OkWithMessage("批量删除成功", c)
- }
- }
- // UpdateReadCount 更新ReadCount
- // @Tags ReadCount
- // @Summary 更新ReadCount
- // @Security ApiKeyAuth
- // @accept application/json
- // @Produce application/json
- // @Param data body autocode.ReadCount true "更新ReadCount"
- // @Success 200 {string} string "{"success":true,"data":{},"msg":"更新成功"}"
- // @Router /readCount/updateReadCount [put]
- func (readCountApi *ReadCountApi) UpdateReadCount(c *gin.Context) {
- var readCount autocode.ReadCount
- _ = c.ShouldBindJSON(&readCount)
- if err := readCountService.UpdateReadCount(readCount); err != nil {
- global.GVA_LOG.Error("更新失败!", zap.Any("err", err))
- response.FailWithMessage("更新失败", c)
- } else {
- response.OkWithMessage("更新成功", c)
- }
- }
- // FindReadCount 用id查询ReadCount
- // @Tags ReadCount
- // @Summary 用id查询ReadCount
- // @Security ApiKeyAuth
- // @accept application/json
- // @Produce application/json
- // @Param data query autocode.ReadCount true "用id查询ReadCount"
- // @Success 200 {string} string "{"success":true,"data":{},"msg":"查询成功"}"
- // @Router /readCount/findReadCount [get]
- func (readCountApi *ReadCountApi) FindReadCount(c *gin.Context) {
- var readCount autocode.ReadCount
- _ = c.ShouldBindQuery(&readCount)
- if err, rereadCount := readCountService.GetReadCount(readCount.ID); err != nil {
- global.GVA_LOG.Error("查询失败!", zap.Any("err", err))
- response.FailWithMessage("查询失败", c)
- } else {
- response.OkWithData(gin.H{"rereadCount": rereadCount}, c)
- }
- }
- // GetReadCountList 分页获取ReadCount列表
- // @Tags ReadCount
- // @Summary 分页获取ReadCount列表
- // @Security ApiKeyAuth
- // @accept application/json
- // @Produce application/json
- // @Param data query autocodeReq.ReadCountSearch true "分页获取ReadCount列表"
- // @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
- // @Router /readCount/getReadCountList [get]
- func (readCountApi *ReadCountApi) GetReadCountList(c *gin.Context) {
- var pageInfo autocodeReq.ReadCountSearch
- _ = c.ShouldBindQuery(&pageInfo)
- if err, list, total := readCountService.GetReadCountInfoList(pageInfo); err != nil {
- global.GVA_LOG.Error("获取失败!", zap.Any("err", err))
- response.FailWithMessage("获取失败", c)
- } else {
- response.OkWithDetailed(response.PageResult{
- List: list,
- Total: total,
- Page: pageInfo.Page,
- PageSize: pageInfo.PageSize,
- }, "获取成功", c)
- }
- }
|