|
@@ -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
|
|
|
+}
|