mirror of
https://github.com/weizhiqiang1995/erp-pro.git
synced 2025-02-26 16:32:58 +08:00
Merge branch 'company_server' of https://gitee.com/doc_wei01/skyeye into company_server
This commit is contained in:
commit
88dd363a08
7 changed files with 123 additions and 8 deletions
|
@ -40,4 +40,19 @@ public class ForumHotController {
|
|||
public void queryHotForumList(InputObject inputObject, OutputObject outputObject) {
|
||||
forumHotService.queryHotForumList(inputObject, outputObject);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取热门标签
|
||||
*
|
||||
* @param inputObject 入参以及用户信息等获取对象
|
||||
* @param outputObject 出参以及提示信息的返回值对象
|
||||
*/
|
||||
@ApiOperation(id = "queryHotTagList", value = "获取热门标签", method = "POST", allUse = "2")
|
||||
@ApiImplicitParams(classBean = CommonPageInfo.class)
|
||||
@RequestMapping("/post/ForumHotController/queryHotTagList")
|
||||
public void queryHotTagList(InputObject inputObject, OutputObject outputObject) {
|
||||
forumHotService.queryHotTagList(inputObject, outputObject);
|
||||
}
|
||||
|
||||
// TODO 获取热门标签 的定时任务
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.skyeye.eve.forum.controller;
|
|||
|
||||
|
||||
import com.skyeye.annotation.api.Api;
|
||||
import com.skyeye.annotation.api.ApiImplicitParam;
|
||||
import com.skyeye.annotation.api.ApiImplicitParams;
|
||||
import com.skyeye.annotation.api.ApiOperation;
|
||||
import com.skyeye.common.entity.search.CommonPageInfo;
|
||||
|
@ -46,10 +47,11 @@ public class ForumNoticeController {
|
|||
* @param inputObject 入参以及用户信息等获取对象
|
||||
* @param outputObject 出参以及提示信息的返回值对象
|
||||
*/
|
||||
@ApiOperation(id = "deleteNoticeById", value = "根据通知id删除通知", method = "DELETE", allUse = "2")
|
||||
@ApiImplicitParams(classBean = CommonPageInfo.class)
|
||||
@RequestMapping("/post/ForumNoticeController/deleteNoticeById")
|
||||
public void deleteNoticeById(InputObject inputObject, OutputObject outputObject) {
|
||||
@ApiOperation(id = "deleteForumNoticeById", value = "根据通知id删除通知", method = "DELETE", allUse = "2")
|
||||
@ApiImplicitParams(
|
||||
@ApiImplicitParam(id = "id", name = "id",value = "主键id", required = "required"))
|
||||
@RequestMapping("/post/ForumNoticeController/deleteForumNoticeById")
|
||||
public void deleteForumNoticeById(InputObject inputObject, OutputObject outputObject) {
|
||||
forumNoticeService.deleteById(inputObject, outputObject);
|
||||
}
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ import lombok.Data;
|
|||
|
||||
@Data
|
||||
@TableName("forum_hot")
|
||||
@ApiModel("热门帖子实体类")
|
||||
@ApiModel("热门帖子和标签实体类")
|
||||
public class ForumHot extends OperatorUserInfo {
|
||||
|
||||
@TableId("id")
|
||||
|
@ -29,6 +29,10 @@ public class ForumHot extends OperatorUserInfo {
|
|||
@ApiModelProperty(value = "帖子id")
|
||||
private String forumId;
|
||||
|
||||
@TableField("tag_id")
|
||||
@ApiModelProperty(value = "标签id")
|
||||
private String tagId;
|
||||
|
||||
@TableField("update_time")
|
||||
@ApiModelProperty(value = "更新时间")
|
||||
private String updateTime;
|
||||
|
|
|
@ -18,4 +18,8 @@ public interface ForumHotService extends SkyeyeBusinessService<ForumHot> {
|
|||
void queryHotForumList(InputObject inputObject, OutputObject outputObject);
|
||||
|
||||
void editHotForumMation();
|
||||
|
||||
void queryHotTagList(InputObject inputObject, OutputObject outputObject);
|
||||
|
||||
void queryHotForumTagList();
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.skyeye.eve.forum.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.skyeye.annotation.service.SkyeyeService;
|
||||
import com.skyeye.base.business.service.impl.SkyeyeBusinessServiceImpl;
|
||||
|
@ -20,6 +21,9 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
@ -114,6 +118,76 @@ public class ForumHotServiceImpl extends SkyeyeBusinessServiceImpl<ForumHotDao,
|
|||
createEntity(beans,null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void queryHotTagList(InputObject inputObject, OutputObject outputObject) {
|
||||
QueryWrapper<ForumHot> queryWrapper = new QueryWrapper<>();
|
||||
// 获取前一个月的日期范围yyyy-MM-dd
|
||||
LocalDate today = LocalDate.now();
|
||||
LocalDate beforeMonth = today.minusMonths(1);
|
||||
String start = beforeMonth.format(DateTimeFormatter.ISO_DATE);
|
||||
String end = today.format(DateTimeFormatter.ISO_DATE);
|
||||
|
||||
queryWrapper.between(MybatisPlusUtil.toColumns(ForumHot::getUpdateTime), start, end)
|
||||
.select(MybatisPlusUtil.toColumns(ForumHot::getTagId))
|
||||
.orderByDesc(MybatisPlusUtil.toColumns(ForumHot::getUpdateTime));
|
||||
List<ForumHot> forumHots = list(queryWrapper);
|
||||
outputObject.setBeans(forumHots);
|
||||
outputObject.settotal(forumHots.size());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取热门标签
|
||||
* */
|
||||
@Override
|
||||
public void queryHotForumTagList() {
|
||||
String beforeDay = getBeforeOrFutureDay(-29);
|
||||
String today = DateUtil.getTimeAndToString();
|
||||
QueryWrapper<ForumContent> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq(MybatisPlusUtil.toColumns(ForumContent::getState), CommonNumConstants.NUM_ONE)
|
||||
.between(MybatisPlusUtil.toColumns(ForumContent::getCreateTime), beforeDay, today)
|
||||
.select(MybatisPlusUtil.toColumns(ForumContent::getTagId))
|
||||
.orderByDesc(MybatisPlusUtil.toColumns(ForumContent::getCreateTime));
|
||||
List<ForumContent> forumContents = forumContentService.list(queryWrapper);
|
||||
|
||||
List<String> tagIds = new ArrayList<>();
|
||||
for(ForumContent content:forumContents){
|
||||
String[] tagId = content.getTagId().split(",");
|
||||
for (int i = 0; i < tagId.length; i++) {
|
||||
if(StrUtil.isNotEmpty(tagId[i])){
|
||||
tagIds.add(tagId[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
// 分组统计
|
||||
Map<String, Long> collect = tagIds.stream().collect(
|
||||
Collectors.groupingBy(e -> e, Collectors.counting())
|
||||
);
|
||||
// 排序
|
||||
List<Map.Entry<String, Long>> collectSort = collect.entrySet()
|
||||
.stream().sorted(Map.Entry.comparingByValue()).collect(Collectors.toList());
|
||||
List<String> tagIdList = new ArrayList<>();
|
||||
for (Map.Entry<String, Long> entry : collectSort) {
|
||||
tagIdList.add(entry.getKey());
|
||||
}
|
||||
// 取前10
|
||||
if(tagIdList.size()>10){
|
||||
tagIdList = tagIdList.subList(0, 10);
|
||||
}
|
||||
// 保存到ForumHot
|
||||
List<ForumHot> forumHots = new ArrayList<>();
|
||||
for (String tagId : tagIdList) {
|
||||
ForumHot forumHot = new ForumHot();
|
||||
forumHot.setTagId(tagId);
|
||||
// 当前时间yyyy-mm-dd
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||
String formattedDate = now.format(formatter);
|
||||
forumHot.setUpdateTime(formattedDate);
|
||||
forumHots.add(forumHot);
|
||||
}
|
||||
createEntity(forumHots,null);
|
||||
}
|
||||
|
||||
public String getBeforeOrFutureDay(int num) {
|
||||
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
|
||||
Calendar c = Calendar.getInstance();
|
||||
|
|
|
@ -48,11 +48,9 @@ public class ForumNoticeServiceImpl extends SkyeyeBusinessServiceImpl<ForumNotic
|
|||
Page page = PageHelper.startPage(commonPageInfo.getPage(), commonPageInfo.getLimit());
|
||||
QueryWrapper<ForumNotice> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq(MybatisPlusUtil.toColumns(ForumNotice::getState), ReadEnum.NO_READ.getKey());
|
||||
queryWrapper.eq(MybatisPlusUtil.toColumns(ForumNotice::getCreateId), userId);
|
||||
queryWrapper.eq(MybatisPlusUtil.toColumns(ForumNotice::getReceiveId), userId);
|
||||
queryWrapper.orderByDesc(MybatisPlusUtil.toColumns(ForumNotice::getCreateTime));
|
||||
List<ForumNotice> bean = list(queryWrapper);
|
||||
iAuthUserService.setName(bean, "createId", "createName");
|
||||
iAuthUserService.setName(bean, "updateId", "updateName");
|
||||
for (ForumNotice forumNotice : bean) {
|
||||
ForumContent forumContent = forumContentService.selectById(forumNotice.getForumId());
|
||||
forumNotice.setForumContentMation(forumContent);
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
package com.skyeye.xxljob;
|
||||
|
||||
import com.skyeye.eve.forum.service.ForumHotService;
|
||||
import com.xxl.job.core.handler.annotation.XxlJob;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class HotForumTag {
|
||||
|
||||
@Autowired
|
||||
private ForumHotService forumHotService;
|
||||
|
||||
@XxlJob("queryHotForumTagList")
|
||||
public void queryHotForumTagList() {
|
||||
forumHotService.queryHotForumTagList();
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue