SysConfigServiceImpl.java
2.34 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
package com.diligrp.website.service.impl;
import javax.annotation.Resource;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component;
import com.diligrp.website.domain.SysConfig;
import com.diligrp.website.manager.SysConfigManager;
import com.diligrp.website.service.SysConfigService;
import com.diligrp.website.util.dao.BaseQuery;
import com.diligrp.website.util.domain.Result;
import com.diligrp.website.util.format.DateFormatUtils;
import com.diligrp.website.util.web.PageTemplate;
@Component("sysConfigService")
public class SysConfigServiceImpl implements SysConfigService {
@Resource
private SysConfigManager sysConfigManager;
@Override
public SysConfig getSysConfigByCode(String code) {
return sysConfigManager.getSysConfigByCode(code);
}
@Override
public PageTemplate getSysConfigList(BaseQuery query) {
return sysConfigManager.getSysConfigList(query);
}
@Override
public Result addSysConfig(SysConfig cfg) {
if (cfg == null) {
return Result.create(false).setMsg("参数错误!");
}
if (StringUtils.isEmpty(cfg.getConfigCode())
|| StringUtils.isEmpty(cfg.getConfigName())
|| StringUtils.isEmpty(cfg.getValue())) {
return Result.create(false).setMsg("必填参数为空");
}
cfg.setCreated(DateFormatUtils.currTimestamp());
cfg.setModified(DateFormatUtils.currTimestamp());
cfg.setYn(1);
return sysConfigManager.addSysConfig(cfg);
}
@Override
public Result getSysConfigById(Integer id) {
SysConfig cfg = sysConfigManager.getSysConfigById(id);
if (cfg == null) {
return Result.create(false).setMsg("预制变量不存在");
}
return Result.create().addResult("cfg", cfg);
}
@Override
public Result editSysConfig(SysConfig cfg) {
if (cfg == null) {
return Result.create(false).setMsg("参数错误!");
}
if (StringUtils.isEmpty(cfg.getConfigCode())
|| StringUtils.isEmpty(cfg.getConfigName())
|| StringUtils.isEmpty(cfg.getValue())) {
return Result.create(false).setMsg("必填参数为空");
}
cfg.setModified(DateFormatUtils.currTimestamp());
return sysConfigManager.editSysConfig(cfg);
}
}