ziwen 1 year ago
parent
commit
6e23b29dcb
3 changed files with 63 additions and 50 deletions
  1. 57 50
      controllers/yanxuan_special.go
  2. 1 0
      models/cygx_yanxuan_special.go
  3. 5 0
      models/cygx_yanxuan_special_user.go

+ 57 - 50
controllers/yanxuan_special.go

@@ -11,7 +11,6 @@ type YanxuanSpecialController struct {
 	BaseAuthController
 }
 
-
 // @Title 专栏列表
 // @Description 专栏列表
 // @Param	request	body help_doc.AddHelpDocReq true "type json string"
@@ -42,9 +41,8 @@ func (this *YanxuanSpecialController) List() {
 		pars = append(pars, userId)
 	}
 
-
 	specialUser, err = models.GetYanxuanSpecialAuthor(sysUser.UserId)
-	if err != nil && err.Error() != utils.ErrNoRow(){
+	if err != nil && err.Error() != utils.ErrNoRow() {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取失败, Err:" + err.Error()
 		return
@@ -63,13 +61,12 @@ func (this *YanxuanSpecialController) List() {
 		if err != nil {
 			return
 		}
-		if hasImg{
+		if hasImg {
 			v.ContentHasImg = 1
 		}
 	}
 	resp := new(models.SpecialListResp)
 
-
 	if specialUser != nil {
 		resp.IsAuthor = true
 	}
@@ -108,8 +105,7 @@ func (this *YanxuanSpecialController) Detail() {
 		return
 	}
 
-
-	item, tmpErr := models.GetYanxuanSpecialById(specialId,sysUser.UserId)
+	item, tmpErr := models.GetYanxuanSpecialById(specialId, sysUser.UserId)
 	if tmpErr != nil {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取失败, Err:" + tmpErr.Error()
@@ -123,7 +119,6 @@ func (this *YanxuanSpecialController) Detail() {
 		return
 	}
 
-
 	br.Data = item
 	br.Ret = 200
 	br.Success = true
@@ -157,7 +152,6 @@ func (this *YanxuanSpecialController) AuthorSave() {
 		return
 	}
 
-
 	if req.UserId <= 0 {
 		br.Msg = "用户id有误"
 		return
@@ -266,12 +260,12 @@ func (this *YanxuanSpecialController) Save() {
 	}
 
 	errCode := models.WxCheckContent(req.Content)
-	if errCode != 0{
+	if errCode != 0 {
 		br.Msg = "文章内容含有违法违规内容"
 		br.ErrMsg = "文章内容含有违法违规内容"
 		return
 	}
-	if req.Id == 0{
+	if req.Id == 0 {
 		_, err = models.AddCygxYanxuanSpecial(&item)
 		if err != nil {
 			br.Msg = "新增失败"
@@ -287,7 +281,6 @@ func (this *YanxuanSpecialController) Save() {
 		}
 	}
 
-
 	br.Ret = 200
 	br.Success = true
 	br.Msg = "保存成功"
@@ -423,17 +416,17 @@ func (this *YanxuanSpecialController) Collect() {
 	}
 	if req.Status == 1 {
 		item := models.CygxYanxuanSpecialCollect{
-			UserId:                      sysUser.UserId,
-			Mobile:                      sysUser.Mobile,
-			Email:                       sysUser.Email,
-			CompanyId:                   sysUser.CompanyId,
-			CompanyName:                 sysUser.CompanyName,
-			RealName:                    sysUser.RealName,
-			SellerName:                  sellerName,
-			CreateTime:                  time.Now(),
-			ModifyTime:                  time.Now(),
-			RegisterPlatform:            utils.REGISTER_PLATFORM,
-			YanxuanSpecialId:            req.Id,
+			UserId:           sysUser.UserId,
+			Mobile:           sysUser.Mobile,
+			Email:            sysUser.Email,
+			CompanyId:        sysUser.CompanyId,
+			CompanyName:      sysUser.CompanyName,
+			RealName:         sysUser.RealName,
+			SellerName:       sellerName,
+			CreateTime:       time.Now(),
+			ModifyTime:       time.Now(),
+			RegisterPlatform: utils.REGISTER_PLATFORM,
+			YanxuanSpecialId: req.Id,
 		}
 		_, err = models.AddCygxYanxuanSpecialCollect(&item)
 		if err != nil {
@@ -487,14 +480,13 @@ func (this *YanxuanSpecialController) Center() {
 	var condition string
 	var pars []interface{}
 
-
 	condition += ` AND a.user_id = ? `
 	pars = append(pars, sysUser.UserId)
 
 	condition += ` AND a.status = ? `
 	pars = append(pars, status)
 
-	list, tmpErr := models.GetYanxuanSpecialList(sysUser.UserId,condition, pars)
+	list, tmpErr := models.GetYanxuanSpecialList(sysUser.UserId, condition, pars)
 	if tmpErr != nil {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取失败, Err:" + tmpErr.Error()
@@ -543,17 +535,17 @@ func (this *YanxuanSpecialController) Record() {
 		return
 	}
 	item := models.CygxYanxuanSpecialRecord{
-		UserId:                     user.UserId,
-		Mobile:                     user.Mobile,
-		Email:                      user.Email,
-		CompanyId:                  user.CompanyId,
-		CompanyName:                user.CompanyName,
-		RealName:                   user.RealName,
-		SellerName:                 sellerName,
-		CreateTime:                 time.Now(),
-		ModifyTime:                 time.Now(),
-		RegisterPlatform:           utils.REGISTER_PLATFORM,
-		YanxuanSpecialId:           req.SpecialId,
+		UserId:           user.UserId,
+		Mobile:           user.Mobile,
+		Email:            user.Email,
+		CompanyId:        user.CompanyId,
+		CompanyName:      user.CompanyName,
+		RealName:         user.RealName,
+		SellerName:       sellerName,
+		CreateTime:       time.Now(),
+		ModifyTime:       time.Now(),
+		RegisterPlatform: utils.REGISTER_PLATFORM,
+		YanxuanSpecialId: req.SpecialId,
 	}
 	_, err = models.AddCygxYanxuanSpecialRecord(&item)
 	if err != nil {
@@ -609,18 +601,18 @@ func (this *YanxuanSpecialController) Follow() {
 	}
 	if req.Status == 1 {
 		item := models.CygxYanxuanSpecialFollow{
-			UserId:                     sysUser.UserId,
-			FollowUserId:               req.FollowUserId,
-			Mobile:                     sysUser.Mobile,
-			Email:                      sysUser.Email,
-			CompanyId:                  sysUser.CompanyId,
-			CompanyName:                sysUser.CompanyName,
-			RealName:                   sysUser.RealName,
-			SellerName:                 sellerName,
-			CreateTime:                 time.Now(),
-			ModifyTime:                 time.Now(),
-			RegisterPlatform:           utils.REGISTER_PLATFORM,
-			YanxuanSpecialId:           req.SpecialId,
+			UserId:           sysUser.UserId,
+			FollowUserId:     req.FollowUserId,
+			Mobile:           sysUser.Mobile,
+			Email:            sysUser.Email,
+			CompanyId:        sysUser.CompanyId,
+			CompanyName:      sysUser.CompanyName,
+			RealName:         sysUser.RealName,
+			SellerName:       sellerName,
+			CreateTime:       time.Now(),
+			ModifyTime:       time.Now(),
+			RegisterPlatform: utils.REGISTER_PLATFORM,
+			YanxuanSpecialId: req.SpecialId,
 		}
 		err = models.AddCygxYanxuanSpecialFollow(&item)
 		if err != nil {
@@ -703,7 +695,6 @@ func (this *YanxuanSpecialController) CompanySearch() {
 		return
 	}
 
-
 	list, tmpErr := models.GetYanxuanSpecialCompany(keyword)
 	if tmpErr != nil {
 		br.Msg = "获取失败"
@@ -777,6 +768,15 @@ func (this *YanxuanSpecialController) AuthorList() {
 		br.Ret = 408
 		return
 	}
+	var specialUser *models.CygxYanxuanSpecialAuthorItem
+	var err error
+
+	specialUser, err = models.GetYanxuanSpecialAuthor(sysUser.UserId)
+	if err != nil && err.Error() != utils.ErrNoRow() {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取失败, Err:" + err.Error()
+		return
+	}
 
 	list, tmpErr := models.GetYanxuanSpecialAuthorList()
 	if tmpErr != nil {
@@ -785,7 +785,14 @@ func (this *YanxuanSpecialController) AuthorList() {
 		return
 	}
 
-	br.Data = list
+	resp := new(models.SpecialAuthorListResp)
+
+	if specialUser != nil {
+		resp.IsAuthor = true
+	}
+	resp.List = list
+
+	br.Data = resp
 	br.Ret = 200
 	br.Success = true
 	br.Msg = "获取成功"

+ 1 - 0
models/cygx_yanxuan_special.go

@@ -148,3 +148,4 @@ func CancelPublishYanxuanSpecial(id int) (err error) {
 	_, err = o.Raw(sql, id).Exec()
 	return
 }
+

+ 5 - 0
models/cygx_yanxuan_special_user.go

@@ -108,3 +108,8 @@ FROM
 	_, err = o.Raw(sql).QueryRows(&items)
 	return
 }
+
+type SpecialAuthorListResp struct {
+	List     []*CygxYanxuanSpecialAuthorItem
+	IsAuthor bool
+}