作者 yangfu

公告消息数量统计修改

... ... @@ -210,6 +210,21 @@ func GetIncrementSql(table string, column string, incre int, id int64) *utils.Sq
}
}
//构建统计sql语句
func GetIncrementSqlBatch(table string, column string, incre int, ids ...int64) *utils.SqlData {
var sql *bytes.Buffer
sql = bytes.NewBuffer(nil)
sql.WriteString(fmt.Sprintf("update %s set %s=%s+%d ", table, column, column, incre))
if incre > 0 {
sql.WriteString(fmt.Sprintf(" where id in (%v)", utils.JoinInt64s(ids, ",")))
} else {
sql.WriteString(fmt.Sprintf(" where id in (%v) and %v>0", utils.JoinInt64s(ids, ","), column))
}
return &utils.SqlData{
Sql: sql.String(),
}
}
//清楚未填写的表单数据
func ClearEmptyForm(inputFormList []*protocol.Form) (FormList []*protocol.Form) {
if len(inputFormList) == 0 {
... ...
... ... @@ -135,6 +135,7 @@ func Comments(header *protocol.RequestHeader, request *protocol.CommentsRequest)
baseUserInfo *protocol.BaseUserInfo
total int
exists bool
commentIds []int64
)
if comments, total, err = models.GetComments(0, request.SourceType, request.SourceId, request.LastId, request.PageSize); err != nil {
log.Error(err)
... ... @@ -163,8 +164,14 @@ func Comments(header *protocol.RequestHeader, request *protocol.CommentsRequest)
if exists, _ = models.ExitsChanceFavorite(header.UserId, header.CompanyId, comment.Id, protocol.MarkFlagZan); exists {
item.IsZan = true
}
commentIds = append(commentIds, comment.Id)
rsp.Comments = append(rsp.Comments, item)
}
if len(commentIds) > 0 {
if !utils.ExecuteSqlByRoll(true, agg.GetIncrementSqlBatch("comment", "view_total", 1, commentIds...)) {
//
}
}
return
}
... ...