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();