增加租车详情接口
This commit is contained in:
58
src/main/java/com/sczx/car/aspect/FacadeAspect.java
Normal file
58
src/main/java/com/sczx/car/aspect/FacadeAspect.java
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -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";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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));
|
||||||
|
}
|
||||||
|
}
|
||||||
14
src/main/java/com/sczx/car/dto/CarRentalDetailDTO.java
Normal file
14
src/main/java/com/sczx/car/dto/CarRentalDetailDTO.java
Normal 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;
|
||||||
|
}
|
||||||
15
src/main/java/com/sczx/car/service/CarRentalService.java
Normal file
15
src/main/java/com/sczx/car/service/CarRentalService.java
Normal 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);
|
||||||
|
}
|
||||||
@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -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;
|
||||||
|
|
||||||
|
}
|
||||||
14
src/main/java/com/sczx/car/thirdpart/facade/StoreFacade.java
Normal file
14
src/main/java/com/sczx/car/thirdpart/facade/StoreFacade.java
Normal 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);
|
||||||
|
}
|
||||||
@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user