rdluck 4 年之前
父节点
当前提交
205fe98f58
共有 3 个文件被更改,包括 24 次插入25 次删除
  1. 14 24
      controllers/article.go
  2. 8 0
      models/article.go
  3. 2 1
      models/article_interview_apply.go

+ 14 - 24
controllers/article.go

@@ -245,6 +245,7 @@ func (this *ArticleController) InterviewApply() {
 		item.InterviewTime = time.Now()
 		item.CreateTime = time.Now()
 		item.ModifyTime = time.Now()
+		item.ArticleIdMd5 = article.ArticleIdMd5
 		_, err = models.AddCygxInterviewApply(item)
 		if err != nil {
 			br.Msg = "申请失败"
@@ -270,7 +271,7 @@ func (this *ArticleController) InterviewApply() {
 
 // @Title 获取报告详情
 // @Description 获取报告详情接口
-// @Param   ArticleId   query   int  true       "报告ID"
+// @Param   ArticleIdMd5   query   int  true       "报告ID"
 // @Success 200 {object} models.ArticleDetailResp
 // @router /look/detail [get]
 func (this *ArticleCommonController) Detail() {
@@ -279,37 +280,26 @@ func (this *ArticleCommonController) Detail() {
 		this.Data["json"] = br
 		this.ServeJSON()
 	}()
-	userName := this.GetString("UserName")
-	if userName == "" {
+
+	articleIdMd5:= this.GetString("ArticleIdMd5")
+	if articleIdMd5 =="" {
 		br.Msg = "参数错误"
-		br.ErrMsg = "参数错误,UserName Is Empty"
+		br.ErrMsg = "参数错误"
 		return
 	}
-	sellerItem, err := models.GetSellerByName(userName)
-	if err != nil {
-		br.Msg = "获取数据失败"
-		br.ErrMsg = "获取数据失败,Err:" + err.Error()
+	resp := new(models.ArticleDetailResp)
+	detail, err := models.GetArticleDetailByIdMd5(articleIdMd5)
+	if err != nil && err.Error()!=utils.ErrNoRow() {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "获取信息失败,Err:"+err.Error()
 		return
 	}
-	resp := new(models.ArticleDetailResp)
-	if sellerItem.AdminId <= 0 {
+	if detail==nil {
 		resp.HasPermission = 2
-	} else {
-		articleId, _ := this.GetInt("ArticleId")
-		if articleId <= 0 {
-			br.Msg = "参数错误"
-			br.ErrMsg = "参数错误"
-			return
-		}
-		detail, err := models.GetArticleDetailById(articleId)
-		if err != nil {
-			br.Msg = "获取信息失败"
-			br.ErrMsg = "获取信息失败"
-			return
-		}
-		resp.Detail = detail
+	}else{
 		resp.HasPermission = 1
 	}
+	resp.Detail = detail
 	br.Ret = 200
 	br.Success = true
 	br.Msg = "获取成功"

+ 8 - 0
models/article.go

@@ -55,6 +55,7 @@ type ArticleDetail struct {
 	ExpertNumber         string    `description:"专家编号"`
 	Department           string    `description:"作者"`
 	SellerMobile         string    `description:"销售手机号"`
+	ArticleIdMd5         string    `description:"纪要id"`
 }
 
 func GetArticleDetailById(articleId int) (item *ArticleDetail, err error) {
@@ -64,6 +65,13 @@ func GetArticleDetailById(articleId int) (item *ArticleDetail, err error) {
 	return
 }
 
+func GetArticleDetailByIdMd5(articleIdMd5 string) (item *ArticleDetail, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM cygx_article WHERE article_id_md5 = ? `
+	err = o.Raw(sql, articleIdMd5).QueryRow(&item)
+	return
+}
+
 func GetArticleDetailByIdStr(articleIdStr string) (items []*ArticleDetail, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT * FROM cygx_article WHERE article_id IN(` + articleIdStr + `) `

+ 2 - 1
models/article_interview_apply.go

@@ -16,6 +16,7 @@ type CygxInterviewApply struct {
 	ArticleTitle     string    `description:"纪要标题"`
 	CreateTime       time.Time `description:"创建时间"`
 	ModifyTime       time.Time `description:"修改时间"`
+	ArticleIdMd5     string    `description:"纪要id"`
 }
 
 //添加申请访谈信息
@@ -30,7 +31,7 @@ type ArticleInterviewApplyReq struct {
 }
 
 type ArticleInterviewApplyResp struct {
-	Status       int `description:"1:申请成功,2:取消申请"`
+	Status int `description:"1:申请成功,2:取消申请"`
 }
 
 func RemoveArticleInterviewApply(userId, articleId int) (err error) {