2
13693261870
2022-09-16 653761a31dfeb50dd3d007e892d69c90bf0cdafc
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
package com.landtool.lanbase.modules.org.service.impl;
 
import java.io.IOException;
 
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
 
import com.landtool.lanbase.common.utils.HttpOperateUtils;
import com.landtool.lanbase.config.SysTemPropertyConfig;
import com.landtool.lanbase.modules.org.entity.OrgUnit;
import com.landtool.lanbase.modules.org.redis.OrgUnitRedis;
import com.landtool.lanbase.modules.org.service.OrgUnitService;
 
@Service("unitService")
public class OrgUnitServiceImpl implements OrgUnitService {
 
    @Autowired
    private SysTemPropertyConfig tokenConfig;
 
    @Autowired
    private OrgUnitRedis orgUserRedis;
 
    @Override
    public OrgUnit queryObject(Long unitid) {
        OrgUnit orgUnit = orgUserRedis.get(unitid);
        if(orgUnit == null) {
            try {
                String url = tokenConfig.getApiServer() + "/api/org/user/getInfoById/" + unitid;
                orgUnit = (OrgUnit) HttpOperateUtils.getJsonObject(url, OrgUnit.class);
                if (orgUnit != null && orgUnit.getUnitid() != null) {
                    orgUserRedis.saveOrUpdate(orgUnit);
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return orgUnit;
    }
 
    @Override
    public String  getUnitName(Long unitid) {
        OrgUnit orgUnit = getUnitById(unitid);
        return  orgUnit==null?"":orgUnit.getUnitname();
    }
 
    @Override
    public OrgUnit getUnitById(Long unitid) {
        OrgUnit orgUnit = new OrgUnit();
        try {
            String url = tokenConfig.getApiServer() + "/api/org/unit/getInfoById/" + unitid;
            orgUnit = (OrgUnit) HttpOperateUtils.getJsonObject(url, OrgUnit.class);
        } catch (IOException e) {
            e.printStackTrace();
        }
        return orgUnit;
    }
 
}