|
@@ -450,7 +450,6 @@ func (this *ReportController) ArticleCollect() {
|
|
|
return
|
|
|
}
|
|
|
industrialManagementId := req.IndustrialManagementId
|
|
|
- fmt.Println(industrialManagementId)
|
|
|
countIndustrial, err := models.GetIndustrialManagementCount(industrialManagementId)
|
|
|
if err != nil {
|
|
|
br.Msg = "获取数据失败!"
|
|
@@ -559,7 +558,7 @@ func (this *ReportController) Fllow() {
|
|
|
br.ErrMsg = "操作失败,Err:" + err.Error()
|
|
|
return
|
|
|
}
|
|
|
- resp.GoFllow = true
|
|
|
+ resp.GoFollow = true
|
|
|
resp.Status = 1
|
|
|
} else {
|
|
|
var doType int
|
|
@@ -643,6 +642,9 @@ func (this *ReportController) IndustryListByDepartment() {
|
|
|
br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
|
|
|
return
|
|
|
}
|
|
|
+ if v.FollowNum > 0 {
|
|
|
+ list[k].IsMyFollow = true
|
|
|
+ }
|
|
|
}
|
|
|
resp := new(models.CygxArticleDepartmentList)
|
|
|
resp.ListnNew, err = models.GetIndustrialSubjectByDepartmentNew(chartPermissionId)
|
|
@@ -658,3 +660,172 @@ func (this *ReportController) IndustryListByDepartment() {
|
|
|
br.Msg = "获取成功"
|
|
|
br.Data = resp
|
|
|
}
|
|
|
+
|
|
|
+// @Title 关注作者/取消关注作者
|
|
|
+// @Description 关注作者/取消关注作者 接口
|
|
|
+// @Param request body models.CygxArticleDepartmentId true "type json string"
|
|
|
+// @Success 200
|
|
|
+// @router /fllowDepartment [post]
|
|
|
+func (this *ReportController) FllowDepartment() {
|
|
|
+ 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
|
|
|
+ }
|
|
|
+ uid := user.UserId
|
|
|
+ var req models.CygxArticleDepartmentId
|
|
|
+ err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "参数解析异常!"
|
|
|
+ br.ErrMsg = "参数解析失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ departmentId := req.DepartmentId
|
|
|
+ var condition string
|
|
|
+ countDepartment, err := models.GetDepartmentCount(departmentId)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取数据失败!"
|
|
|
+ br.ErrMsg = "获取数据失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if countDepartment == 0 {
|
|
|
+ br.Msg = "作者不存在!"
|
|
|
+ br.ErrMsg = "作者ID不存在:" + strconv.Itoa(departmentId)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ count, err := models.GetArticleDepartmentFollow(uid, departmentId, condition)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取数据失败!"
|
|
|
+ br.ErrMsg = "获取数据失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ resp := new(models.CygxArticleDepartmentFollowResp)
|
|
|
+ if count == 0 {
|
|
|
+ item := new(models.CygxArticleDepartmentFollow)
|
|
|
+ item.DepartmentId = departmentId
|
|
|
+ item.UserId = uid
|
|
|
+ item.Email = user.Email
|
|
|
+ item.Mobile = user.Mobile
|
|
|
+ item.CompanyId = user.CompanyId
|
|
|
+ item.CompanyName = user.CompanyName
|
|
|
+ item.Type = 1
|
|
|
+ item.CreateTime = time.Now()
|
|
|
+ item.ModifyTime = time.Now()
|
|
|
+ _, err = models.AddArticleDepartmentFollow(item)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "操作失败"
|
|
|
+ br.ErrMsg = "操作失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ resp.Status = 1
|
|
|
+ resp.GoFollow = true
|
|
|
+ } else {
|
|
|
+ var doType int
|
|
|
+ condition = ` AND type = 1`
|
|
|
+ count, err = models.GetArticleDepartmentFollow(uid, departmentId, condition)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "操作失败!"
|
|
|
+ br.ErrMsg = "获取数据失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if count == 1 {
|
|
|
+ resp.Status = 2
|
|
|
+ doType = 2
|
|
|
+ } else {
|
|
|
+ resp.Status = 1
|
|
|
+ doType = 1
|
|
|
+ }
|
|
|
+ err = models.RemoveArticleDepartmentFollow(uid, departmentId, doType)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "操作失败"
|
|
|
+ br.ErrMsg = "取消关注失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+ br.Msg = "操作成功"
|
|
|
+ br.Ret = 200
|
|
|
+ br.Success = true
|
|
|
+ br.Data = resp
|
|
|
+}
|
|
|
+
|
|
|
+// @Title 研选文章列表接口
|
|
|
+// @Description 获取研选文章列表接口
|
|
|
+// @Param PageSize query int true "每页数据条数"
|
|
|
+// @Param CurrentIndex query int true "当前页页码,从1开始"
|
|
|
+// @Param DepartmentId query int true "作者ID"
|
|
|
+// @Param IndustrialManagementId query int true "产业ID"
|
|
|
+// @Success 200 {object} models.ReportArticleWhichIndustrialRepList
|
|
|
+// @router /industry/reportList [get]
|
|
|
+func (this *ReportController) ReportList() {
|
|
|
+ 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
|
|
|
+ }
|
|
|
+ uid := user.UserId
|
|
|
+ pageSize, _ := this.GetInt("PageSize")
|
|
|
+ currentIndex, _ := this.GetInt("CurrentIndex")
|
|
|
+ departmentId, _ := this.GetInt("DepartmentId")
|
|
|
+ industrialManagementId, _ := this.GetInt("IndustrialManagementId")
|
|
|
+
|
|
|
+ var condition string
|
|
|
+ var startSize int
|
|
|
+ if pageSize <= 0 {
|
|
|
+ pageSize = utils.PageSize20
|
|
|
+ }
|
|
|
+ if currentIndex <= 0 {
|
|
|
+ currentIndex = 1
|
|
|
+ }
|
|
|
+ startSize = paging.StartIndex(currentIndex, pageSize)
|
|
|
+ var pars []interface{}
|
|
|
+ var total int
|
|
|
+ resp := new(models.ReportArticleWhichIndustrialRepList)
|
|
|
+ page := paging.GetPaging(currentIndex, pageSize, total)
|
|
|
+
|
|
|
+ if departmentId > 0 {
|
|
|
+ condition += ` AND art.department_id = ` + strconv.Itoa(departmentId)
|
|
|
+ }
|
|
|
+
|
|
|
+ if industrialManagementId > 0 {
|
|
|
+ condition += ` AND m.industrial_management_id = ` + strconv.Itoa(industrialManagementId)
|
|
|
+ }
|
|
|
+ total, err := models.GetWhichDepartmentCount(condition)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取信息失败"
|
|
|
+ br.ErrMsg = "获取帖子总数失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ page = paging.GetPaging(currentIndex, pageSize, total)
|
|
|
+ condition += ` ORDER BY art.publish_date DESC`
|
|
|
+ list, err := models.IndustrialToArticleWhichDepartment(condition, pars, uid, startSize, pageSize)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取失败"
|
|
|
+ br.ErrMsg = "获取失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for k, v := range list {
|
|
|
+ if v.Readnum == 0 {
|
|
|
+ list[k].IsRed = true
|
|
|
+ }
|
|
|
+ resp.NickName = v.NickName
|
|
|
+ resp.IndustryName = v.IndustryName
|
|
|
+ }
|
|
|
+ resp.List = list
|
|
|
+ resp.Paging = page
|
|
|
+ br.Ret = 200
|
|
|
+ br.Success = true
|
|
|
+ br.Msg = "获取成功"
|
|
|
+ br.Data = resp
|
|
|
+}
|