新增查询门店详情接口,并修改服务名称
This commit is contained in:
55
src/main/java/com/sczx/store/aspect/FacadeAspect.java
Normal file
55
src/main/java/com/sczx/store/aspect/FacadeAspect.java
Normal file
@ -0,0 +1,55 @@
|
||||
package com.sczx.store.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.*;
|
||||
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;
|
||||
}
|
||||
}
|
||||
@ -33,7 +33,7 @@ public class StoreClientController {
|
||||
// @ApiImplicitParam(name = "Accept-Language", value = "语言标识,如 zh-CN", required = false, dataType = "string", paramType = "header")
|
||||
// })
|
||||
@PostMapping("/listStoresByBBoxWithDistance")
|
||||
Result<IPage<CompanyStoreDTO>> listStoresByBBoxWithDistance(@RequestParam(name = "pageNo", required = false, defaultValue = "1") Integer pageNo, @RequestParam(name = "pageSize", required = false, defaultValue = "10") Integer pageSize, @RequestBody StoreDistanceReq storeDistanceReq){
|
||||
public Result<IPage<CompanyStoreDTO>> listStoresByBBoxWithDistance(@RequestParam(name = "pageNo", required = false, defaultValue = "1") Integer pageNo, @RequestParam(name = "pageSize", required = false, defaultValue = "10") Integer pageSize, @RequestBody StoreDistanceReq storeDistanceReq){
|
||||
return Result.ok(storeService.listStoresByBBoxWithDistance(storeDistanceReq, pageNo, pageSize));
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,36 @@
|
||||
package com.sczx.store.controller;
|
||||
|
||||
|
||||
import com.sczx.store.common.Result;
|
||||
import com.sczx.store.dto.CompanyStoreDTO;
|
||||
import com.sczx.store.service.StoreService;
|
||||
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-08 21:16:36
|
||||
*/
|
||||
@Api(value = "门店公共接口", tags = "公共接口")
|
||||
@RestController
|
||||
@RequestMapping("/pub")
|
||||
public class StorePubController {
|
||||
|
||||
@Autowired
|
||||
private StoreService storeService;
|
||||
|
||||
@ApiOperation(value = "根据门店id查询门店信息")
|
||||
@GetMapping("/getStoreById")
|
||||
public Result<CompanyStoreDTO> getStoreById(@RequestParam(name = "storeId") Integer storeId){
|
||||
return Result.ok(storeService.getStoreById(storeId));
|
||||
}
|
||||
}
|
||||
13
src/main/java/com/sczx/store/convert/StoreConvert.java
Normal file
13
src/main/java/com/sczx/store/convert/StoreConvert.java
Normal file
@ -0,0 +1,13 @@
|
||||
package com.sczx.store.convert;
|
||||
|
||||
import com.sczx.store.dto.CompanyStoreDTO;
|
||||
import com.sczx.store.po.CompanyStorePO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
@Mapper
|
||||
public interface StoreConvert {
|
||||
StoreConvert INSTANCE = Mappers.getMapper(StoreConvert.class);
|
||||
CompanyStorePO dtoToPO(CompanyStoreDTO dto);
|
||||
CompanyStoreDTO poToDTO(CompanyStorePO po);
|
||||
}
|
||||
@ -13,4 +13,12 @@ public interface StoreService {
|
||||
* @return
|
||||
*/
|
||||
IPage<CompanyStoreDTO> listStoresByBBoxWithDistance(StoreDistanceReq storeDistanceReq, Integer pageNo, Integer pageSize);
|
||||
|
||||
/**
|
||||
* 根据id获取门店信息
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
CompanyStoreDTO getStoreById(Integer id);
|
||||
}
|
||||
|
||||
@ -1,16 +1,15 @@
|
||||
package com.sczx.store.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.sczx.store.convert.StoreConvert;
|
||||
import com.sczx.store.dto.CompanyStoreDTO;
|
||||
import com.sczx.store.dto.req.StoreDistanceReq;
|
||||
import com.sczx.store.po.CompanyStorePO;
|
||||
import com.sczx.store.repository.CompanyStoreRepo;
|
||||
import com.sczx.store.service.StoreService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class StoreServiceImpl implements StoreService {
|
||||
|
||||
@ -20,4 +19,13 @@ public class StoreServiceImpl implements StoreService {
|
||||
public IPage<CompanyStoreDTO> listStoresByBBoxWithDistance(StoreDistanceReq storeDistanceReq, Integer pageNo, Integer pageSize) {
|
||||
return companyStoreRepo.listStoresByBBoxWithDistance(storeDistanceReq,pageNo, pageSize);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompanyStoreDTO getStoreById(Integer id) {
|
||||
// LambdaQueryWrapper<CompanyStorePO> wrapper = Wrappers.lambdaQuery(CompanyStorePO.class);
|
||||
// wrapper.eq(CompanyStorePO::getId, id).orderByDesc(CompanyStorePO::getCreateTime).last("limit 1");
|
||||
CompanyStorePO companyStorePO = companyStoreRepo.getById(id);
|
||||
|
||||
return StoreConvert.INSTANCE.poToDTO(companyStorePO);
|
||||
}
|
||||
}
|
||||
|
||||
@ -4,7 +4,7 @@ server:
|
||||
|
||||
spring:
|
||||
application:
|
||||
name: sczx_store # 微服务名称
|
||||
name: sczx-store # 微服务名称
|
||||
http:
|
||||
encoding:
|
||||
charset: UTF-8
|
||||
|
||||
Reference in New Issue
Block a user