Răsfoiți Sursa

Merge branch 'cygx_need_886' of http://8.136.199.33:3000/hongze/hongze_open_api into debug

xingzai 1 an în urmă
părinte
comite
4e9179fdab
2 a modificat fișierele cu 29 adăugiri și 3 ștergeri
  1. 9 3
      controllers/yidong.go
  2. 20 0
      models/tables/company_product/company_product.go

+ 9 - 3
controllers/yidong.go

@@ -379,7 +379,7 @@ func (c *YiDongController) UserCheck() {
 		c.FailWithMessage("签名错误!")
 		return
 	}
-	_, err = cygxActivity.GetAddActivityInfoById(activityIdYiDong)
+	activityDetail, err := cygxActivity.GetAddActivityInfoById(activityIdYiDong)
 	if err != nil {
 		c.FailWithMessage("会议id异常:" + activityIdYiDong)
 		return
@@ -393,12 +393,18 @@ func (c *YiDongController) UserCheck() {
 		return
 	}
 	resp := new(yidong.CheckHaspermissionResp)
-	total, err := company_product.CheckUserAaiPerssionByMobile(deMobile)
+	//total, err := company_product.CheckUserAaiPerssionByMobile(deMobile)
+	//if err != nil {
+	//	c.FailWithMessage("校验失败!" + err.Error())
+	//	return
+	//}
+	//获取所有的权限名称
+	companyPermissionName, err := company_product.GetCompanyPermissionByMobile(deMobile)
 	if err != nil {
 		c.FailWithMessage("校验失败!" + err.Error())
 		return
 	}
-	if total > 0 {
+	if strings.Contains(companyPermissionName, activityDetail.ChartPermissionName) {
 		resp.Haspermission = true
 	}
 	//添加请求日志记录

+ 20 - 0
models/tables/company_product/company_product.go

@@ -77,3 +77,23 @@ func CheckUserAaiPerssionByMobile(mobile string) (count int, err error) {
 	err = o.Raw(sql, mobile).QueryRow(&count)
 	return
 }
+
+func GetCompanyPermissionByMobile(mobile string) (permission string, err error) {
+	sql := ` SELECT
+			GROUP_CONCAT( DISTINCT b.remark ORDER BY b.sort ASC SEPARATOR ',' ) AS permission 
+		FROM
+			company_report_permission AS a
+			INNER JOIN chart_permission AS b ON a.chart_permission_id = b.chart_permission_id
+			INNER JOIN company_product AS c ON a.company_id = c.company_id
+			INNER JOIN wx_user AS u ON u.company_id = c.company_id 
+			AND a.product_id = c.product_id 
+		WHERE
+			u.mobile = ? 
+			AND c.is_suspend = 0 
+			AND b.cygx_auth = 1
+			AND c.STATUS IN ( '正式', '试用', '永续' ) 
+			AND a.STATUS IN ( '正式', '试用', '永续' ) `
+	o := orm.NewOrm()
+	err = o.Raw(sql, mobile).QueryRow(&permission)
+	return
+}