中扬CRM客户关系管理系统
#
luxiaotao1123
2023-07-31 ef8f08ff763cae09314fa90e0582f8f120c62ff1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
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();
    }
 
}