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;
|
}
|
|
}
|