|
@@ -1,9 +1,14 @@
|
|
|
package com.fjhx.xmhjc.service.browsing.impl;
|
|
|
|
|
|
+import cn.hutool.core.date.DateUtil;
|
|
|
+import com.fjhx.xmhjc.entity.browsing.dto.AddBrowsingDto;
|
|
|
import com.fjhx.xmhjc.entity.browsing.po.BrowsingHistory;
|
|
|
import com.fjhx.xmhjc.mapper.browsing.BrowsingHistoryMapper;
|
|
|
import com.fjhx.xmhjc.service.browsing.BrowsingHistoryService;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.fjhx.xmhjc.utils.NetUtils;
|
|
|
+import com.ruoyi.common.utils.SecurityUtils;
|
|
|
+import com.ruoyi.common.utils.ServletUtils;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.fjhx.xmhjc.entity.browsing.vo.BrowsingHistoryVo;
|
|
@@ -12,6 +17,8 @@ import com.ruoyi.common.utils.wrapper.IWrapper;
|
|
|
import com.fjhx.xmhjc.entity.browsing.dto.BrowsingHistoryDto;
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
+import java.util.Date;
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
@@ -63,4 +70,18 @@ public class BrowsingHistoryServiceImpl extends ServiceImpl<BrowsingHistoryMappe
|
|
|
this.removeById(id);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public void addBrowsingHistory(AddBrowsingDto addBrowsingDto) {
|
|
|
+ HttpServletRequest request = ServletUtils.getRequest();
|
|
|
+ String ip = NetUtils.getIpAddress(request);
|
|
|
+ BrowsingHistoryDto browsingHistoryDto = new BrowsingHistoryDto();
|
|
|
+ BeanUtil.copyProperties(addBrowsingDto, browsingHistoryDto);
|
|
|
+ browsingHistoryDto.setIp(ip);
|
|
|
+ Date createTime = addBrowsingDto.getCreateTime();
|
|
|
+ browsingHistoryDto.setYear(DateUtil.year(createTime));
|
|
|
+ browsingHistoryDto.setMonth(DateUtil.month(createTime) + 1);
|
|
|
+ browsingHistoryDto.setDay(DateUtil.dayOfMonth(createTime));
|
|
|
+ browsingHistoryDto.setHour(DateUtil.hour(createTime, true));
|
|
|
+ browsingHistoryDto.setWeek(DateUtil.weekOfYear(createTime));
|
|
|
+ }
|
|
|
}
|