123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119 |
- 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 + "%"
- var groupId int
- if sysUser.RoleTypeCode == utils.ROLE_TYPE_CODE_FICC_GROUP || sysUser.RoleTypeCode == utils.ROLE_TYPE_CODE_RAI_GROUP {
- groupId = sysUser.GroupId
- } else {
- groupId = -1
- }
- list, err := roadshow.CompanySearchV2(sysUser.AdminId, groupId, KeyWord, sysUser.RoleTypeCode)
- 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, "获取成功")
- }
|