package roadshow import ( "hongze/hongze_mobile_admin/models/roadshow" "hongze/hongze_mobile_admin/models/tables/english_company" "hongze/hongze_mobile_admin/services" "hongze/hongze_mobile_admin/utils" "strings" ) // @Title 我的日历列表 // @Description 我的日历列表接口 // @Param KeyWord query string true "搜索关键词" // @Success 200 {object} rs.CalendarListResp // @router /company/search [get] func (this *CalendarController) CompanySearch() { sysUser := this.AdminWx if sysUser == nil { this.FailWithMessage("请登录", "请登录,SysUser Is Empty") return } KeyWord := this.GetString("KeyWord") if KeyWord == "" { this.FailWithMessage("请输入搜索词!", "请输入搜索词!") return } KeyWord = "%" + KeyWord + "%" list, err := roadshow.CompanySearchV2(sysUser.AdminId, KeyWord) if err != nil && err.Error() != utils.ErrNoRow() { this.FailWithMessage("搜索客户失败!", "搜索客户失败!Err:"+err.Error()) return } if list == nil { list = make([]*roadshow.CompanySearchView, 0) } this.OkDetailed(list, "获取成功") } // CompanyDetail // @Title 我的日历列表 // @Description 我的日历列表接口 // @Param CompanyId query int true "公司id" // @Param EnglishCompany query int true "是否为英文客户" // @Success 200 {object} rs.CompanyDetailView // @router /company/detail [get] func (this *CalendarController) CompanyDetail() { sysUser := this.AdminWx if sysUser == nil { this.FailWithMessage("请登录", "请登录,SysUser Is Empty") return } companyId, _ := this.GetInt("CompanyId") if companyId <= 0 { this.FailWithMessage("参数错误!", "参数错误!") return } englishCompany, _ := this.GetInt("EnglishCompany") productId := services.GetProductId(sysUser.RoleTypeCode) if productId == 0 { productId = 1 } detailView := new(roadshow.CompanyDetailView) if englishCompany == 0 { companyProductItem, err := roadshow.GetCompanyProductByCompanyIdAndProductId(companyId, productId) if err != nil { this.FailWithMessage("搜索客户失败!", "搜索客户失败!Err:"+err.Error()) return } permissionList, err := roadshow.GetCompanyProductReportPermissionList(companyId, productId) if err != nil { this.FailWithMessage("搜索客户权限失败!", "搜索客户权限失败!Err:"+err.Error()) return } var permissionArr []string for _, v := range permissionList { permissionArr = append(permissionArr, v.PermissionName) } //readMap, err := services.GetFiccCountUserViewHistoryByCompanyIds(strconv.Itoa(companyId)) //if err != nil { // this.FailWithMessage("获取阅读次数失败!", "获取阅读次数失败!Err:"+err.Error()) // return //} //readNum, ok := readMap[companyId] //if !ok { // readNum = 0 //} detailView.CompanyId = companyProductItem.CompanyId detailView.CompanyName = companyProductItem.CompanyName detailView.Status = companyProductItem.Status detailView.IndustryId = companyProductItem.IndustryId detailView.IndustryName = companyProductItem.IndustryName detailView.PermissionName = strings.Join(permissionArr, "/") detailView.ReportReadTotal = companyProductItem.ViewTotal //ficc报告-累计阅读次数 this.OkDetailed(detailView, "获取成功") return } // 英文客户 enItem, e := english_company.GetEnglishCompanyById(companyId) if e != nil { this.FailWithMessage("搜索客户失败!", "获取英文客户详情失败, Err: "+e.Error()) return } detailView.CompanyId = enItem.CompanyId detailView.CompanyName = enItem.CompanyName detailView.Status = "正常" detailView.EnglishCompany = 1 detailView.EnglishCountry = enItem.Country detailView.EnglishViewTotal = enItem.ViewTotal this.OkDetailed(detailView, "获取成功") }