From 2ef657b48c027f585e500ea48233ed38366a3798 Mon Sep 17 00:00:00 2001 From: huangyw <1207046171@qq.com> Date: Thu, 31 Oct 2024 20:54:17 +0800 Subject: [PATCH] =?UTF-8?q?release-=20=E8=AE=BF=E9=97=AE=E5=85=81=E8=AE=B8?= =?UTF-8?q?=E8=87=AA=E5=B8=A6=E5=8F=82=E6=95=B0=EF=BC=8Cweb/o2o?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/VisitCountController.java | 17 ++++++++++------- .../luoo/comment/service/VisitCountService.java | 4 ++-- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/luoo_comment/src/main/java/com/luoo/comment/controller/VisitCountController.java b/luoo_comment/src/main/java/com/luoo/comment/controller/VisitCountController.java index 2c73a96..1599421 100644 --- a/luoo_comment/src/main/java/com/luoo/comment/controller/VisitCountController.java +++ b/luoo_comment/src/main/java/com/luoo/comment/controller/VisitCountController.java @@ -4,11 +4,11 @@ import api.Result; import com.luoo.comment.service.VisitCountService; import controller.BaseController; import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiImplicitParams; +import io.swagger.annotations.ApiParam; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.CrossOrigin; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import javax.servlet.http.HttpServletRequest; @@ -26,10 +26,13 @@ public class VisitCountController extends BaseController { @Autowired private VisitCountService visitCountService; - @GetMapping("/count/o2o") - public Result addNewVisit(HttpServletRequest req){ + @GetMapping("/count/{type}") + @ApiImplicitParams(value = { + @ApiImplicitParam(name = "type", value = "web/o2o", required = true) + }) + public Result addNewVisit(HttpServletRequest req, @PathVariable String type){ String ipAddr = getIpAddr(req); - visitCountService.addNewVisit(ipAddr); + visitCountService.addNewVisit(ipAddr, type); return Result.success(); } } diff --git a/luoo_comment/src/main/java/com/luoo/comment/service/VisitCountService.java b/luoo_comment/src/main/java/com/luoo/comment/service/VisitCountService.java index d4b80ab..6ab292a 100644 --- a/luoo_comment/src/main/java/com/luoo/comment/service/VisitCountService.java +++ b/luoo_comment/src/main/java/com/luoo/comment/service/VisitCountService.java @@ -30,11 +30,11 @@ public class VisitCountService { /** * 新增一次访问 */ - public void addNewVisit(String ipAddr) { + public void addNewVisit(String ipAddr,String type) { String ipLocation = IpUtil.getIpLocation(ipAddr); VisitCount visitCount = VisitCount.builder() .ip(ipAddr) - .type(VisitTypeEnums.O2O.getType()) + .type(type) .visitTime(LocalDateTime.now()) .location(ipLocation) .build();