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 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<Void> addNewVisit(HttpServletRequest req){
@GetMapping("/count/{type}")
@ApiImplicitParams(value = {
@ApiImplicitParam(name = "type", value = "web/o2o", required = true)
})
public Result<Void> addNewVisit(HttpServletRequest req, @PathVariable String type){
String ipAddr = getIpAddr(req);
visitCountService.addNewVisit(ipAddr);
visitCountService.addNewVisit(ipAddr, type);
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);
VisitCount visitCount = VisitCount.builder()
.ip(ipAddr)
.type(VisitTypeEnums.O2O.getType())
.type(type)
.visitTime(LocalDateTime.now())
.location(ipLocation)
.build();

Loading…
Cancel
Save