SysConfigManagerImpl.java
2.33 KB
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
65
66
67
68
69
70
71
72
73
74
75
package com.diligrp.website.manager.impl;
import java.util.List;
import javax.annotation.Resource;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import com.diligrp.website.dao.SysConfigDao;
import com.diligrp.website.domain.SysConfig;
import com.diligrp.website.manager.SysConfigManager;
import com.diligrp.website.manager.cache.SysConfigCache;
import com.diligrp.website.util.dao.BaseQuery;
import com.diligrp.website.util.domain.Result;
import com.diligrp.website.util.web.PageTemplate;
@Component("sysConfigManager")
public class SysConfigManagerImpl implements SysConfigManager {
@Resource
private SysConfigDao sysConfigDao;
@Resource
private SysConfigCache sysConfigCache;
@Override
public SysConfig getSysConfigByCode(String code) {
return sysConfigCache.getSysConfig(code);
}
@Override
public PageTemplate getSysConfigList(BaseQuery query) {
Integer totalSize = sysConfigDao.getSysConfigListCount(query);
List<SysConfig> list = sysConfigDao.getSysConfigList(query);
return PageTemplate.create(query, totalSize, list);
}
@Override
public Result addSysConfig(SysConfig cfg) {
SysConfig dbCfg = sysConfigDao.getSysConfigByCode(cfg.getConfigCode());
if (dbCfg != null) {
return Result.create(false).setMsg("变量编码“" + cfg.getConfigCode() + "”已经存在了");
}
boolean flag = sysConfigDao.saveSysConfig(cfg);
Result rst = Result.create(flag);
if (!flag) {
rst.setMsg("添加变量失败");
}
return rst;
}
@Override
public SysConfig getSysConfigById(Integer id) {
return sysConfigDao.getSysConfigById(id);
}
@Override
@Transactional
public Result editSysConfig(SysConfig cfg) {
SysConfig dbCfg = sysConfigDao.getSysConfigByCode(cfg.getConfigCode());
if (dbCfg == null) {
return Result.create(false).setMsg("变量已经存在了");
}
cfg.setId(dbCfg.getId());
cfg.setYn(dbCfg.getYn());
sysConfigCache.clearSysConfig(cfg.getId());
boolean flag = sysConfigDao.editSysConfig(cfg);
Result rst = Result.create(flag);
if (!flag) {
rst.setMsg("修改失败");
}
return rst;
}
}