Skip to content

Commit

Permalink
#408 支持按照前缀查找systemconfig
Browse files Browse the repository at this point in the history
  • Loading branch information
kfchu committed Apr 21, 2018
1 parent d5dd6b0 commit 8fa209b
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ public interface SystemConfigRepository {

List<SystemConfig> selectByLastly();

List<SystemConfig> selectByPropertyPrefix(String prefix);

Integer insert(SystemConfig systemConfig);

Integer updateById(SystemConfig systemConfig);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ public interface SystemConfig4SqlService {

List<SystemConfig> selectByLastly();

List<SystemConfig> selectByPropertyPrefix(String prefix);

Integer insert(SystemConfig systemConfig);

Integer updateById(SystemConfig systemConfig);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ public List<SystemConfig> selectByLastly() {
return systemConfigRepository.selectByLastly();
}

@Transactional
@Override
public List<SystemConfig> selectByPropertyPrefix(String prefix) {
return systemConfigRepository.selectByPropertyPrefix(prefix);
}

@Transactional
@Override
public Integer insert(SystemConfig systemConfig) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ public interface SystemConfigService {

List<SystemConfig> getSystemConfigsDirectly(List<String> properties) throws SaturnJobConsoleException;

List<SystemConfig> getSystemConfigsByPrefix(String prefix) throws SaturnJobConsoleException;

String getPropertiesCached() throws SaturnJobConsoleException;

Integer insertOrUpdate(SystemConfig systemConfig) throws SaturnJobConsoleException;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.vip.saturn.job.console.service.impl;

import com.google.common.collect.Lists;
import com.vip.saturn.job.console.exception.SaturnJobConsoleException;
import com.vip.saturn.job.console.mybatis.entity.SystemConfig;
import com.vip.saturn.job.console.mybatis.service.SystemConfig4SqlService;
Expand All @@ -18,6 +19,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;

/**
* @author xiaopeng.he
Expand Down Expand Up @@ -130,6 +132,16 @@ public List<SystemConfig> getSystemConfigsDirectly(List<String> properties) thro
: systemConfig4SqlService.selectByLastly();
}

@Override
public List<SystemConfig> getSystemConfigsByPrefix(String prefix) throws SaturnJobConsoleException {
if (StringUtils.isEmpty(prefix)) {
return Lists.newArrayList();
}

return systemConfig4SqlService.selectByPropertyPrefix(prefix);
}


@Override
public String getPropertiesCached() throws SaturnJobConsoleException {
StringBuilder sb = new StringBuilder(100);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@
where id in
(select max(id) from sys_config group by property)
</select>
<select id="selectByPropertyPrefix" resultMap="BaseResultMap" parameterType="java.lang.String">
select
<include refid="Base_Column_List"/>
from sys_config
where property like
concat(#{prefix, jdbcType=VARCHAR},'%')
</select>
<insert id="insert" parameterType="com.vip.saturn.job.console.mybatis.entity.SystemConfig">
insert into sys_config(property, value) values(#{property,jdbcType=VARCHAR}, #{value,jdbcType=VARCHAR})
</insert>
Expand Down

0 comments on commit 8fa209b

Please sign in to comment.