parent
70f7a30dd5
commit
89a22c85a8
@ -0,0 +1,30 @@
|
|||||||
|
package com.mashibing.common.exception;
|
||||||
|
|
||||||
|
import com.mashibing.common.enums.ExceptionEnums;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author heqijun
|
||||||
|
* @ClassName: SearchException
|
||||||
|
* @Description: 搜索模块自定义异常
|
||||||
|
* @date 2025/6/12 18:13
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
public class SearchException extends RuntimeException {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
private final Integer code;
|
||||||
|
|
||||||
|
public SearchException(Integer code, String message) {
|
||||||
|
super(message);
|
||||||
|
this.code = code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SearchException(ExceptionEnums exceptionEnums) {
|
||||||
|
super(exceptionEnums.getMsg());
|
||||||
|
this.code = exceptionEnums.getCode();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,22 @@
|
|||||||
|
package com.mashibing.search.service;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author heqijun
|
||||||
|
* @ClassName: SearchService
|
||||||
|
* @Description: 搜索模块增删改查service接口
|
||||||
|
* @date 2025/6/12 18:00
|
||||||
|
*/
|
||||||
|
|
||||||
|
public interface SearchService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 向es中添加一行文档
|
||||||
|
*
|
||||||
|
* @param index 索引信息
|
||||||
|
* @param id 文档id
|
||||||
|
* @param json 文档内容
|
||||||
|
*/
|
||||||
|
void index(String index, String id, String json) throws IOException;
|
||||||
|
}
|
@ -0,0 +1,28 @@
|
|||||||
|
package com.mashibing.search.service.impl;
|
||||||
|
|
||||||
|
import com.mashibing.search.service.SearchService;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
|
import org.springframework.test.context.junit4.SpringRunner;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
|
||||||
|
@SpringBootTest
|
||||||
|
@RunWith(SpringRunner.class)
|
||||||
|
class ElasticSearchServiceImplTest {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SearchService service;
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void index() throws IOException {
|
||||||
|
String index = "sms_submit_log_2023";
|
||||||
|
String id = "1";
|
||||||
|
String json = "{\"clientId\": 1}";
|
||||||
|
service.index(index, id, json);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in new issue