Browse Source

no message

xingzai 1 year ago
parent
commit
c5f3e3d112

+ 71 - 0
controllers/morning_meeting.go

@@ -0,0 +1,71 @@
+package controllers
+
+import (
+	"github.com/rdlucklib/rdluck_tools/paging"
+	"hongze/hongze_cygx/models"
+	"hongze/hongze_cygx/utils"
+)
+
+// 晨会精华
+type MorningMeetingController struct {
+	BaseAuthController
+}
+
+// @Title 晨会精华汇总列表
+// @Description 晨会精华汇总列表接口
+// @Param   PageSize   query   int  true       "每页数据条数"
+// @Param   CurrentIndex   query   int  true       "当前页页码,从1开始"
+// @Success Ret=200 {object} cygx.GetCygxTacticsTimeLineResp
+// @router /gather/list [get]
+func (this *MorningMeetingController) List() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	user := this.User
+	if user == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,用户信息为空"
+		br.Ret = 408
+		return
+	}
+	resp := new(models.GetCygxProductInteriorResp)
+	pageSize, _ := this.GetInt("PageSize")
+	currentIndex, _ := this.GetInt("CurrentIndex")
+
+	var startSize int
+	if pageSize <= 0 {
+		pageSize = utils.PageSize20
+	}
+	if currentIndex <= 0 {
+		currentIndex = 1
+	}
+	startSize = utils.StartIndex(currentIndex, pageSize)
+	var condition string
+	var pars []interface{}
+	condition += ` AND art.status = 1 `
+	total, err := models.GetCygxProductInteriorCount(condition, pars)
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取失败,Err:" + err.Error()
+		return
+	}
+	condition += "	ORDER BY art.publish_time DESC , art.product_interior_id DESC "
+	list, err := models.GetCygxProductInteriorList(condition, pars, startSize, pageSize)
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取失败,Err:" + err.Error()
+		return
+	}
+	for _, v := range list {
+		v.PublishTime = utils.TimeRemoveHms(v.PublishTime)
+	}
+	page := paging.GetPaging(currentIndex, pageSize, total)
+	resp.List = list
+	resp.Paging = page
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+	br.Data = resp
+}

+ 162 - 0
controllers/product_interior.go

@@ -0,0 +1,162 @@
+package controllers
+
+import (
+	"fmt"
+	"github.com/rdlucklib/rdluck_tools/paging"
+	"hongze/hongze_cygx/models"
+	"hongze/hongze_cygx/services"
+	"hongze/hongze_cygx/utils"
+	"regexp"
+	"strings"
+)
+
+// 产品内测
+type ProductInteriorController struct {
+	BaseAuthController
+}
+
+// @Title 列表
+// @Description 列表接口
+// @Param   PageSize   query   int  true       "每页数据条数"
+// @Param   CurrentIndex   query   int  true       "当前页页码,从1开始"
+// @Success Ret=200 {object} cygx.GetCygxTacticsTimeLineResp
+// @router /list [get]
+func (this *ProductInteriorController) List() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	user := this.User
+	if user == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,用户信息为空"
+		br.Ret = 408
+		return
+	}
+	resp := new(models.GetCygxProductInteriorResp)
+	pageSize, _ := this.GetInt("PageSize")
+	currentIndex, _ := this.GetInt("CurrentIndex")
+
+	var startSize int
+	if pageSize <= 0 {
+		pageSize = utils.PageSize20
+	}
+	if currentIndex <= 0 {
+		currentIndex = 1
+	}
+	startSize = utils.StartIndex(currentIndex, pageSize)
+	var condition string
+	var pars []interface{}
+	condition += ` AND art.status = 1 `
+	total, err := models.GetCygxProductInteriorCount(condition, pars)
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取失败,Err:" + err.Error()
+		return
+	}
+	condition += "	ORDER BY art.publish_time DESC , art.product_interior_id DESC "
+	list, err := models.GetCygxProductInteriorList(condition, pars, startSize, pageSize)
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取失败,Err:" + err.Error()
+		return
+	}
+	for _, v := range list {
+		v.PublishTime = utils.TimeRemoveHms(v.PublishTime)
+	}
+	page := paging.GetPaging(currentIndex, pageSize, total)
+	resp.List = list
+	resp.Paging = page
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+	br.Data = resp
+}
+
+// @Title  详情
+// @Description 获取详情接口
+// @Param   ProductInteriorId   query   int  true       "ID"
+// @Success Ret=200 {object} cygx.GetCygxProductInteriorDetailResp
+// @router /detail [get]
+func (this *ProductInteriorController) Detail() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	user := this.User
+	if user == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,用户信息为空"
+		br.Ret = 408
+		return
+	}
+	resp := new(models.GetCygxProductInteriorDetailResp)
+	productInteriorId, _ := this.GetInt("ProductInteriorId")
+	if productInteriorId < 1 {
+		br.Msg = "请输入详情ID"
+		return
+	}
+	detail, err := models.GetCygxProductInteriorDetail(productInteriorId)
+	if err != nil {
+		br.Msg = "详情不存在"
+		br.ErrMsg = "获取失败,Err:" + err.Error()
+		return
+	}
+	//判断用户权限
+	hasPermission, err := services.GetUserhasPermission(user)
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "获取用户权限信息失败,Err:" + err.Error()
+	}
+	//未设置全部可见的只能给弘则内部查看
+	if detail.VisibleRange == 1 || user.CompanyId == utils.HZ_COMPANY_ID {
+		resp.IsShow = true
+	}
+	resp.HasPermission = hasPermission
+	if hasPermission != 1 || !resp.IsShow {
+		br.Ret = 200
+		br.Success = true
+		br.Msg = "获取成功"
+		br.Data = resp
+		return
+	}
+	detail.PublishTime = utils.TimeRemoveHms2(detail.PublishTime)
+	resp.Detail = detail
+	body := detail.Body
+	var randStrStart = "start_cygx_{|}"
+	var randStr = "start_cygx_{|}_end_cygx"
+	urlMap := make(map[string]string)
+	var hrefRegexp = regexp.MustCompile(utils.RegularUrl)
+	match := hrefRegexp.FindAllString(body, -1)
+	if match != nil {
+		for _, v := range match {
+			body = strings.Replace(body, fmt.Sprint("href=\"", v, "\""), "", -1)
+			body = strings.Replace(body, fmt.Sprint("<a >"), "", -1)
+			body = strings.Replace(body, fmt.Sprint("</a>"), "", -1)
+			body = strings.Replace(body, v, randStrStart+v+randStr, -1)
+			urlMap[v] = v
+		}
+	}
+	sliceBody := strings.Split(body, randStr)
+	var sliceBodyUrl []string
+	for _, v := range sliceBody {
+		sliceUrl := strings.Split(v, randStrStart)
+		for _, url := range sliceUrl {
+			if url == "" {
+				continue
+			}
+			sliceBodyUrl = append(sliceBodyUrl, url)
+		}
+	}
+	for _, v := range sliceBodyUrl {
+		detail.BodySlice = append(detail.BodySlice, services.GetProductInteriorUrl(v, urlMap))
+	}
+
+	go services.AddCygxProductInteriorHistory(user, productInteriorId)
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+	br.Data = resp
+}

+ 1 - 0
models/db.go

@@ -135,6 +135,7 @@ func init() {
 		new(CygxXzsChooseCategory),
 		new(CygxReportSelectionSubjectHistory),
 		new(CygxTacticsTimeLineHistory),
+		new(CygxProductInteriorHistory),
 	)
 	// 记录ORM查询日志
 	orm.Debug = true

+ 156 - 0
models/product_interior.go

@@ -0,0 +1,156 @@
+package models
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+	"github.com/rdlucklib/rdluck_tools/paging"
+	"time"
+)
+
+type CygxProductInterior struct {
+	ProductInteriorId int       `orm:"column(product_interior_id);pk"`
+	ColumnName        string    `description:"栏目名称"`
+	Title             string    `description:"标题"`
+	PublishTime       time.Time `description:"发布日期"`
+	CreateTime        time.Time `description:"创建时间"`
+	ModifyTime        time.Time `description:"更新时间"`
+	Status            int       `description:"0:未发布,1:已发布"`
+	Body              string    `description:"内容"`
+	IsCancel          int       `description:"是否取消,1是,0否"`
+	VisibleRange      int       `description:"设置可见范围1全部,0内部"`
+	Abstract          string    `description:"摘要"`
+	Department        string    `description:"作者"`
+	AdminId           int       `description:"管理员ID"`
+}
+
+type AddProductInteriorReq struct {
+	ProductInteriorId int    `description:"ID"`
+	DoType            int    `description:"操作类型 0,保存 、1,发布"`
+	ColumnName        string `description:"栏目名称"`
+	Title             string `description:"标题"`
+	Abstract          string `description:"摘要"`
+	Department        string `description:"作者"`
+	Body              string `description:"内容"`
+	PublishTime       string `description:"发布日期"`
+}
+type ProductInteriorIdReq struct {
+	ProductInteriorId int `description:"ID"`
+}
+
+// 添加
+func AddProductInterior(item *CygxProductInterior) (err error) {
+	o := orm.NewOrm()
+	_, err = o.Insert(item)
+	return
+}
+
+// 修改
+func UpdateProductInterior(item *CygxProductInterior) (err error) {
+	to := orm.NewOrm()
+	updateParams := make(map[string]interface{})
+	updateParams["PublishTime"] = item.PublishTime
+	updateParams["ModifyTime"] = item.ModifyTime
+	updateParams["ColumnName"] = item.ColumnName
+	updateParams["Title"] = item.Title
+	updateParams["Status"] = item.Status
+	updateParams["Body"] = item.Body
+	updateParams["IsCancel"] = item.IsCancel
+	updateParams["VisibleRange"] = item.VisibleRange
+	updateParams["Abstract"] = item.Abstract
+	updateParams["Department"] = item.Department
+	ptrStructOrTableName := "cygx_product_interior"
+	whereParam := map[string]interface{}{"product_interior_id": item.ProductInteriorId}
+	qs := to.QueryTable(ptrStructOrTableName)
+	for expr, exprV := range whereParam {
+		qs = qs.Filter(expr, exprV)
+	}
+	_, err = qs.Update(updateParams)
+	return
+}
+
+type GetCygxProductInteriorResp struct {
+	Paging *paging.PagingItem `description:"分页数据"`
+	List   []*CygxProductInteriorResp
+}
+
+type CygxProductInteriorResp struct {
+	ProductInteriorId int                       `description:"ID"`
+	PublishTime       string                    `description:"发布日期"`
+	CreateTime        string                    `description:"创建时间"`
+	ModifyTime        string                    `description:"更新时间"`
+	Title             string                    `description:"标题"`
+	ColumnName        string                    `description:"栏目名称"`
+	Body              string                    `description:"内容"`
+	BodySlice         []*ProductInteriorUrlResp `description:"内容切片"`
+	IsCancel          int                       `description:"是否取消,1是,0否"`
+	VisibleRange      int                       `description:"设置可见范围1全部,0内部"`
+	Abstract          string                    `description:"摘要"`
+	Department        string                    `description:"作者"`
+}
+
+type ProductInteriorUrlResp struct {
+	ChartPermissionId int    `description:"行业id"`
+	SourceId          int    `description:"资源ID"`
+	Type              int    `description:"类型:1普通文本,2:文章、3:活动、4:产业"`
+	Body              string `description:"内容"`
+}
+
+// 获取数量
+func GetCygxProductInteriorCount(condition string, pars []interface{}) (count int, err error) {
+	sqlCount := ` SELECT COUNT(1) AS count  FROM cygx_product_interior as art WHERE 1= 1  `
+	if condition != "" {
+		sqlCount += condition
+	}
+	o := orm.NewOrm()
+	err = o.Raw(sqlCount, pars).QueryRow(&count)
+	return
+}
+
+// 列表
+func GetCygxProductInteriorList(condition string, pars []interface{}, startSize, pageSize int) (items []*CygxProductInteriorResp, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM cygx_product_interior as art WHERE 1= 1 `
+	if condition != "" {
+		sql += condition
+	}
+	sql += ` LIMIT ?,?  `
+	_, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
+	return
+}
+
+type GetCygxProductInteriorDetailResp struct {
+	Detail        *CygxProductInteriorResp
+	HasPermission int  `description:"1:有该行业权限,正常展示,2:无该行业权限,不存在权益客户下,3:无该品类权限,已提交过申请,4:无该行业权限,未提交过申请,5:潜在客户,未提交过申请,6:潜在客户,已提交过申请"`
+	IsShow        bool `description:"是否展示"`
+}
+
+// 通过ID获取详情
+func GetCygxProductInteriorDetail(productInteriorId int) (item *CygxProductInteriorResp, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM cygx_product_interior  WHERE product_interior_id=? AND status = 1  `
+	err = o.Raw(sql, productInteriorId).QueryRow(&item)
+	return
+}
+
+// 删除数据
+func DeleteProductInterior(productInteriorId int) (err error) {
+	o := orm.NewOrm()
+	sql := ` DELETE FROM cygx_product_interior WHERE product_interior_id = ?`
+	_, err = o.Raw(sql, productInteriorId).Exec()
+	return
+}
+
+// 修改是否展示
+func EditProductInteriorStatus(status, isCancel, productInteriorId int) (err error) {
+	o := orm.NewOrm()
+	sql := `UPDATE cygx_product_interior SET status=?,is_cancel = ? , modify_time=NOW()   WHERE product_interior_id=? `
+	_, err = o.Raw(sql, status, isCancel, productInteriorId).Exec()
+	return
+}
+
+// 修改可见范围
+func ProductInteriorVisibleRange(visibleRange, productInteriorId int) (err error) {
+	o := orm.NewOrm()
+	sql := `UPDATE cygx_product_interior SET visible_range=?, modify_time=NOW()   WHERE product_interior_id=?  `
+	_, err = o.Raw(sql, visibleRange, productInteriorId).Exec()
+	return
+}

+ 28 - 0
models/product_interior_history.go

@@ -0,0 +1,28 @@
+package models
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+	"time"
+)
+
+type CygxProductInteriorHistory struct {
+	Id                int `orm:"column(id);pk"`
+	ProductInteriorId int
+	UserId            int
+	CreateTime        time.Time
+	Mobile            string    `description:"手机号"`
+	Email             string    `description:"邮箱"`
+	CompanyId         int       `description:"公司id"`
+	CompanyName       string    `description:"公司名称"`
+	ModifyTime        time.Time `description:"修改时间"`
+	RealName          string    `description:"用户实际名称"`
+	SellerName        string    `description:"所属销售"`
+}
+
+// 添加历史信息
+func AddCygxProductInteriorHistory(item *CygxProductInteriorHistory) (lastId int64, err error) {
+	o := orm.NewOrm()
+	item.ModifyTime = time.Now()
+	lastId, err = o.Insert(item)
+	return
+}

+ 27 - 0
routers/commentsRouter.go

@@ -700,6 +700,33 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:MorningMeetingController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:MorningMeetingController"],
+        beego.ControllerComments{
+            Method: "List",
+            Router: `/gather/list`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
+    beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ProductInteriorController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ProductInteriorController"],
+        beego.ControllerComments{
+            Method: "Detail",
+            Router: `/detail`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
+    beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ProductInteriorController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ProductInteriorController"],
+        beego.ControllerComments{
+            Method: "List",
+            Router: `/list`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ReportBillboardController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ReportBillboardController"],
         beego.ControllerComments{
             Method: "FllowList",

+ 10 - 0
routers/router.go

@@ -139,6 +139,16 @@ func init() {
 				&controllers.ReportSelectionController{},
 			),
 		),
+		web.NSNamespace("/product_interior",
+			web.NSInclude(
+				&controllers.ProductInteriorController{},
+			),
+		),
+		web.NSNamespace("/morning_meeting",
+			web.NSInclude(
+				&controllers.MorningMeetingController{},
+			),
+		),
 	)
 	web.AddNamespace(ns)
 }

+ 65 - 0
services/product_interior.go

@@ -0,0 +1,65 @@
+package services
+
+import (
+	"hongze/hongze_cygx/models"
+	"hongze/hongze_cygx/utils"
+	"strconv"
+	"strings"
+	"time"
+)
+
+// GetProductInteriorUrl 处理产品内测中的连接并做跳转处理
+func GetProductInteriorUrl(url string, urlMap map[string]string) (itemResp *models.ProductInteriorUrlResp) {
+	//2:文章详情  https://web.hzinsights.com/material/info/8436
+	//3:活动详情  https://web.hzinsights.com/activity/detail/2701
+	//4:产业详情  https://web.hzinsights.com/indepth/info/20/79
+	item := new(models.ProductInteriorUrlResp)
+	item.Body = url
+	if urlMap[url] == "" {
+		item.Type = 1
+	} else {
+		urlSlice := strings.Split(url, "/")
+		lenurlSlice := len(urlSlice)
+		sourceId, _ := strconv.Atoi(urlSlice[lenurlSlice-1])
+		item.SourceId = sourceId
+		if strings.Contains(url, "material/info") {
+			item.Type = 2
+		} else if strings.Contains(url, "activity/detail") {
+			item.Type = 3
+		} else if strings.Contains(url, "indepth/info") {
+			if lenurlSlice >= 2 {
+				chartPermissionId, _ := strconv.Atoi(urlSlice[lenurlSlice-2])
+				item.ChartPermissionId = chartPermissionId
+			}
+			item.Type = 4
+		}
+	}
+	itemResp = item
+	return
+}
+
+func AddCygxProductInteriorHistory(user *models.WxUserItem, articleId int) (err error) {
+	defer func() {
+		if err != nil {
+			go utils.SendAlarmMsg("产品内测用户浏览信息记录失败"+err.Error(), 2)
+		}
+	}()
+	historyRecord := new(models.CygxProductInteriorHistory)
+	historyRecord.UserId = user.UserId
+	historyRecord.ProductInteriorId = articleId
+	historyRecord.CreateTime = time.Now()
+	historyRecord.Mobile = user.Mobile
+	historyRecord.Email = user.Email
+	historyRecord.CompanyId = user.CompanyId
+	historyRecord.CompanyName = user.CompanyName
+	sellerItem, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
+	if err != nil && err.Error() != utils.ErrNoRow() {
+		return
+	}
+	historyRecord.RealName = user.RealName
+	if sellerItem != nil {
+		historyRecord.SellerName = sellerItem.RealName
+	}
+	_, err = models.AddCygxProductInteriorHistory(historyRecord)
+	return
+}

+ 32 - 0
services/user.go

@@ -791,6 +791,38 @@ func GetUserhasPermission(user *models.WxUserItem) (hasPermission int, err error
 	return
 }
 
+// 获取用户有没有开通任意一个行业权限
+func GetUserhasPermissionOne(user *models.WxUserItem) (hasPermission int, err error) {
+	//判断是否已经申请过
+	applyCount, err := models.GetApplyRecordCount(user.UserId)
+	if err != nil && err.Error() != utils.ErrNoRow() {
+		return
+	}
+	if applyCount > 0 {
+		hasPermission = 3
+	} else {
+		hasPermission = 4
+	}
+	//HasPermission int  `description:"1:有该行业权限,正常展示,2:无该行业权限,不存在权益客户下,3:无该品类权限,已提交过申请,4:无该行业权限,未提交过申请,5:潜在客户,未提交过申请,6:潜在客户,已提交过申请"`
+	if user.CompanyId > 1 {
+		companyPermission, errPer := models.GetCompanyPermission(user.CompanyId)
+		if errPer != nil {
+			err = errPer
+			return
+		}
+		if companyPermission == "" {
+			if applyCount > 0 {
+				hasPermission = 3
+			} else {
+				hasPermission = 4
+			}
+		} else {
+			hasPermission = 1
+		}
+	}
+	return
+}
+
 // 每周五发送当前所有的权益用户
 func SendEmailAllUserWithRAI() (err error) {
 	defer func() {

+ 5 - 4
utils/constants.go

@@ -31,10 +31,11 @@ const (
 
 // 手机号,电子邮箱正则
 const (
-	RegularMobile             = "^((13[0-9])|(14[5|7])|(15([0-3]|[5-9]))|(18[0-9])|(17[0-9])|(16[0-9])|(19[0-9]))\\d{8}$" //手机号码
-	RegularFixedTelephone     = "^(\\(\\d{3,4}\\)|\\d{3,4}-|\\s)?\\d{7,14}$"                                              //手机号码
-	RegularFixedTelephoneEasy = "^[0-9\\-]+$"                                                                             //手机号码
-	RegularEmail              = `\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*`                                             //匹配电子邮箱
+	RegularMobile             = "^((13[0-9])|(14[5|7])|(15([0-3]|[5-9]))|(18[0-9])|(17[0-9])|(16[0-9])|(19[0-9]))\\d{8}$"               //手机号码
+	RegularFixedTelephone     = "^(\\(\\d{3,4}\\)|\\d{3,4}-|\\s)?\\d{7,14}$"                                                            //手机号码
+	RegularFixedTelephoneEasy = "^[0-9\\-]+$"                                                                                           //手机号码
+	RegularEmail              = `\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*`                                                           //匹配电子邮箱
+	RegularUrl                = `(http|ftp|https):\/\/([\w\-_]+(?:(?:\.[\w\-_]+)+))([\w\-\.,@?^=%&amp;:/~\+#]*[\w\-\@?^=%&amp;/~\+#])?` //匹配电子邮箱
 )
 
 // 聚合短信