From e49bb1f0ddc7791df7d888c86cfb9f62ae1bad4e Mon Sep 17 00:00:00 2001 From: elf <360197197@qq.com> Date: Thu, 19 Sep 2024 01:08:01 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/manage/order.go | 21 +++++++++++++++++++ .../student_insure_info_query_request.go | 1 + router/manage.go | 2 ++ service/student_insure_service.go | 4 ++-- 4 files changed, 26 insertions(+), 2 deletions(-) diff --git a/api/manage/order.go b/api/manage/order.go index e6b182c..7f7d052 100644 --- a/api/manage/order.go +++ b/api/manage/order.go @@ -44,3 +44,24 @@ func DownloadOrders(c *gin.Context) { f := service.OrderService.GenerateOrdersExcel(req) excel.Download(f, "订单列表.xlsx", c) } + +func GetInfos(c *gin.Context) (result.Data, error) { + var req request.StudentInsureInfoQueryRequest + err := c.ShouldBindQuery(&req) + if err != nil { + return nil, e.NewError("参数错误") + } + records, total := service.StudentInsureService.GetInfos(req) + data := result.Data{ + "records": records, + "total": total, + } + return data, nil +} + +func DownloadInfos(c *gin.Context) { + var req request.StudentInsureInfoQueryRequest + _ = c.ShouldBindQuery(&req) + f := service.StudentInsureService.GenerateInfosExcel(req) + excel.Download(f, "学生投保信息.xlsx", c) +} diff --git a/dto/request/manage/student_insure_info_query_request.go b/dto/request/manage/student_insure_info_query_request.go index 7b4f7d5..53441dd 100644 --- a/dto/request/manage/student_insure_info_query_request.go +++ b/dto/request/manage/student_insure_info_query_request.go @@ -1,6 +1,7 @@ package manage type StudentInsureInfoQueryRequest struct { + PageQueryRequest SchoolName string `json:"schoolName" form:"schoolName"` StudentName string `json:"studentName" form:"studentName"` StudentIdentityNo string `json:"studentIdentityNo" form:"studentIdentityNo"` diff --git a/router/manage.go b/router/manage.go index d170007..7655cf0 100644 --- a/router/manage.go +++ b/router/manage.go @@ -21,5 +21,7 @@ func adminRouteInit(r *gin.Engine) { authGroup.Match([]string{"GET", "OPTIONS"}, "/get-orders", result.Json(manage.GetOrders)) authGroup.Match([]string{"GET", "OPTIONS"}, "/get-order", result.Json(manage.GetOrder)) authGroup.Match([]string{"GET", "OPTIONS"}, "/download-orders", manage.DownloadOrders) + authGroup.Match([]string{"GET", "OPTIONS"}, "/get-infos", result.Json(manage.GetInfos)) + authGroup.Match([]string{"GET", "OPTIONS"}, "/download-infos", manage.DownloadInfos) } } diff --git a/service/student_insure_service.go b/service/student_insure_service.go index 09f70c3..56c2816 100644 --- a/service/student_insure_service.go +++ b/service/student_insure_service.go @@ -38,7 +38,7 @@ func (s *studentInsureService) Save(r request.StudentInsureInfoRequest) (*model. return &info, nil } -func (s *studentInsureService) GetInfos(req manage.OrderQueryRequest) ([]model.StudentInsureInfo, int64) { +func (s *studentInsureService) GetInfos(req manage.StudentInsureInfoQueryRequest) ([]model.StudentInsureInfo, int64) { records := make([]model.StudentInsureInfo, req.PageSize) offset := (req.Page - 1) * req.PageSize var total int64 @@ -83,7 +83,7 @@ func (s *studentInsureService) buildQuery(req manage.StudentInsureInfoQueryReque return tx } -func (s *studentInsureService) GenerateOrdersExcel(req manage.StudentInsureInfoQueryRequest) *excelize.File { +func (s *studentInsureService) GenerateInfosExcel(req manage.StudentInsureInfoQueryRequest) *excelize.File { pageSize := 200 lastID := 0