|
@@ -1,16 +1,19 @@
|
|
|
package com.nokia.sms.controller;
|
|
|
|
|
|
import com.nokia.common.http.R;
|
|
|
+import com.nokia.sms.service.QueryService;
|
|
|
import com.nokia.sms.service.SocketClientService;
|
|
|
import com.nokia.sms.vo.DelBlkResp;
|
|
|
-import com.nokia.sms.vo.QueryResp;
|
|
|
import com.nokia.sms.vo.RequestParams;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.springframework.util.CollectionUtils;
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
/**
|
|
|
* 黑名单查询及解除接口类
|
|
|
*/
|
|
@@ -19,9 +22,11 @@ import org.springframework.web.bind.annotation.RestController;
|
|
|
@RequestMapping("/sms/blacklist/api/")
|
|
|
public class BlkController {
|
|
|
private final SocketClientService socketClientService;
|
|
|
+ private final QueryService queryService;
|
|
|
|
|
|
- public BlkController(SocketClientService socketClientService) {
|
|
|
+ public BlkController(SocketClientService socketClientService, QueryService queryService) {
|
|
|
this.socketClientService = socketClientService;
|
|
|
+ this.queryService = queryService;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -29,9 +34,16 @@ public class BlkController {
|
|
|
*/
|
|
|
@PostMapping("remove")
|
|
|
public R remove(@RequestBody RequestParams params) {
|
|
|
- // 尝试解除黑名单
|
|
|
- log.debug("入参 -- {} ", params);
|
|
|
DelBlkResp delBlkResp = new DelBlkResp();
|
|
|
+ // 查询黑名单
|
|
|
+ Map<String, Object> current = queryService.getBlackListInfo(params.getPhone());
|
|
|
+ // 不可以解黑
|
|
|
+ if (!CollectionUtils.isEmpty(current) && !current.get("suggestion").equals(1)) {
|
|
|
+ delBlkResp.setDelBlkSuccess(false);
|
|
|
+ delBlkResp.setDelBlkMessage("解除黑名单失败");
|
|
|
+ return R.ok().data(delBlkResp);
|
|
|
+ }
|
|
|
+ // 尝试解除黑名单
|
|
|
// TODO 此处测试环境和正式环境不同,待测试环境下的server部署后,可以修改测试环境的配置文件,即可考虑测试环境和正式环境部署相同的jar包
|
|
|
if (socketClientService.delBlk(params.getPhone())) {
|
|
|
// if (params.getPhone().equals("13231899751")) {
|
|
@@ -41,7 +53,6 @@ public class BlkController {
|
|
|
delBlkResp.setDelBlkSuccess(false);
|
|
|
delBlkResp.setDelBlkMessage("解除黑名单失败");
|
|
|
}
|
|
|
- log.debug("返回 -- {}", delBlkResp);
|
|
|
return R.ok().data(delBlkResp);
|
|
|
}
|
|
|
|
|
@@ -50,19 +61,6 @@ public class BlkController {
|
|
|
*/
|
|
|
@PostMapping("query")
|
|
|
public R query(@RequestBody RequestParams params) {
|
|
|
- log.debug("入参 -- {} ", params);
|
|
|
- QueryResp r = new QueryResp();
|
|
|
- r.setQuerySuccess(true);
|
|
|
- r.setQueryMessage("成功");
|
|
|
- QueryResp.QueryResultDTO dto = new QueryResp.QueryResultDTO();
|
|
|
- dto.setReason("手动加黑");
|
|
|
- dto.setStartTime("20220807012233");
|
|
|
- dto.setEndTime("20220807012233");
|
|
|
- dto.setSmsData("这是一条推销短信");
|
|
|
- dto.setDescribe("推销");
|
|
|
- dto.setAllowToDel(true);
|
|
|
- r.setQueryResult(dto);
|
|
|
- log.debug("返回 -- {}", r);
|
|
|
- return R.ok().data(r);
|
|
|
+ return queryService.query(params);
|
|
|
}
|
|
|
}
|