作者 王勇

ES相关接口,基本完善

... ... @@ -102,10 +102,23 @@ management:
shutdown:
enabled: true
es:
hostname: 192.168.37.139
port: 9200
scheme: http
elasticsearch:
# http连接超时时间
connectTimeout: 3000
# socket连接超时时间
socketTimeout: 60000
# 获取连接的超时时间,
connectionRequestTimeout: 3000
# 最大连接数
maxConnTotal: 3000
# 最大路由连接数
maxConnPerRoute: 3000
# 任务最长可执行时间 (单位:小时)
executeTimeout: 10
# 链接凭证:用户名
username: admin
# 链接凭证:密码
password: 123456
# 基础信息配置
info:
... ...
... ... @@ -132,6 +132,12 @@
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.73</version>
... ... @@ -177,11 +183,11 @@
<version>1.6.1</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<!-- <dependency>-->
<!-- <groupId>org.springframework.boot</groupId>-->
<!-- <artifactId>spring-boot-starter-test</artifactId>-->
<!-- <scope>test</scope>-->
<!-- </dependency>-->
<!-- tools end -->
</dependencies>
... ...
package com.sunyo.wlpt.message.bus.service.config;
import com.sunyo.wlpt.message.bus.service.domain.es.ElasticSearchInfo;
import com.sunyo.wlpt.message.bus.service.domain.es.ElasticSearchProperties;
import com.sunyo.wlpt.message.bus.service.service.ElasticSearchInfoService;
import lombok.RequiredArgsConstructor;
import org.apache.http.HttpHost;
import org.apache.http.auth.AuthScope;
import org.apache.http.auth.UsernamePasswordCredentials;
import org.apache.http.client.CredentialsProvider;
import org.apache.http.impl.client.BasicCredentialsProvider;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestClientBuilder;
import org.elasticsearch.client.RestHighLevelClient;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.elasticsearch.config.AbstractElasticsearchConfiguration;
import org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate;
import javax.annotation.Resource;
import java.util.List;
/**
* @author 子诚
* Description:ES的配置文件
* 时间:2020/8/5 10:23
*/
@RequiredArgsConstructor(onConstructor_ = @Autowired)
@Configuration
public class ElasticSearchConfig extends AbstractElasticsearchConfiguration {
@Value("${es.hostname}")
private String hostname;
@Resource
private ElasticSearchInfoService elasticSearchInfoService;
@Value("${es.port}")
private Integer port;
private final ElasticSearchProperties elasticSearchProperties;
@Value("${es.scheme}")
private String scheme;
/**
* 获取ES集群信息
*
* @return ES集群信息
*/
public HttpHost[] getHttpHosts()
{
List<ElasticSearchInfo> elasticSearchInfos = elasticSearchInfoService.selectList();
int size = elasticSearchInfos.size();
HttpHost[] httpHosts = new HttpHost[size];
for (int i = 0; i < size; i++) {
String hostname = elasticSearchInfos.get(i).getHostname();
Integer port = elasticSearchInfos.get(i).getPort();
String scheme = elasticSearchInfos.get(i).getScheme();
httpHosts[i] = new HttpHost(hostname, port, scheme);
}
return httpHosts;
}
@Override
@Bean
public RestHighLevelClient elasticsearchClient()
{
RestHighLevelClient client = new RestHighLevelClient(
RestClient.builder(
// 天生契合集群,有几个es环境,就 new HttpHost 几个,用,相隔
new HttpHost(hostname, port, scheme)
)
);
final CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
credentialsProvider.setCredentials(AuthScope.ANY, new UsernamePasswordCredentials(
elasticSearchProperties.getUsername(), elasticSearchProperties.getPassword()
));
RestClientBuilder builder = RestClient.builder(getHttpHosts());
// 异步的请求配置
builder.setRequestConfigCallback(builder1 -> {
// 连接超时时间 默认-1
builder1.setConnectTimeout(elasticSearchProperties.getConnectTimeout());
builder1.setSocketTimeout(elasticSearchProperties.getSocketTimeout());
// 获取连接的超时时间 默认-1
builder1.setConnectionRequestTimeout(elasticSearchProperties.getConnectionRequestTimeout());
return builder1;
});
// 异步的httpclient连接数配置
builder.setHttpClientConfigCallback(httpAsyncClientBuilder -> {
// 最大连接数
httpAsyncClientBuilder.setMaxConnTotal(elasticSearchProperties.getMaxConnTotal());
// 最大路由连接数
httpAsyncClientBuilder.setMaxConnPerRoute(elasticSearchProperties.getMaxConnPerRoute());
// 赋予连接凭证
httpAsyncClientBuilder.setDefaultCredentialsProvider(credentialsProvider);
return httpAsyncClientBuilder;
});
RestHighLevelClient client = new RestHighLevelClient(builder);
return client;
}
... ...
package com.sunyo.wlpt.message.bus.service.controller.es;
import com.sunyo.wlpt.message.bus.service.domain.es.ElasticSearchInfo;
import com.sunyo.wlpt.message.bus.service.response.ResultJson;
import com.sunyo.wlpt.message.bus.service.service.ElasticSearchInfoService;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
/**
* @author 子诚
* Description:
* 时间:2020/9/10 17:09
*/
@CrossOrigin
@RequestMapping("bus/es")
@RestController
public class ElasticSearchInfoController {
@Resource
private ElasticSearchInfoService elasticSearchInfoService;
/**
* 分页查询,ES信息列表
*
* @param clusterName 集群名称
* @param elasticsearchName ES节点名称
* @param elasticsearchState ES状态
* @param pageNum 当前页数
* @param pageSize 每页大小
* @return
*/
@GetMapping("/page")
public ResultJson selectBusServerList(
@RequestParam(value = "clusterName", required = false) String clusterName,
@RequestParam(value = "elasticsearchName", required = false) String elasticsearchName,
@RequestParam(value = "elasticsearchState", required = false) Boolean elasticsearchState,
@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
@RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize)
{
// 获取查询参数
ElasticSearchInfo elasticSearchInfo = ElasticSearchInfo.builder()
.clusterName(clusterName).elasticsearchName(elasticsearchName).elasticsearchState(elasticsearchState)
.build();
// 分页查询
return elasticSearchInfoService.selectListByPage(elasticSearchInfo, pageNum, pageSize);
}
/**
* 删除ES信息
*
* @return {@link ResultJson}
*/
@DeleteMapping("/delete")
public ResultJson deleteElasticSearchInfo(@RequestBody ElasticSearchInfo elasticSearchInfo)
{
return elasticSearchInfoService.deleteByPrimaryKey(elasticSearchInfo.getId());
}
/**
* 批量删除ES信息
*
* @param elasticSearchInfo {@link ResultJson} ES信息实体类
* @return
*/
@DeleteMapping("/batchRemove")
public ResultJson batchRemoveElasticSearchInfo(@RequestBody ElasticSearchInfo elasticSearchInfo)
{
String id = elasticSearchInfo.getId();
return id.contains(",")
? elasticSearchInfoService.batchRemoveByIds(id)
: elasticSearchInfoService.deleteByPrimaryKey(id);
}
@PostMapping("/insert")
public ResultJson insertElasticSearchInfo(@RequestBody ElasticSearchInfo elasticSearchInfo)
{
return elasticSearchInfoService.insertSelective(elasticSearchInfo);
}
@PutMapping("/update")
public ResultJson editElasticSearchInfo(@RequestBody ElasticSearchInfo elasticSearchInfo)
{
return elasticSearchInfoService.updateByPrimaryKeySelective(elasticSearchInfo);
}
}
... ...
package com.sunyo.wlpt.message.bus.service.domain.es;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.util.Date;
/**
* @author 子诚
* Description:ES服务器信息表,控制ES集群的详细信息
* 时间:2020/9/10 17:53
*/
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class ElasticSearchInfo implements Serializable {
private static final long serialVersionUID = 379812159019579949L;
/**
* ES服务器ID
*/
private String id;
/**
* 集群名称
*/
private String clusterName;
/**
* ES服务器名称
*/
private String elasticsearchName;
/**
* ES服务器IP地址
*/
private String hostname;
/**
* ES服务器端口号
*/
private Integer port;
/**
* scheme协议,默认(必须是http)
*/
private String scheme;
/**
* 默认(即创建时),是否是主节点?
*/
private Boolean isMaster;
/**
* ES状态,运行,还是宕机?
*/
private Boolean elasticsearchState;
/**
* ES服务器相关描述
*/
private String description;
/**
* ES服务器创建时间
*/
private Date gmtCreate;
/**
* ES服务器修改时间
*/
private Date gmtModified;
}
\ No newline at end of file
... ...
package com.sunyo.wlpt.message.bus.service.domain.es;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
/**
* @author 子诚
* Description:ES中使用的http连接的设置
* 时间:2020/9/9 17:42
*/
@Data
@ConfigurationProperties(prefix = "elasticsearch")
@Configuration
public class ElasticSearchProperties {
/**
* http连接超时时间
*/
private Integer connectTimeout;
/**
* socket连接超时时间
*/
private Integer socketTimeout;
/**
* 获取连接的超时时间
*/
private Integer connectionRequestTimeout;
/**
* 最大连接数
*/
private Integer maxConnTotal;
/**
* 最大路由连接数
*/
private Integer maxConnPerRoute;
/**
* 任务最长可执行时间 (单位:小时)
*/
private Integer executeTimeout;
/**
* 链接凭证:用户名
*/
private String username;
/**
* 链接凭证:密码
*/
private String password;
}
... ...
package com.sunyo.wlpt.message.bus.service.mapper;
import com.sunyo.wlpt.message.bus.service.domain.es.ElasticSearchInfo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* @author 子诚
* Description:
* 时间:2020/9/10 17:53
*/
@Mapper
public interface ElasticSearchInfoMapper {
/**
* delete by primary key
*
* @param id primaryKey
* @return deleteCount
*/
int deleteByPrimaryKey(String id);
/**
* insert record to table
*
* @param record the record
* @return insert count
*/
int insert(ElasticSearchInfo record);
/**
* insert record to table selective
*
* @param record the record
* @return insert count
*/
int insertSelective(ElasticSearchInfo record);
/**
* select by primary key
*
* @param id primary key
* @return object by primary key
*/
ElasticSearchInfo selectByPrimaryKey(String id);
/**
* update record selective
*
* @param record the updated record
* @return update count
*/
int updateByPrimaryKeySelective(ElasticSearchInfo record);
/**
* update record
*
* @param record the updated record
* @return update count
*/
int updateByPrimaryKey(ElasticSearchInfo record);
/**
* 查询所有ES信息,配置中使用
*
* @return 所有ES信息
*/
List<ElasticSearchInfo> selectList();
/**
* 分页查询,ES列表
*
* @param elasticSearchInfo {@link ElasticSearchInfo}
* @return
*/
List<ElasticSearchInfo> selectListByPage(ElasticSearchInfo elasticSearchInfo);
/**
* 批量删除
*
* @param idList id数组
* @return
*/
int batchRemoveByIds(String[] idList);
/**
* 根据ES名称(节点名称)查询ES信息
*
* @return
*/
List<ElasticSearchInfo> selectListByElasticsearchName(@Param("elasticsearchName") String elasticsearchName);
/**
* 根据Url,校验
*
* @param hostname ip地址
* @param port 端口号
* @param scheme 协议(http)
* @return
*/
List<ElasticSearchInfo> selectByUrl(@Param("hostname") String hostname, @Param("port") Integer port, @Param("scheme") String scheme);
}
\ No newline at end of file
... ...
package com.sunyo.wlpt.message.bus.service.service;
import com.sunyo.wlpt.message.bus.service.domain.es.ElasticSearchInfo;
import com.sunyo.wlpt.message.bus.service.response.ResultJson;
import java.util.List;
/**
* @author 子诚
* Description:
* 时间:2020/9/8 15:49
*/
public interface ElasticSearchInfoService {
/**
* delete by primary key
*
* @param id primaryKey
* @return deleteCount
*/
ResultJson deleteByPrimaryKey(String id);
/**
* insert record to table
*
* @param record the record
* @return insert count
*/
int insert(ElasticSearchInfo record);
/**
* insert record to table selective
*
* @param record the record
* @return insert count
*/
ResultJson insertSelective(ElasticSearchInfo record);
/**
* select by primary key
*
* @param id primary key
* @return object by primary key
*/
ElasticSearchInfo selectByPrimaryKey(String id);
/**
* update record selective
*
* @param record the updated record
* @return update count
*/
ResultJson updateByPrimaryKeySelective(ElasticSearchInfo record);
/**
* update record
*
* @param record the updated record
* @return update count
*/
int updateByPrimaryKey(ElasticSearchInfo record);
/**
* 查询所有ES信息
*
* @return 所有ES信息
*/
List<ElasticSearchInfo> selectList();
/**
* 分页查询,ES列表
*
* @param elasticSearchInfo {@link ElasticSearchInfo}
* @param pageNum 当前页数
* @param pageSize 每页大小
* @return
*/
ResultJson selectListByPage(ElasticSearchInfo elasticSearchInfo, Integer pageNum, Integer pageSize);
/**
* 批量删除ES信息
*
* @param ids id以,相连接的字符串
* @return
*/
ResultJson batchRemoveByIds(String ids);
}
... ...
package com.sunyo.wlpt.message.bus.service.service.impl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.sunyo.wlpt.message.bus.service.domain.es.ElasticSearchInfo;
import com.sunyo.wlpt.message.bus.service.mapper.ElasticSearchInfoMapper;
import com.sunyo.wlpt.message.bus.service.response.ResultJson;
import com.sunyo.wlpt.message.bus.service.service.ElasticSearchInfoService;
import com.sunyo.wlpt.message.bus.service.utils.IdUtils;
import io.netty.util.internal.StringUtil;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
import static com.sunyo.wlpt.message.bus.service.common.Constant.RESULT_SUCCESS;
/**
* @author 子诚
* Description:
* 时间:2020/9/8 15:49
*/
@Service
public class ElasticSearchInfoServiceImpl implements ElasticSearchInfoService {
@Resource
private ElasticSearchInfoMapper elasticSearchInfoMapper;
@Override
public ResultJson deleteByPrimaryKey(String id)
{
return elasticSearchInfoMapper.deleteByPrimaryKey(id) > 0
? new ResultJson<>("200", "删除ES信息,成功")
: new ResultJson<>("500", "删除ES信息,失败");
}
@Override
public ResultJson batchRemoveByIds(String ids)
{
String[] idList = ids.split(",");
return elasticSearchInfoMapper.batchRemoveByIds(idList) > 0
? new ResultJson<>("200", "批量删除ES信息,成功")
: new ResultJson<>("500", "批量删除ES信息,失败");
}
@Override
public int insert(ElasticSearchInfo record)
{
return elasticSearchInfoMapper.insert(record);
}
@Override
public ResultJson insertSelective(ElasticSearchInfo record)
{
ResultJson validate = validate(record);
if (!RESULT_SUCCESS.equals(validate.getCode())) {
return validate;
}
record.setId(IdUtils.generateId());
return elasticSearchInfoMapper.insertSelective(record) > 0
? new ResultJson<>("200", "新增ES信息,成功")
: new ResultJson<>("500", "新增ES信息,失败");
}
@Override
public ElasticSearchInfo selectByPrimaryKey(String id)
{
return elasticSearchInfoMapper.selectByPrimaryKey(id);
}
@Override
public ResultJson updateByPrimaryKeySelective(ElasticSearchInfo record)
{
ResultJson validate = validate(record);
if (!RESULT_SUCCESS.equals(validate.getCode())) {
return validate;
}
return elasticSearchInfoMapper.updateByPrimaryKeySelective(record) > 0
? new ResultJson<>("200", "编辑ES信息,成功")
: new ResultJson<>("500", "编辑ES信息,失败");
}
@Override
public int updateByPrimaryKey(ElasticSearchInfo record)
{
return elasticSearchInfoMapper.updateByPrimaryKey(record);
}
@Override
public List<ElasticSearchInfo> selectList()
{
return elasticSearchInfoMapper.selectList();
}
/**
* 分页查询
*
* @param elasticSearchInfo {@link ElasticSearchInfo}
* @param pageNum 当前页数
* @param pageSize 每页大小
* @return
*/
@Override
public ResultJson selectListByPage(ElasticSearchInfo elasticSearchInfo, Integer pageNum, Integer pageSize)
{
PageHelper.startPage(pageNum, pageSize);
List<ElasticSearchInfo> elasticSearchInfos = elasticSearchInfoMapper.selectListByPage(elasticSearchInfo);
PageInfo<ElasticSearchInfo> pageInfo = new PageInfo<>(elasticSearchInfos);
return pageInfo.getTotal() > 0
? new ResultJson<>("200", "查询ES服务器列表,成功!", pageInfo)
: new ResultJson<>("500", "查询ES服务器列表,失败!");
}
/**
* 校验规则,增加,修改时
*
* @param elasticSearchInfo {@link ResultJson} ES信息实体类
* @return
*/
public ResultJson validate(ElasticSearchInfo elasticSearchInfo)
{
String clusterName = elasticSearchInfo.getClusterName();
String elasticsearchName = elasticSearchInfo.getElasticsearchName();
String hostname = elasticSearchInfo.getHostname();
Integer port = elasticSearchInfo.getPort();
String scheme = elasticSearchInfo.getScheme();
if (StringUtil.isNullOrEmpty(clusterName)
|| StringUtil.isNullOrEmpty(elasticsearchName)
|| StringUtil.isNullOrEmpty(hostname)
|| StringUtil.isNullOrEmpty(scheme)
|| port == null
) {
return new ResultJson<>("400", "集群名称、节点名称、Ip地址、端口号或协议,不存在");
}
String id = elasticSearchInfo.getId();
return StringUtil.isNullOrEmpty(id)
// 新增ES信息
? validateInsert(elasticsearchName, hostname, port, scheme)
// 编辑ES信息
: validateEdit(id, elasticsearchName, hostname, port, scheme);
}
/**
* 编辑ES信息方法的校验
* <p>
* 判断Id,是否真实存在
* <p>
* 判断ES名称,即节点名称,是否已存在
* <p>
* 判断url信息是否已存在,即 scheme://hostname:port
*
* @param id id
* @param elasticsearchName ES名称,即节点名称
* @param hostname IP地址
* @param port 端口号
* @param scheme 协议
* @return 校验通过与否
*/
private ResultJson validateEdit(String id, String elasticsearchName, String hostname, Integer port, String scheme)
{
ElasticSearchInfo oldInfo = elasticSearchInfoMapper.selectByPrimaryKey(id);
if (oldInfo == null) {
return new ResultJson<>("400", "该ES信息不存在");
}
if (!elasticsearchName.equals(oldInfo.getElasticsearchName())) {
if (elasticSearchInfoMapper.selectListByElasticsearchName(elasticsearchName).size() > 0) {
return new ResultJson<>("400", "节点名称(ES名称),已存在");
}
}
if (hostname.equals(oldInfo.getHostname()) && port.equals(oldInfo.getPort()) && scheme.equals(oldInfo.getScheme())) {
return ResultJson.success("编辑ES信息,通过检验!");
}
return elasticSearchInfoMapper.selectByUrl(hostname, port, scheme).size() > 0
? new ResultJson<>("500", "该ES详细信息,已存在")
: ResultJson.success("编辑ES信息,通过检验!");
}
/**
* 新增ES信息方法的校验
* <p>
* 判断ES名称,即节点名称,是否已存在
* <p>
* 判断url信息是否已存在,即 scheme://hostname:port
*
* @param elasticsearchName ES名称,即节点名称
* @param hostname IP地址
* @param port 端口号
* @param scheme 协议
* @return 校验通过与否
*/
private ResultJson validateInsert(String elasticsearchName, String hostname, Integer port, String scheme)
{
if (elasticSearchInfoMapper.selectListByElasticsearchName(elasticsearchName).size() > 0) {
return new ResultJson<>("400", "节点名称(ES名称),已存在");
}
return elasticSearchInfoMapper.selectByUrl(hostname, port, scheme).size() > 0
? new ResultJson<>("500", "该ES详细信息,已存在")
: ResultJson.success("新增ES信息,通过检验!");
}
}
... ...
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.sunyo.wlpt.message.bus.service.mapper.ElasticSearchInfoMapper">
<resultMap id="BaseResultMap" type="com.sunyo.wlpt.message.bus.service.domain.es.ElasticSearchInfo">
<!--@mbg.generated-->
<!--@Table elastic_search_info-->
<id column="id" jdbcType="VARCHAR" property="id"/>
<result column="cluster_name" jdbcType="VARCHAR" property="clusterName"/>
<result column="elasticsearch_name" jdbcType="VARCHAR" property="elasticsearchName"/>
<result column="hostname" jdbcType="VARCHAR" property="hostname"/>
<result column="port" jdbcType="INTEGER" property="port"/>
<result column="scheme" jdbcType="VARCHAR" property="scheme"/>
<result column="is_master" jdbcType="BOOLEAN" property="isMaster"/>
<result column="elasticsearch_state" jdbcType="BOOLEAN" property="elasticsearchState"/>
<result column="description" jdbcType="VARCHAR" property="description"/>
<result column="gmt_create" jdbcType="TIMESTAMP" property="gmtCreate"/>
<result column="gmt_modified" jdbcType="TIMESTAMP" property="gmtModified"/>
</resultMap>
<sql id="Base_Column_List">
<!--@mbg.generated-->
id, cluster_name, elasticsearch_name, hostname, port, scheme, is_master, elasticsearch_state,
description, gmt_create, gmt_modified
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
<!--@mbg.generated-->
select
<include refid="Base_Column_List"/>
from elastic_search_info
where id = #{id,jdbcType=VARCHAR}
</select>
<!-- 分页查询, -->
<select id="selectListByPage" parameterType="com.sunyo.wlpt.message.bus.service.domain.es.ElasticSearchInfo"
resultMap="BaseResultMap">
<!--@mbg.generated-->
select
<include refid="Base_Column_List"/>
from elastic_search_info
<where>
<if test="clusterName != null and clusterName != ''">
cluster_name = #{clusterName,jdbcType=VARCHAR}
</if>
<if test="elasticsearchName != null and elasticsearchName != ''">
and elasticsearch_name = #{elasticsearchName,jdbcType=VARCHAR}
</if>
<if test="elasticsearchState != null and elasticsearchState != ''">
and elasticsearch_state = #{elasticsearchState,jdbcType=BOOLEAN}
</if>
</where>
</select>
<!-- 查询ES的所有列表 -->
<select id="selectList" resultMap="BaseResultMap">
<!--@mbg.generated-->
select
<include refid="Base_Column_List"/>
from elastic_search_info
</select>
<!-- 根据ES名称(即节点名称)查询 -->
<select id="selectListByElasticsearchName" parameterType="java.lang.String" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from elastic_search_info
where elasticsearch_name = #{elasticsearchName,jdbcType=VARCHAR}
</select>
<!-- 根据Url信息查询 -->
<select id="selectByUrl" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from elastic_search_info
where hostname = #{hostname,jdbcType=VARCHAR}
and scheme = #{scheme,jdbcType=VARCHAR}
and port = #{port,jdbcType=INTEGER}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.String">
<!--@mbg.generated-->
delete
from elastic_search_info
where id = #{id,jdbcType=VARCHAR}
</delete>
<delete id="batchRemoveByIds" parameterType="java.lang.String">
<!--@mbg.generated-->
delete
from elastic_search_info
where id in
<foreach collection="array" open="(" close=")" separator="," item="id">
#{id}
</foreach>
</delete>
<insert id="insert" parameterType="com.sunyo.wlpt.message.bus.service.domain.es.ElasticSearchInfo">
<!--@mbg.generated-->
insert into elastic_search_info (id, cluster_name, elasticsearch_name,
hostname, port, scheme,
is_master, elasticsearch_state, description,
gmt_create, gmt_modified)
values (#{id,jdbcType=VARCHAR}, #{clusterName,jdbcType=VARCHAR}, #{elasticsearchName,jdbcType=VARCHAR},
#{hostname,jdbcType=VARCHAR}, #{port,jdbcType=INTEGER}, #{scheme,jdbcType=VARCHAR},
#{isMaster,jdbcType=BOOLEAN}, #{elasticsearchState,jdbcType=BOOLEAN}, #{description,jdbcType=VARCHAR},
#{gmtCreate,jdbcType=TIMESTAMP}, #{gmtModified,jdbcType=TIMESTAMP})
</insert>
<insert id="insertSelective" parameterType="com.sunyo.wlpt.message.bus.service.domain.es.ElasticSearchInfo">
<!--@mbg.generated-->
insert into elastic_search_info
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="clusterName != null">
cluster_name,
</if>
<if test="elasticsearchName != null">
elasticsearch_name,
</if>
<if test="hostname != null">
hostname,
</if>
<if test="port != null">
port,
</if>
<if test="scheme != null">
scheme,
</if>
<if test="isMaster != null">
is_master,
</if>
<if test="elasticsearchState != null">
elasticsearch_state,
</if>
<if test="description != null">
description,
</if>
<if test="gmtCreate != null">
gmt_create,
</if>
<if test="gmtModified != null">
gmt_modified,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=VARCHAR},
</if>
<if test="clusterName != null">
#{clusterName,jdbcType=VARCHAR},
</if>
<if test="elasticsearchName != null">
#{elasticsearchName,jdbcType=VARCHAR},
</if>
<if test="hostname != null">
#{hostname,jdbcType=VARCHAR},
</if>
<if test="port != null">
#{port,jdbcType=INTEGER},
</if>
<if test="scheme != null">
#{scheme,jdbcType=VARCHAR},
</if>
<if test="isMaster != null">
#{isMaster,jdbcType=BOOLEAN},
</if>
<if test="elasticsearchState != null">
#{elasticsearchState,jdbcType=BOOLEAN},
</if>
<if test="description != null">
#{description,jdbcType=VARCHAR},
</if>
<if test="gmtCreate != null">
#{gmtCreate,jdbcType=TIMESTAMP},
</if>
<if test="gmtModified != null">
#{gmtModified,jdbcType=TIMESTAMP},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.sunyo.wlpt.message.bus.service.domain.es.ElasticSearchInfo">
<!--@mbg.generated-->
update elastic_search_info
<set>
<if test="clusterName != null">
cluster_name = #{clusterName,jdbcType=VARCHAR},
</if>
<if test="elasticsearchName != null">
elasticsearch_name = #{elasticsearchName,jdbcType=VARCHAR},
</if>
<if test="hostname != null">
hostname = #{hostname,jdbcType=VARCHAR},
</if>
<if test="port != null">
port = #{port,jdbcType=INTEGER},
</if>
<if test="scheme != null">
scheme = #{scheme,jdbcType=VARCHAR},
</if>
<if test="isMaster != null">
is_master = #{isMaster,jdbcType=BOOLEAN},
</if>
<if test="elasticsearchState != null">
elasticsearch_state = #{elasticsearchState,jdbcType=BOOLEAN},
</if>
<if test="description != null">
description = #{description,jdbcType=VARCHAR},
</if>
<if test="gmtCreate != null">
gmt_create = #{gmtCreate,jdbcType=TIMESTAMP},
</if>
<if test="gmtModified != null">
gmt_modified = #{gmtModified,jdbcType=TIMESTAMP},
</if>
</set>
where id = #{id,jdbcType=VARCHAR}
</update>
<update id="updateByPrimaryKey" parameterType="com.sunyo.wlpt.message.bus.service.domain.es.ElasticSearchInfo">
<!--@mbg.generated-->
update elastic_search_info
set cluster_name = #{clusterName,jdbcType=VARCHAR},
elasticsearch_name = #{elasticsearchName,jdbcType=VARCHAR},
hostname = #{hostname,jdbcType=VARCHAR},
port = #{port,jdbcType=INTEGER},
scheme = #{scheme,jdbcType=VARCHAR},
is_master = #{isMaster,jdbcType=BOOLEAN},
elasticsearch_state = #{elasticsearchState,jdbcType=BOOLEAN},
description = #{description,jdbcType=VARCHAR},
gmt_create = #{gmtCreate,jdbcType=TIMESTAMP},
gmt_modified = #{gmtModified,jdbcType=TIMESTAMP}
where id = #{id,jdbcType=VARCHAR}
</update>
</mapper>
\ No newline at end of file
... ...
package com.sunyo.wlpt.message.bus.service;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
@RunWith(SpringRunner.class)
@SpringBootTest
public class MessageBusServiceApplicationTests {
@Test
public void contextLoads() {
}
}