소스 검색

no message

xingzai 1 년 전
부모
커밋
46be52aa70
2개의 변경된 파일65개의 추가작업 그리고 0개의 파일을 삭제
  1. 42 0
      models/xzs_choose_category.go
  2. 23 0
      services/init_10.3.go

+ 42 - 0
models/xzs_choose_category.go

@@ -16,6 +16,7 @@ type CygxXzsChooseCategory struct {
 	CategoryId  int       `description:"权益文章对应分类,cygx_article"`
 	CreateTime  time.Time `description:"创建时间"`
 	ModifyTime  time.Time `description:"更新时间"`
+	IdCygx      int       `description:"cygx_report_mapping_cygx 表主键ID"`
 }
 
 // 根据手机号获取用户关注的产业
@@ -40,3 +41,44 @@ func RemoveCygxCategoryFllow(mobile string, CategoryId int) (err error) {
 	_, err = o.Raw(sql, mobile, CategoryId).Exec()
 	return
 }
+
+// 根据手机号获取用户关注的产业
+func GetCygxXzsChooseCategoryWhithIdCygxList() (items []*CygxXzsChooseCategory, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM cygx_xzs_choose_category WHERE id_cygx = 0`
+	_, err = o.Raw(sql).QueryRows(&items)
+	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
+}
+
+// 修改数据
+func UpdateCygxXzsChooseCategory(idCygx, id int) (err error) {
+	o := orm.NewOrm()
+	sql := `UPDATE cygx_xzs_choose_category SET id_cygx=?  WHERE id=?   `
+	_, err = o.Raw(sql, idCygx, id).Exec()
+	return
+}

+ 23 - 0
services/init_10.3.go

@@ -73,3 +73,26 @@ func init333() {
 	}
 	fmt.Println(listrMeet)
 }
+
+func init444() {
+	listMap, err := models.GetCygxXzsChooseCategoryMapList()
+	if err != nil {
+		fmt.Println(err)
+	}
+	mapReport := make(map[int]int)
+	for _, v := range listMap {
+		mapReport[v.CategoryId] = v.Id
+	}
+
+	list, err := models.GetCygxXzsChooseCategoryWhithIdCygxList()
+	if err != nil {
+		fmt.Println(err)
+	}
+	for _, v := range list {
+		fmt.Println(mapReport[v.CategoryId])
+		err = models.UpdateCygxXzsChooseCategory(mapReport[v.CategoryId], v.Id)
+		if err != nil {
+			fmt.Println(err)
+		}
+	}
+}