ziwen před 1 rokem
rodič
revize
3fd37d6fd8

+ 1 - 1
controllers/research.go

@@ -801,7 +801,7 @@ func (this *ResearchController) ArticleNewList() {
 		item := models.ArticleResearchResp{
 			ArticleId:       v.ArticleId,
 			Title:           v.Title,
-			PublishDate:     v.PublishDate,
+			PublishDate:     v.PublishTime.Format(utils.FormatDate),
 			DepartmentId:    v.DepartmentId,
 			NickName:        v.NickName,
 			IsCollect:       v.IsCollect,

+ 8 - 8
controllers/yanxuan_special.go

@@ -47,7 +47,9 @@ func (this *YanxuanSpecialController) List() {
 		pars = append(pars, userId)
 	}
 
-	specialUser, err = models.GetYanxuanSpecialAuthor(sysUser.UserId, sysUser.UserId)
+	cond := ``
+	cond += ` AND a.status = 1 `
+	specialUser, err = models.GetYanxuanSpecialAuthor(sysUser.UserId, sysUser.UserId, cond)
 	if err != nil && err.Error() != utils.ErrNoRow() {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取失败, Err:" + err.Error()
@@ -366,7 +368,7 @@ func (this *YanxuanSpecialController) AuthorDetail() {
 	if userId == 0 {
 		userId = sysUser.UserId
 	}
-	item, tmpErr := models.GetYanxuanSpecialAuthor(userId, sysUser.UserId)
+	item, tmpErr := models.GetYanxuanSpecialAuthor(userId, sysUser.UserId,"")
 	if tmpErr != nil && tmpErr.Error() != utils.ErrNoRow() {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取失败, Err:" + tmpErr.Error()
@@ -830,7 +832,9 @@ func (this *YanxuanSpecialController) AuthorList() {
 	var specialUser *models.CygxYanxuanSpecialAuthorItem
 	var err error
 
-	specialUser, err = models.GetYanxuanSpecialAuthor(sysUser.UserId, sysUser.UserId)
+	cond := ``
+	cond += ` AND a.status = 1 `
+	specialUser, err = models.GetYanxuanSpecialAuthor(sysUser.UserId, sysUser.UserId, cond)
 	if err != nil && err.Error() != utils.ErrNoRow() {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取失败, Err:" + err.Error()
@@ -845,11 +849,7 @@ func (this *YanxuanSpecialController) AuthorList() {
 	}
 
 	for _, v := range list {
-		if !v.LatestPublishTime.IsZero() {
-			v.LatestPublishDate = v.LatestPublishTime.Format(utils.FormatDate) + "更新"
-		} else {
-			v.LatestPublishDate = v.ModifyTime.Format(utils.FormatDate) + "更新"
-		}
+		v.LatestPublishDate = v.LatestPublishTime.Format(utils.FormatDate) + "更新"
 	}
 	resp := new(models.SpecialAuthorListResp)
 

+ 1 - 1
models/cygx_yanxuan_special.go

@@ -94,7 +94,7 @@ type EnableCygxYanxuanSpecialReq struct {
 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 = ? `
+	sql = `UPDATE cygx_yanxuan_special SET status=?,reason=?,publish_time=NOW(),modify_time=NOW() WHERE id = ? `
 	_, err = o.Raw(sql, status, reason, id).Exec()
 	return
 }

+ 7 - 5
models/cygx_yanxuan_special_user.go

@@ -36,7 +36,7 @@ type CygxYanxuanSpecialAuthorItem struct {
 	ModifyTime        time.Time // 修改时间
 	HeadImg           string    // 头像
 	BgImg             string    // 背景图
-	BgImgDown             string    // 背景图下半部分
+	BgImgDown         string    // 背景图下半部分
 	Status            int       // 1启用2禁用
 	CollectNum        int       // 被收藏数
 	FollowNum         int       // 被关注数
@@ -66,7 +66,7 @@ func EnableYanxuanSpecialAuthor(userId, status int) (err error) {
 	return
 }
 
-func GetYanxuanSpecialAuthor(reqUserId, sysUserId int) (item *CygxYanxuanSpecialAuthorItem, err error) {
+func GetYanxuanSpecialAuthor(reqUserId, sysUserId int,cond string) (item *CygxYanxuanSpecialAuthorItem, err error) {
 	o := orm.NewOrm()
 	sql := ``
 	sql = `SELECT
@@ -79,6 +79,9 @@ FROM
 	cygx_yanxuan_special_author as a
 	LEFT JOIN wx_user AS u ON u.user_id = a.user_id
 	LEFT JOIN company AS c ON c.company_id = u.company_id WHERE a.user_id=? `
+	if cond != "" {
+		sql += cond
+	}
 	err = o.Raw(sql, reqUserId, sysUserId, reqUserId).QueryRow(&item)
 	return
 }
@@ -107,14 +110,13 @@ func GetYanxuanSpecialAuthorList() (items []*CygxYanxuanSpecialAuthorItem, err e
 	sql = `SELECT
 	a.*,
 	c.company_name,
-	( SELECT publish_time FROM cygx_yanxuan_special WHERE user_id = a.user_id AND STATUS = 3 ORDER BY publish_time DESC LIMIT 1 ) AS latest_publish_time 
+	IFNULL(( SELECT publish_time FROM cygx_yanxuan_special WHERE user_id = a.user_id AND STATUS = 3 ORDER BY publish_time DESC LIMIT 1 ), a.modify_time) AS latest_publish_time
 FROM
 	cygx_yanxuan_special_author AS a
 	INNER JOIN wx_user AS u ON u.user_id = a.user_id
 	INNER JOIN company AS c ON c.company_id = u.company_id 
 WHERE
-	a.nick_name <> '' 
-	AND a.STATUS = 1 
+	a.nick_name <> ''
 ORDER BY
 	latest_publish_time DESC `
 	_, err = o.Raw(sql).QueryRows(&items)

+ 6 - 5
models/report.go

@@ -486,7 +486,8 @@ func GetArticleIdsBySubId(subjectId string) (articleIds string, err error) {
 type ArticleCollectionResp struct {
 	ArticleId              int                         `description:"文章id"`
 	Title                  string                      `description:"标题"`
-	PublishDate            string                      `description:"发布时间"`
+	PublishDate            string                      `description:"发布日期"`
+	PublishTime            time.Time                   `description:"发布时间"`
 	IndustrialManagementId int                         `description:"产业Id"`
 	IndustryName           string                      `description:"产业名称"`
 	DepartmentId           int                         `description:"作者Id"`
@@ -628,7 +629,7 @@ func GetArticleResearchList(condition string, pars []interface{}, startSize, pag
 	sql := `SELECT
 			a.article_id,
 			a.title,
-			date_format( a.publish_date, '%Y-%m-%d' ) AS publish_date,
+			a.publish_date AS publish_time,
 			a.article_type_id,
 			d.nick_name,
 			d.department_id,
@@ -658,7 +659,7 @@ func GetArticleResearchList(condition string, pars []interface{}, startSize, pag
 	SELECT
 		a.id AS article_id,
 		a.title AS title,
-		date_format( a.publish_time, '%Y-%m-%d' ) AS publish_date,
+		a.publish_time AS publish_time,
 		-1 AS article_type_id,
 		b.nick_name AS nick_name,
 		a.user_id AS department_id,
@@ -676,10 +677,10 @@ func GetArticleResearchList(condition string, pars []interface{}, startSize, pag
 	JOIN cygx_yanxuan_special_author AS b ON a.user_id = b.user_id
 	WHERE
 	1 = 1  AND a.status = 3 `
-		sql += ` ORDER  BY publish_date DESC  LIMIT ?,? `
+		sql += ` ORDER  BY publish_time DESC  LIMIT ?,? `
 		_, err = o.Raw(sql, userId, userId, pars, startSize, pageSize).QueryRows(&items)
 	} else {
-		sql += ` ORDER  BY publish_date DESC  LIMIT ?,? `
+		sql += ` ORDER  BY publish_time DESC  LIMIT ?,? `
 		_, err = o.Raw(sql, userId, pars, startSize, pageSize).QueryRows(&items)
 	}