mirror of https://gitee.com/stylefeng/roses
【config】更新config业务模块
parent
971638e69b
commit
d4d0ca43ee
|
@ -7,9 +7,9 @@ import cn.hutool.http.HttpRequest;
|
|||
import cn.hutool.http.HttpUtil;
|
||||
import cn.hutool.http.useragent.UserAgent;
|
||||
import cn.hutool.http.useragent.UserAgentUtil;
|
||||
import cn.stylefeng.roses.kernel.rule.exception.base.ServiceException;
|
||||
import cn.stylefeng.roses.kernel.rule.exception.enums.http.ServletExceptionEnum;
|
||||
import com.alibaba.fastjson.JSONPath;
|
||||
import cn.stylefeng.roses.kernel.rule.exception.base.ServiceException;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.context.request.RequestContextHolder;
|
||||
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||
|
@ -130,7 +130,7 @@ public class HttpServletUtil {
|
|||
resultJson = String.join("", (List<String>) JSONPath.read(resultJson, jsonPath));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error(">>> 根据ip定位异常,具体信息为:{}", e.getMessage());
|
||||
log.error("根据ip定位异常,具体信息为:{}", e.getMessage());
|
||||
}
|
||||
return resultJson;
|
||||
}
|
||||
|
|
|
@ -39,18 +39,6 @@ public class SysConfigController {
|
|||
return new SuccessResponseData();
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑系统参数配置
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2020/4/14 11:11
|
||||
*/
|
||||
@PostResource(name = "编辑系统参数配置", path = "/sysConfig/edit")
|
||||
public ResponseData edit(@RequestBody @Validated(SysConfigParam.edit.class) SysConfigParam sysConfigParam) {
|
||||
sysConfigService.edit(sysConfigParam);
|
||||
return new SuccessResponseData();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除系统参数配置
|
||||
*
|
||||
|
@ -63,6 +51,18 @@ public class SysConfigController {
|
|||
return new SuccessResponseData();
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑系统参数配置
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2020/4/14 11:11
|
||||
*/
|
||||
@PostResource(name = "编辑系统参数配置", path = "/sysConfig/edit")
|
||||
public ResponseData edit(@RequestBody @Validated(SysConfigParam.edit.class) SysConfigParam sysConfigParam) {
|
||||
sysConfigService.edit(sysConfigParam);
|
||||
return new SuccessResponseData();
|
||||
}
|
||||
|
||||
/**
|
||||
* 查看系统参数配置
|
||||
*
|
||||
|
|
|
@ -83,10 +83,10 @@ public class ConfigInitListener implements ApplicationListener<ApplicationContex
|
|||
entityList.forEach(sysConfig -> ConfigContext.me().putConfig(sysConfig.getStr("config_code"), sysConfig.getStr("config_value")));
|
||||
}
|
||||
} catch (ClassNotFoundException e) {
|
||||
log.error(">>> 初始化系统配置表失败,找不到com.mysql.cj.jdbc.Driver类", e);
|
||||
log.error("初始化系统配置表失败,找不到com.mysql.cj.jdbc.Driver类", e);
|
||||
throw new ConfigException(ConfigExceptionEnum.CLASS_NOT_FOUND_ERROR);
|
||||
} catch (SQLException sqlException) {
|
||||
log.error(">>> 初始化系统配置表失败,执行查询语句失败", sqlException);
|
||||
log.error("初始化系统配置表失败,执行查询语句失败", sqlException);
|
||||
throw new ConfigException(ConfigExceptionEnum.CONFIG_SQL_EXE_ERROR);
|
||||
} finally {
|
||||
DbUtil.close(conn);
|
||||
|
|
|
@ -48,15 +48,6 @@ public interface SysConfigService extends IService<SysConfig> {
|
|||
*/
|
||||
void add(SysConfigParam sysConfigParam);
|
||||
|
||||
/**
|
||||
* 编辑系统参数配置
|
||||
*
|
||||
* @param sysConfigParam 编辑参数
|
||||
* @author fengshuonan
|
||||
* @date 2020/4/14 11:15
|
||||
*/
|
||||
void edit(SysConfigParam sysConfigParam);
|
||||
|
||||
/**
|
||||
* 删除系统参数配置
|
||||
*
|
||||
|
@ -66,6 +57,15 @@ public interface SysConfigService extends IService<SysConfig> {
|
|||
*/
|
||||
void del(SysConfigParam sysConfigParam);
|
||||
|
||||
/**
|
||||
* 编辑系统参数配置
|
||||
*
|
||||
* @param sysConfigParam 编辑参数
|
||||
* @author fengshuonan
|
||||
* @date 2020/4/14 11:15
|
||||
*/
|
||||
void edit(SysConfigParam sysConfigParam);
|
||||
|
||||
/**
|
||||
* 查看系统参数配置
|
||||
*
|
||||
|
|
|
@ -48,25 +48,6 @@ public class SysConfigServiceImpl extends ServiceImpl<SysConfigMapper, SysConfig
|
|||
ConfigContext.me().putConfig(sysConfigParam.getConfigCode(), sysConfigParam.getConfigValue());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void edit(SysConfigParam sysConfigParam) {
|
||||
|
||||
// 1.根据id获取常量信息
|
||||
SysConfig sysConfig = this.querySysConfig(sysConfigParam);
|
||||
|
||||
// 2.请求参数转化为实体
|
||||
BeanUtil.copyProperties(sysConfigParam, sysConfig);
|
||||
// 不能修改状态,用修改状态接口修改状态
|
||||
sysConfig.setStatusFlag(null);
|
||||
|
||||
// 3.更新记录
|
||||
this.updateById(sysConfig);
|
||||
|
||||
// 4.更新对应常量context
|
||||
ConfigContext.me().putConfig(sysConfigParam.getConfigCode(), sysConfigParam.getConfigValue());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void del(SysConfigParam sysConfigParam) {
|
||||
|
@ -92,6 +73,25 @@ public class SysConfigServiceImpl extends ServiceImpl<SysConfigMapper, SysConfig
|
|||
ConfigContext.me().deleteConfig(sysConfigParam.getConfigCode());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void edit(SysConfigParam sysConfigParam) {
|
||||
|
||||
// 1.根据id获取常量信息
|
||||
SysConfig sysConfig = this.querySysConfig(sysConfigParam);
|
||||
|
||||
// 2.请求参数转化为实体
|
||||
BeanUtil.copyProperties(sysConfigParam, sysConfig);
|
||||
// 不能修改状态,用修改状态接口修改状态
|
||||
sysConfig.setStatusFlag(null);
|
||||
|
||||
// 3.更新记录
|
||||
this.updateById(sysConfig);
|
||||
|
||||
// 4.更新对应常量context
|
||||
ConfigContext.me().putConfig(sysConfigParam.getConfigCode(), sysConfigParam.getConfigValue());
|
||||
}
|
||||
|
||||
@Override
|
||||
public SysConfig detail(SysConfigParam sysConfigParam) {
|
||||
return this.querySysConfig(sysConfigParam);
|
||||
|
@ -148,7 +148,6 @@ public class SysConfigServiceImpl extends ServiceImpl<SysConfigMapper, SysConfig
|
|||
|
||||
// 如果分类编码不为空,则带上分类编码
|
||||
queryWrapper.eq(ObjectUtil.isNotEmpty(groupCode), SysConfig::getGroupCode, groupCode);
|
||||
|
||||
}
|
||||
|
||||
// 查询未删除的
|
||||
|
|
|
@ -79,7 +79,7 @@ public class DruidDatasourceFactory {
|
|||
try {
|
||||
dataSource.setFilters(druidProperties.getFilters());
|
||||
} catch (SQLException e) {
|
||||
log.error(">>> 数据库连接池初始化异常:{}", e.getMessage());
|
||||
log.error("数据库连接池初始化异常:{}", e.getMessage());
|
||||
}
|
||||
|
||||
return dataSource;
|
||||
|
|
|
@ -103,7 +103,7 @@ public class FlywayInitListener implements ApplicationListener<ApplicationContex
|
|||
flyway.migrate();
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error(">>> flyway初始化失败", e);
|
||||
log.error("flyway初始化失败", e);
|
||||
throw new DaoException(FlywayExceptionEnum.FLYWAY_MIGRATE_ERROR);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ public class CustomMetaObjectHandler implements MetaObjectHandler {
|
|||
|
||||
|
||||
} catch (ReflectionException e) {
|
||||
log.warn(">>> CustomMetaObjectHandler处理过程中无相关字段,不做处理");
|
||||
log.warn("CustomMetaObjectHandler处理过程中无相关字段,不做处理");
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ public class CustomMetaObjectHandler implements MetaObjectHandler {
|
|||
setFieldValByName(UPDATE_TIME, new Date(), metaObject);
|
||||
|
||||
} catch (ReflectionException e) {
|
||||
log.warn(">>> CustomMetaObjectHandler处理过程中无相关字段,不做处理");
|
||||
log.warn("CustomMetaObjectHandler处理过程中无相关字段,不做处理");
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -72,4 +72,4 @@ public class CustomMetaObjectHandler implements MetaObjectHandler {
|
|||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -51,16 +51,16 @@ public class MultiSourceExchangeAop implements Ordered {
|
|||
// 如果有DataSource注解,则设置DataSourceContextHolder为注解上的名称
|
||||
if (datasource != null) {
|
||||
CurrentDataSourceContext.setDataSourceName(datasource.name());
|
||||
log.debug(">>> 设置数据源为:" + datasource.name());
|
||||
log.debug("设置数据源为:" + datasource.name());
|
||||
} else {
|
||||
CurrentDataSourceContext.setDataSourceName(MASTER_DATASOURCE_NAME);
|
||||
log.debug(">>> 设置数据源为:dataSourceCurrent");
|
||||
log.debug("设置数据源为:dataSourceCurrent");
|
||||
}
|
||||
|
||||
try {
|
||||
return point.proceed();
|
||||
} finally {
|
||||
log.debug(">>> 清空数据源信息!");
|
||||
log.debug("清空数据源信息!");
|
||||
CurrentDataSourceContext.clearDataSourceName();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -70,7 +70,7 @@ public class DataSourceInitListener implements ApplicationListener<ApplicationCo
|
|||
try {
|
||||
DataSourceContext.initDataSource(druidProperties, druidDataSource);
|
||||
} catch (Exception exception) {
|
||||
log.error(">>> 初始化数据源容器错误!", exception);
|
||||
log.error("初始化数据源容器错误!", exception);
|
||||
String userTip = StrUtil.format(INIT_DATASOURCE_CONTAINER_ERROR.getUserTip(), exception.getMessage());
|
||||
throw new DatasourceContainerException(INIT_DATASOURCE_CONTAINER_ERROR, userTip);
|
||||
}
|
||||
|
|
|
@ -59,7 +59,7 @@ public class DataBaseInfoPersistence {
|
|||
return dataSourceList;
|
||||
|
||||
} catch (Exception exception) {
|
||||
log.error(">>> 查询数据源信息错误!", exception);
|
||||
log.error("查询数据源信息错误!", exception);
|
||||
String userTip = StrUtil.format(QUERY_DBS_DAO_ERROR.getUserTip(), exception.getMessage());
|
||||
throw new DatasourceContainerException(QUERY_DBS_DAO_ERROR, userTip);
|
||||
}
|
||||
|
@ -89,9 +89,9 @@ public class DataBaseInfoPersistence {
|
|||
preparedStatement.setString(8, DateUtil.formatDateTime(new Date()));
|
||||
|
||||
int i = preparedStatement.executeUpdate();
|
||||
log.info(">>> 初始化master的databaseInfo信息!初始化" + i + "条!");
|
||||
log.info("初始化master的databaseInfo信息!初始化" + i + "条!");
|
||||
} catch (Exception exception) {
|
||||
log.error(">>> 初始化master的databaseInfo信息错误!", exception);
|
||||
log.error("初始化master的databaseInfo信息错误!", exception);
|
||||
String userTip = StrUtil.format(INSERT_DBS_DAO_ERROR.getUserTip(), exception.getMessage());
|
||||
throw new DatasourceContainerException(INSERT_DBS_DAO_ERROR, userTip);
|
||||
}
|
||||
|
@ -112,9 +112,9 @@ public class DataBaseInfoPersistence {
|
|||
PreparedStatement preparedStatement = conn.prepareStatement(new DeleteDatabaseInfoSql().getSql(druidProperties.getUrl()));
|
||||
preparedStatement.setString(1, MASTER_DATASOURCE_NAME);
|
||||
int i = preparedStatement.executeUpdate();
|
||||
log.info(">>> 删除master的databaseInfo信息!删除" + i + "条!");
|
||||
log.info("删除master的databaseInfo信息!删除" + i + "条!");
|
||||
} catch (Exception exception) {
|
||||
log.info(">>> 删除master的databaseInfo信息失败!", exception);
|
||||
log.info("删除master的databaseInfo信息失败!", exception);
|
||||
String userTip = StrUtil.format(DELETE_DBS_DAO_ERROR.getUserTip(), exception.getMessage());
|
||||
throw new DatasourceContainerException(DELETE_DBS_DAO_ERROR, userTip);
|
||||
}
|
||||
|
@ -139,7 +139,7 @@ public class DataBaseInfoPersistence {
|
|||
druidProperties.setUsername(resultSet.getString("username"));
|
||||
druidProperties.setPassword(resultSet.getString("password"));
|
||||
} catch (SQLException exception) {
|
||||
log.info(">>> 根据数据库查询结果,创建DruidProperties失败!", exception);
|
||||
log.info("根据数据库查询结果,创建DruidProperties失败!", exception);
|
||||
String userTip = StrUtil.format(CREATE_PROP_DAO_ERROR.getUserTip(), exception.getMessage());
|
||||
throw new DatasourceContainerException(CREATE_PROP_DAO_ERROR, userTip);
|
||||
}
|
||||
|
|
|
@ -82,7 +82,7 @@ public class SysFileInfoServiceImpl extends ServiceImpl<SysFileInfoMapper, SysFi
|
|||
try {
|
||||
fileBytes = fileOperatorApi.getFileBytes(DEFAULT_BUCKET_NAME, sysFileInfo.getFileObjectName());
|
||||
} catch (Exception e) {
|
||||
log.error(">>> 获取文件流异常,具体信息为:{}", e.getMessage());
|
||||
log.error("获取文件流异常,具体信息为:{}", e.getMessage());
|
||||
throw new FileException(FileExceptionEnum.FILE_STREAM_ERROR);
|
||||
}
|
||||
|
||||
|
@ -221,7 +221,7 @@ public class SysFileInfoServiceImpl extends ServiceImpl<SysFileInfoMapper, SysFi
|
|||
// 下载文件
|
||||
DownloadUtil.download(DateUtil.now() + "-打包下载" + FILE_POSTFIX_SEPARATOR + "zip", bos.toByteArray(), response);
|
||||
} catch (Exception e) {
|
||||
log.error(">>> 获取文件流异常,具体信息为:{}", e.getMessage());
|
||||
log.error("获取文件流异常,具体信息为:{}", e.getMessage());
|
||||
throw new FileException(FileExceptionEnum.FILE_STREAM_ERROR);
|
||||
} finally {
|
||||
try {
|
||||
|
@ -229,7 +229,7 @@ public class SysFileInfoServiceImpl extends ServiceImpl<SysFileInfoMapper, SysFi
|
|||
zip.close();
|
||||
bos.close();
|
||||
} catch (IOException e) {
|
||||
log.error(">>> 关闭数据流失败,具体信息为:{}", e.getMessage());
|
||||
log.error("关闭数据流失败,具体信息为:{}", e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -328,7 +328,7 @@ public class SysFileInfoServiceImpl extends ServiceImpl<SysFileInfoMapper, SysFi
|
|||
try {
|
||||
fileBytes = fileOperatorApi.getFileBytes(sysFileInfoRequest.getFileBucket(), sysFileInfoRequest.getFileObjectName());
|
||||
} catch (Exception e) {
|
||||
log.error(">>> 获取文件流异常,具体信息为:{}", e.getMessage());
|
||||
log.error("获取文件流异常,具体信息为:{}", e.getMessage());
|
||||
throw new FileException(FileExceptionEnum.FILE_STREAM_ERROR);
|
||||
}
|
||||
|
||||
|
|
|
@ -90,7 +90,7 @@ public class SysSmsInfoServiceImpl extends ServiceImpl<SysSmsMapper, SysSms> imp
|
|||
// 4. 存储短信到数据库
|
||||
Long smsId = this.saveSmsInfo(sysSmsSendParam, validateCode);
|
||||
|
||||
log.info(">>> 开始发送短信:发送的电话号码= " + sysSmsSendParam.getPhone() + ",发送的模板号=" + sysSmsSendParam.getTemplateCode() + ",发送的参数是:" + JSON.toJSONString(params));
|
||||
log.info("开始发送短信:发送的电话号码= " + sysSmsSendParam.getPhone() + ",发送的模板号=" + sysSmsSendParam.getTemplateCode() + ",发送的参数是:" + JSON.toJSONString(params));
|
||||
|
||||
// 5. 发送短信
|
||||
smsSenderApi.sendSms(sysSmsSendParam.getPhone(), sysSmsSendParam.getTemplateCode(), params);
|
||||
|
@ -123,7 +123,7 @@ public class SysSmsInfoServiceImpl extends ServiceImpl<SysSmsMapper, SysSms> imp
|
|||
|
||||
this.save(sysSms);
|
||||
|
||||
log.info(">>> 发送短信,存储短信到数据库,数据为:" + JSON.toJSONString(sysSms));
|
||||
log.info("发送短信,存储短信到数据库,数据为:" + JSON.toJSONString(sysSms));
|
||||
|
||||
return sysSms.getSmsId();
|
||||
}
|
||||
|
@ -148,7 +148,7 @@ public class SysSmsInfoServiceImpl extends ServiceImpl<SysSmsMapper, SysSms> imp
|
|||
|
||||
List<SysSms> sysSmsList = this.list(smsQueryWrapper);
|
||||
|
||||
log.info(">>> 验证短信Provider接口,查询到sms记录:" + JSON.toJSONString(sysSmsList));
|
||||
log.info("验证短信Provider接口,查询到sms记录:" + JSON.toJSONString(sysSmsList));
|
||||
|
||||
// 如果找不到记录,提示验证失败
|
||||
if (ObjectUtil.isEmpty(sysSmsList)) {
|
||||
|
|
|
@ -68,7 +68,7 @@ public class HutoolTimerExeServiceImpl implements TimerExeService {
|
|||
TimerAction timerAction = (TimerAction) SpringUtil.getBean(Class.forName(className));
|
||||
timerAction.action();
|
||||
} catch (ClassNotFoundException e) {
|
||||
log.error(">>> 任务执行异常:{}", e.getMessage());
|
||||
log.error("任务执行异常:{}", e.getMessage());
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue