//package com.example.controller; // //import cn.hutool.json.JSONObject; //import cn.hutool.json.JSONUtil; //import com.example.domain.HisSyncDict; //import com.example.service.HisSyncDictService; //import com.example.utils.DictionaryUtil; //import com.example.utils.DictionaryUtilNew; //import lombok.extern.slf4j.Slf4j; //import org.springframework.beans.factory.annotation.Autowired; //import org.springframework.web.bind.annotation.*; // //import java.io.*; //import java.util.List; // ///** // * @Company: 西安路泰科技有限公司 // * @Author: zhaowenxuan // * @Date: 2024/6/3 15:25 // */ //@Slf4j //@RestController //public class TestController { // private static final String LOG_PATH = "src/main/resources/log.log"; // @Autowired // private DictionaryUtil dictionaryUtil; // @Autowired // private DictionaryUtilNew dictionaryUtilNew; // @Autowired // private HisSyncDictService hisSyncDictService; // // /** // * 全部字典同步 // * @return // */ // @GetMapping("exec") // public String exce(){ // // 将文件内容设置为空 // FileWriter fileWriter = null; // try { // fileWriter = new FileWriter(LOG_PATH); // fileWriter.write(""); // fileWriter.close(); // } catch (IOException ignored) {} // new Thread(()->{ // // dictionaryUtil.exec1(); // dictionaryUtilNew.exec1(); // }).start(); // return "已提交执行"; // } // // /** // * 显示日志 // * @return // */ // @GetMapping("/show") // public String showLog() { // StringBuilder logContent = new StringBuilder(); // try (BufferedReader reader = new BufferedReader(new FileReader(LOG_PATH))) { // String line; // while ((line = reader.readLine()) != null) { // logContent.append(line).append("
"); // } // return logContent.toString(); // } catch (IOException e) { // log.error("Error reading log file", e); // return e.getMessage(); // } // } // // /** // * 清除日志 // * @return // */ // @GetMapping("/clear") // public String cleanLog() { // try { // // 将文件内容设置为空 // FileWriter fileWriter = new FileWriter(LOG_PATH); // fileWriter.write(""); // fileWriter.close(); // return "Log content cleared successfully."; // } catch (IOException e) { // e.printStackTrace(); // return "Failed to clear log content."; // } // } // // /** // * 手动同步 // * @param data json格式 methods为String集合 存储字典名 type为布尔类型 是否清理日志 // * @return // */ // @PostMapping("exec") // public String execPost(@RequestBody String data){ // JSONObject entries = JSONUtil.parseObj(data); // List methods = entries.getBeanList("methods", String.class); // Boolean type = entries.getBool("type"); // if (type){ // FileWriter fileWriter = null; // try { // fileWriter = new FileWriter(LOG_PATH); // fileWriter.write(""); // fileWriter.close(); // } catch (IOException ignored) {} // } // new Thread(()->{ // // dictionaryUtil.exec1(); // dictionaryUtilNew.execMethods(methods); // }).start(); // return "已提交执行 提交字典为 ->"+methods+",是否清理日志 ->"+type; // } // // @GetMapping("list") // public String listDict(){ // List list = hisSyncDictService.list(); // JSONObject obj = JSONUtil.createObj(); // obj.putOpt("code",200); // obj.putOpt("data",list); // return obj.toString(); // } //}