格式化

This commit is contained in:
Lemon
2023-10-14 09:30:07 +08:00
parent 881a619d16
commit 5a14be81e6

View File

@@ -27,106 +27,107 @@ import java.util.List;
@RequestMapping("/app-xcx-h5") @RequestMapping("/app-xcx-h5")
public class JumpController extends BaseController { public class JumpController extends BaseController {
@Autowired @Autowired
private PileService pileService; private PileService pileService;
@Autowired @Autowired
private IPileBasicInfoService pileBasicInfoService; private IPileBasicInfoService pileBasicInfoService;
/** /**
* 查询充电桩详情 * 查询充电桩详情
* http://localhost:8080/app-xcx-h5/pile/pileDetail/{pileSn} * http://localhost:8080/app-xcx-h5/pile/pileDetail/{pileSn}
*/ */
@GetMapping("/pile/pileDetail/{pileSn}") @GetMapping("/pile/pileDetail/{pileSn}")
public RestApiResponse<?> getPileDetail(HttpServletRequest request, @PathVariable("pileSn") String pileSn) { public RestApiResponse<?> getPileDetail(HttpServletRequest request, @PathVariable("pileSn") String pileSn) {
// logger.info("app-xcx-h5查询充电桩详情 param:{}", pileSn); // logger.info("app-xcx-h5查询充电桩详情 param:{}", pileSn);
logger.info("User-Agent:{}", request.getHeader("user-agent")); logger.info("User-Agent:{}", request.getHeader("user-agent"));
RestApiResponse<?> response = null; RestApiResponse<?> response = null;
try { try {
PileConnectorVO vo = pileService.getPileDetailByPileSn(pileSn); PileConnectorVO vo = pileService.getPileDetailByPileSn(pileSn);
response = new RestApiResponse<>(vo); response = new RestApiResponse<>(vo);
} catch (BusinessException e) { } catch (BusinessException e) {
logger.warn("app-xcx-h5查询充电桩详情 warn", e); logger.warn("app-xcx-h5查询充电桩详情 warn", e);
response = new RestApiResponse<>(e.getCode(), e.getMessage()); response = new RestApiResponse<>(e.getCode(), e.getMessage());
} catch (Exception e) { } catch (Exception e) {
logger.error("app-xcx-h5查询充电桩详情 error", e); logger.error("app-xcx-h5查询充电桩详情 error", e);
response = new RestApiResponse<>(ReturnCodeEnum.CODE_GET_PILE_DETAIL_ERROR); response = new RestApiResponse<>(ReturnCodeEnum.CODE_GET_PILE_DETAIL_ERROR);
} }
logger.info("app-xcx-h5查询充电桩详情 param:{}, result:{}", pileSn, JSONObject.toJSONString(response)); logger.info("app-xcx-h5查询充电桩详情 param:{}, result:{}", pileSn, JSONObject.toJSONString(response));
return response; return response;
} }
/** /**
* 查询充电枪口详情 * 查询充电枪口详情
* http://localhost:8080/app-xcx-h5/pile/connectorDetail/{pileConnectorCode} * http://localhost:8080/app-xcx-h5/pile/connectorDetail/{pileConnectorCode}
*/ */
@GetMapping("/pile/connectorDetail/{pileConnectorCode}") @GetMapping("/pile/connectorDetail/{pileConnectorCode}")
public RestApiResponse<?> getConnectorDetail(HttpServletRequest request, @PathVariable("pileConnectorCode") String pileConnectorCode) { public RestApiResponse<?> getConnectorDetail(HttpServletRequest request, @PathVariable("pileConnectorCode") String pileConnectorCode) {
// logger.info("app-xcx-h5查询充电枪口详情 param:{}", pileConnectorCode); // logger.info("app-xcx-h5查询充电枪口详情 param:{}", pileConnectorCode);
logger.info("User-Agent:{}", request.getHeader("user-agent")); logger.info("User-Agent:{}", request.getHeader("user-agent"));
RestApiResponse<?> response = null; RestApiResponse<?> response = null;
try { try {
PileConnectorVO vo = pileService.getConnectorDetail(pileConnectorCode); PileConnectorVO vo = pileService.getConnectorDetail(pileConnectorCode);
response = new RestApiResponse<>(vo); response = new RestApiResponse<>(vo);
} catch (BusinessException e) { } catch (BusinessException e) {
logger.warn("app-xcx-h5查询充电枪口详情 warn param:{}", pileConnectorCode, e); logger.warn("app-xcx-h5查询充电枪口详情 warn param:{}", pileConnectorCode, e);
response = new RestApiResponse<>(e.getCode(), e.getMessage()); response = new RestApiResponse<>(e.getCode(), e.getMessage());
} catch (Exception e) { } catch (Exception e) {
logger.error("app-xcx-h5查询充电枪口详情 error param:{}", pileConnectorCode, e); logger.error("app-xcx-h5查询充电枪口详情 error param:{}", pileConnectorCode, e);
response = new RestApiResponse<>(ReturnCodeEnum.CODE_GET_PILE_DETAIL_ERROR); response = new RestApiResponse<>(ReturnCodeEnum.CODE_GET_PILE_DETAIL_ERROR);
} }
logger.info("app-xcx-h5查询充电枪口详情 param:{} result:{}", pileConnectorCode, JSONObject.toJSONString(response)); logger.info("app-xcx-h5查询充电枪口详情 param:{} result:{}", pileConnectorCode, JSONObject.toJSONString(response));
return response; return response;
} }
/** /**
* 上传到阿里云oss * 上传到阿里云oss
* http://localhost:8080/app-xcx-h5/uploadOSS * http://localhost:8080/app-xcx-h5/uploadOSS
* @param file *
* @return * @param file
*/ * @return
@CrossOrigin */
@PostMapping("/uploadOSS") @CrossOrigin
public AjaxResult uploadFileOSS(MultipartFile file) { @PostMapping("/uploadOSS")
try { public AjaxResult uploadFileOSS(MultipartFile file) {
String url = AliyunOssUploadUtils.uploadFile(file); try {
AjaxResult ajax = AjaxResult.success(); String url = AliyunOssUploadUtils.uploadFile(file);
ajax.put("url", url); AjaxResult ajax = AjaxResult.success();
ajax.put("fileName", FileUtils.getName(url)); ajax.put("url", url);
ajax.put("newFileName", FileUtils.getName(url)); ajax.put("fileName", FileUtils.getName(url));
ajax.put("originalFilename", file.getOriginalFilename()); ajax.put("newFileName", FileUtils.getName(url));
return ajax; ajax.put("originalFilename", file.getOriginalFilename());
}catch (Exception e){ return ajax;
return AjaxResult.error(e.getMessage()); } catch (Exception e) {
} return AjaxResult.error(e.getMessage());
} }
}
/** /**
* 获取地锁列表信息 * 获取地锁列表信息
* http://localhost:8080/app-xcx-h5/getGroundLockInfo/{stationId} * http://localhost:8080/app-xcx-h5/getGroundLockInfo/{stationId}
* @param stationId *
* @return * @param stationId
*/ * @return
@GetMapping("/getGroundLockInfo/{stationId}") */
public RestApiResponse<?> getGroundLockInfo(@PathVariable("stationId") String stationId, HttpServletRequest request) { @GetMapping("/getGroundLockInfo/{stationId}")
logger.info("获取地锁列表信息 params:{}", stationId); public RestApiResponse<?> getGroundLockInfo(@PathVariable("stationId") String stationId, HttpServletRequest request) {
RestApiResponse<?> response = null; logger.info("获取地锁列表信息 params:{}", stationId);
try { RestApiResponse<?> response = null;
String memberId = getMemberIdByAuthorization(request); try {
if (StringUtils.isBlank(memberId)) { String memberId = getMemberIdByAuthorization(request);
throw new BusinessException(ReturnCodeEnum.CODE_TOKEN_ERROR); if (StringUtils.isBlank(memberId)) {
} throw new BusinessException(ReturnCodeEnum.CODE_TOKEN_ERROR);
List<GroundLockInfoVO> list = pileBasicInfoService.getGroundLockInfo(stationId); }
response = new RestApiResponse<>(list); List<GroundLockInfoVO> list = pileBasicInfoService.getGroundLockInfo(stationId);
}catch (BusinessException e) { response = new RestApiResponse<>(list);
logger.error("获取地锁列表信息 error,", e); } catch (BusinessException e) {
response = new RestApiResponse<>(e.getCode(), e.getMessage()); logger.error("获取地锁列表信息 error,", e);
} response = new RestApiResponse<>(e.getCode(), e.getMessage());
catch (Exception e) { } catch (Exception e) {
logger.error("获取地锁列表信息 error, ", e); logger.error("获取地锁列表信息 error, ", e);
response = new RestApiResponse<>(e); response = new RestApiResponse<>(e);
} }
logger.info("获取地锁列表信息 result:{}", response); logger.info("获取地锁列表信息 result:{}", response);
return response; return response;
} }
} }