|
@@ -1,6 +1,7 @@
|
|
|
package services
|
|
|
|
|
|
import (
|
|
|
+ "errors"
|
|
|
"fmt"
|
|
|
"hongze/hongze_cygx/models"
|
|
|
"hongze/hongze_cygx/utils"
|
|
@@ -41,13 +42,22 @@ func GetProductInteriorUrl(url string, urlMap map[string]string) (itemResp *mode
|
|
|
}
|
|
|
|
|
|
// GetProductInteriorUrl 处理产品内测中的连接并做跳转处理
|
|
|
-func GetProductInteriorUrlBody(body string) (itemResp []*models.ProductInteriorUrlResp) {
|
|
|
+func GetProductInteriorUrlBody(body string, user *models.WxUserItem) (itemResp []*models.ProductInteriorUrlResp, err error) {
|
|
|
//2:文章详情 https://web.hzinsights.com/material/info/8436
|
|
|
//3:活动详情 https://web.hzinsights.com/activity/detail/2701
|
|
|
//4:产业详情 https://web.hzinsights.com/indepth/info/20/79
|
|
|
- material := "material/info"
|
|
|
- activity := "activity/detail"
|
|
|
- indepth := "indepth/info"
|
|
|
+
|
|
|
+ // 用户权限
|
|
|
+ authInfo, permissionArr, e := GetUserRaiPermissionInfo(user.UserId, user.CompanyId)
|
|
|
+ if e != nil {
|
|
|
+ err = errors.New("GetUserRaiPermissionInfo, Err: " + e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ material := "material/info" // 2:文章详情
|
|
|
+ activity := "activity/detail" //3:活动详情
|
|
|
+ indepth := "indepth/info" //4:产业详情
|
|
|
+ ctivityvideo := "ctivity/video" //5:活动音频
|
|
|
|
|
|
var randStrStart = "start_cygx_{|}"
|
|
|
var randStr = "start_cygx_{|}_end_cygx"
|
|
@@ -57,10 +67,9 @@ func GetProductInteriorUrlBody(body string) (itemResp []*models.ProductInteriorU
|
|
|
if match != nil {
|
|
|
for _, v := range match {
|
|
|
//过滤不相干的超链接
|
|
|
- if !strings.Contains(v, material) && !strings.Contains(v, activity) && !strings.Contains(v, indepth) {
|
|
|
+ if !strings.Contains(v, material) && !strings.Contains(v, activity) && !strings.Contains(v, indepth) && !strings.Contains(v, ctivityvideo) {
|
|
|
continue
|
|
|
}
|
|
|
- fmt.Println(v)
|
|
|
body = strings.Replace(body, fmt.Sprint("href=\"", v, "\""), "", -1)
|
|
|
body = strings.Replace(body, fmt.Sprint("<a >"), "", -1)
|
|
|
body = strings.Replace(body, fmt.Sprint("</a>"), "", -1)
|
|
@@ -68,7 +77,6 @@ func GetProductInteriorUrlBody(body string) (itemResp []*models.ProductInteriorU
|
|
|
urlMap[v] = v
|
|
|
}
|
|
|
}
|
|
|
- fmt.Println(urlMap)
|
|
|
sliceBody := strings.Split(body, randStr)
|
|
|
var sliceBodyUrl []string
|
|
|
for _, v := range sliceBody {
|
|
@@ -101,6 +109,46 @@ func GetProductInteriorUrlBody(body string) (itemResp []*models.ProductInteriorU
|
|
|
item.ChartPermissionId = chartPermissionId
|
|
|
}
|
|
|
item.Type = 4
|
|
|
+ } else if strings.Contains(url, ctivityvideo) {
|
|
|
+ if lenurlSlice >= 2 {
|
|
|
+ chartPermissionId, _ := strconv.Atoi(urlSlice[lenurlSlice-2])
|
|
|
+ item.ChartPermissionId = chartPermissionId
|
|
|
+ }
|
|
|
+ item.Type = 5
|
|
|
+ activityVideo, e := models.GetCygxActivityVideoReqByActivityId(sourceId)
|
|
|
+ if e != nil {
|
|
|
+ err = errors.New("GetCygxActivityVideoReqByActivityId, Err: " + e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if activityVideo != nil {
|
|
|
+ item.ActivityVideo = activityVideo
|
|
|
+ }
|
|
|
+ activityInfo, e := models.GetAddActivityInfoById(sourceId)
|
|
|
+ if e != nil {
|
|
|
+ err = errors.New("GetAddActivityInfoById, Err: " + e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ // 权限
|
|
|
+ au := new(models.UserPermissionAuthInfo)
|
|
|
+ au.SellerName = authInfo.SellerName
|
|
|
+ au.SellerMobile = authInfo.SellerMobile
|
|
|
+ au.HasPermission = authInfo.HasPermission
|
|
|
+ au.OperationMode = authInfo.OperationMode
|
|
|
+ if au.HasPermission == 1 {
|
|
|
+ // 非宏观权限进一步判断是否有权限
|
|
|
+ if activityInfo.ChartPermissionId != utils.HONG_GUAN_ID && !utils.InArrayByStr(permissionArr, activityInfo.ChartPermissionName) {
|
|
|
+ au.HasPermission = 2
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 无权限的弹框提示
|
|
|
+ if au.HasPermission != 1 {
|
|
|
+ if au.OperationMode == UserPermissionOperationModeCall {
|
|
|
+ au.PopupMsg = UserPermissionPopupMsgCallMicroVideo
|
|
|
+ } else {
|
|
|
+ au.PopupMsg = UserPermissionPopupMsgApplyActivity
|
|
|
+ }
|
|
|
+ }
|
|
|
+ item.AuthInfo = au
|
|
|
}
|
|
|
}
|
|
|
itemResp = append(itemResp, item)
|