xingzai 1 anno fa
parent
commit
cdddab6268
3 ha cambiato i file con 42 aggiunte e 5 eliminazioni
  1. 11 0
      controllers/user.go
  2. 2 1
      models/xzs_choose_category.go
  3. 29 4
      models/xzs_choose_send.go

+ 11 - 0
controllers/user.go

@@ -211,6 +211,16 @@ func (this *UserController) ChooseSubmit() {
 		br.Msg = "请至少选择一项主客观内容"
 		return
 	}
+	listMap, err := models.GetCygxXzsChooseCategoryMapList()
+	if err != nil {
+		br.Msg = "操作失败!"
+		br.ErrMsg = "获取数据失败,Err:" + err.Error()
+		return
+	}
+	mapReport := make(map[int]int)
+	for _, v := range listMap {
+		mapReport[v.CategoryId] = v.Id
+	}
 	var itemsFllow []*models.CygxIndustryFllow
 	var itemsCategory []*models.CygxXzsChooseCategory
 	industrialFllowNum := make(map[int]int) // 提交过来的不同行业的下对应的产业数量
@@ -262,6 +272,7 @@ func (this *UserController) ChooseSubmit() {
 				item := new(models.CygxXzsChooseCategory)
 				categoryId, _ := strconv.Atoi(v)
 				item.CategoryId = categoryId
+				item.IdCygx = mapReport[categoryId]
 				item.UserId = user.UserId
 				item.Mobile = user.Mobile
 				item.Email = user.Email

+ 2 - 1
models/xzs_choose_category.go

@@ -16,9 +16,10 @@ type CygxXzsChooseCategory struct {
 	CategoryId  int       `description:"权益文章对应分类,cygx_article"`
 	CreateTime  time.Time `description:"创建时间"`
 	ModifyTime  time.Time `description:"更新时间"`
+	IdCygx      int       `description:"cygx_report_mapping_cygx 表主键ID"`
 }
 
-//根据手机号获取用户关注的产业
+// 根据手机号获取用户关注的产业
 func GetCygxXzsChooseCategoryList(mobile string) (items []*CygxXzsChooseCategory, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT * FROM cygx_xzs_choose_category WHERE mobile = ?`

+ 29 - 4
models/xzs_choose_send.go

@@ -45,7 +45,7 @@ type IndustrialManagementIdResp struct {
 	ChartPermissionId       int    `description:"权限id"`
 }
 
-//添加
+// 添加
 func AddCygxXzsChooseSend(item *CygxXzsChooseSend, itemsFllow []*CygxIndustryFllow, itemsCategory []*CygxXzsChooseCategory) (err error) {
 	o, err := orm.NewOrm().Begin()
 	if err != nil {
@@ -97,7 +97,7 @@ func AddCygxXzsChooseSend(item *CygxXzsChooseSend, itemsFllow []*CygxIndustryFll
 	return
 }
 
-//获取数量
+// 获取数量
 func GetXzsChooseSendCountByMobile(mobile string) (count int, err error) {
 	sql := ` SELECT  COUNT(1) AS count  FROM cygx_xzs_choose_send WHERE mobile = ? `
 	o := orm.NewOrm()
@@ -105,7 +105,7 @@ func GetXzsChooseSendCountByMobile(mobile string) (count int, err error) {
 	return
 }
 
-//添加
+// 添加
 func UpdateCygxXzsChooseSend(item *CygxXzsChooseSend, itemsFllow []*CygxIndustryFllow, itemsCategory []*CygxXzsChooseCategory) (err error) {
 	o, err := orm.NewOrm().Begin()
 	if err != nil {
@@ -175,10 +175,35 @@ func UpdateCygxXzsChooseSend(item *CygxXzsChooseSend, itemsFllow []*CygxIndustry
 	return
 }
 
-//根据用户openid获取token
+// 根据用户openid获取token
 func GetCygxXzsChooseSendByMobile(mobile string) (item *CygxXzsChooseSend, err error) {
 	sql := `SELECT * FROM cygx_xzs_choose_send WHERE mobile=?  LIMIT 1 `
 	o := orm.NewOrm()
 	err = o.Raw(sql, mobile).QueryRow(&item)
 	return
 }
+
+type XzsChooseMapResp struct {
+	Id                  int    `description:"id"`
+	CategoryId          int    `description:"权益文章对应分类,cygx_article"`
+	CharPpermissionName string `description:"权限名称"`
+	MatchTypeName       string `description:"分类名称"`
+}
+
+// 根据手机号获取用户关注的产业
+func GetCygxXzsChooseCategoryMapList() (items []*XzsChooseMapResp, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT
+			r.id,
+			r.chart_permission_name,
+			r.match_type_name,
+			c.category_id 
+		FROM
+			cygx_report_mapping_cygx AS r
+			INNER JOIN cygx_report_mapping_group AS p ON p.id_cygx = r.id
+			INNER JOIN cygx_report_mapping_celue AS c ON c.category_id = p.category_id_celue 
+		WHERE
+			r.chart_permission_id IN (23,100000)`
+	_, err = o.Raw(sql).QueryRows(&items)
+	return
+}