package com.ld.igds.view.service;
|
|
import java.util.HashMap;
|
import java.util.List;
|
import java.util.Map;
|
|
import org.hibernate.Session;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Component;
|
|
import com.bstek.bdf2.core.orm.hibernate.HibernateDao;
|
import com.ld.igds.common.CoreCommonService;
|
import com.ld.igds.models.DicSysConf;
|
import com.ld.igds.util.ContextUtil;
|
|
@Component
|
public class SysConfService extends HibernateDao {
|
|
@Autowired
|
private CoreCommonService coreCommonService;
|
|
public DicSysConf getSysConf(String companyId) {
|
String hql = " from " + DicSysConf.class.getName()
|
+ " where companyId=:companyId";
|
|
if(null == companyId){
|
companyId = ContextUtil.getDefaultCompanyId();
|
}
|
|
Map<String, Object> args = new HashMap<String, Object>();
|
args.put("companyId", companyId);
|
|
List<DicSysConf> list = this.query(hql, args);
|
|
if (null == list || list.isEmpty()) {
|
return new DicSysConf();
|
}
|
|
return list.get(0);
|
}
|
|
public void updateSysConf(DicSysConf data) throws Exception {
|
Session session = this.getSessionFactory().openSession();
|
try {
|
if (null == data.getCompanyId()) {
|
data.setCompanyId(ContextUtil.getCompanyId());
|
}
|
session.saveOrUpdate(data);
|
|
coreCommonService.setCacheSysConf(data.getCompanyId(),data);
|
|
} finally {
|
session.flush();
|
session.close();
|
}
|
}
|
|
public void flushCacheSysConf(String companyId) {
|
|
if(null == companyId){
|
companyId = ContextUtil.getCompanyId();
|
}
|
|
DicSysConf data = this.getSysConf(companyId);
|
|
coreCommonService.setCacheSysConf(companyId,data);
|
}
|
|
}
|