package hdl import ( "applet/app/admin/md" "applet/app/admin/svc" "applet/app/bigData/lib/validate" "applet/app/db" "applet/app/e" "fmt" "github.com/gin-gonic/gin" "os" ) func DataStatisticsList(c *gin.Context) { var req md.ExportRecordsListReq err := c.ShouldBindJSON(&req) if err != nil { err = validate.HandleValidateErr(err) err1 := err.(e.E) e.OutErr(c, err1.Code, err1.Error()) return } if req.Limit == 0 { req.Limit = 10 } if req.Page == 0 { req.Page = 10 } exportRecordsDb := db.ExportRecordsDb{} exportRecordsDb.Set() list, total, err := exportRecordsDb.ExportRecordsExportRecordsList(req) if err != nil { e.OutErr(c, e.ERR_DB_ORM, err.Error()) return } e.OutSuc(c, map[string]interface{}{ "list": list, "total": total, "kind": []map[string]interface{}{ { "name": "商品销售明细表", "value": 1, }, { "name": "对账单", "value": 2, }, }, }, nil) return } func DataStatisticsDelete(c *gin.Context) { var req struct { Ids []int `json:"ids"` } err := c.ShouldBindJSON(&req) if err != nil { err = validate.HandleValidateErr(err) err1 := err.(e.E) e.OutErr(c, err1.Code, err1.Error()) return } for _, id := range req.Ids { exportRecordsDb := db.ExportRecordsDb{} exportRecordsDb.Set() exportRecords, err1 := exportRecordsDb.GetExportRecordsExportRecords(id) if err1 != nil { e.OutErr(c, e.ERR_DB_ORM, err1.Error()) return } if exportRecords == nil { e.OutErr(c, e.ERR_NO_DATA, "未查询到相关记录") return } err = os.RemoveAll("./data/export/" + exportRecords.DownloadPath) //移除文件 if err != nil { fmt.Println("err>>>>>>>>>>>>>>", err.Error()) } _, err2 := exportRecordsDb.ExportRecordsExportRecordsDelete(id) if err2 != nil { e.OutErr(c, e.ERR_DB_ORM, err2.Error()) return } } e.OutSuc(c, "success", nil) return } func DataStatisticsExport(c *gin.Context) { var req md.DataStatisticsExportReq err := c.ShouldBindJSON(&req) if err != nil { err = validate.HandleValidateErr(err) err1 := err.(e.E) e.OutErr(c, err1.Code, err1.Error()) return } if req.EnterpriseId != 0 { enterpriseDb := db.EnterpriseDb{} enterpriseDb.Set() enterprise, err1 := enterpriseDb.GetEnterprise(req.EnterpriseId) if err1 != nil { e.OutErr(c, e.ERR_DB_ORM, err1.Error()) return } req.EnterpriseName = enterprise.Name } go svc.DataStatisticsExport(req) e.OutSuc(c, map[string]interface{}{ "msg": "导出成功,请稍后刷新数据列表", }, nil) return }