Blame view

src/main/java/com/huaheng/pc/system/config/service/ConfigServiceImpl.java 3.58 KB
tangying authored
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
package com.huaheng.pc.system.config.service;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.huaheng.common.constant.UserConstants;
import com.huaheng.common.support.Convert;
import com.huaheng.common.utils.StringUtils;
import com.huaheng.common.utils.security.ShiroUtils;
import com.huaheng.pc.system.config.domain.Config;
import com.huaheng.pc.system.config.mapper.ConfigMapper;

/**
 * 参数配置 服务层实现
 * 
 * @author huaheng
 */
@Service
public class ConfigServiceImpl implements IConfigService
{
    @Autowired
    private ConfigMapper configMapper;

    /**
     * 查询参数配置信息
     * 
     * @param id 参数配置ID
     * @return 参数配置信息
     */
    @Override
    public Config selectConfigById(Integer id)
    {
        Config config = new Config();
        config.setId(id);
        return configMapper.selectConfig(config);
    }

    /**
     * 根据键名查询参数配置信息
     * 
     * @param configKey 参数名称
     * @return 参数键值
     */
    @Override
45
    public String selectConfigByKey(String configKey,String warehouseCode)
tangying authored
46
47
48
    {
        Config config = new Config();
        config.setConfigKey(configKey);
49
        config.setWarehouseCode(warehouseCode);
tangying authored
50
51
52
53
        Config retConfig = configMapper.selectConfig(config);
        return StringUtils.isNotNull(retConfig) ? retConfig.getConfigValue() : "";
    }
54
55
56
57
58
59
60
61
62
63
    @Override
    public String selectConfigByKey(String configKey)
    {
        Config config = new Config();
        config.setConfigKey(configKey);
        config.setWarehouseCode(ShiroUtils.getWarehouseCode());
        Config retConfig = configMapper.selectConfig(config);
        return StringUtils.isNotNull(retConfig) ? retConfig.getConfigValue() : "";
    }
tangying authored
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
    /**
     * 查询参数配置列表
     * 
     * @param config 参数配置信息
     * @return 参数配置集合
     */
    @Override
    public List<Config> selectConfigList(Config config)
    {
        return configMapper.selectConfigList(config);
    }

    /**
     * 新增参数配置
     * 
     * @param config 参数配置信息
     * @return 结果
     */
    @Override
    public int insertConfig(Config config)
    {
        config.setCreateBy(ShiroUtils.getLoginName());
        return configMapper.insertConfig(config);
    }

    /**
     * 修改参数配置
     * 
     * @param config 参数配置信息
     * @return 结果
     */
    @Override
    public int updateConfig(Config config)
    {
98
99
100
        if(ShiroUtils.getLoginName()!=null){
            config.setUpdateBy(ShiroUtils.getLoginName());
        }
tangying authored
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
        return configMapper.updateConfig(config);
    }

    /**
     * 批量删除参数配置对象
     * 
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteConfigByIds(String ids)
    {
        return configMapper.deleteConfigByIds(Convert.toStrArray(ids));
    }

    /**
     * 校验参数键名是否唯一
     * 
     * @param config 参数配置信息
     * @return 结果
     */
    @Override
唐高鑫 authored
123
124
125
    public Integer checkConfigKeyUnique(Config config) {
        String configKey = config.getConfigKey();
        String warehouseCode = ShiroUtils.getWarehouseCode();
tangying authored
126
        Integer id = StringUtils.isNull(config.getId()) ? -1 : config.getId();
唐高鑫 authored
127
128
        Config info = configMapper.checkConfigKeyUnique(configKey, warehouseCode);
        if (StringUtils.isNotNull(info))
tangying authored
129
130
131
132
133
134
135
        {
            return UserConstants.CONFIG_KEY_NOT_UNIQUE;
        }
        return UserConstants.CONFIG_KEY_UNIQUE;
    }

}