增加租车详情接口

This commit is contained in:
2025-07-13 14:21:45 +08:00
parent 9ded13d973
commit 5a83189579
10 changed files with 252 additions and 2 deletions

View File

@ -0,0 +1,58 @@
package com.sczx.car.aspect;
import com.alibaba.fastjson.JSON;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;
/**
* @Author Huang Kai
* @Date 2023/1/18 17:01
* @Version 1.0
*/
@Aspect
@Component
@Slf4j
public class FacadeAspect {
/** 以 controller 包下定义的所有请求为切入点 */
@Pointcut("execution(public * com..facade.*.*(..))")
public void facadeLog() {}
/**
* 在切点之前织入
* @param joinPoint
*/
@Before("facadeLog()")
public void doBefore(JoinPoint joinPoint) {
// 打印请求相关参数
log.info("=========================remote Start =========================");
// 打印 Http method
//log.info("HTTP Method : {}", request.getMethod());
// 打印调用 controller 的全路径以及执行方法
log.info("Class Method:{}.{}", joinPoint.getSignature().getDeclaringTypeName(), joinPoint.getSignature().getName());
// 打印请求的 IP
//log.info("IP : {}", request.getRemoteAddr());
// 打印请求入参
log.info("facadeAspect_Request:{}", JSON.toJSONString(joinPoint.getArgs()));
}
@Around("facadeLog()")
public Object doAround(ProceedingJoinPoint proceedingJoinPoint) throws Throwable {
long startTime = System.currentTimeMillis();
Object result = proceedingJoinPoint.proceed();
// 打印出参
log.info("facadeAspect_Response:{}", JSON.toJSONString(result));
// 执行耗时
log.info("Time-Consuming : {} ms", System.currentTimeMillis() - startTime);
log.info("=========================remote End =========================");
return result;
}
}

View File

@ -18,6 +18,6 @@ public interface SystemConstants {
/*** /***
* feign客户端所在包路径 * feign客户端所在包路径
*/ */
String FEIGN_CLIENT_BASE_PACKAGE = "com.sczx.app.thirdpart.facade"; String FEIGN_CLIENT_BASE_PACKAGE = "com.sczx.car.thirdpart.facade";
} }

View File

@ -0,0 +1,37 @@
package com.sczx.car.controller;
import com.sczx.car.common.Result;
import com.sczx.car.dto.CarRentalDetailDTO;
import com.sczx.car.service.CarRentalService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/**
* <p>
* 车型表 前端控制器
* </p>
*
* @author zhangli
* @since 2025-07-12 19:55:31
*/
@Api(value = "租车相关接口", tags = "租车相关")
@RestController
@RequestMapping("/carRental")
public class CarRentalController {
@Autowired
private CarRentalService carRentalService;
@ApiOperation(value = "分页查询门店车型列表")
@GetMapping("/queryCarRentalDetail")
public Result<CarRentalDetailDTO> queryCarRentalDetail(@RequestParam(name = "storeId") Integer storeId,
@RequestParam(name = "carModelId") Integer carModelId){
return Result.ok(carRentalService.queryCarRentalDetail(storeId, carModelId));
}
}

View File

@ -0,0 +1,14 @@
package com.sczx.car.dto;
import com.sczx.car.thirdpart.dto.CompanyStoreDTO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
@ApiModel(value = "租车详情对象")
public class CarRentalDetailDTO {
@ApiModelProperty("门店信息")
private CompanyStoreDTO storeInfo;
}

View File

@ -0,0 +1,15 @@
package com.sczx.car.service;
import com.sczx.car.dto.CarRentalDetailDTO;
public interface CarRentalService {
/**
* 根据门店id和车型id查询租车详情信息
*
* @param storeId
* @param carModelId
* @return
*/
CarRentalDetailDTO queryCarRentalDetail(Integer storeId, Integer carModelId);
}

View File

@ -0,0 +1,23 @@
package com.sczx.car.service.impl;
import com.sczx.car.dto.CarRentalDetailDTO;
import com.sczx.car.service.CarRentalService;
import com.sczx.car.thirdpart.integration.StoreInteg;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Slf4j
@Service
public class CarRentalServiceImpl implements CarRentalService {
@Autowired
private StoreInteg storeInteg;
@Override
public CarRentalDetailDTO queryCarRentalDetail(Integer storeId, Integer carModelId) {
CarRentalDetailDTO carRentalDetailDTO = new CarRentalDetailDTO();
//查询门店信息
carRentalDetailDTO.setStoreInfo(storeInteg.getStoreById(storeId));
return carRentalDetailDTO;
}
}

View File

@ -0,0 +1,58 @@
package com.sczx.car.thirdpart.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
@ApiModel(value = "CompanyStoreDTO对象", description = "门店信息")
public class CompanyStoreDTO {
@ApiModelProperty("主键id")
private Integer id;
@ApiModelProperty("门店名称")
private String name;
@ApiModelProperty("联系人")
private String contactPerson;
@ApiModelProperty("手机号码")
private String phone;
@ApiModelProperty("联系人2")
private String contactPerson2;
@ApiModelProperty("手机号码2")
private String phone2;
@ApiModelProperty("详细地址")
private String detailedAddress;
@ApiModelProperty("门店logo")
private String image;
@ApiModelProperty("纬度")
private Double latitude;
@ApiModelProperty("经度")
private Double longitude;
@ApiModelProperty("标签 1.可租车 2.可换电 3.二手车多个用号隔开例如1,2,3")
private String label;
@ApiModelProperty("运营公司id")
private Integer operatingCompanyId;
@ApiModelProperty("运营性质 1.直营 0.合作")
private Boolean operatingNature;
@ApiModelProperty("简介")
private String introduction;
@ApiModelProperty("门店编号")
private String storeNumber;
}

View File

@ -0,0 +1,14 @@
package com.sczx.car.thirdpart.facade;
import com.sczx.car.common.Result;
import com.sczx.car.thirdpart.dto.CompanyStoreDTO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
@FeignClient(name = "sczx-store")
public interface StoreFacade {
@GetMapping("/pub/getStoreById")
Result<CompanyStoreDTO> getStoreById(@RequestParam(name = "storeId") Integer storeId);
}

View File

@ -0,0 +1,30 @@
package com.sczx.car.thirdpart.integration;
import com.sczx.car.common.Result;
import com.sczx.car.exception.InnerException;
import com.sczx.car.thirdpart.dto.CompanyStoreDTO;
import com.sczx.car.thirdpart.facade.StoreFacade;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@Slf4j
@Component
public class StoreInteg {
@Autowired
private StoreFacade storeFacade;
public CompanyStoreDTO getStoreById(Integer storeId) {
try{
Result<CompanyStoreDTO> result = storeFacade.getStoreById(storeId);
if(result.isSuccess()){
return result.getData();
}
} catch (Exception e){
log.error("根据门店id获取门店信息失败",e);
throw new InnerException("根据门店id获取门店信息失败");
}
return null;
}
}

View File

@ -4,7 +4,7 @@ server:
spring: spring:
application: application:
name: sczx_car # 微服务名称 name: sczx-car # 微服务名称
http: http:
encoding: encoding:
charset: UTF-8 charset: UTF-8
@ -31,6 +31,7 @@ spring:
hikari: hikari:
maximum-pool-size: 10 maximum-pool-size: 10
auto-commit: true auto-commit: true
connection_init_sql: SELECT 1
redis: redis:
host: 115.190.8.52 host: 115.190.8.52
port: 6379 port: 6379