zhibing.pu
2024-07-25 b3b7d3ae4789eb3d4d4bbadccd03d79adb28cb1a
UserIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/api/UserInfoController.java
@@ -1341,20 +1341,47 @@
    @PostMapping("/api/user/getFleetEngineAuth")
    @ApiOperation(value = "获取google地图授权token", tags = {"用户端-个人中心"}, notes = "")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "行程id", name = "tripId", required = true, dataType = "string"),
            @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
    })
    public ResultUtil<Map<String, Object>> getFleetEngineAuth(HttpServletRequest request){
    public ResultUtil<Map<String, Object>> getFleetEngineAuth(String tripId, HttpServletRequest request){
        try {
            Integer uid = userInfoService.getUserIdFormRedis(request);
            if(null == uid){
                return ResultUtil.tokenErr();
            }
            Map<String, Object> s = fleetEngineUtil.fleetEngineAuth(1, uid);
            Map<String, Object> s = fleetEngineUtil.fleetEngineAuth(1, tripId);
            return ResultUtil.success(s);
        }catch (Exception e){
            e.printStackTrace();
            return ResultUtil.runErr();
        }
    }
    @ResponseBody
    @PostMapping("/base/user/textToSpeech")
    public String textToSpeech(String languageCode, String text, String fileName){
        try {
            String s = TextToSpeechUtil.create(languageCode, text, fileName + ".mp3");
            //定时任务删除语音文件
            new Timer().schedule(new TimerTask() {
                @Override
                public void run() {
                    Process process = null;
                    try {
                        process = Runtime.getRuntime().exec("rm -rf /usr/local/nginx/html/files/audio/" + fileName + ".mp3");
                    } catch (IOException e) {
                        throw new RuntimeException(e);
                    }
                    if (process != null) {
                        process.destroy();
                    }
                }
            }, 30000);
            return s;
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
}