作者 yangfu

公告消息数量统计修改

@@ -210,6 +210,21 @@ func GetIncrementSql(table string, column string, incre int, id int64) *utils.Sq @@ -210,6 +210,21 @@ func GetIncrementSql(table string, column string, incre int, id int64) *utils.Sq
210 } 210 }
211 } 211 }
212 212
  213 +//构建统计sql语句
  214 +func GetIncrementSqlBatch(table string, column string, incre int, ids ...int64) *utils.SqlData {
  215 + var sql *bytes.Buffer
  216 + sql = bytes.NewBuffer(nil)
  217 + sql.WriteString(fmt.Sprintf("update %s set %s=%s+%d ", table, column, column, incre))
  218 + if incre > 0 {
  219 + sql.WriteString(fmt.Sprintf(" where id in (%v)", utils.JoinInt64s(ids, ",")))
  220 + } else {
  221 + sql.WriteString(fmt.Sprintf(" where id in (%v) and %v>0", utils.JoinInt64s(ids, ","), column))
  222 + }
  223 + return &utils.SqlData{
  224 + Sql: sql.String(),
  225 + }
  226 +}
  227 +
213 //清楚未填写的表单数据 228 //清楚未填写的表单数据
214 func ClearEmptyForm(inputFormList []*protocol.Form) (FormList []*protocol.Form) { 229 func ClearEmptyForm(inputFormList []*protocol.Form) (FormList []*protocol.Form) {
215 if len(inputFormList) == 0 { 230 if len(inputFormList) == 0 {
@@ -135,6 +135,7 @@ func Comments(header *protocol.RequestHeader, request *protocol.CommentsRequest) @@ -135,6 +135,7 @@ func Comments(header *protocol.RequestHeader, request *protocol.CommentsRequest)
135 baseUserInfo *protocol.BaseUserInfo 135 baseUserInfo *protocol.BaseUserInfo
136 total int 136 total int
137 exists bool 137 exists bool
  138 + commentIds []int64
138 ) 139 )
139 if comments, total, err = models.GetComments(0, request.SourceType, request.SourceId, request.LastId, request.PageSize); err != nil { 140 if comments, total, err = models.GetComments(0, request.SourceType, request.SourceId, request.LastId, request.PageSize); err != nil {
140 log.Error(err) 141 log.Error(err)
@@ -163,8 +164,14 @@ func Comments(header *protocol.RequestHeader, request *protocol.CommentsRequest) @@ -163,8 +164,14 @@ func Comments(header *protocol.RequestHeader, request *protocol.CommentsRequest)
163 if exists, _ = models.ExitsChanceFavorite(header.UserId, header.CompanyId, comment.Id, protocol.MarkFlagZan); exists { 164 if exists, _ = models.ExitsChanceFavorite(header.UserId, header.CompanyId, comment.Id, protocol.MarkFlagZan); exists {
164 item.IsZan = true 165 item.IsZan = true
165 } 166 }
  167 + commentIds = append(commentIds, comment.Id)
166 rsp.Comments = append(rsp.Comments, item) 168 rsp.Comments = append(rsp.Comments, item)
167 } 169 }
  170 + if len(commentIds) > 0 {
  171 + if !utils.ExecuteSqlByRoll(true, agg.GetIncrementSqlBatch("comment", "view_total", 1, commentIds...)) {
  172 + //
  173 + }
  174 + }
168 return 175 return
169 } 176 }
170 177