116 lines
3.4 KiB
Go
116 lines
3.4 KiB
Go
package test_data
|
|
|
|
import (
|
|
"github.com/gin-gonic/gin"
|
|
"gorm.io/gorm"
|
|
"testData/global"
|
|
"testData/model/response"
|
|
test_data "testData/repository/test.data"
|
|
"testData/request"
|
|
"testData/utils"
|
|
)
|
|
|
|
type IFinalReportExcelInterface struct {
|
|
}
|
|
|
|
type SFinalReportExcelService struct {
|
|
DB *gorm.DB
|
|
}
|
|
|
|
func InitFinalReportExcelService() *SFinalReportExcelService {
|
|
db := global.PostGreSQL
|
|
return &SFinalReportExcelService{
|
|
DB: db,
|
|
}
|
|
}
|
|
|
|
// @Tags 数据分析平台
|
|
// @Summary 添加结批报告字段信息
|
|
// @Security ApiKeyAuth
|
|
// @accept application/json
|
|
// @Produce application/json
|
|
// @Param date body request.CreateFinalReportExcel true "添加结批报告字段信息"
|
|
// @Success 200 {string} string "{"success": true, "data": {}, "msg": "操作成功"}"
|
|
// @Router /testData/finalReport/excel [post]
|
|
func (S *SFinalReportExcelService) Create(c *gin.Context) {
|
|
r := request.CreateFinalReportExcel{}
|
|
_ = c.ShouldBind(&r)
|
|
if msg, ok := utils.ValidateInfo2CN(r); !ok {
|
|
response.FailWithMessage(msg, c)
|
|
return
|
|
}
|
|
if err := test_data.CreateFinalReportExcel(&r); err != nil {
|
|
response.FailWithMessage(err.Error(), c)
|
|
} else {
|
|
response.Ok(c)
|
|
}
|
|
}
|
|
|
|
// @Tags 数据分析平台
|
|
// @Summary 分页查询结批报告字段信息
|
|
// @Security ApiKeyAuth
|
|
// @accept application/json
|
|
// @Produce application/json
|
|
// @Param page query int true "页数"
|
|
// @Param pageSize query int true "每页显示数量"
|
|
// @Param key_word query string false "关键词"
|
|
// @Success 200 {string} string "{"success": true, "data": {}, "msg": "操作成功"}"
|
|
// @Router /testData/finalReport/excel [get]
|
|
func (S *SFinalReportExcelService) ShowList(c *gin.Context) {
|
|
keyWord := c.Query("key_word")
|
|
offset, limit, err := utils.PaginationLimitAndPage(c)
|
|
if err != nil {
|
|
response.FailWithMessage(err.Error(), c)
|
|
return
|
|
}
|
|
if finalReportExcel, total, err := test_data.ShowListFinalReportExcel(offset, limit, keyWord); err != nil {
|
|
response.FailWithMessage(err.Error(), c)
|
|
} else {
|
|
response.OkWithData(gin.H{"final_report_excel": finalReportExcel, "total": total}, c)
|
|
}
|
|
}
|
|
|
|
// @Tags 数据分析平台
|
|
// @Summary 更新结批报告字段信息
|
|
// @Security ApiKeyAuth
|
|
// @accept application/json
|
|
// @Produce application/json
|
|
// @Param date body request.UpdateFinalReportExcel true "更新结批报告字段信息"
|
|
// @Success 200 {string} string "{"success": true, "data": {}, "msg": "操作成功"}"
|
|
// @Router /testData/finalReport/excel [put]
|
|
func (S *SFinalReportExcelService) Update(c *gin.Context) {
|
|
r := request.UpdateFinalReportExcel{}
|
|
_ = c.ShouldBind(&r)
|
|
if msg, ok := utils.ValidateInfo2CN(r); !ok {
|
|
response.FailWithMessage(msg, c)
|
|
return
|
|
}
|
|
if err := test_data.UpdateFinalReportExcel(&r); err != nil {
|
|
response.FailWithMessage(err.Error(), c)
|
|
} else {
|
|
response.Ok(c)
|
|
}
|
|
}
|
|
|
|
// @Tags 数据分析平台
|
|
// @Summary 删除结批报告字段信息
|
|
// @Security ApiKeyAuth
|
|
// @accept application/json
|
|
// @Produce application/json
|
|
// @Param date body request.DeleteFinalReportExcel true "删除结批报告字段信息"
|
|
// @Success 200 {string} string "{"success": true, "data": {}, "msg": "操作成功"}"
|
|
// @Router /testData/finalReport/excel [delete]
|
|
func (S *SFinalReportExcelService) Delete(c *gin.Context) {
|
|
r := request.DeleteFinalReportExcel{}
|
|
_ = c.ShouldBind(&r)
|
|
if msg, ok := utils.ValidateInfo2CN(r); !ok {
|
|
response.FailWithMessage(msg, c)
|
|
return
|
|
}
|
|
if err := test_data.DeleteFinalReportExcel(&r); err != nil {
|
|
response.FailWithMessage(err.Error(), c)
|
|
} else {
|
|
response.Ok(c)
|
|
}
|
|
}
|