Helius
2021-08-11 05d329244f158d1d16664c62b9a754c0905b4341
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
package com.matrix.system.dataMove;
 
import com.alibaba.fastjson.JSONObject;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.matrix.system.shopXcx.bean.ShopProductAttribute;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
 
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
 
/**
 * @author wzy
 * @date 2021-08-11
 **/
@Service
public class SjfDataMoveServiceImpl {
 
    @Autowired
    private JdbcTemplate jdbcTemplate;
 
 
    public <T> List<T> mapsToListBean(List<Map<String, Object>> maps, Class<T> t) {
        List<T> list = new ArrayList<>();
        for (Map<String, Object> map : maps) {
            String s = JSONObject.toJSONString(map);
            T object = JSONObject.parseObject(s, t);
            list.add(object);
        }
        return list;
    }
 
    public <T> T mapToBane(Map<String, Object> map, Class<T> t) {
        String s = JSONObject.toJSONString(map);
        return JSONObject.parseObject(s, t);
    }
 
    @DS("slave")
    public List<ShopProductAttribute> oldProductAttr() {
        return null;
    }
 
}