package com.product.lucene.controller;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RestController;
|
|
import com.product.core.controller.support.AbstractBaseController;
|
import com.product.core.entity.FieldSetEntity;
|
import com.product.core.exception.BaseException;
|
import com.product.lucene.config.CmnConst;
|
import com.product.lucene.config.SystemCode;
|
import com.product.lucene.service.SearchTermService;
|
import com.product.module.sys.version.ApiVersion;
|
import com.product.util.BaseUtil;
|
import com.product.util.ResultInfo;
|
|
|
@RequestMapping("/api/search-term")
|
@RestController
|
public class SearchTermController extends AbstractBaseController{
|
|
@Autowired
|
SearchTermService searchTermService;
|
|
/**
|
* 获取检索词条(常用词条和历史记录)
|
* @param request
|
*/
|
@RequestMapping("/list/{version}")
|
@ApiVersion(1)
|
public String listSearchTerm(HttpServletRequest request) {
|
try {
|
searchTermService.listSearchTerm();
|
return ResultInfo.success(searchTermService.listSearchTerm());
|
} catch (BaseException e) {
|
e.printStackTrace();
|
return this.error(e.getCode(), e.getMessage());
|
} catch (Exception e) {
|
e.printStackTrace();
|
return this.error(SystemCode.LIST_SEARCH_CENTENT_FAIL.getValue(), SystemCode.LIST_SEARCH_CENTENT_FAIL.getText());
|
}
|
}
|
|
/**
|
* 新增检索词条(常用词条)
|
* @param request
|
*/
|
@RequestMapping("/add/{version}")
|
@ApiVersion(1)
|
public String addSearchTerm(HttpServletRequest request) {
|
try {
|
FieldSetEntity fse = BaseUtil.getFieldSetEntity(request, CmnConst.PRODUCT_SYS_DOCUMENT_SEARCH_CONTENT);
|
return OK_Add(searchTermService.addSearchTerm(fse.getString(CmnConst.SEARCH_CONTENT), fse.getString(CmnConst.CONTENT_TYPE)));
|
} catch (BaseException e) {
|
e.printStackTrace();
|
return this.error(e.getCode(), e.getMessage());
|
} catch (Exception e) {
|
e.printStackTrace();
|
return this.error(SystemCode.ADD_SEARCH_CENTENT_FAIL.getValue(), SystemCode.ADD_SEARCH_CENTENT_FAIL.getText());
|
}
|
}
|
|
/**
|
* 删除检索词条(常用词条和历史记录)
|
* @param request
|
*/
|
@RequestMapping("/delete/{version}")
|
@ApiVersion(1)
|
public String deleteSearchTerm(HttpServletRequest request) {
|
try {
|
FieldSetEntity fse = BaseUtil.getFieldSetEntity(request, CmnConst.PRODUCT_SYS_DOCUMENT_SEARCH_CONTENT);
|
searchTermService.deleteSearchTerm(fse.getUUID());
|
boolean succ = searchTermService.deleteSearchTerm(fse.getUUID());
|
if (succ) {
|
return OK();
|
}
|
throw new BaseException(SystemCode.DELETE_SEARCH_CENTENT_FAIL.getValue(), SystemCode.DELETE_SEARCH_CENTENT_FAIL.getText());
|
} catch (BaseException e) {
|
e.printStackTrace();
|
return this.error(e.getCode(), e.getMessage());
|
} catch (Exception e) {
|
e.printStackTrace();
|
return this.error(SystemCode.DELETE_SEARCH_CENTENT_FAIL.getValue(), SystemCode.DELETE_SEARCH_CENTENT_FAIL.getText());
|
}
|
}
|
}
|