Hexo
SF开发规范
  1. jetty层只做透传,微服务层处理复杂逻辑

  2. jetty层,DTO进,String出。微服务DTO进,Result<DTO>出。

    jetty层模板

    @PostMapping("demo")
    String Demo(DemoRequest request) {
        AssertUtil.isNotNull(request.getParamOne, "001", "ParamOne can't be null");
        AssertUtil.isNotNull(request.getParamTwo, "001", "ParamTwo can't be null");    ...
        String result = http.post(url, JsonUtil.toJsonStr(request));
        logger.info(Controller.Demo()url = {}request = {}result = {}, url, JsonUtil.toJsonStr(request), result);
        AssertUtil.isNotBlank(result, "002", "apiGate not response");
        return result;
    }

    微服务模板

    @PostMapping("demo")
    Result<T> Demo(DemoRequest request) {
        AssertUtil.isNotNull(request.getParamOne, "001", "ParamOne can't be null");
        AssertUtil.isNotNull(request.getParamTwo, "001", "ParamTwo can't be null");    
        ...
        String result = http.post(url, JsonUtil.toJsonStr(request));
        logger.info(Controller.Demo()url = {}request = {}result = {}, url, JsonUtil.toJsonStr(request), result);
        AssertUtil.isNotBlank(result, "003", "OMS not response");
        DemoObject demoObject = JsonUtil.toJsonObject(result, DemoObject.class);     
        ... // 复杂处理逻辑
        return ResponseUtil.success(demoObject);
    }
  3. 多写注释,白痴也要看得懂我的代码

  4. 一定要打日志

  5. 接口名单词-单词,要有意义,要短,要容易读懂