浏览代码

Merge branch 'cygx_12.0' into debug

# Conflicts:
#	models/db.go
#	routers/router.go
ziwen 1 年之前
父节点
当前提交
daa5c4491c

+ 676 - 0
controllers/yanxuan_special.go

@@ -0,0 +1,676 @@
+package controllers
+
+import (
+	"encoding/json"
+	"hongze/hongze_cygx/models"
+	"hongze/hongze_cygx/utils"
+	"time"
+)
+
+type YanxuanSpecialController struct {
+	BaseAuthController
+}
+
+
+// @Title 专栏列表
+// @Description 专栏列表
+// @Param	request	body help_doc.AddHelpDocReq true "type json string"
+// @Success 200 {object} models.AddEnglishReportResp
+// @router /list [get]
+func (this *YanxuanSpecialController) List() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	sysUser := this.User
+	if sysUser == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,SysUser Is Empty"
+		br.Ret = 408
+		return
+	}
+
+	userId, _ := this.GetInt("UserId", 0)
+	var condition string
+	var pars []interface{}
+
+	var specialUser *models.CygxYanxuanSpecialAuthorItem
+	var err error
+	if userId > 0 {
+		condition += ` AND a.user_id = ? `
+		pars = append(pars, userId)
+
+		specialUser, err = models.GetYanxuanSpecialAuthor(userId)
+		if err != nil && err.Error() != utils.ErrNoRow(){
+			br.Msg = "获取失败"
+			br.ErrMsg = "获取失败, Err:" + err.Error()
+			return
+		}
+	}
+
+	condition += ` AND a.status = 2 `
+
+	list, tmpErr := models.GetYanxuanSpecialList(condition, pars)
+	if tmpErr != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取失败, Err:" + tmpErr.Error()
+		return
+	}
+
+	resp := new(models.SpecialListResp)
+
+
+	if specialUser != nil {
+		resp.IsAuthor = true
+	}
+	resp.List = list
+
+	br.Data = list
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+}
+
+// @Title 专栏详情
+// @Description 专栏详情
+// @Param	request	body help_doc.AddHelpDocReq true "type json string"
+// @Success 200 {object} models.AddEnglishReportResp
+// @router /detail [get]
+func (this *YanxuanSpecialController) Detail() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	sysUser := this.User
+	if sysUser == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,SysUser Is Empty"
+		br.Ret = 408
+		return
+	}
+
+	specialId, _ := this.GetInt("Id", 0)
+
+	if specialId <= 0 {
+		br.Msg = "参数错误"
+		br.ErrMsg = "参数错误"
+		return
+	}
+
+
+	item, tmpErr := models.GetYanxuanSpecialById(specialId)
+	if tmpErr != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取失败, Err:" + tmpErr.Error()
+		return
+	}
+
+	if item.Status != 3 {
+		br.Msg = "获取失败,专栏未发布"
+		br.ErrMsg = "获取失败, Err:" + tmpErr.Error()
+		return
+	}
+
+
+	br.Data = item
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+}
+
+// @Title 新增保存专栏作者详情
+// @Description 新增保存专栏作者详情
+// @Param	request	body help_doc.AddHelpDocReq true "type json string"
+// @Success 200 {object} models.AddEnglishReportResp
+// @router /author/save [post]
+func (this *YanxuanSpecialController) AuthorSave() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	sysUser := this.User
+	if sysUser == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,SysUser Is Empty"
+		br.Ret = 408
+		return
+	}
+
+	var req models.SaveCygxYanxuanSpecialAuthorReq
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
+	if err != nil {
+		br.Msg = "参数解析异常!"
+		br.ErrMsg = "参数解析失败,Err:" + err.Error()
+		return
+	}
+
+	if req.UserId <= 0 {
+		br.Msg = "请输入内容"
+		return
+	}
+	if req.RealName == "" {
+		br.Msg = "请输入内容"
+		return
+	}
+	if req.Mobile == "" {
+		br.Msg = "请输入内容"
+		return
+	}
+
+	item := models.CygxYanxuanSpecialAuthor{
+		Id:           req.Id,
+		UserId:       req.UserId,
+		SpecialName:  req.SpecialName,
+		Introduction: req.Introduction,
+		Label:        req.Label,
+		NickName:     req.NickName,
+		RealName:     req.RealName,
+		Mobile:       req.Mobile,
+		CreateTime:   time.Now(),
+		ModifyTime:   time.Now(),
+		HeadImg:      "",
+		BgImg:        "",
+		Status:       1,
+	}
+
+	if req.Id == 0{
+		_, err = models.AddCygxYanxuanSpecialAuthor(&item)
+		if err != nil {
+			br.Msg = "新增失败"
+			br.ErrMsg = "新增失败,Err:" + err.Error()
+			return
+		}
+	} else {
+		err = models.UpdateYanxuanSpecialAuthor(&item)
+		if err != nil {
+			br.Msg = "保存失败"
+			br.ErrMsg = "保存失败,Err:" + err.Error()
+			return
+		}
+	}
+
+
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "保存成功"
+}
+
+// @Title 新增保存专栏
+// @Description 新增保存专栏
+// @Param	request	body help_doc.AddHelpDocReq true "type json string"
+// @Success 200 {object} models.AddEnglishReportResp
+// @router /save [post]
+func (this *YanxuanSpecialController) Save() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	sysUser := this.User
+	if sysUser == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,SysUser Is Empty"
+		br.Ret = 408
+		return
+	}
+
+	var req models.CygxYanxuanSpecialReq
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
+	if err != nil {
+		br.Msg = "参数解析异常!"
+		br.ErrMsg = "参数解析失败,Err:" + err.Error()
+		return
+	}
+
+	if req.UserId <= 0 {
+		br.Msg = "请输入内容"
+		return
+	}
+	if req.Content == "" {
+		br.Msg = "请输入内容"
+		return
+	}
+	if req.Tags == "" {
+		br.Msg = "请输入内容"
+		return
+	}
+
+	item := models.CygxYanxuanSpecial{
+		Id:          req.Id,
+		UserId:      req.UserId,
+		CreateTime:  time.Now(),
+		ModifyTime:  time.Now(),
+		PublishTime: time.Now(),
+		Content:     req.Content,
+		Tags:        req.Tags,
+		ImgUrl:      req.ImgUrl,
+		DocUrl:      req.DocUrl,
+		Title:       req.Title,
+		Type:        req.Type,
+	}
+	if req.DoType == 1 {
+		item.Status = 1
+	} else {
+		item.Status = 2
+	}
+
+	errCode := models.WxCheckContent(req.Content)
+	if errCode != 0{
+		br.Msg = "文章内容含有违法违规内容"
+		br.ErrMsg = "文章内容含有违法违规内容"
+		return
+	}
+	if req.Id == 0{
+		_, err = models.AddCygxYanxuanSpecial(&item)
+		if err != nil {
+			br.Msg = "新增失败"
+			br.ErrMsg = "新增失败,Err:" + err.Error()
+			return
+		}
+	} else {
+		err = models.UpdateYanxuanSpecial(&item)
+		if err != nil {
+			br.Msg = "保存失败"
+			br.ErrMsg = "保存失败,Err:" + err.Error()
+			return
+		}
+	}
+
+
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "保存成功"
+}
+
+// @Title 专栏作者详情
+// @Description 专栏作者详情
+// @Param	request	body help_doc.AddHelpDocReq true "type json string"
+// @Success 200 {object} models.AddEnglishReportResp
+// @router /author/detail [get]
+func (this *YanxuanSpecialController) AuthorDetail() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	sysUser := this.User
+	if sysUser == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,SysUser Is Empty"
+		br.Ret = 408
+		return
+	}
+
+	userId, _ := this.GetInt("UserId", 0)
+	if userId == 0 {
+		userId = sysUser.UserId
+	}
+	item, tmpErr := models.GetYanxuanSpecialAuthor(userId)
+	if tmpErr != nil && tmpErr.Error() != utils.ErrNoRow() {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取失败, Err:" + tmpErr.Error()
+		return
+	}
+
+	br.Data = item
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+}
+
+// @Title 审批研选专栏
+// @Description 审批研选专栏
+// @Param	request	body help_doc.AddHelpDocReq true "type json string"
+// @Success 200 {object} models.AddEnglishReportResp
+// @router /enable [post]
+func (this *YanxuanSpecialController) Enable() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	sysUser := this.User
+	if sysUser == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,SysUser Is Empty"
+		br.Ret = 408
+		return
+	}
+	var req models.EnableCygxYanxuanSpecialReq
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
+	if err != nil {
+		br.Msg = "参数解析异常!"
+		br.ErrMsg = "参数解析失败,Err:" + err.Error()
+		return
+	}
+
+	if req.Id <= 0 {
+		br.Msg = "文章id错误"
+		return
+	}
+	if req.Status <= 0 {
+		br.Msg = "参数错误"
+		return
+	}
+	status := 0
+	if req.Status == 1 {
+		status = 3
+	} else {
+		status = 4
+	}
+	if tmpErr := models.EnableYanxuanSpecial(req.Id, status, req.Reason); tmpErr != nil {
+		br.Msg = "审批失败"
+		br.ErrMsg = "审批失败, Err:" + tmpErr.Error()
+		return
+	}
+
+	br.Msg = "审批成功"
+	br.Ret = 200
+	br.Success = true
+}
+
+// @Title 研选专栏收藏
+// @Description 研选专栏收藏
+// @Param	request	body help_doc.AddHelpDocReq true "type json string"
+// @Success 200 {object} models.AddEnglishReportResp
+// @router /collect [post]
+func (this *YanxuanSpecialController) Collect() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	sysUser := this.User
+	if sysUser == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,SysUser Is Empty"
+		br.Ret = 408
+		return
+	}
+	var req models.CollectCygxYanxuanSpecialReq
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
+	if err != nil {
+		br.Msg = "参数解析异常!"
+		br.ErrMsg = "参数解析失败,Err:" + err.Error()
+		return
+	}
+
+	if req.Id <= 0 {
+		br.Msg = "文章id错误"
+		return
+	}
+	if req.Status <= 0 {
+		br.Msg = "参数错误"
+		return
+	}
+	var sellerName string
+	sellerName, err = models.GetCompanySellerName(sysUser.CompanyId)
+	if err != nil {
+		br.Msg = "报名失败!"
+		br.ErrMsg = "获取对应销售失败,Err:" + err.Error()
+		return
+	}
+	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,
+		}
+		_, err = models.AddCygxYanxuanSpecialCollect(&item)
+		if err != nil {
+			br.Msg = "新增失败"
+			br.ErrMsg = "新增失败,Err:" + err.Error()
+			return
+		}
+		br.Msg = "收藏成功"
+	} else {
+		err = models.DelCygxYanxuanSpecialCollect(sysUser.UserId, req.Id)
+		if err != nil {
+			br.Msg = "删除失败"
+			br.ErrMsg = "删除失败,Err:" + err.Error()
+			return
+		}
+		br.Msg = "取消收藏成功"
+	}
+
+	br.Ret = 200
+	br.Success = true
+}
+
+// @Title 专栏内容中心
+// @Description 专栏内容中心
+// @Param	request	body help_doc.AddHelpDocReq true "type json string"
+// @Success 200 {object} models.AddEnglishReportResp
+// @router /center [get]
+func (this *YanxuanSpecialController) Center() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	sysUser := this.User
+	if sysUser == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,SysUser Is Empty"
+		br.Ret = 408
+		return
+	}
+
+	// 1:未发布,2:审核中 3:已发布 4:驳回
+	status, _ := this.GetInt("Status", 0)
+
+	if status <= 0 {
+		br.Msg = "参数错误"
+		br.ErrMsg = "参数错误"
+		return
+	}
+
+	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(condition, pars)
+	if tmpErr != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取失败, Err:" + tmpErr.Error()
+		return
+	}
+
+	br.Data = list
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+}
+
+// @Title 专栏点击记录
+// @Description 专栏点击记录
+// @Param	request	body models.AddCygxReportSelectionSubjectHistoryReq true "type json string"
+// @router /record [post]
+func (this *YanxuanSpecialController) Record() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	user := this.User
+	if user == nil {
+		br.Msg = "请重新登录"
+		br.Ret = 408
+		return
+	}
+	var req models.AddCygxYanxuanSpecialRecordReq
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
+	if err != nil {
+		br.Msg = "参数解析异常!"
+		br.ErrMsg = "参数解析失败,Err:" + err.Error()
+		return
+	}
+	if req.SpecialId <= 0 {
+		br.Msg = "文章不存在"
+		br.ErrMsg = "文章不存在,文章ID错误"
+		return
+	}
+	var sellerName string
+	sellerName, err = models.GetCompanySellerName(user.CompanyId)
+	if err != nil {
+		br.Msg = "报名失败!"
+		br.ErrMsg = "获取对应销售失败,Err:" + err.Error()
+		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,
+	}
+	_, err = models.AddCygxYanxuanSpecialRecord(&item)
+	if err != nil {
+		br.Msg = "记录失败"
+		br.ErrMsg = "记录失败,Err:" + err.Error()
+		return
+	}
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "记录成功"
+}
+
+// @Title 研选专栏关注
+// @Description 研选专栏关注
+// @Param	request	body help_doc.AddHelpDocReq true "type json string"
+// @Success 200 {object} models.AddEnglishReportResp
+// @router /follow [post]
+func (this *YanxuanSpecialController) Follow() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	sysUser := this.User
+	if sysUser == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,SysUser Is Empty"
+		br.Ret = 408
+		return
+	}
+	var req models.FollowCygxYanxuanSpecialReq
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
+	if err != nil {
+		br.Msg = "参数解析异常!"
+		br.ErrMsg = "参数解析失败,Err:" + err.Error()
+		return
+	}
+
+	if req.FollowUserId <= 0 {
+		br.Msg = "被关注的用户id"
+		return
+	}
+	if req.Status <= 0 {
+		br.Msg = "参数错误"
+		return
+	}
+	var sellerName string
+	sellerName, err = models.GetCompanySellerName(sysUser.CompanyId)
+	if err != nil {
+		br.Msg = "报名失败!"
+		br.ErrMsg = "获取对应销售失败,Err:" + err.Error()
+		return
+	}
+	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,
+		}
+		err = models.AddCygxYanxuanSpecialFollow(&item)
+		if err != nil {
+			br.Msg = "新增失败"
+			br.ErrMsg = "新增失败,Err:" + err.Error()
+			return
+		}
+		br.Msg = "关注成功"
+	} else {
+		err = models.DelCygxYanxuanSpecialFollow(sysUser.UserId, req.FollowUserId)
+		if err != nil {
+			br.Msg = "删除失败"
+			br.ErrMsg = "删除失败,Err:" + err.Error()
+			return
+		}
+		br.Msg = "取消关注成功"
+	}
+
+	br.Ret = 200
+	br.Success = true
+}
+
+// @Title 行业标签搜索
+// @Description 行业标签搜索
+// @Param	request	body help_doc.AddHelpDocReq true "type json string"
+// @Success 200 {object} models.AddEnglishReportResp
+// @router /industrySearch [get]
+func (this *YanxuanSpecialController) IndustrySearch() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	sysUser := this.User
+	if sysUser == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,SysUser Is Empty"
+		br.Ret = 408
+		return
+	}
+
+	keyword := this.GetString("Keyword")
+
+	if keyword == "" {
+		br.Ret = 200
+		return
+	}
+
+
+	list, tmpErr := models.GetYanxuanSpecialIndustry(keyword)
+	if tmpErr != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取失败, Err:" + tmpErr.Error()
+		return
+	}
+
+	br.Data = list
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+}

+ 128 - 0
models/cygx_yanxuan_special.go

@@ -0,0 +1,128 @@
+package models
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+	"time"
+)
+
+type CygxYanxuanSpecial struct {
+	Id          int       `orm:"column(id);pk"`
+	UserId      int       // 用户ID
+	CreateTime  time.Time // 创建时间
+	ModifyTime  time.Time // 修改时间
+	PublishTime time.Time // 提审过审或驳回时间
+	Content     string    // 内容
+	Tags        string    // 标签
+	Status      int       // 1:未发布,2:审核中 3:已发布 4:驳回
+	ImgUrl      string    // 图片链接
+	DocUrl      string    // 文档链接
+	Reason      string    // 理由
+	Title       string    // 标题
+	Type        int       // 类型1:笔记,2:观点
+}
+
+type CygxYanxuanSpecialItem struct {
+	Id           int    `orm:"column(id);pk"`
+	UserId       int    // 用户ID
+	CreateTime   string // 创建时间
+	ModifyTime   string // 修改时间
+	PublishTime  string // 提审过审或驳回时间
+	Content      string // 内容
+	Tags         string // 标签
+	Status       int    // 1:未发布,2:审核中 3:已发布 4:驳回
+	ImgUrl       string // 图片链接
+	DocUrl       string // 文档链接
+	SpecialName  string // 专栏名称
+	Introduction string // 介绍
+	Label        string // 标签
+	NickName     string // 昵称
+	RealName     string // 姓名
+	Mobile       string // 手机号
+	HeadImg      string // 头像
+	BgImg        string // 背景图
+	Reason       string // 理由
+	Title        string // 标题
+	Type         string // 类型1:笔记,2:观点
+}
+
+func GetYanxuanSpecialList(condition string, pars []interface{}) (items []*CygxYanxuanSpecialItem, err error) {
+	o := orm.NewOrm()
+	sql := ``
+	sql = `SELECT a.*,b.bg_img,b.head_img,b.introduction,b.label,b.mobile,b.nick_name,b.real_name,b.special_name
+FROM cygx_yanxuan_special AS a
+JOIN cygx_yanxuan_special_author AS b ON a.user_id = b.user_id 
+ WHERE 1=1 `
+	if condition != "" {
+		sql += condition
+	}
+	sql += `ORDER BY a.publish_time DESC `
+	_, err = o.Raw(sql, pars).QueryRows(&items)
+	return
+}
+
+type EnableCygxYanxuanSpecialReq struct {
+	Id     int    // 文章id
+	Status int    // 1通过2驳回
+	Reason string //理由
+}
+
+func EnableYanxuanSpecial(id, status int, reason string) (err error) {
+	o := orm.NewOrm()
+	sql := ``
+	sql = `UPDATE cygx_yanxuan_special SET status=?,reason=?,publish_time=NOW() WHERE id = ? `
+	_, err = o.Raw(sql, status, reason, id).Exec()
+	return
+}
+
+type SpecialListResp struct {
+	List     []*CygxYanxuanSpecialItem
+	IsAuthor bool
+}
+
+func GetYanxuanSpecialById(specialId int) (item *CygxYanxuanSpecialItem, err error) {
+	o := orm.NewOrm()
+	sql := ``
+	sql = `SELECT a.*,b.bg_img,b.head_img,b.introduction,b.label,b.mobile,b.nick_name,b.real_name,b.special_name
+FROM cygx_yanxuan_special AS a
+JOIN cygx_yanxuan_special_author AS b ON a.user_id = b.user_id 
+ WHERE a.id=? `
+	err = o.Raw(sql, specialId).QueryRow(&item)
+	return
+}
+
+type CygxYanxuanSpecialReq struct {
+	Id      int    `orm:"column(id);pk"`
+	UserId  int    // 用户ID
+	Content string // 内容
+	Tags    string // 标签
+	DoType  int    // 1保存 2发布
+	ImgUrl  string // 图片链接
+	DocUrl  string // 文档链接
+	Title   string // 标题
+	Type    int    // 类型1:笔记,2:观点
+}
+
+func AddCygxYanxuanSpecial(item *CygxYanxuanSpecial) (lastId int64, err error) {
+	o := orm.NewOrm()
+	lastId, err = o.Insert(item)
+	return
+}
+
+func UpdateYanxuanSpecial(item *CygxYanxuanSpecial) (err error) {
+	o := orm.NewOrm()
+	sql := ``
+	sql = `UPDATE cygx_yanxuan_special SET title=?,content=?,tags=?,img_url=?,doc_url=?,type=?,status=?,
+	modify_time=NOW(),publish_time=NOW() WHERE id = ? `
+	_, err = o.Raw(sql, item.Title, item.Content,item.Tags,item.ImgUrl,item.DocUrl,item.Type,item.Status).Exec()
+	return
+}
+
+
+
+func GetYanxuanSpecialIndustry(keyword string) (IndustryNames []string, err error) {
+	o := orm.NewOrm()
+	sql := ``
+	sql = `SELECT industry_name FROM cygx_yanxuan_special_industry WHERE industry_name LIKE '%`+keyword+`%' `
+	_, err = o.Raw(sql).QueryRows(&IndustryNames)
+	return
+}

+ 39 - 0
models/cygx_yanxuan_special_collect.go

@@ -0,0 +1,39 @@
+package models
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+	"time"
+)
+
+type CygxYanxuanSpecialCollect struct {
+	CygxYanxuanSpecialCollectId int       `orm:"column(cygx_yanxuan_special_collect_id);pk"`
+	UserId                      int        // 用户ID
+	Mobile                      string     // 手机号
+	Email                       string     // 邮箱
+	CompanyId                   int        // 公司ID
+	CompanyName                 string     // 公司名称
+	RealName                    string     // 用户实际名称
+	SellerName                  string     // 所属销售
+	CreateTime                  time.Time  // 创建时间
+	ModifyTime                  time.Time  // 修改时间
+	RegisterPlatform            int        // 来源 1小程序,2:网页
+	YanxuanSpecialId            int        // cygx_yanxuan_special 表主键ID
+}
+
+func AddCygxYanxuanSpecialCollect(item *CygxYanxuanSpecialCollect) (lastId int64, err error) {
+	o := orm.NewOrm()
+	lastId, err = o.Insert(item)
+	return
+}
+
+type CollectCygxYanxuanSpecialReq struct {
+	Id     int    // 文章id
+	Status int    // 1收藏2取消收藏
+}
+
+func DelCygxYanxuanSpecialCollect(userId, articleId int) (err error) {
+	o := orm.NewOrm()
+	sql := `DELETE FROM cygx_yanxuan_special_collect WHERE user_id=? AND yanxuan_special_id=? `
+	_, err = o.Raw(sql, userId, articleId).Exec()
+	return
+}

+ 41 - 0
models/cygx_yanxuan_special_follow.go

@@ -0,0 +1,41 @@
+package models
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+	"time"
+)
+
+type CygxYanxuanSpecialFollow struct {
+	CygxYanxuanSpecialFollowId int        `orm:"column(cygx_yanxuan_special_follow_id);pk"`
+	UserId                     int        // 用户ID
+	FollowUserId               int        // 被关注用户ID
+	Mobile                     string     // 手机号
+	Email                      string     // 邮箱
+	CompanyId                  int        // 公司ID
+	CompanyName                string     // 公司名称
+	RealName                   string     // 用户实际名称
+	SellerName                 string     // 所属销售
+	CreateTime                 time.Time  // 创建时间
+	ModifyTime                 time.Time  // 修改时间
+	RegisterPlatform           int        // 来源 1小程序,2:网页
+	YanxuanSpecialId           int        // cygx_yanxuan_special 表主键ID
+}
+
+type FollowCygxYanxuanSpecialReq struct {
+	FollowUserId int // 被关注的用户id
+	Status       int // 1关注2取消关注
+	SpecialId    int // 研选专栏Id
+}
+
+func AddCygxYanxuanSpecialFollow(item *CygxYanxuanSpecialFollow) (err error) {
+	o := orm.NewOrm()
+	_, err = o.Insert(item)
+	return
+}
+
+func DelCygxYanxuanSpecialFollow(userId, followUserId int) (err error) {
+	o := orm.NewOrm()
+	sql := `DELETE FROM cygx_yanxuan_special_follow WHERE user_id=? AND follow_user_id=? `
+	_, err = o.Raw(sql, userId, followUserId).Exec()
+	return
+}

+ 32 - 0
models/cygx_yanxuan_special_record.go

@@ -0,0 +1,32 @@
+package models
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+	"time"
+)
+
+type CygxYanxuanSpecialRecord struct {
+	CygxYanxuanSpecialRecordId int       `orm:"column(cygx_yanxuan_special_record_id);pk"`
+	UserId                     int       // 用户ID
+	Mobile                     string    // 手机号
+	Email                      string    // 邮箱
+	CompanyId                  int       // 公司ID
+	CompanyName                string    // 公司名称
+	RealName                   string    // 用户实际名称
+	SellerName                 string    // 所属销售
+	CreateTime                 time.Time // 创建时间
+	ModifyTime                 time.Time // 修改时间
+	RegisterPlatform           int       // 来源 1小程序,2:网页
+	YanxuanSpecialId           int       // cygx_yanxuan_special 表主键ID
+	StopTime                   int       // 停留时间
+}
+
+func AddCygxYanxuanSpecialRecord(item *CygxYanxuanSpecialRecord) (lastId int64, err error) {
+	o := orm.NewOrm()
+	lastId, err = o.Insert(item)
+	return
+}
+
+type AddCygxYanxuanSpecialRecordReq struct {
+	SpecialId           int `description:"专栏文章id"`
+}

+ 100 - 0
models/cygx_yanxuan_special_user.go

@@ -0,0 +1,100 @@
+package models
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+	"time"
+)
+
+type CygxYanxuanSpecialAuthor struct {
+	Id           int       `orm:"column(id);pk"`
+	UserId       int       // 用户ID
+	SpecialName  string    // 专栏名称
+	Introduction string    // 介绍
+	Label        string    // 标签
+	NickName     string    // 昵称
+	RealName     string    // 姓名
+	Mobile       string    // 手机号
+	CreateTime   time.Time // 创建时间
+	ModifyTime   time.Time // 修改时间
+	HeadImg      string    // 头像
+	BgImg        string    // 背景图
+	Status       int       // 1启用2禁用
+}
+
+type CygxYanxuanSpecialAuthorItem struct {
+	Id           int    `orm:"column(id);pk"`
+	UserId       int    // 用户ID
+	SpecialName  string // 专栏名称
+	Introduction string // 介绍
+	Label        string // 标签
+	NickName     string // 昵称
+	RealName     string // 姓名
+	CompanyName  string // 公司名
+	Mobile       string // 手机号
+	CreateTime   string // 创建时间
+	ModifyTime   string // 修改时间
+	HeadImg      string // 头像
+	BgImg        string // 背景图
+	Status       int    // 1启用2禁用
+	CollectNum   int    // 被收藏数
+	FollowNum    int    // 被关注数
+}
+
+func AddCygxYanxuanSpecialAuthor(item *CygxYanxuanSpecialAuthor) (lastId int64, err error) {
+	o := orm.NewOrm()
+	lastId, err = o.Insert(item)
+	return
+}
+
+type EnableCygxYanxuanSpecialAuthorReq struct {
+	UserId int // 用户ID
+	Status int // 1启用2禁用
+}
+
+// 启用禁用作者
+func EnableYanxuanSpecialAuthor(userId, status int) (err error) {
+	o := orm.NewOrm()
+	sql := ``
+	sql = `UPDATE cygx_yanxuan_special_author SET status=?,modify_time=NOW() WHERE user_id = ? `
+	_, err = o.Raw(sql, status, userId).Exec()
+	return
+}
+
+func GetYanxuanSpecialAuthor(userId int) (item *CygxYanxuanSpecialAuthorItem, err error) {
+	o := orm.NewOrm()
+	sql := ``
+	sql = `SELECT
+	a.*,c.company_name,
+	( SELECT count( 1 ) FROM cygx_yanxuan_special_collect AS ac  INNER JOIN cygx_yanxuan_special as cs ON  ac.yanxuan_special_id = cs.id  WHERE cs.user_id = a.user_id  ) AS collect_num,
+	( SELECT count( 1 ) FROM cygx_yanxuan_special_follow AS cf  WHERE cf.follow_user_id = a.user_id  ) AS follow_num 
+FROM
+	cygx_yanxuan_special_author as a
+	INNER JOIN wx_user AS u ON u.user_id = a.user_id
+	INNER JOIN company AS c ON c.company_id = u.company_id WHERE a.user_id=? `
+	err = o.Raw(sql, userId).QueryRow(&item)
+	return
+}
+
+type SaveCygxYanxuanSpecialAuthorReq struct {
+	Id           int
+	UserId       int       // 用户ID
+	SpecialName  string    // 专栏名称
+	Introduction string    // 介绍
+	Label        string    // 标签
+	NickName     string    // 昵称
+	RealName     string    // 姓名
+	Mobile       string    // 手机号
+	CreateTime   time.Time // 创建时间
+	ModifyTime   time.Time // 修改时间
+	HeadImg      string    // 头像
+	BgImg        string    // 背景图
+}
+
+func UpdateYanxuanSpecialAuthor(item *CygxYanxuanSpecialAuthor) (err error) {
+	o := orm.NewOrm()
+	sql := ``
+	sql = `UPDATE cygx_yanxuan_special_author SET special_name=?,introduction=?,label=?,nick_name=?,
+	head_img=?,modify_time=NOW() WHERE id = ? `
+	_, err = o.Raw(sql, item.SpecialName, item.Introduction, item.Label, item.NickName, item.HeadImg).Exec()
+	return
+}

+ 4 - 0
models/db.go

@@ -162,6 +162,10 @@ func init() {
 		new(CygxArticleApplyAppointmentExpert),
 		new(CygxBannerYxSurvey),
 		new(CygxReportSelectionLogApply),
+		new(CygxYanxuanSpecialRecord),
+		new(CygxYanxuanSpecialCollect),
+		new(CygxYanxuanSpecial),
+		new(CygxYanxuanSpecialFollow),
 	)
 	// 记录ORM查询日志
 	orm.Debug = true

+ 23 - 3
models/report.go

@@ -628,12 +628,32 @@ func GetArticleResearchList(condition string, pars []interface{}, startSize, pag
 			INNER JOIN cygx_industrial_management AS m ON m.industrial_management_id = mg.industrial_management_id
 			INNER JOIN cygx_article_department AS d ON d.department_id = a.department_id 
 		WHERE
-			1 = 1  AND a.publish_status = 1  `
+			1 = 1  AND a.publish_status = 1
+		  `
 	if condition != "" {
 		sql += condition
 	}
-	sql += ` GROUP BY a.article_id ORDER  BY   a.publish_date DESC  LIMIT ?,? `
-	_, err = o.Raw(sql, userId, pars, startSize, pageSize).QueryRows(&items)
+	sql += ` GROUP BY a.article_id  `
+	sql += `UNION ALL
+	SELECT
+		a.id AS article_id,
+		a.title AS title,
+		date_format( a.publish_time, '%Y-%m-%d' ) AS publish_date,
+		16 AS article_type_id,
+		b.nick_name AS nick_name,
+		0 AS department_id,
+		( SELECT count( 1 ) FROM cygx_yanxuan_special_record AS h WHERE h.yanxuan_special_id = a.id ) AS pv,
+		( SELECT count( 1 ) FROM cygx_yanxuan_special_collect AS ac  INNER JOIN wx_user as u ON  u.user_id = ac.user_id  WHERE ac.yanxuan_special_id = a.id  ) AS collect_num,
+		0 AS collect_num_order,
+		( SELECT count( 1 ) FROM cygx_yanxuan_special_collect AS ac WHERE ac.yanxuan_special_id = a.id  AND user_id = ? ) AS my_collect_num
+	FROM
+	cygx_yanxuan_special AS a
+	JOIN cygx_yanxuan_special_author AS b ON a.user_id = b.user_id
+	WHERE
+	1 = 1  AND a.status = 3 `
+
+	sql += ` ORDER  BY publish_date DESC  LIMIT ?,? `
+	_, err = o.Raw(sql, userId,userId, pars, startSize, pageSize).QueryRows(&items)
 	return
 }
 

+ 2 - 2
models/wechat.go

@@ -204,7 +204,7 @@ type WxCheckContentJson struct {
 	Errmsg       string `json:"errmsg"`
 }
 
-func WxCheckContent(content string) {
+func WxCheckContent(content string) (errCode int){
 	accessToken, err := GetWxAccessToken()
 	if err != nil {
 		utils.FileLog.Info("GetWxAccessToken Err:%s", err.Error())
@@ -225,5 +225,5 @@ func WxCheckContent(content string) {
 		return
 	}
 	fmt.Println(result)
-	return
+	return item.Errcode
 }

+ 99 - 0
routers/commentsRouter.go

@@ -1690,4 +1690,103 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:YanxuanSpecialController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:YanxuanSpecialController"],
+        beego.ControllerComments{
+            Method: "AuthorDetail",
+            Router: `/author/detail`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
+    beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:YanxuanSpecialController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:YanxuanSpecialController"],
+        beego.ControllerComments{
+            Method: "AuthorSave",
+            Router: `/author/save`,
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
+    beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:YanxuanSpecialController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:YanxuanSpecialController"],
+        beego.ControllerComments{
+            Method: "Center",
+            Router: `/center`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
+    beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:YanxuanSpecialController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:YanxuanSpecialController"],
+        beego.ControllerComments{
+            Method: "Collect",
+            Router: `/collect`,
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
+    beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:YanxuanSpecialController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:YanxuanSpecialController"],
+        beego.ControllerComments{
+            Method: "Detail",
+            Router: `/detail`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
+    beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:YanxuanSpecialController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:YanxuanSpecialController"],
+        beego.ControllerComments{
+            Method: "Enable",
+            Router: `/enable`,
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
+    beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:YanxuanSpecialController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:YanxuanSpecialController"],
+        beego.ControllerComments{
+            Method: "Follow",
+            Router: `/follow`,
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
+    beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:YanxuanSpecialController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:YanxuanSpecialController"],
+        beego.ControllerComments{
+            Method: "IndustrySearch",
+            Router: `/industrySearch`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
+    beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:YanxuanSpecialController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:YanxuanSpecialController"],
+        beego.ControllerComments{
+            Method: "List",
+            Router: `/list`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
+    beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:YanxuanSpecialController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:YanxuanSpecialController"],
+        beego.ControllerComments{
+            Method: "Record",
+            Router: `/record`,
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
+    beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:YanxuanSpecialController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:YanxuanSpecialController"],
+        beego.ControllerComments{
+            Method: "Save",
+            Router: `/save`,
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
 }

+ 5 - 0
routers/router.go

@@ -170,6 +170,11 @@ func init() {
 				&controllers.CollectionController{},
 			),
 		),
+		web.NSNamespace("/yanxuan_special",
+			web.NSInclude(
+				&controllers.YanxuanSpecialController{},
+			),
+		),
 	)
 	web.AddNamespace(ns)
 }