Commit b79ddbd7 by xmh

gateway:

失败时返回信息格式化

task:
TaskController.channelUnidWithTask 返回结果修改
1 parent 50509e46
package com.viontech.fanxing.forward;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.viontech.fanxing.commons.config.VionConfig;
import com.viontech.keliu.util.JsonMessageUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
......@@ -85,7 +87,9 @@ public class AuthorizationFilter implements GlobalFilter {
response.setStatusCode(HttpStatus.UNAUTHORIZED);
return response.writeWith(Mono.just(msg).map(x -> {
byte[] bytes = x.getBytes(StandardCharsets.UTF_8);
JsonMessageUtil.JsonMessage errorJsonMsg = JsonMessageUtil.getErrorJsonMsg(msg);
String s = JSON.toJSONString(errorJsonMsg);
byte[] bytes = s.getBytes(StandardCharsets.UTF_8);
return response.bufferFactory().wrap(bytes);
}));
}
......
......@@ -2,6 +2,7 @@ package com.viontech.fanxing.task.controller.web;
import com.alibaba.fastjson.JSONObject;
import com.viontech.fanxing.commons.base.BaseExample;
import com.viontech.fanxing.commons.base.BaseModel;
import com.viontech.fanxing.commons.model.Task;
import com.viontech.fanxing.commons.model.TaskExample;
import com.viontech.fanxing.commons.vo.TaskVo;
......@@ -11,7 +12,7 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Set;
import java.util.Map;
import java.util.stream.Collectors;
@RestController
......@@ -75,10 +76,12 @@ public class TaskController extends TaskBaseController {
@GetMapping("channelUnidWithTask")
public JsonMessageUtil.JsonMessage channelUnidWithTask() {
TaskExample taskExample = new TaskExample();
taskExample.createColumns().hasChannelUnidColumn();
taskExample.createColumns().hasChannelUnidColumn().addColumnStr("count(*) as count");
taskExample.setGroupByClause("channel_unid");
taskExample.setOrderByClause("channel_unid");
List<Task> tasks = taskService.selectByExample(taskExample);
Set<String> collect = tasks.stream().map(Task::getChannelUnid).collect(Collectors.toSet());
return JsonMessageUtil.getSuccessJsonMsg(collect);
Map<String, Long> result = tasks.stream().collect(Collectors.toMap(Task::getChannelUnid, BaseModel::getCount));
return JsonMessageUtil.getSuccessJsonMsg(result);
}
}
\ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!