| | |
| | | package com.yeshi.fanli.service.impl.config;
|
| | |
|
| | | import java.util.List;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.springframework.stereotype.Service;
|
| | |
|
| | | import com.yeshi.fanli.dao.mongo.system.ConfigCategoryDao;
|
| | | import com.yeshi.fanli.entity.system.ConfigCategory;
|
| | | import com.yeshi.fanli.entity.system.ConfigCategory.ConfigCategoryEnum;
|
| | | import com.yeshi.fanli.entity.system.ConfigKeyEnum;
|
| | | import com.yeshi.fanli.service.inter.config.ConfigCategoryService;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | |
|
| | | @Service
|
| | | public class ConfigCategoryServiceImpl implements ConfigCategoryService {
|
| | |
|
| | | @Resource
|
| | | private ConfigCategoryDao configCategoryDao;
|
| | |
|
| | | @Override
|
| | | public void addConfigCategory(ConfigCategory configCategory) {
|
| | | if (configCategory == null) {
|
| | | return;
|
| | | }
|
| | | |
| | | ConfigCategoryEnum type = configCategory.getType();
|
| | | ConfigKeyEnum keyEnum = configCategory.getKeyEnum();
|
| | | if (type == null || keyEnum == null) {
|
| | | return; |
| | | }
|
| | | |
| | | configCategory.setId(StringUtil.Md5(type.name() +"#space#" + keyEnum.name()));
|
| | | configCategoryDao.save(configCategory);
|
| | | }
|
| | | |
| | | @Override
|
| | | public List<ConfigCategory> listByType(ConfigCategoryEnum type) {
|
| | | return configCategoryDao.listByType(type);
|
| | | }
|
| | | |
| | | |
| | | @Override
|
| | | public ConfigCategoryEnum getCategoryEnum(String name) {
|
| | | if (StringUtil.isNullOrEmpty(name)) {
|
| | | return null;
|
| | | }
|
| | | |
| | | ConfigCategoryEnum[] array = ConfigCategoryEnum.values();
|
| | | for (int i = 0; i < array.length; i ++) {
|
| | | if (array[i].name().equals(name)) {
|
| | | return array[i];
|
| | | }
|
| | | }
|
| | | return null;
|
| | | }
|
| | | |
| | | }
|
| | | package com.yeshi.fanli.service.impl.config; |
| | | |
| | | import java.util.List; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import com.yeshi.fanli.dao.mongo.system.ConfigCategoryDao; |
| | | import com.yeshi.fanli.entity.system.ConfigCategory; |
| | | import com.yeshi.fanli.entity.system.ConfigCategory.ConfigCategoryEnum; |
| | | import com.yeshi.fanli.entity.system.ConfigKeyEnum; |
| | | import com.yeshi.fanli.service.inter.config.ConfigCategoryService; |
| | | import com.yeshi.fanli.util.StringUtil; |
| | | |
| | | @Service |
| | | public class ConfigCategoryServiceImpl implements ConfigCategoryService { |
| | | |
| | | @Resource |
| | | private ConfigCategoryDao configCategoryDao; |
| | | |
| | | @Override |
| | | public void addConfigCategory(ConfigCategory configCategory) { |
| | | if (configCategory == null) { |
| | | return; |
| | | } |
| | | |
| | | ConfigCategoryEnum type = configCategory.getType(); |
| | | ConfigKeyEnum keyEnum = configCategory.getKeyEnum(); |
| | | if (type == null || keyEnum == null) { |
| | | return; |
| | | } |
| | | |
| | | // 默认文本编辑 |
| | | if (configCategory.getEditMode() == 0) { |
| | | configCategory.setEditMode(1); |
| | | } |
| | | |
| | | configCategory.setId(StringUtil.Md5(type.name() +"#space#" + keyEnum.name())); |
| | | configCategoryDao.save(configCategory); |
| | | } |
| | | |
| | | @Override |
| | | public List<ConfigCategory> listByType(ConfigCategoryEnum type) { |
| | | return configCategoryDao.listByType(type); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public ConfigCategoryEnum getCategoryEnum(String name) { |
| | | if (StringUtil.isNullOrEmpty(name)) { |
| | | return null; |
| | | } |
| | | |
| | | ConfigCategoryEnum[] array = ConfigCategoryEnum.values(); |
| | | for (int i = 0; i < array.length; i ++) { |
| | | if (array[i].name().equals(name)) { |
| | | return array[i]; |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | } |