| | |
| | | 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.GetMapping; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.io.*; |
| | | import java.util.List; |
| | |
| | | private DictionaryUtil dictionaryUtil; |
| | | @Autowired |
| | | private DictionaryUtilNew dictionaryUtilNew; |
| | | @Autowired |
| | | private HisSyncDictService hisSyncDictService; |
| | | |
| | | /** |
| | | * 全部字典同步 |
| | |
| | | |
| | | /** |
| | | * 手动同步 |
| | | * @param methods 同步的字典名 |
| | | * @param type 是否在同步前清除日志 默认否 |
| | | * @param data json格式 methods为String集合 存储字典名 type为布尔类型 是否清理日志 |
| | | * @return |
| | | */ |
| | | @PostMapping("exec") |
| | | public String execPost(@RequestParam("methods")List<String > methods,@RequestParam(value = "type",required = false,defaultValue = "false")Boolean type){ |
| | | public String execPost(@RequestBody String data){ |
| | | JSONObject entries = JSONUtil.parseObj(data); |
| | | List<String> methods = entries.getBeanList("methods", String.class); |
| | | Boolean type = entries.getBool("type"); |
| | | if (type){ |
| | | FileWriter fileWriter = null; |
| | | try { |
| | |
| | | // dictionaryUtil.exec1(); |
| | | dictionaryUtilNew.execMethods(methods); |
| | | }).start(); |
| | | return "已提交执行"; |
| | | return "已提交执行 提交字典为 ->"+methods+",是否清理日志 ->"+type; |
| | | } |
| | | |
| | | @GetMapping("list") |
| | | public String listDict(){ |
| | | List<HisSyncDict> list = hisSyncDictService.list(); |
| | | JSONObject obj = JSONUtil.createObj(); |
| | | obj.putOpt("code",200); |
| | | obj.putOpt("data",list); |
| | | return obj.toString(); |
| | | } |
| | | } |