package home import ( "eta/eta_mini_ht_api/controllers" ) type HomeController struct { controllers.ListController } // Search 搜索报告列表 // @Description 搜索报告列表 // @Success 200 {object} // @router /search [get] func (r *HomeController) Search(key string) { controllers.Wrap(&r.BaseController, func() (result *controllers.WrapData, err error) { result = r.InitWrapData("分页搜索报告列表失败") //if key == "" { // err = exception.New(exception.SearchKeyEmptyError) // r.FailedResult("分页搜索报告列表失败", result) // return //} //detailType := r.Data["detailType"].(string) //userInfo := r.Data["user"].(user.User) //pageRes := page.Page{ // Current: r.PageInfo.Current, // PageSize: r.PageInfo.PageSize, //} ////获取当前可以被搜索的报告原始ID ////先要限制查询的id范围 //var reportIds []int //pageRes.Total, pageRes.LatestId, reportIds, err = report.RangeSearch(key, isLogin(detailType), userInfo.Id) //if err != nil { // logger.Error("获取报告原始ID列表失败:%v", err) // r.FailedResult("分页搜索报告列表失败", result) // return //} //if len(reportIds) == 0 { // reports := new(page.PageResult) // reports.Data = []reportService.ReportDTO{} // reports.Page = pageRes // logger.Info("没有可以查询的报告列表") // r.SuccessResult("分页搜索报告列表成功", reports, result) // return //} // //if r.PageInfo.LatestId == 0 { // //pageRes.Total, pageRes.LatestId = report.SearchMaxReportId(key) // r.PageInfo.LatestId = pageRes.LatestId // r.PageInfo.Total = pageRes.Total //} else { // pageRes.LatestId = r.PageInfo.LatestId // pageRes.Total = r.PageInfo.Total //} //pageRes.TotalPage = page.TotalPages(pageRes.Total, pageRes.PageSize) //list := make([]reportService.ReportDTO, 0) //if pageRes.LatestId > 0 { // //订阅 TODO // list, err = report.SearchReportList(key, reportIds, r.PageInfo, isLogin(detailType), userInfo.Id) // if err != nil { // r.FailedResult("分页搜索报告列表失败", result) // return // } //} //reports := new(page.PageResult) //reports.Data = list //reports.Page = pageRes //r.SuccessResult("分页搜索报告列表成功", reports, result) return }) }