ziwen 1 year ago
parent
commit
7d826da09c

+ 250 - 0
controllers/cygx/yanxuan_special.go

@@ -0,0 +1,250 @@
+package cygx
+
+import (
+	"encoding/json"
+	"hongze/hz_crm_api/controllers"
+	"hongze/hz_crm_api/models"
+	"hongze/hz_crm_api/models/cygx"
+	"time"
+)
+
+// YanxuanSpecialController 研选专栏
+type YanxuanSpecialController struct {
+	controllers.BaseAuthController
+}
+
+// @Title 新增研选专栏作者
+// @Description 新增研选专栏作者
+// @Param	request	body help_doc.AddHelpDocReq true "type json string"
+// @Success 200 {object} models.AddEnglishReportResp
+// @router /yanxuan_special/author/add [post]
+func (this *YanxuanSpecialController) Add() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	sysUser := this.SysUser
+	if sysUser == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,SysUser Is Empty"
+		br.Ret = 408
+		return
+	}
+	var req cygx.AddCygxYanxuanSpecialAuthorReq
+	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 := cygx.CygxYanxuanSpecialAuthor{
+		UserId:     req.UserId,
+		RealName:   req.RealName,
+		Mobile:     req.Mobile,
+		CreateTime: time.Now(),
+		ModifyTime: time.Now(),
+		HeadImg:    "",
+		BgImg:      "",
+		Status:     1,
+	}
+
+	_, err = cygx.AddCygxYanxuanSpecialAuthor(&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 /yanxuan_special/author/enable [post]
+func (this *YanxuanSpecialController) AuthorEnable() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	sysUser := this.SysUser
+	if sysUser == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,SysUser Is Empty"
+		br.Ret = 408
+		return
+	}
+	var req cygx.EnableCygxYanxuanSpecialAuthorReq
+	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 = "用户id错误"
+		return
+	}
+	if req.Status <= 0 {
+		br.Msg = "参数错误"
+		return
+	}
+	if tmpErr := cygx.EnableYanxuanSpecialAuthor(req.UserId, req.Status); tmpErr != nil {
+		br.Msg = "启用/禁用作者失败"
+		br.ErrMsg = "启用/禁用作者失败, Err:" + tmpErr.Error()
+		return
+	}
+
+	if req.Status == 1 {
+		br.Msg = "启用成功"
+	} else {
+		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 /yanxuan_special/author/list [get]
+func (this *YanxuanSpecialController) AuthorList() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	sysUser := this.SysUser
+	if sysUser == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,SysUser Is Empty"
+		br.Ret = 408
+		return
+	}
+
+	list, tmpErr := cygx.GetYanxuanSpecialAuthorList()
+	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 help_doc.AddHelpDocReq true "type json string"
+// @Success 200 {object} models.AddEnglishReportResp
+// @router /yanxuan_special/list [get]
+func (this *YanxuanSpecialController) List() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	sysUser := this.SysUser
+	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{}
+
+	if userId > 0 {
+		condition += ` AND a.user_id = ? `
+		pars = append(pars, userId)
+	}
+
+	list, tmpErr := cygx.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 help_doc.AddHelpDocReq true "type json string"
+// @Success 200 {object} models.AddEnglishReportResp
+// @router /yanxuan_special/enable [post]
+func (this *YanxuanSpecialController) Enable() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	sysUser := this.SysUser
+	if sysUser == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,SysUser Is Empty"
+		br.Ret = 408
+		return
+	}
+	var req cygx.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 := cygx.EnableYanxuanSpecial(req.Id, status, req.Reason); tmpErr != nil {
+		br.Msg = "审批失败"
+		br.ErrMsg = "审批失败, Err:" + tmpErr.Error()
+		return
+	}
+
+	br.Msg = "审批成功"
+	br.Ret = 200
+	br.Success = true
+}

+ 71 - 0
models/cygx/cygx_yanxuan_special.go

@@ -0,0 +1,71 @@
+package cygx
+
+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    // 理由
+}
+
+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 // 理由
+}
+
+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.create_time `
+	_, err = o.Raw(sql).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
+}

+ 73 - 0
models/cygx/cygx_yanxuan_special_user.go

@@ -0,0 +1,73 @@
+package cygx
+
+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    // 姓名
+	Mobile       string    // 手机号
+	CreateTime   string // 创建时间
+	ModifyTime   string // 修改时间
+	HeadImg      string    // 头像
+	BgImg        string    // 背景图
+	Status       int       // 1启用2禁用
+}
+
+func AddCygxYanxuanSpecialAuthor(item *CygxYanxuanSpecialAuthor) (lastId int64, err error) {
+	o := orm.NewOrm()
+	lastId, err = o.Insert(item)
+	return
+}
+
+type AddCygxYanxuanSpecialAuthorReq struct {
+	UserId   int    // 用户ID
+	RealName string // 姓名
+	Mobile   string // 手机号
+}
+
+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 GetYanxuanSpecialAuthorList() (items []*CygxYanxuanSpecialAuthorItem, err error) {
+	o := orm.NewOrm()
+	sql := ``
+	sql = `SELECT * FROM cygx_yanxuan_special_author ORDER BY create_time DESC `
+	_, err = o.Raw(sql).QueryRows(&items)
+	return
+}
+

+ 45 - 0
routers/commentsRouter.go

@@ -2788,6 +2788,51 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["hongze/hz_crm_api/controllers/cygx:YanxuanSpecialController"] = append(beego.GlobalControllerRouter["hongze/hz_crm_api/controllers/cygx:YanxuanSpecialController"],
+        beego.ControllerComments{
+            Method: "Add",
+            Router: `/yanxuan_special/author/add`,
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
+    beego.GlobalControllerRouter["hongze/hz_crm_api/controllers/cygx:YanxuanSpecialController"] = append(beego.GlobalControllerRouter["hongze/hz_crm_api/controllers/cygx:YanxuanSpecialController"],
+        beego.ControllerComments{
+            Method: "AuthorEnable",
+            Router: `/yanxuan_special/author/enable`,
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
+    beego.GlobalControllerRouter["hongze/hz_crm_api/controllers/cygx:YanxuanSpecialController"] = append(beego.GlobalControllerRouter["hongze/hz_crm_api/controllers/cygx:YanxuanSpecialController"],
+        beego.ControllerComments{
+            Method: "AuthorList",
+            Router: `/yanxuan_special/author/list`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
+    beego.GlobalControllerRouter["hongze/hz_crm_api/controllers/cygx:YanxuanSpecialController"] = append(beego.GlobalControllerRouter["hongze/hz_crm_api/controllers/cygx:YanxuanSpecialController"],
+        beego.ControllerComments{
+            Method: "Enable",
+            Router: `/yanxuan_special/enable`,
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
+    beego.GlobalControllerRouter["hongze/hz_crm_api/controllers/cygx:YanxuanSpecialController"] = append(beego.GlobalControllerRouter["hongze/hz_crm_api/controllers/cygx:YanxuanSpecialController"],
+        beego.ControllerComments{
+            Method: "List",
+            Router: `/yanxuan_special/list`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["hongze/hz_crm_api/controllers/data_manage/correlation:CorrelationChartClassifyController"] = append(beego.GlobalControllerRouter["hongze/hz_crm_api/controllers/data_manage/correlation:CorrelationChartClassifyController"],
         beego.ControllerComments{
             Method: "AddChartClassify",

+ 1 - 0
routers/router.go

@@ -150,6 +150,7 @@ func init() {
 				&cygx.ProductInteriorController{},
 				&cygx.BannerCoAntroller{},
 				&cygx.TagManagementController{},
+				&cygx.YanxuanSpecialController{},
 			),
 		),
 		web.NSNamespace("/advisory",