package com.zy.crm.common.web;
|
|
import com.core.common.R;
|
import org.springframework.core.io.ClassPathResource;
|
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.RestController;
|
|
import javax.annotation.PostConstruct;
|
import java.io.IOException;
|
import java.io.InputStream;
|
|
/**
|
* Created by vincent on 2023/7/25
|
*/
|
@RestController
|
public class DatavController {
|
|
private String sql1;
|
|
@PostConstruct
|
public void init() throws IOException {
|
this.sql1 = read(new ClassPathResource("datav/sql/1.sql").getInputStream());
|
}
|
|
@GetMapping("/1test")
|
public R test1() {
|
return R.ok(this.sql1);
|
}
|
|
public static String read(InputStream inputStream) {
|
StringBuilder stringBuilder = new StringBuilder();
|
byte[] buffer = new byte[1024];
|
try {
|
int bytesRead;
|
while ((bytesRead = inputStream.read(buffer)) != -1) {
|
stringBuilder.append(new String(buffer, 0, bytesRead));
|
}
|
} catch (IOException e) {
|
e.printStackTrace();
|
} finally {
|
try {
|
inputStream.close();
|
} catch (IOException e) {
|
e.printStackTrace();
|
}
|
}
|
return stringBuilder.toString();
|
}
|
|
}
|