mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/per-boe/java-servers.git
synced 2025-12-10 19:36:50 +08:00
Merge branch 'master' of codeup.aliyun.com:6265f483e4166464dc2f9c14/boeu/baseservers
This commit is contained in:
@@ -40,6 +40,9 @@ public interface ICourseFullTextSearch {
|
||||
*/
|
||||
boolean checkHas(String indexName,String id);
|
||||
|
||||
|
||||
boolean reCreateIndex(String indexName) throws Exception;
|
||||
|
||||
/**
|
||||
* 更新一个字段
|
||||
* @param indexName
|
||||
|
||||
@@ -74,6 +74,18 @@ public class CourseElasticsearchImpl implements ICourseFullTextSearch{
|
||||
* @param indexName
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean reCreateIndex(String indexName) throws Exception{
|
||||
boolean isExists = esUtil.isIndexExists(indexName);
|
||||
if(!isExists) {
|
||||
boolean ok =createIndex(indexName);
|
||||
if(!ok) {
|
||||
log.error("创建索引【"+indexName+"】失败");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建索引
|
||||
@@ -99,7 +111,7 @@ public class CourseElasticsearchImpl implements ICourseFullTextSearch{
|
||||
XContentBuilder builder = XContentFactory.jsonBuilder();
|
||||
builder.startObject();
|
||||
builder.field("properties").startObject();
|
||||
builder.field("id").startObject().field("index", "true").field("type", "text").endObject();
|
||||
builder.field("id").startObject().field("index", "true").field("type", "keyword").endObject();
|
||||
//builder.field("name").startObject().field("type", "text").field("analyzer", "ik_max_word").field("search_analyzer","ik_smart").endObject();
|
||||
builder.field("name").startObject().field("type", "keyword").endObject();
|
||||
builder.field("keywords").startObject().field("type", "text").field("analyzer", "ik_max_word").field("search_analyzer","ik_smart").endObject();
|
||||
@@ -208,6 +220,15 @@ public class CourseElasticsearchImpl implements ICourseFullTextSearch{
|
||||
@Override
|
||||
public String republish(String indexName, CourseFullText item, String fullTextId) throws Exception{
|
||||
|
||||
boolean isExists = esUtil.isIndexExists(indexName);
|
||||
if(!isExists) {
|
||||
boolean ok =createIndex(indexName);
|
||||
if(!ok) {
|
||||
log.error("创建索引【"+indexName+"】失败");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
String fullId=fullTextId;
|
||||
|
||||
boolean exists=false;
|
||||
@@ -373,6 +394,7 @@ public class CourseElasticsearchImpl implements ICourseFullTextSearch{
|
||||
|
||||
if(StringUtils.isNotBlank(params.getKeywords())) {
|
||||
|
||||
|
||||
String words=QueryParser.escape(params.getKeywords());
|
||||
|
||||
// System.out.println(params.getKeywords());
|
||||
@@ -380,9 +402,10 @@ public class CourseElasticsearchImpl implements ICourseFullTextSearch{
|
||||
|
||||
BoolQueryBuilder keywordQuery = QueryBuilders.boolQuery();
|
||||
keywordQuery.should(QueryBuilders.wildcardQuery("name", "*"+words+"*").boost(9f));
|
||||
keywordQuery.should(QueryBuilders.wildcardQuery("teacher", "*"+words+"*").boost(7f));
|
||||
//keywordQuery.should(QueryBuilders.queryStringQuery(words).field("name", 9f));//用此方法无法查询出有转义符的处理
|
||||
//keywordQuery.should(QueryBuilders.queryStringQuery(words).field("teacher", 8f));
|
||||
keywordQuery.should(QueryBuilders.wildcardQuery("teacher", "*"+words+"*").boost(7f));
|
||||
|
||||
keywordQuery.minimumShouldMatch(1);
|
||||
boolQuery.must(keywordQuery);
|
||||
//boolQuery.must(QueryBuilders.wildcardQuery("name", "*"+params.getKeywords()+"*").boost(9f));
|
||||
@@ -437,7 +460,7 @@ public class CourseElasticsearchImpl implements ICourseFullTextSearch{
|
||||
timeLimit.gte(second);
|
||||
boolQuery.filter(timeLimit);
|
||||
}
|
||||
|
||||
//System.out.println(boolQuery.toString());
|
||||
return boolQuery;
|
||||
}
|
||||
|
||||
@@ -621,6 +644,8 @@ public class CourseElasticsearchImpl implements ICourseFullTextSearch{
|
||||
List<CourseFullText> list=new ArrayList<>();
|
||||
|
||||
ObjectMapper mapper=new ObjectMapper();
|
||||
|
||||
|
||||
|
||||
SearchResponse response = restHighLevelClient.search(searchRequest, RequestOptions.DEFAULT);
|
||||
SearchHits hits = response.getHits();
|
||||
|
||||
@@ -55,6 +55,9 @@ public class CourseFullTextApi extends ApiBaseController{
|
||||
if(fullTextSearch==null) {
|
||||
return error("初始化失败:未实现全文检索功能");
|
||||
}
|
||||
//重新创建索引,如果已经存在,不会重新建
|
||||
fullTextSearch.reCreateIndex(ICourseFullTextSearch.DEFAULT_INDEX_NAME);
|
||||
|
||||
//提取课程信息,因为现在课程没有太多,所以一次性全部查出来,
|
||||
CourseQueryDto dto =new CourseQueryDto();
|
||||
dto.setPublish(true);//必须是已发布的
|
||||
|
||||
@@ -389,6 +389,8 @@ public class CourseManageApi extends ApiBaseController{
|
||||
return badRequest("请选择资源归属");
|
||||
}
|
||||
|
||||
//如果是默认管理员,就直接发布,不经过审核
|
||||
|
||||
if(dto.getAuditUser()==null) {
|
||||
return badRequest("HRBP审核信息错误");
|
||||
}
|
||||
|
||||
@@ -57,6 +57,11 @@ public class CourseFullDto {
|
||||
*/
|
||||
private CourseAuditUser auditUser;
|
||||
|
||||
/**
|
||||
* 管理员类型
|
||||
*/
|
||||
private Integer adminType;
|
||||
|
||||
/**
|
||||
* 生成课程的目录树
|
||||
* @return
|
||||
|
||||
@@ -67,11 +67,11 @@ public class PortalConsoleApi extends ApiBaseController{
|
||||
return error("账号错误,无此账号");
|
||||
}
|
||||
|
||||
// UserData userData = outsideDataService.getUserInfoByUserId(null);
|
||||
// if(userData==null) {
|
||||
// log.error("通过api获取用用户信息错误【"+getCurrent().getAccountId()+"】对应的用户");
|
||||
// return error("未能获取当前用户信息");
|
||||
// }
|
||||
UserData userData = outsideDataService.getUserInfoByUserId(null);
|
||||
if(userData==null) {
|
||||
log.error("通过api获取用用户信息错误【"+getCurrent().getAccountId()+"】对应的用户");
|
||||
return error("未能获取当前用户信息");
|
||||
}
|
||||
|
||||
User user = userService.get(getCurrent().getAccountId());
|
||||
Organization org = null;
|
||||
@@ -87,44 +87,42 @@ public class PortalConsoleApi extends ApiBaseController{
|
||||
}
|
||||
}
|
||||
//检查是否是教师,并计算用户的类型,修改于220507
|
||||
Teacher t = teacherService.get(account.getId());
|
||||
int utype=1,ttype=0;
|
||||
//本地判断是否是管理员
|
||||
if(user.getUserType()!=null && user.getUserType()==3) {
|
||||
utype=3;
|
||||
}
|
||||
//判断是否是老师
|
||||
if(t!=null && (t.getDeleted()==null || !t.getDeleted())) {
|
||||
ttype=2;
|
||||
}
|
||||
if(utype==3) {
|
||||
if(ttype==2) {
|
||||
utype=5;//是管理员,又是教师
|
||||
}
|
||||
}else {
|
||||
if(ttype==2) {
|
||||
utype=2;
|
||||
}
|
||||
}
|
||||
|
||||
// int utype=1;//仅仅是学员
|
||||
// if(userData.getTeacher()) {
|
||||
// utype=2;
|
||||
// Teacher t = teacherService.get(account.getId());
|
||||
// int utype=1,ttype=0;
|
||||
// //本地判断是否是管理员
|
||||
// if(user.getUserType()!=null && user.getUserType()==3) {
|
||||
// utype=3;
|
||||
// }
|
||||
// if(userData.getAdminType()>0) {
|
||||
// if(utype==2) {
|
||||
// //判断是否是老师
|
||||
// if(t!=null && (t.getDeleted()==null || !t.getDeleted())) {
|
||||
// ttype=2;
|
||||
// }
|
||||
// if(utype==3) {
|
||||
// if(ttype==2) {
|
||||
// utype=5;//是管理员,又是教师
|
||||
// }else {
|
||||
// utype=3;
|
||||
// }
|
||||
// }else {
|
||||
// if(ttype==2) {
|
||||
// utype=2;
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
int utype=1;//仅仅是学员
|
||||
if(userData.getTeacher()) {
|
||||
utype=2;
|
||||
}
|
||||
if(userData.getAdminType()>0) {
|
||||
if(utype==2) {
|
||||
utype=5;//是管理员,又是教师
|
||||
}else {
|
||||
utype=3;
|
||||
}
|
||||
}
|
||||
|
||||
map.put("aid",account.getId());
|
||||
map.put("sysId",user.getSysId());
|
||||
//map.put("adminType",userData.getAdminType());//管理员类型,1表默认管理员,2表非默认管理员,0表不是管理员
|
||||
map.put("adminType",0);
|
||||
map.put("adminType",userData.getAdminType());//管理员类型,1表默认管理员,2表非默认管理员,0表不是管理员
|
||||
//map.put("adminType",0);
|
||||
map.put("companyId",user.getCompanyId());
|
||||
map.put("name",user.getName());
|
||||
map.put("sex",user.getGender());
|
||||
|
||||
Reference in New Issue
Block a user