release- 访问允许自带参数,web/o2o

release-2024-04-25
huangyw 3 weeks ago
parent d3a8e62eb0
commit 2ef657b48c

@ -4,11 +4,11 @@ import api.Result;
import com.luoo.comment.service.VisitCountService; import com.luoo.comment.service.VisitCountService;
import controller.BaseController; import controller.BaseController;
import io.swagger.annotations.Api; 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.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
@ -26,10 +26,13 @@ public class VisitCountController extends BaseController {
@Autowired @Autowired
private VisitCountService visitCountService; private VisitCountService visitCountService;
@GetMapping("/count/o2o") @GetMapping("/count/{type}")
public Result<Void> addNewVisit(HttpServletRequest req){ @ApiImplicitParams(value = {
@ApiImplicitParam(name = "type", value = "web/o2o", required = true)
})
public Result<Void> addNewVisit(HttpServletRequest req, @PathVariable String type){
String ipAddr = getIpAddr(req); String ipAddr = getIpAddr(req);
visitCountService.addNewVisit(ipAddr); visitCountService.addNewVisit(ipAddr, type);
return Result.success(); return Result.success();
} }
} }

@ -30,11 +30,11 @@ public class VisitCountService {
/** /**
* 访 * 访
*/ */
public void addNewVisit(String ipAddr) { public void addNewVisit(String ipAddr,String type) {
String ipLocation = IpUtil.getIpLocation(ipAddr); String ipLocation = IpUtil.getIpLocation(ipAddr);
VisitCount visitCount = VisitCount.builder() VisitCount visitCount = VisitCount.builder()
.ip(ipAddr) .ip(ipAddr)
.type(VisitTypeEnums.O2O.getType()) .type(type)
.visitTime(LocalDateTime.now()) .visitTime(LocalDateTime.now())
.location(ipLocation) .location(ipLocation)
.build(); .build();

Loading…
Cancel
Save