jinlin
2025-03-01 86f02fee03614fef275c6e0c355d73318ca3025e
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package com.example.server.mysql.service;
 
import com.example.client.entity.RenException;
import com.example.client.service.BaseService;
import com.example.server.mysql.dao.SysMysqlDao;
import com.example.server.mysql.model.ColumnsTemp;
import com.example.server.mysql.model.SysMysql;
import org.apache.commons.io.input.ReversedLinesFileReader;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
 
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
 
 
@Service
public class SysMysqlService extends BaseService<SysMysqlDao, SysMysql> {
 
 
    public SysMysql check(String sql) {
        try {
            SysMysql sysMysql = new SysMysql();
            List<Map<String, Object>> data = baseDao.check(sql);
            List<ColumnsTemp> tableColumns = new ArrayList<>();
 
            for (Map<String, Object> map : data) {
                ColumnsTemp obj = null;
                for (Map.Entry<String, Object> entry : map.entrySet()) {
                    obj = new ColumnsTemp();
                    obj.setProp(entry.getKey());
                    obj.setLabel(entry.getKey());
                    tableColumns.add(obj);
                }
                break;
            }
            sysMysql.setTableColumns(tableColumns);
            sysMysql.setTableData(data);
            return sysMysql;
        } catch (Exception e) {
            e.printStackTrace();
            throw new RenException(String.valueOf(e));
        }
 
 
    }
 
    public void execute(String sql) {
        try {
            baseDao.execute(sql);
        } catch (Exception e) {
            e.printStackTrace();
            throw new RenException(String.valueOf(e));
        }
    }
}