74 lines
2.3 KiB
Java
74 lines
2.3 KiB
Java
package com.lovenav.service.serviceImpl;
|
|
|
|
import com.lovenav.dao.ConfigDao;
|
|
import com.lovenav.entity.Config;
|
|
import com.lovenav.service.ConfigService;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import java.util.HashMap;
|
|
@Service
|
|
public class ConfigServiceImpl implements ConfigService {
|
|
@Autowired
|
|
ConfigDao configDao;
|
|
@Override
|
|
public HashMap<String, Object> getAllConfig() {
|
|
return null;
|
|
}
|
|
|
|
@Override
|
|
public int updateConfig(Config config) {
|
|
if (configDao.selectByName(config.getName())==null){
|
|
return 2;
|
|
}
|
|
return configDao.updateByName(config);
|
|
}
|
|
|
|
@Override
|
|
public String addConfig(Config config) {
|
|
if(configDao.selectByName(config.getName())!=null){
|
|
return "该配置文件已经存在!";
|
|
}else {
|
|
int result=configDao.insertSelective(config);
|
|
if (result==1){
|
|
return "添加成功!";
|
|
}else {
|
|
return "添加失败!";
|
|
}
|
|
}
|
|
|
|
}
|
|
//获得邮箱配置的信息,若没有值则采用默认信息
|
|
@Override
|
|
public HashMap<String, String> selectEmailConfig() {
|
|
HashMap<String,String> configMap= new HashMap<>();
|
|
if (configDao.selectByName("email_sendEmail").getValue()!=null){
|
|
configMap.put("email_sendEmail",configDao.selectByName("email_sendEmail").getValue());
|
|
}else {
|
|
configMap.put("email_sendEmail","482370576@qq.com");
|
|
return configMap;
|
|
}
|
|
if (configDao.selectByName("email_host").getValue()!=null){
|
|
configMap.put("email_host",configDao.selectByName("email_host").getValue());
|
|
}else {
|
|
configMap.put("email_host","smtp.qq.com");
|
|
return configMap;
|
|
}
|
|
if (configDao.selectByName("email_password").getValue()!=null){
|
|
configMap.put("email_password",configDao.selectByName("email_password").getValue());
|
|
}else {
|
|
configMap.put("email_password","ksuebkfenixhdbbh");
|
|
return configMap;
|
|
}
|
|
return configMap;
|
|
}
|
|
|
|
@Override
|
|
public Config selectAlreadyExist(Config config) {
|
|
|
|
return configDao.selectByName(config.getName());
|
|
}
|
|
|
|
|
|
}
|