|
@@ -43,7 +43,6 @@ func GetValidPermissionByCompany2ProductId(companyId, productId int64) (list []*
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-
|
|
|
// GetPurchasePermissionIdsByCompany2ProductId 根据客户id和产品id获取有效的权限id集合
|
|
|
func GetPurchasePermissionIdsByCompany2ProductId(companyId, productId int64) (permissionIds []int, err error) {
|
|
|
where := make(map[string]interface{})
|
|
@@ -54,7 +53,7 @@ func GetPurchasePermissionIdsByCompany2ProductId(companyId, productId int64) (pe
|
|
|
if err != nil {
|
|
|
return
|
|
|
}
|
|
|
- for _, v := range list {
|
|
|
+ for _, v := range list {
|
|
|
permissionIds = append(permissionIds, v.ChartPermissionID)
|
|
|
}
|
|
|
return
|
|
@@ -154,7 +153,7 @@ func CheckPermissionByPermissionIdList2Ficc(companyId int64, userId int, permiss
|
|
|
ok, _ = checkPermissionByPermissionIdList2Rai(companyId, userId, permissionIdList)
|
|
|
}
|
|
|
if ok == false && permissionCheckInfo.Type == "apply" {
|
|
|
- _, err = yb_apply_record.GetLastNotOpRecordByUserId(userId) // 从来源我的/活动申请的记录
|
|
|
+ _, err = yb_apply_record.GetLastNotOpRecordByUserId(userId) // 从来源我的/活动申请的记录
|
|
|
if err != nil && err != utils.ErrNoRow {
|
|
|
return
|
|
|
}
|
|
@@ -280,7 +279,7 @@ func GetCheckPermission(companyId int64, userId int, permissionIdList []int) (ok
|
|
|
ok, _ = checkPermissionByPermissionIdList2Rai(companyId, userId, permissionIdList)
|
|
|
}
|
|
|
if ok == false && permissionCheckInfo.Type == "apply" {
|
|
|
- _, err = yb_apply_record.GetLastNotOpRecordByUserId(userId) // 从来源我的/活动申请的记录
|
|
|
+ _, err = yb_apply_record.GetLastNotOpRecordByUserId(userId) // 从来源我的/活动申请的记录
|
|
|
if err != nil {
|
|
|
if err == utils.ErrNoRow {
|
|
|
err = nil
|
|
@@ -451,10 +450,10 @@ func checkPermissionByPermissionIdList2Rai(companyId int64, userId int, permissi
|
|
|
|
|
|
// ChartPermissionCheckInfo 图表权限验证信息
|
|
|
type ChartPermissionCheckInfo struct {
|
|
|
- Name string `json:"name" description:"销售名称"`
|
|
|
- Mobile string `json:"mobile" description:"手机号"`
|
|
|
- Type string `json:"type" description:"无权限,需要前端处理的类型,枚举值:expired, apply, contact"`
|
|
|
- CustomerInfo CustomerInfo `json:"customer_info" description:"客户信息"`
|
|
|
+ Name string `json:"name" description:"销售名称"`
|
|
|
+ Mobile string `json:"mobile" description:"手机号"`
|
|
|
+ Type string `json:"type" description:"无权限,需要前端处理的类型,枚举值:expired, apply, contact"`
|
|
|
+ CustomerInfo CustomerInfo `json:"customer_info" description:"客户信息"`
|
|
|
}
|
|
|
|
|
|
// CheckUserChartPermission 验证用户/联系人的图库权限
|
|
@@ -462,7 +461,7 @@ func CheckUserChartPermission(companyId int64, userId int) (ok bool, permissionC
|
|
|
defer func() {
|
|
|
// 如果无权限,那么就去查询是否申请过
|
|
|
if ok == false && permissionCheckInfo.Type == "apply" {
|
|
|
- _, err = yb_apply_record.GetLastNotOpRecordByUserId(userId) // 图库申请
|
|
|
+ _, err = yb_apply_record.GetLastNotOpRecordByUserId(userId) // 图库申请
|
|
|
// 查询是否有申请过,如果有申请过的话,那么err是nil
|
|
|
if err != nil {
|
|
|
if err == utils.ErrNoRow {
|
|
@@ -563,7 +562,7 @@ func CheckUserChartPermission(companyId int64, userId int) (ok bool, permissionC
|
|
|
permissionCheckInfo.Type = "contact"
|
|
|
return
|
|
|
}
|
|
|
- endTime := permissionInfo.EndTime.Add(23 * time.Hour + 59 * time.Minute + 59 * time.Second)
|
|
|
+ endTime := permissionInfo.EndTime.Add(23*time.Hour + 59*time.Minute + 59*time.Second)
|
|
|
if nowTime.After(permissionInfo.StartTime) && nowTime.Before(endTime) {
|
|
|
ok = true
|
|
|
} else {
|
|
@@ -582,42 +581,18 @@ func CheckUserChartPermission(companyId int64, userId int) (ok bool, permissionC
|
|
|
}
|
|
|
|
|
|
type FiccPermissionList struct {
|
|
|
- ClassifyName string `description:"分类"`
|
|
|
- HasPermission bool `description:"是否有权限"`
|
|
|
- Items []*PermissionItem `description:"子类"`
|
|
|
+ ClassifyName string `description:"分类"`
|
|
|
+ HasPermission bool `description:"是否有权限"`
|
|
|
+ Items []*PermissionItem `description:"子类"`
|
|
|
}
|
|
|
|
|
|
type PermissionItem struct {
|
|
|
- PermissionId int `description:"权限id"`
|
|
|
- PermissionName string `description:"权限名称"`
|
|
|
- HasPermission bool `description:"是否有权限"`
|
|
|
-}
|
|
|
-
|
|
|
-// GetFiccPermissionList 获取FICC品种权限列表
|
|
|
-func GetFiccPermissionList() (list []*FiccPermissionList, err error) {
|
|
|
- productId := 1
|
|
|
- for _, v := range utils.PermissionFiccClassifyArr {
|
|
|
- classify := new(FiccPermissionList)
|
|
|
- classify.ClassifyName = v
|
|
|
- items, tmpErr := chart_permission.GetListByProductIdAndClassifyName(productId, v)
|
|
|
- if tmpErr != nil {
|
|
|
- return
|
|
|
- }
|
|
|
- tmpItems := make([]*PermissionItem, 0)
|
|
|
- for _, iv := range items {
|
|
|
- item := new(PermissionItem)
|
|
|
- item.PermissionId = int(iv.ChartPermissionID)
|
|
|
- item.PermissionName = iv.PermissionName
|
|
|
- tmpItems = append(tmpItems, item)
|
|
|
- }
|
|
|
- classify.Items = tmpItems
|
|
|
- list = append(list, classify)
|
|
|
- }
|
|
|
-
|
|
|
- return
|
|
|
+ PermissionId int `description:"权限id"`
|
|
|
+ PermissionName string `description:"权限名称"`
|
|
|
+ HasPermission bool `description:"是否有权限"`
|
|
|
}
|
|
|
|
|
|
-func GetHomeFiccPermissions(user user.UserInfo) (ret response.PermissionFiccResp, err error){
|
|
|
+func GetHomeFiccPermissions(user user.UserInfo) (ret response.PermissionFiccResp, err error) {
|
|
|
var errMsg string
|
|
|
defer func() {
|
|
|
if err != nil {
|
|
@@ -657,7 +632,7 @@ func GetHomeFiccPermissions(user user.UserInfo) (ret response.PermissionFiccResp
|
|
|
if int(v.ChartPermissionID) == myPerId {
|
|
|
permissionMap[v.ChartPermissionID] = true
|
|
|
permissionList[k].Sort = v.Sort - 1000
|
|
|
- if _, ok := permissionFirstMap[v.ClassifyName]; ok && !permissionFirstMap[v.ClassifyName].IsCheck {
|
|
|
+ if _, ok := permissionFirstMap[v.ClassifyName]; ok && !permissionFirstMap[v.ClassifyName].IsCheck {
|
|
|
permissionFirstMap[v.ClassifyName].AuthOk = true
|
|
|
permissionFirstMap[v.ClassifyName].Sort -= 1000
|
|
|
permissionFirstMap[v.ClassifyName].IsCheck = true
|
|
@@ -673,16 +648,15 @@ func GetHomeFiccPermissions(user user.UserInfo) (ret response.PermissionFiccResp
|
|
|
temp.ChartPermissionID = int(v.ChartPermissionID)
|
|
|
temp.ChartPermissionName = v.PermissionName
|
|
|
temp.AuthOk = permissionMap[v.ChartPermissionID]
|
|
|
- if _, ok := permissionFirstMap[v.ClassifyName]; ok{
|
|
|
+ if _, ok := permissionFirstMap[v.ClassifyName]; ok {
|
|
|
permissionFirstMap[v.ClassifyName].List = append(permissionFirstMap[v.ClassifyName].List, temp)
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
permissionFirstMap[v.ClassifyName] = &response.PermissionFirstItem{
|
|
|
List: []*response.PermissionFiccSecondItem{temp},
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
}
|
|
|
+
|
|
|
var list response.PermissionFiccList
|
|
|
for k, v := range permissionFirstMap {
|
|
|
temp := new(response.PermissionFiccItem)
|
|
@@ -690,20 +664,20 @@ func GetHomeFiccPermissions(user user.UserInfo) (ret response.PermissionFiccResp
|
|
|
temp.ClassifyName = k
|
|
|
if strings.Contains(temp.ClassifyName, "宏观") {
|
|
|
temp.ClassifyName = "宏观经济"
|
|
|
- temp.SelectIconUrl = utils.ALIYUN_YBIMG_HOST+"ficc_icon_idx_hongguan_select.png"
|
|
|
- temp.IconUrl = utils.ALIYUN_YBIMG_HOST+"ficc_icon_idx_hongguan.png"
|
|
|
- }else if temp.ClassifyName == "化工产业" {
|
|
|
+ temp.SelectIconUrl = utils.ALIYUN_YBIMG_HOST + "ficc_icon_idx_hongguan_select.png"
|
|
|
+ temp.IconUrl = utils.ALIYUN_YBIMG_HOST + "ficc_icon_idx_hongguan.png"
|
|
|
+ } else if temp.ClassifyName == "化工产业" {
|
|
|
temp.ClassifyName = "化工"
|
|
|
- temp.SelectIconUrl = utils.ALIYUN_YBIMG_HOST+"ficc_icon_idx_huagong_select.png"
|
|
|
- temp.IconUrl = utils.ALIYUN_YBIMG_HOST+"ficc_icon_idx_huagong.png"
|
|
|
- }else if temp.ClassifyName == "黑色产业" {
|
|
|
+ temp.SelectIconUrl = utils.ALIYUN_YBIMG_HOST + "ficc_icon_idx_huagong_select.png"
|
|
|
+ temp.IconUrl = utils.ALIYUN_YBIMG_HOST + "ficc_icon_idx_huagong.png"
|
|
|
+ } else if temp.ClassifyName == "黑色产业" {
|
|
|
temp.ClassifyName = "黑色"
|
|
|
- temp.SelectIconUrl = utils.ALIYUN_YBIMG_HOST+"ficc_icon_idx_black_select.png"
|
|
|
- temp.IconUrl = utils.ALIYUN_YBIMG_HOST+"ficc_icon_idx_black.png"
|
|
|
- }else if temp.ClassifyName == "有色产业" {
|
|
|
+ temp.SelectIconUrl = utils.ALIYUN_YBIMG_HOST + "ficc_icon_idx_black_select.png"
|
|
|
+ temp.IconUrl = utils.ALIYUN_YBIMG_HOST + "ficc_icon_idx_black.png"
|
|
|
+ } else if temp.ClassifyName == "有色产业" {
|
|
|
temp.ClassifyName = "有色"
|
|
|
- temp.SelectIconUrl = utils.ALIYUN_YBIMG_HOST+"ficc_icon_idx_youse_select.png"
|
|
|
- temp.IconUrl = utils.ALIYUN_YBIMG_HOST+"ficc_icon_idx_youse.png"
|
|
|
+ temp.SelectIconUrl = utils.ALIYUN_YBIMG_HOST + "ficc_icon_idx_youse_select.png"
|
|
|
+ temp.IconUrl = utils.ALIYUN_YBIMG_HOST + "ficc_icon_idx_youse.png"
|
|
|
}
|
|
|
if len(v.List) > 0 {
|
|
|
temp.List = v.List
|
|
@@ -746,8 +720,8 @@ func GetHomeFiccPermissions(user user.UserInfo) (ret response.PermissionFiccResp
|
|
|
}
|
|
|
|
|
|
temp := new(response.PermissionFiccItem)
|
|
|
- temp.SelectIconUrl = utils.ALIYUN_YBIMG_HOST+"ficc_icon_idx_more_select.png"
|
|
|
- temp.IconUrl = utils.ALIYUN_YBIMG_HOST+"ficc_icon_idx_more.png"
|
|
|
+ temp.SelectIconUrl = utils.ALIYUN_YBIMG_HOST + "ficc_icon_idx_more_select.png"
|
|
|
+ temp.IconUrl = utils.ALIYUN_YBIMG_HOST + "ficc_icon_idx_more.png"
|
|
|
temp.ClassifyName = "更多报告"
|
|
|
temp.Sort = 100000
|
|
|
list = append(list, temp)
|
|
@@ -756,4 +730,4 @@ func GetHomeFiccPermissions(user user.UserInfo) (ret response.PermissionFiccResp
|
|
|
ret.CheckFlag = checkFlag
|
|
|
ret.ContactInfo = contactInfo
|
|
|
return
|
|
|
-}
|
|
|
+}
|