提交 534b0877 作者: 布红亮

Merge remote-tracking branch 'origin/yjzx' into yjzx

...@@ -54,6 +54,8 @@ public class Constants { ...@@ -54,6 +54,8 @@ public class Constants {
/*数据权限类型*/ /*数据权限类型*/
public final static String PERMISSION_SUBJECT = "subject"; public final static String PERMISSION_SUBJECT = "subject";
public static final Integer SUCCESS_CODE = 200;
//事件默认绑定模型集合 //事件默认绑定模型集合
public static final Map<String, String> DEFAULT_MODEL = new HashMap<String, String>() {{ public static final Map<String, String> DEFAULT_MODEL = new HashMap<String, String>() {{
put("1706918153597943809","3"); put("1706918153597943809","3");
......
...@@ -79,6 +79,12 @@ public class EventDataController { ...@@ -79,6 +79,12 @@ public class EventDataController {
@Value("${clb.eventAdd}") @Value("${clb.eventAdd}")
private String CLB_EVENT_ADD; private String CLB_EVENT_ADD;
@Value("${clb.eventEdit}")
private String CLB_EVENT_EDIT;
@Value("${clb.eventDelete}")
private String CLB_EVENT_DELETE;
/** /**
* 事件分页列表-门户 * 事件分页列表-门户
* *
...@@ -138,7 +144,7 @@ public class EventDataController { ...@@ -138,7 +144,7 @@ public class EventDataController {
String resultStr = HttpUtil.doPost(CLB_EVENT_ADD, params, 1000 * 30); String resultStr = HttpUtil.doPost(CLB_EVENT_ADD, params, 1000 * 30);
JSONObject jsonObject = JSONObject.parseObject(resultStr); JSONObject jsonObject = JSONObject.parseObject(resultStr);
Integer code = jsonObject.getInteger("code"); Integer code = jsonObject.getInteger("code");
if (code != null && code.equals(200)) { if (code != null && code.equals(Constants.SUCCESS_CODE)) {
JSONObject resultMap = jsonObject.getJSONObject("result"); JSONObject resultMap = jsonObject.getJSONObject("result");
String id = resultMap.getString("id"); String id = resultMap.getString("id");
String eventCode = resultMap.getString("eventCode"); String eventCode = resultMap.getString("eventCode");
...@@ -164,10 +170,11 @@ public class EventDataController { ...@@ -164,10 +170,11 @@ public class EventDataController {
// }); // });
return Result.OK(); return Result.OK();
} else { } else {
log.error("调用克虏宝新增返回失败");
return Result.FAIL(500, "保存事件信息失败!"); return Result.FAIL(500, "保存事件信息失败!");
} }
} catch (Exception e) { } catch (Exception e) {
log.error("调用克虏宝事件异常:{}", e); log.error("调用克虏宝新增事件异常:{}", e);
return Result.FAIL(500, "保存事件信息失败!"); return Result.FAIL(500, "保存事件信息失败!");
} }
} else { } else {
...@@ -183,25 +190,44 @@ public class EventDataController { ...@@ -183,25 +190,44 @@ public class EventDataController {
* @date 2024/7/22 * @date 2024/7/22
*/ */
@PostMapping("/simpleUpdateEvent") @PostMapping("/simpleUpdateEvent")
public Result<?> updateEvent(@RequestBody AddEventVO addEventVO) { public Result<?> updateEvent(HttpServletRequest request, @RequestBody AddEventVO addEventVO) {
KeywordsVO keywordsVO = addEventVO.getKeywordsVO(); KeywordsVO keywordsVO = addEventVO.getKeywordsVO();
addEventVO.setTenant(RequestUtil.getTenantByRequest(request));
if (keywordsVO != null) { if (keywordsVO != null) {
// 调用克虏宝编辑接口
UserVo currentUser = UserUtil.getLoginUser();
JSONObject params = JSONObject.from(addEventVO);
params.put("username", currentUser.getUsername());
try{
String resultStr = HttpUtil.doPost(CLB_EVENT_EDIT, params, 1000 * 30);
JSONObject jsonObject = JSONObject.parseObject(resultStr);
Integer code = jsonObject.getInteger("code");
if (code != null && code.equals(Constants.SUCCESS_CODE)) {
// 本地编辑接口
eventSimpleService.updateMain(addEventVO); eventSimpleService.updateMain(addEventVO);
keyWordsService.update(Wrappers.<KeyWords>lambdaUpdate().eq(KeyWords::getId, keywordsVO.getId()) keyWordsService.update(Wrappers.<KeyWords>lambdaUpdate().eq(KeyWords::getId, keywordsVO.getId())
.set(KeyWords::getKeyWord, keywordsVO.getKeyword()) .set(KeyWords::getKeyWord, keywordsVO.getKeyword())
.set(KeyWords::getExclusionWord, keywordsVO.getExclusionWord())); .set(KeyWords::getExclusionWord, keywordsVO.getExclusionWord()));
CompletableFuture.runAsync(()->{ // CompletableFuture.runAsync(()->{
//关键词 // //关键词
KeyWordsDTO redisKeywordDTO = new KeyWordsDTO(); // KeyWordsDTO redisKeywordDTO = new KeyWordsDTO();
BeanUtils.copyProperties(keywordsVO, redisKeywordDTO); // BeanUtils.copyProperties(keywordsVO, redisKeywordDTO);
redisKeywordDTO.setKeyWord(keywordsVO.getKeyword()); // redisKeywordDTO.setKeyWord(keywordsVO.getKeyword());
redisKeywordDTO.setStartTime(addEventVO.getStartTime()); // redisKeywordDTO.setStartTime(addEventVO.getStartTime());
redisKeywordDTO.setEndTime(addEventVO.getEndTime()); // redisKeywordDTO.setEndTime(addEventVO.getEndTime());
redisKeywordDTO.setSearchEngines(new ArrayList<>(Constants.DEFAULT_SEARCH_ENGINE.values())); // redisKeywordDTO.setSearchEngines(new ArrayList<>(Constants.DEFAULT_SEARCH_ENGINE.values()));
redisUtil.set(Constants.KEY_WORDS_TO_REDIS_PREFIX + keywordsVO.getWordsCode(), redisKeywordDTO); // redisUtil.set(Constants.KEY_WORDS_TO_REDIS_PREFIX + keywordsVO.getWordsCode(), redisKeywordDTO);
//为了立即响应,关键词新增时放入一个首次录入消息队列 // //为了立即响应,关键词新增时放入一个首次录入消息队列
kafkaTemplate.send(Constants.KEY_WORDS_COLLECT_TOPIC, JSON.toJSONString(redisKeywordDTO)); // kafkaTemplate.send(Constants.KEY_WORDS_COLLECT_TOPIC, JSON.toJSONString(redisKeywordDTO));
}); // });
} else {
log.error("调用克虏宝编辑返回失败");
return Result.FAIL(500, "编辑事件信息失败!");
}
} catch (Exception e) {
log.error("调用克虏宝编辑事件异常:{}", e);
return Result.FAIL(500, "编辑事件信息失败!");
}
return Result.OK(); return Result.OK();
} else { } else {
return Result.FAIL(500, "关键词不能为空"); return Result.FAIL(500, "关键词不能为空");
...@@ -217,18 +243,28 @@ public class EventDataController { ...@@ -217,18 +243,28 @@ public class EventDataController {
@ApiOperation(value = "事件-通过id删除", notes = "事件-通过id删除") @ApiOperation(value = "事件-通过id删除", notes = "事件-通过id删除")
@GetMapping(value = "/simpleDeleteEvent") @GetMapping(value = "/simpleDeleteEvent")
public Result<?> delete(@RequestParam(name = "id") String id) { public Result<?> delete(@RequestParam(name = "id") String id) {
try {
// 调用克虏宝删除接口
Map<String, String> params = new HashMap<>();
params.put("id", id);
String resultStr = HttpUtil.doGet(CLB_EVENT_DELETE, params, "utf-8");
// 调用本地删除
EventVO eventVO = eventService.queryInfo(id); EventVO eventVO = eventService.queryInfo(id);
eventService.deleteMain(id); eventService.deleteMain(id);
CompletableFuture.runAsync(() -> { CompletableFuture.runAsync(() -> {
iXxlJobInfoService.deleteByInfosourceCode(eventVO.getEventCode()); //iXxlJobInfoService.deleteByInfosourceCode(eventVO.getEventCode());
KeywordsVO keywordsVO = eventVO.getKeywordsVO(); KeywordsVO keywordsVO = eventVO.getKeywordsVO();
if (keywordsVO != null) { if (keywordsVO != null) {
String wordsCode = keywordsVO.getWordsCode(); String wordsCode = keywordsVO.getWordsCode();
keyWordsService.remove(Wrappers.<KeyWords>lambdaQuery().eq(KeyWords::getWordsCode, wordsCode)); keyWordsService.remove(Wrappers.<KeyWords>lambdaQuery().eq(KeyWords::getWordsCode, wordsCode));
redisUtil.del(Constants.KEY_WORDS_TO_REDIS_PREFIX + wordsCode); //redisUtil.del(Constants.KEY_WORDS_TO_REDIS_PREFIX + wordsCode);
iXxlJobInfoService.deleteByInfosourceCode(wordsCode); //iXxlJobInfoService.deleteByInfosourceCode(wordsCode);
} }
}); });
} catch (Exception e) {
log.error("调用克虏宝删除事件异常:{}", e);
return Result.FAIL(500, "删除事件信息失败!");
}
return Result.OK(); return Result.OK();
} }
......
...@@ -126,6 +126,8 @@ checkToken: ...@@ -126,6 +126,8 @@ checkToken:
url: http://114.116.39.74:9988/sys/checkToken url: http://114.116.39.74:9988/sys/checkToken
clb: clb:
eventAdd: http://1.95.72.34:1688/event/third/api/saveEvent eventAdd: http://1.95.72.34:1688/event/third/api/saveEvent
eventEdit: http://1.95.72.34:1688/event/third/api/editEvent
eventDelete: http://1.95.72.34:1688/event/third/api/deleteEvent
scoreRule: scoreRule:
weekScore: 10 weekScore: 10
monthScore: 5 monthScore: 5
......
...@@ -132,6 +132,8 @@ clbLogin: ...@@ -132,6 +132,8 @@ clbLogin:
url: http://114.116.39.74:9988/sys/loginBS url: http://114.116.39.74:9988/sys/loginBS
clb: clb:
eventAdd: http://1.95.72.34:1688/event/third/api/saveEvent eventAdd: http://1.95.72.34:1688/event/third/api/saveEvent
eventEdit: http://1.95.72.34:1688/event/third/api/editEvent
eventDelete: http://1.95.72.34:1688/event/third/api/deleteEvent
scoreRule: scoreRule:
weekScore: 10 weekScore: 10
monthScore: 5 monthScore: 5
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论