文档章节

用springfox-swagger2生成resultfulAPI

 逍遥`游
发布于 2017/04/08 14:11
字数 5704
阅读 151
收藏 3
点赞 0
评论 1

前段时间项目改造,由dubbo接口改成了http接口,引入中心层的概念,故使用springMVC集成springfox-swagger2描述生成http接口以便平台调用。

1、引入swagger2包,使用maven进行项目jar包的依赖管理

<!-- 引入swagger2 -->
			<dependency>  
			    <groupId>io.springfox</groupId>
			    <artifactId>springfox-swagger2</artifactId>
			    <version>2.2.2</version>
			</dependency>  
			<dependency>  
			    <groupId>io.springfox</groupId>
			    <artifactId>springfox-swagger-ui</artifactId>
			    <version>2.2.2</version>
			</dependency>

<!--petstore是官方的一个demo,加入此依赖是为了稍后参考接口描述的编写-->
	        <dependency>
	            <groupId>io.springfox</groupId>
	            <artifactId>springfox-petstore</artifactId>
	            <version>2.2.2</version>
	        </dependency>

2、springmvc-servlet.xml配置信息

<!-- 自动搜索@Controller标注的类 -->
	<context:component-scan base-package="com.xxx.dluc.web.controller">
		<context:include-filter type="annotation"
			expression="org.springframework.stereotype.Controller" />
	</context:component-scan>
<!-- Swagger -->
	<mvc:resources mapping="swagger-ui.html" location="classpath:/META-INF/resources/" />
	<mvc:resources mapping="/webjars/**" location="classpath:/META-INF/resources/webjars/" />

上面的作用其实就是通过配置进行swagger静态资源的访问,如图

3、加入swagger2的配置类SpringfoxDocConfig类

设置api文档的描述信息

package com.xxx.dluc.swagger2;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;

import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * Created by DCLab on 12/17/2015.
 */
@Configuration
@EnableWebMvc //NOTE: Only needed in a non-springboot application
@EnableSwagger2 //Enable swagger 2.0 spec
@ComponentScan("com.xxx.dluc.web.controller")
public class SpringfoxDocConfig {
    @Bean
    public Docket createRestApi() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.xxx.dluc.web.controller"))
                .paths(PathSelectors.any())
                .build();
    }

    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("RESTful API Docs Of UserCenter")
                .description("RESTful API Docs")
                .termsOfServiceUrl("http://uc.xxx.com/")
                .contact("jingxiao")
                .version("1.0")
                .build();
    }
}

如上代码所示,通过@Configuration注解,让Spring来加载该类配置。再通过@EnableSwagger2注解来启用Swagger2。

再通过createRestApi函数创建Docket的Bean之后,apiInfo()用来创建该Api的基本信息(这些基本信息会展现在文档页面中)。select()函数返回一个ApiSelectorBuilder实例用来控制哪些接口暴露给Swagger来展现,本例采用指定扫描的包路径来定义,Swagger会扫描该包下所有Controller定义的API,并产生文档内容(除了被@ApiIgnore指定的请求)。

4、建立一个controller类(例子),通过swagger2对方法进行注解说明

内容可以忽略不计哈,或者直接略过

package com.xxx.dluc.web.controller;

import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiParam;
import io.swagger.annotations.ApiResponses;
import io.swagger.annotations.ApiResponse;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

import com.xxx.dlcommon.result.JsonPage;
import com.xxx.dlcommon.result.JsonResult;
import com.xxx.dlcommon.result.PagerInfo;
import com.xxx.dlcommon.result.ServiceResult;
import com.xxx.dlcompany.api.DlOrderCommentAPI;
import com.xxx.dlcompany.dto.ext.DlOrderCommentExtDTO;
import com.xxx.dlcompany.dto.ext.DlOrderConentExtDTO;
import com.xxx.dlcompany.dto.ext.DlOrderDetailExtDTO;
import com.xxx.dlcompany.dto.orderComment.DlBusinessStatisticsDTO;
import com.xxx.dlcompany.dto.orderComment.DlCommentTagStorageDTO;
import com.xxx.dlcompany.dto.orderComment.DlOrderCommentConentDTO;
import com.xxx.dlcompany.dto.orderComment.DlOrderCommentDTO;
import com.xxx.dlcompany.dto.orderComment.DlOrderCommentPicDTO;
import com.xxx.dlcompany.dto.orderComment.DlOrderCommentTagDTO;
import com.xxx.dlhttpx.HttpService;
import com.xxx.dlhttpx.aspect.HttpAspect;
import com.xxx.dlorder.api.DlorderServiceAPI;
import com.xxx.dlorder.dto.OrderDetailDTO;
import com.xxx.dluc.constant.CenterBase;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Maps;

@Controller
@RequestMapping("/center/order_comment")
public class DlClOrderCommentController {
    private Logger logger = LoggerFactory.getLogger(DlClOrderCommentController.class);
    @Resource
    DlOrderCommentAPI dlOrderCommentApi;
    @Resource
    DlorderServiceAPI dlOrderServiceapi;
    @Resource
    HttpService httpService;

    /**
     * 获取评价订单no List
     * 
     * @param Map
     * @param buyerId
     *            ,commentType,PagerInfo
     * @return
     */
    @ApiOperation(value = "获取评价列表", notes = "通过买家id,评论类型获取评价列表")
    @ApiImplicitParams(value = { @ApiImplicitParam(paramType = "header", name = "X-ApiVersion", defaultValue = "1.0", dataType = "string") })
    @ApiResponses(value = { @ApiResponse(code = 200, message = "查询成功", response = JsonResult.class),
            @ApiResponse(code = 400, message = "参数错误", response = Void.class),
            @ApiResponse(code = 404, message = "资源不存在", response = Void.class),
            @ApiResponse(code = 415, message = "不支持的媒体类型/Api废弃/主版本号错误", response = Void.class),
            @ApiResponse(code = 500, message = "服务器异常", response = Void.class) })
    @RequestMapping(value = "/v1/get_ordercomment_list", method = RequestMethod.GET)
    public ResponseEntity<JsonResult<List<DlOrderCommentDTO>>> getOrderCommentList(
            @ApiParam(value = "key:buyerId,买家ID。<br/>key:commentType,评论类型。<br/>key:PagerInfo,分页参数。")
            @RequestParam Map<String, Object> map) {
        logger.info("[{}][{}][{}]", "通过买家id,评论类型获取评价列表", "方法入");
        // 执行getOrderNotCommentList,获得待评价订单id List
        ServiceResult<List<DlOrderCommentDTO>> serviceResult = dlOrderCommentApi.getOrderNotCommentList(map);
        JsonResult<List<DlOrderCommentDTO>> jsonResult = new JsonResult<List<DlOrderCommentDTO>>();
        if (serviceResult.getSuccess() && serviceResult.getResult() != null && serviceResult.getResult().size() > 0) {
            jsonResult.setData(serviceResult.getResult());
        } else {
            jsonResult.setData(null);
        }
        logger.info("[{}][{}][{}]", "通过买家id,评论类型获取评价列表", "方法出");
        // 返回结果
        return new ResponseEntity<JsonResult<List<DlOrderCommentDTO>>>(jsonResult, HttpStatus.OK);
    }

    /**
     * 获取待评价订单数目
     * 
     * @param buyerId
     *            ,sellerId,未评价天数
     * @return
     */
    @ApiOperation(value = "获取待评价订单数目", notes = "通过买家id,卖家id,未评价天数获取待评价订单数量")
    @ApiImplicitParams(value = { @ApiImplicitParam(paramType = "header", name = "X-ApiVersion", defaultValue = "1.0", dataType = "string") })
    @ApiResponses(value = { @ApiResponse(code = 200, message = "查询成功", response = JsonResult.class),
            @ApiResponse(code = 400, message = "参数错误", response = Void.class),
            @ApiResponse(code = 404, message = "资源不存在", response = Void.class),
            @ApiResponse(code = 415, message = "不支持的媒体类型/Api废弃/主版本号错误", response = Void.class),
            @ApiResponse(code = 500, message = "服务器异常", response = Void.class) })
    @RequestMapping(value = "/v1/get_nocomment_count", method = RequestMethod.GET)
    public ResponseEntity<JsonResult<Integer>> getNoCommentCount(
            @ApiParam(value = "买家ID,必传")@RequestParam(value = "buyerId", required = true) final String buyerId,
            @ApiParam(value = "买家ID")@RequestParam(value = "sellerId", required = false) final String sellerId,
            @ApiParam(value = "未评价天数")@RequestParam(value = "noCommentDays", required = false) final String noCommentDays) {
        logger.info("[{}][{}][{}]", "用户中心-通过订单号获取待评价订单数目", "方法入");
        Map<String, Object> map = new HashMap<String, Object>();
        // 将参数存入map中
        Assert.hasText(buyerId, "买家id不可为空!");
        map.put("buyerId", buyerId);
        if (sellerId != null) {
            map.put("sellerId", sellerId);
        }
        if (noCommentDays != null) {
            map.put("noCommentDays", noCommentDays);
        }
        // 执行getNoCommentCount获取待评价订单数目
        JsonResult<Integer> jsonResult = new JsonResult<Integer>();
        ServiceResult<Integer> serviceResult = dlOrderCommentApi.getNoCommentCount(map);
        Integer orderNoComment = serviceResult.getResult();
        jsonResult.setData(orderNoComment);
        jsonResult.setStatus(0);
        logger.info("[{}][{}][{}]", "用户中心-通过订单号获取待评价订单数目", "方法出");
        // 返回结果
        return new ResponseEntity<JsonResult<Integer>>(jsonResult, HttpStatus.OK);
    }

    /**
     * 新增(追加)订单评论
     * 
     * @param new 订单No 评价内容(满意度、标签、内容、图片) 评论者类型(01:买家 02:卖家) add 订单No、评论内容
     * @return
     */
    @ApiOperation(value = "新增(追加)订单评论", notes = "通过订单No新增(追加)订单评论(新增:满意度必须;追加:评论内容必须)")
    @ApiImplicitParams(value = { @ApiImplicitParam(paramType = "header", name = "X-ApiVersion", defaultValue = "1.0", dataType = "string") })
    @ApiResponses(value = { @ApiResponse(code = 201, message = "评论成功", response = Boolean.class),
            @ApiResponse(code = 400, message = "参数错误", response = Void.class),
            @ApiResponse(code = 415, message = "不支持的媒体类型/Api废弃/主版本号错误", response = Void.class),
            @ApiResponse(code = 500, message = "服务器异常", response = Void.class) })
    @RequestMapping(value = "/v1/add_order_comment", method = RequestMethod.POST)
    public ResponseEntity<JsonResult<Boolean>> addOrderComment(
            @ApiParam(value = "key:dlOrderCommentDTO,订单评价信息.<br/>key:commentType,评价类型。<br/>"
                    + "key:dlOrderCommentConentDTO,评价内容.<br/>key:dlOrderCommentTagDTO,评价标签。<br/>key:dlOrderCommentPicDTOList,评价图片。")
            @RequestBody(required = true) final DlOrderCommentExtDTO dlOrderCommentExtDTO) {
        logger.info("[{}][{}][{}]", "用户中心-通过订单号追加和新增评论", "方法入");
        DlOrderCommentDTO dlOrderCommentDTO = dlOrderCommentExtDTO.getOrderCommentDTO();
        JsonResult<Boolean> jsonResult = new JsonResult<Boolean>();
        if (dlOrderCommentDTO == null) {
            // 追加评论
            DlOrderCommentConentDTO dlOrderCommentConentDTO = dlOrderCommentExtDTO.getOrderCommentConentDTO();
            Assert.hasText(dlOrderCommentConentDTO.getConent(), "追加评论内容不可为空!");
            // 追加评论内容
            ServiceResult<Boolean> addOrderCommentConentResult = dlOrderCommentApi
                    .addOrderCommentConent(dlOrderCommentConentDTO);
            Boolean addConent = addOrderCommentConentResult.getResult();
            // 判断执行是否成功
            if (addConent == false) {
                jsonResult.setData(false);
                return new ResponseEntity<JsonResult<Boolean>>(HttpStatus.INTERNAL_SERVER_ERROR);
            }
            // 更新评价类型
            if ("04".equals(dlOrderCommentExtDTO.getCommentType()) || "05".equals(dlOrderCommentExtDTO.getCommentType())  ) {
                Map<String, Object> map = new HashMap<String, Object>();
                List<String> orderNoList = new ArrayList<String>();
                orderNoList.add(dlOrderCommentConentDTO.getOrderNo());
                map.put("orderNoList", orderNoList);
                map.put("updatedPerson", dlOrderCommentConentDTO.getUpdatedPerson());
                map.put("commentType", dlOrderCommentExtDTO.getCommentType());
                // 获取更新结果
                ServiceResult<Boolean> updateByOrderNoListResult = dlOrderCommentApi.updateByOrderNoList(map);
                Boolean updateByOrderNoList = updateByOrderNoListResult.getResult();
                // 判断是否成功
                if (updateByOrderNoList == false) {
                    jsonResult.setData(false);
                    return new ResponseEntity<JsonResult<Boolean>>(HttpStatus.INTERNAL_SERVER_ERROR);
                }
            }
            jsonResult.setData(true);
        } else {
            // 新增评论
            // 校验订单号
            // 新建map,并从参数中取出norderNo放入map中
            Map<String, Object> mapCheck = new HashMap<String, Object>();
            mapCheck.put("orderNo", dlOrderCommentDTO.getOrderNo());
            // 校验是否评价
            ServiceResult<Boolean> checkUpdateOrderCommentResult = dlOrderCommentApi.checkUpdateOrderComment(mapCheck);
            Boolean commentTypeBoolean = checkUpdateOrderCommentResult.getResult();
            // 校验未通过,该订单已评价
            if (commentTypeBoolean == false) {
                jsonResult.setMsg("该订单已评价");
                jsonResult.setData(false);
            } else {
                // 将参数放入map
                Map<String, Object> map = new HashMap<String, Object>();
                List<String> orderNoList = new ArrayList<String>();
                orderNoList.add(dlOrderCommentDTO.getOrderNo());
                map.put("orderNoList", orderNoList);
                map.put("goodsSatisfaction", dlOrderCommentDTO.getGoodsSatisfaction());
                map.put("serviceSatisfaction", dlOrderCommentDTO.getServiceSatisfaction());
                map.put("distributionSatisfaction", dlOrderCommentDTO.getDistributionSatisfaction());
                map.put("commentType", dlOrderCommentDTO.getCommentType());
                map.put("fistCommentTime", dlOrderCommentDTO.getFistCommentTime());
                map.put("isSatisfaction", dlOrderCommentDTO.getIsSatisfaction());
                map.put("updatedPerson", dlOrderCommentDTO.getUpdatedPerson());
                // 获取更新结果
                ServiceResult<Boolean> updateByOrderNoListResult = dlOrderCommentApi.updateByOrderNoList(map);
                Boolean updateByOrderNoList = updateByOrderNoListResult.getResult();
                // 判断是否成功
                if (updateByOrderNoList == false) {
                    return new ResponseEntity<JsonResult<Boolean>>(HttpStatus.INTERNAL_SERVER_ERROR);
                }

            // 新增评论内容
            // 获取参数
            DlOrderCommentConentDTO dlOrderCommentConentDTO = dlOrderCommentExtDTO.getOrderCommentConentDTO();
            // 判断参数是否为空
                // 获取执行结果
                ServiceResult<Boolean> addOrderCommentConentResult = dlOrderCommentApi
                        .addOrderCommentConent(dlOrderCommentConentDTO);
                Boolean insertOrderCommentConent = addOrderCommentConentResult.getResult();
                // 判断执行是否成功
                if (insertOrderCommentConent == false) {
                    return new ResponseEntity<JsonResult<Boolean>>(HttpStatus.INTERNAL_SERVER_ERROR);
                }
            // 新增订单评价标签
            // 获取参数
            DlOrderCommentTagDTO dlOrderCommentTagDTO = dlOrderCommentExtDTO.getOrderCommentTagDTO();
            // 判断参数
            if (dlOrderCommentTagDTO != null && dlOrderCommentTagDTO.getTagId() != null) {
                // 获取执行结果
                ServiceResult<Boolean> addOrderCommentTagResult = dlOrderCommentApi
                        .addOrderCommentTag(dlOrderCommentTagDTO);
                Boolean insertOrderCommentTag = addOrderCommentTagResult.getResult();
                // 判断是否成功
                if (insertOrderCommentTag == false) {
                    return new ResponseEntity<JsonResult<Boolean>>(HttpStatus.INTERNAL_SERVER_ERROR);
                }
            }
            // 新增评价图片
            // 获取参数
            List<DlOrderCommentPicDTO> dlOrderCommentPicDTOList = dlOrderCommentExtDTO.getOrderCommentPicDTOList();
            // 判断参数
            if (dlOrderCommentPicDTOList != null && dlOrderCommentPicDTOList.size() != 0) {
                // 获取执行结果
                ServiceResult<Boolean> addEvaluatePicResult = dlOrderCommentApi
                        .addEvaluatePic(dlOrderCommentPicDTOList);
                Boolean addEvaluatePic = addEvaluatePicResult.getResult();
                // 判断执行结果
                if (addEvaluatePic == false) {
                    return new ResponseEntity<JsonResult<Boolean>>(HttpStatus.INTERNAL_SERVER_ERROR);
                }
            }
            jsonResult.setData(true);
            }
        }
        jsonResult.setStatus(0);
        logger.info("[{}][{}][{}]", "用户中心-通过订单号追加和新增评论", "方法出");
        return new ResponseEntity<JsonResult<Boolean>>(jsonResult, HttpStatus.OK);
    }

    /**
     * 获取订单评价详情
     * 
     * @param 订单No
     *            , 买家Id
     * @return
     */
    @ApiOperation(value = "获取订单评价详情", notes = "通过订单No,买家id获取订单评价详情")
    @ApiImplicitParams(value = { @ApiImplicitParam(paramType = "header", name = "X-ApiVersion", defaultValue = "1.0", dataType = "string") })
    @ApiResponses(value = { @ApiResponse(code = 200, message = "查询成功", response = JsonResult.class),
            @ApiResponse(code = 400, message = "参数错误", response = Void.class),
            @ApiResponse(code = 404, message = "资源不存在", response = Void.class),
            @ApiResponse(code = 415, message = "不支持的媒体类型/Api废弃/主版本号错误", response = Void.class),
            @ApiResponse(code = 500, message = "服务器异常", response = Void.class) })
    @RequestMapping(value = "/v1/get_ordercomment_detail", method = RequestMethod.GET)
    public ResponseEntity<JsonResult<DlOrderCommentExtDTO>> getOrderCommentDetail(
            @ApiParam(value="订单号,必传")@RequestParam(value = "orderNo", required = false) final String orderNo,
            @ApiParam(value="买家ID")@RequestParam(value = "buyerId", required = false) final String buyerId) {
        logger.info("[{}][{}][{}]", "用户中心-通过订单号和买家id获取评价详情", "方法入");
        Map<String, Object> map = new HashMap<String, Object>();
        List<String> orderNoList = new ArrayList<String>();
        if (orderNo != null || orderNo != "") {
            orderNoList.add(orderNo);
            map.put("orderNo", orderNo);
            map.put("orderNoList", orderNoList);
        }
        if (buyerId != null || buyerId != "") {
            map.put("buyerId", buyerId);
        }
        // 调用获取订单评价信息--orderNoList buyerId
        JsonResult<DlOrderCommentExtDTO> jsonResult = new JsonResult<DlOrderCommentExtDTO>();
        List<DlOrderCommentDTO> dlOrderCommentDtoList = new ArrayList<DlOrderCommentDTO>();
        ServiceResult<List<DlOrderCommentDTO>> getOrderCommentDetailListResult = dlOrderCommentApi
                .getOrderCommentDetailList(map, null);
        if (getOrderCommentDetailListResult.getSuccess() && getOrderCommentDetailListResult.getResult() != null
                && getOrderCommentDetailListResult.getResult().size() > 0) {
            dlOrderCommentDtoList = getOrderCommentDetailListResult.getResult();
            // 调用获取订单评价标签--orderNo
            List<String> getOrderCommentTagList = dlOrderCommentApi.getOrderCommentTagByOrderNo(orderNo).getResult();
            // 调用获取评价内容--
            List<DlOrderCommentConentDTO> getOrderCommentConentList = new ArrayList<DlOrderCommentConentDTO>();
            getOrderCommentConentList = dlOrderCommentApi.getOrderCommentConent(map).getResult();
            if (getOrderCommentConentList == null || getOrderCommentConentList.size() == 0) {
                return new ResponseEntity<JsonResult<DlOrderCommentExtDTO>>(HttpStatus.INTERNAL_SERVER_ERROR);
            }
            // 获取订单评价图片
            Map<String, List<DlOrderCommentPicDTO>> dlOrderCommentPicDTOList = new HashMap<String, List<DlOrderCommentPicDTO>>();
            dlOrderCommentPicDTOList = dlOrderCommentApi.getEvaluatePicList(orderNoList).getResult();
            // 组装数据
            DlOrderCommentExtDTO dlOrderCommentExtDTO = new DlOrderCommentExtDTO();
            dlOrderCommentExtDTO.setOrderCommentDTOList(dlOrderCommentDtoList);
            dlOrderCommentExtDTO.setOrderCommentTagList(getOrderCommentTagList);
            dlOrderCommentExtDTO.setOrderCommentConentDTOList(getOrderCommentConentList);
            dlOrderCommentExtDTO.setOrderCommentPicDTOList(dlOrderCommentPicDTOList.get(orderNo));
            jsonResult.setStatus(0);
            jsonResult.setData(dlOrderCommentExtDTO);
        } else {
            jsonResult.setData(null);
        }
        jsonResult.setStatus(0);
        logger.info("[{}][{}][{}]", "用户中心-通过订单号和买家id获取评价详情", "方法出");
        return new ResponseEntity<JsonResult<DlOrderCommentExtDTO>>(jsonResult, HttpStatus.OK);
    }

    /**
     * 获取订单评价信息
     * 
     * @param orderNo
     * @return dlOrderCommentDTO
     */
    @ApiOperation(value = "获取评价信息", notes = "通过订单号获取评价信息")
    @ApiImplicitParams(value = { @ApiImplicitParam(paramType = "header", name = "X-ApiVersion", defaultValue = "1.0", dataType = "string") })
    @ApiResponses(value = { @ApiResponse(code = 200, message = "查询成功", response = JsonResult.class),
            @ApiResponse(code = 400, message = "参数错误", response = Void.class),
            @ApiResponse(code = 404, message = "资源不存在", response = Void.class),
            @ApiResponse(code = 415, message = "不支持的媒体类型/Api废弃/主版本号错误", response = Void.class),
            @ApiResponse(code = 500, message = "服务器异常", response = Void.class) })
    @RequestMapping(value = "/v1/get_order_comment_info", method = RequestMethod.GET)
    public ResponseEntity<JsonResult<DlOrderCommentDTO>> getCommentInfo(
            @ApiParam(value = "key:orderNo,订单号。必传")
            @RequestParam Map<String, Object> map) {
        logger.info("[{}][{}][{}]", "用户中心-通过订单号获取评价信息", "方法入");
        JsonResult<DlOrderCommentDTO> jsonResult = new JsonResult<DlOrderCommentDTO>();
        Map<String, Object> mapParam = new HashMap<String, Object>();
        Assert.hasText((String) map.get("orderNo"), "订单号不可为空!");
        mapParam.put("orderNo", map.get("orderNo"));
        ServiceResult<List<DlOrderCommentDTO>> serviceResult = dlOrderCommentApi.getOrderCommentDetailList(mapParam,
                null);
        if (serviceResult.getSuccess() && serviceResult.getResult() != null && serviceResult.getResult().size() > 0) {
            jsonResult.setData(serviceResult.getResult().get(0));
        } else {
            jsonResult.setData(null);
        }
        jsonResult.setStatus(0);
        logger.info("[{}][{}][{}]", "用户中心-通过订单号获取评价信息", "方法出");
        return new ResponseEntity<JsonResult<DlOrderCommentDTO>>(jsonResult, HttpStatus.OK);
    }

    /**
     * 获取经销商订单满意度统计信息
     * 
     * @param 卖家idList,时间类型:本月、上月、半年 买家类型:终端店、经销商、全部
     * @return 满意度数据
     */
    @ApiOperation(value = "获取经销商订单满意度统计信息", notes = "通过卖家idList、时间类型、买家类型,获取经销商订单满意度统计信息")
    @ApiImplicitParams(value = { @ApiImplicitParam(paramType = "header", name = "X-ApiVersion", defaultValue = "1.0", dataType = "string") })
    @ApiResponses(value = { @ApiResponse(code = 200, message = "查询成功", response = JsonResult.class),
            @ApiResponse(code = 400, message = "参数错误", response = Void.class),
            @ApiResponse(code = 404, message = "资源不存在", response = Void.class),
            @ApiResponse(code = 415, message = "不支持的媒体类型/Api废弃/主版本号错误", response = Void.class),
            @ApiResponse(code = 500, message = "服务器异常", response = Void.class) })
    @RequestMapping(value = "/v1/get_order_satisfaction_record_list", method = RequestMethod.GET)
    public ResponseEntity<JsonResult<Map<String, Object>>> commentEntity(
            @ApiParam(value="key:sellerIdList,卖家id列表,必传。<br/>key:time,时间类型。<br/>key:buyerType,买家类型")
            @RequestParam Map<String, Object> map) {
        logger.info("[{}][{}][{}]", "用户中心-通过卖家idList、时间类型、买家类型,获取经销商订单满意度统计信息", "方法入");
        // 获取行业平均满意度
        ServiceResult<Map<String, Object>> mapAvgStatistics = dlOrderCommentApi.getTradeAvgStatisticsbyTradeType();
        JsonResult<Map<String, Object>> jsonResult = new JsonResult<Map<String, Object>>();
        Map<String, Object> mapReturn = new HashMap<String, Object>();
        if (mapAvgStatistics.getSuccess() && mapAvgStatistics.getResult() != null) {
            Map<String, Object> mapAvg = mapAvgStatistics.getResult();
            // 调用获取满意度接口
            Map<String, Object> mapAllStatistics = new HashMap<String, Object>();
            List<String> sellerIdList = new ArrayList<String>();
            sellerIdList.add(map.get("sellerId").toString());
            mapAllStatistics.put("sellerIdList", sellerIdList);
            ServiceResult<List<DlBusinessStatisticsDTO>> serviceResult = dlOrderCommentApi
                    .getDlBusinessStatistics(mapAllStatistics);
            DlBusinessStatisticsDTO dlBusinessStatisticsDTO1 = new DlBusinessStatisticsDTO();
            if (serviceResult.getSuccess() && serviceResult.getResult().size() != 0) {
                dlBusinessStatisticsDTO1 = serviceResult.getResult().get(0);
                mapReturn.put("allSatistics", dlBusinessStatisticsDTO1);
                String goodsDifferString;
                String serviceDifferString;
                String distributionDifferString;
                float goodsDiffer = new BigDecimal(new Double(dlBusinessStatisticsDTO1.getGoodsSatisfaction())
                        - (Double) mapAvg.get("goods_satisfaction")).setScale(2, BigDecimal.ROUND_HALF_UP).floatValue();
                if (goodsDiffer >= 0) {
                    goodsDifferString = "高" + goodsDiffer;
                } else {
                    goodsDifferString = "低" + Math.abs(goodsDiffer);
                }
                float serviceDiffer = new BigDecimal(new Double(dlBusinessStatisticsDTO1.getServiceSatisfaction())
                        - (Double) mapAvg.get("service_satisfaction")).setScale(2, BigDecimal.ROUND_HALF_UP)
                        .floatValue();
                if (serviceDiffer >= 0) {
                    serviceDifferString = "高" + serviceDiffer;
                } else {
                    serviceDifferString = "低" + Math.abs(serviceDiffer);
                }
                float distributionDiffer = new BigDecimal(new Double(
                        dlBusinessStatisticsDTO1.getDistributionSatisfaction())
                        - (Double) mapAvg.get("distribution_satisfaction")).setScale(2, BigDecimal.ROUND_HALF_UP)
                        .floatValue();
                if (distributionDiffer >= 0) {
                    distributionDifferString = "高" + distributionDiffer;
                } else {
                    distributionDifferString = "低" + Math.abs(distributionDiffer);
                }
                mapReturn.put("goods_satisfaction", goodsDifferString);
                mapReturn.put("service_satisfaction", serviceDifferString);
                mapReturn.put("distribution_satisfaction", distributionDifferString);
                // 调用获取经销商满意度统计信息接口
                Map<String, Object> mapStatisticsInfo = new HashMap<String, Object>();
                mapStatisticsInfo.put("sellerId", map.get("sellerId"));
                mapStatisticsInfo.put("time", map.get("time"));
                mapStatisticsInfo.put("buyerType", map.get("buyerType"));
                DlBusinessStatisticsDTO dlBusinessStatisticsDTO = new DlBusinessStatisticsDTO();
                ServiceResult<DlBusinessStatisticsDTO> serviceResult2 = dlOrderCommentApi
                        .getRecentOrderComment(mapStatisticsInfo);
                    dlBusinessStatisticsDTO = serviceResult2.getResult();
                mapReturn.put("dlBusinessStatisticsDTO", dlBusinessStatisticsDTO);
            }
            jsonResult.setData(mapReturn);
        } else {
            jsonResult.setData(null);
        }
        logger.info("[{}][{}][{}]", "用户中心-通过卖家idList、时间类型、买家类型,获取经销商订单满意度统计信息", "方法出");
        return new ResponseEntity<JsonResult<Map<String, Object>>>(jsonResult, HttpStatus.OK);
    }

    /**
     * 获取经销商订单整体满意度
     * 
     * @param 卖家idList
     *        分页参数  整体满意区间
     * @return 满意度数据 List<Dto>
     */
    @ApiOperation(value = "获取经销商订单整体满意度", notes = "通过卖家idList、分页参数、整体满意区间,获取经销商订单满意度统计信息")
    @ApiImplicitParams(value = { @ApiImplicitParam(paramType = "header", name = "X-ApiVersion", defaultValue = "1.0", dataType = "string") })
    @ApiResponses(value = { @ApiResponse(code = 200, message = "查询成功", response = JsonPage.class),
            @ApiResponse(code = 400, message = "参数错误", response = Void.class),
            @ApiResponse(code = 404, message = "资源不存在", response = Void.class),
            @ApiResponse(code = 415, message = "不支持的媒体类型/Api废弃/主版本号错误", response = Void.class),
            @ApiResponse(code = 500, message = "服务器异常", response = Void.class) })
    @RequestMapping(value = "/v1/get_all_order_satisfaction_record_list", method = RequestMethod.POST)
    public ResponseEntity<JsonPage<List<DlBusinessStatisticsDTO>>> getAllOrderSatisfactionRecord(
            @ApiParam(value="key:sellerIdList,卖家id列表,必传。<br/>key:satisfactionType,满意度类型。<br/>key:pagerInfo,分页参数。")
            @RequestBody Map<String, Object> map) {
        ServiceResult<List<DlBusinessStatisticsDTO>> serviceResult = new ServiceResult<List<DlBusinessStatisticsDTO>>();
        JsonPage<List<DlBusinessStatisticsDTO>> jsonPage = new JsonPage<List<DlBusinessStatisticsDTO>>();
        List<DlBusinessStatisticsDTO> dlBusinessStatisticsDTOList = new ArrayList<DlBusinessStatisticsDTO>();
        // 调用获取经销商整体满意度接口
        serviceResult = dlOrderCommentApi.getDlBusinessStatistics(map);
        if (serviceResult.getSuccess() && serviceResult.getResult() != null) {
            dlBusinessStatisticsDTOList = serviceResult.getResult();
            jsonPage.setData_list(dlBusinessStatisticsDTOList);
            jsonPage.setIndex(serviceResult.getPager().getPageIndex()); // 第几页
            jsonPage.setSize(serviceResult.getPager().getRowsCount()); // 复合条件的总数据大小
            if (serviceResult.getPager().getRowsCount() != 0) {
                jsonPage.setTotal((serviceResult.getPager().getRowsCount() % serviceResult.getPager().getPageSize()) == 0 ? serviceResult
                        .getPager().getRowsCount() / serviceResult.getPager().getPageSize()
                        : serviceResult.getPager().getRowsCount() / serviceResult.getPager().getPageSize() + 1); // 获取总页数
            } else {
                jsonPage.setTotal(0);
            }
        } else {
            jsonPage.setData_list(null);
        }
        return new ResponseEntity<JsonPage<List<DlBusinessStatisticsDTO>>>(jsonPage, HttpStatus.OK);
    }
    /**
     * 获取订单评价标签List
     * 
     * @param
     * @return commentTagStorageList 订单评价标签List
     */
    @ApiOperation(value = "获取订单评价标签List", notes = "获取订单全部评价标签List")
    @ApiImplicitParams(value = { @ApiImplicitParam(paramType = "header", name = "X-ApiVersion", defaultValue = "1.0", dataType = "string") })
    @ApiResponses(value = {
            @ApiResponse(code = 200, message = "查询成功", response = JsonResult.class),
            @ApiResponse(code = 400, message = "参数错误", response = Void.class),
            @ApiResponse(code = 404, message = "资源不存在", response = Void.class),
            @ApiResponse(code = 415, message = "不支持的媒体类型/Api废弃/主版本号错误", response = Void.class),
            @ApiResponse(code = 500, message = "服务器异常", response = Void.class)
    })
    @RequestMapping(value = "/v1/get_comment_tag_storage_list", method = RequestMethod.GET)
    public ResponseEntity<JsonResult<List<DlCommentTagStorageDTO>>> getCommentTagStorageList() {
           // log
           logger.info("[{}][{}][{}]", "用户中心-获取订单评价标签List", "方法入");
            List<DlCommentTagStorageDTO> commentTagStorageList = dlOrderCommentApi.getCommentTagStorage().getResult();
            JsonResult<List<DlCommentTagStorageDTO>> jsonResult = new JsonResult<List<DlCommentTagStorageDTO>>();
            if (commentTagStorageList == null || commentTagStorageList.size() == 0) {
                jsonResult.setStatus(1);
                jsonResult.setData(null);
                return new ResponseEntity<JsonResult<List<DlCommentTagStorageDTO>>>(jsonResult, HttpStatus.OK);
            }
           
            jsonResult.setStatus(0);
            jsonResult.setData(commentTagStorageList);
            // log
            logger.info("[{}][{}][{}]", "用户中心-获取订单评价标签List", "方法出");
            return new ResponseEntity<JsonResult<List<DlCommentTagStorageDTO>>>(jsonResult, HttpStatus.OK);
    }

    /**
     * 根据页面上筛选条件获取订单评价详情 List
     * 
     * @param Map
     *            <String, Object> map(sellerName 卖家名称,buyerName
     *            买家名称,buyerAreaCode 买家区域CODE,orderNo 订单No,commentType
     *            评论类型,goodsSatisfaction 商品包装整洁度, serviceSatisfaction
     *            卖家服务态度,distributionSatisfaction 卖家配送速度,isSatisfaction
     *            是否全部满意(不满意),fistCommentTimeMin 初次评论时间最小值,fistCommentTimeMax
     *            初次评论时间最大值,buyerType 买家类型 (终端店/经销商)
     * @return List<DlOrderConentExtDTO> 订单评价详情 List
     */
    @ApiOperation(value = "获取订单评价详情 List", notes = "根据筛选条件获取订单评价详情 List")
    @ApiImplicitParams(value = { @ApiImplicitParam(paramType = "header", name = "X-ApiVersion", defaultValue = "1.0", dataType = "string") })
    @ApiResponses(value = { @ApiResponse(code = 200, message = "查询成功", response = JsonPage.class),
            @ApiResponse(code = 400, message = "参数错误", response = Void.class),
            @ApiResponse(code = 404, message = "资源不存在", response = Void.class),
            @ApiResponse(code = 415, message = "不支持的媒体类型/Api废弃/主版本号错误", response = Void.class),
            @ApiResponse(code = 500, message = "服务器异常", response = Void.class) })
    @RequestMapping(value = "/v1/get_order_comment_detail_list", method = RequestMethod.POST)
    public ResponseEntity<JsonPage<List<DlOrderConentExtDTO>>> getOrderCommentDetailList(
            @ApiParam(value = "key:sellerName,卖家名称<br/>key:buyerName,买家名称<br/>key:buyerAreaCode,买家区域CODE<br/>"
                    + "key:orderNo,订单No<br/>key:commentType,评论类型<br/>key:goodsSatisfaction,商品包装整洁度<br/>"
                    + "key:serviceSatisfaction,卖家服务态度<br/>key:distributionSatisfaction,卖家配送速度<br/>key:isSatisfaction,是否全部满意(不满意)<br/>"
                    + "key:fistCommentTimeMin,初次评论时间最小值<br/>key:fistCommentTimeMax,初次评论时间最大值<br/>key:buyerType,买家类型 (终端店/经销商)<br/>") @RequestBody Map<String, Object> requestBodyMap) {
        // log
        logger.info("[{}][{}][{}]", "用户中心-根据筛选条件获取订单评价详情 List", "方法入");
        // 分页设置
        Integer pageSize = 0;
        Integer pageIndex = 0;
        PagerInfo pagerInfo = null;
        if (requestBodyMap.get("pageSize") != null && requestBodyMap.get("pageIndex") != null) {
            pageSize = Integer.parseInt(String.valueOf(requestBodyMap.get("pageSize")));
            pageIndex = Integer.parseInt(String.valueOf(requestBodyMap.get("pageIndex")));
            if (pageSize != null && pageIndex != null) {
                pagerInfo = new PagerInfo(pageSize, pageIndex);
            }
        }
        JsonPage<List<DlOrderConentExtDTO>> jsonPage = new JsonPage<List<DlOrderConentExtDTO>>();
        List<String> orderNoList = new ArrayList<String>();
        ServiceResult<List<DlOrderCommentDTO>> serviceResult = dlOrderCommentApi.getOrderCommentDetailList(
                requestBodyMap, pagerInfo);
        if (!serviceResult.getSuccess()) {
            return new ResponseEntity<JsonPage<List<DlOrderConentExtDTO>>>(HttpStatus.INTERNAL_SERVER_ERROR);
        }
        List<DlOrderCommentDTO> orderCommentList = serviceResult.getResult();
        if (orderCommentList == null || orderCommentList.size() == 0) {
            jsonPage.setData_list(null);
            return new ResponseEntity<JsonPage<List<DlOrderConentExtDTO>>>(jsonPage, HttpStatus.OK);
        }
        for (DlOrderCommentDTO dlOrderCommentDTO : orderCommentList) {
            orderNoList.add(dlOrderCommentDTO.getOrderNo());
        }
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("orderNoList", orderNoList);
        if (serviceResult.getPager().getRowsCount() != 0) {
            jsonPage.setTotal((serviceResult.getPager().getRowsCount() % serviceResult.getPager().getPageSize()) == 0 ? serviceResult
                    .getPager().getRowsCount() / serviceResult.getPager().getPageSize()
                    : serviceResult.getPager().getRowsCount() / serviceResult.getPager().getPageSize() + 1); // 获取总页数
        } else {
            jsonPage.setTotal(0);
        }
        // 获取订单评价内容
        Map<String, List<DlOrderCommentConentDTO>> orderCommentConentList = dlOrderCommentApi
                .getOrderCommentConentByOrderNoList(map).getResult();
        // 获取订单评价标签
        Map<String, List<String>> orderCommentTagList = dlOrderCommentApi.getOrderCommentTagByOrderNoList(map)
                .getResult();
        // 获取订单评价图片
        Map<String, List<DlOrderCommentPicDTO>> orderCommentPicList = dlOrderCommentApi.getEvaluatePicList(orderNoList)
                .getResult();
        // 组装数据
        List<DlOrderConentExtDTO> result = new ArrayList<DlOrderConentExtDTO>();
        for (DlOrderCommentDTO dlOrderCommentDTO : orderCommentList) {
            DlOrderConentExtDTO dlOrderConentExtDTO = new DlOrderConentExtDTO();
            String orderNo = dlOrderCommentDTO.getOrderNo();
            // 获取订单No
            dlOrderConentExtDTO.setOrderNo(orderNo);
            dlOrderConentExtDTO.setFistCommentTime(dlOrderCommentDTO.getFistCommentTime());
            // 评论类型
            dlOrderConentExtDTO.setCommentType(dlOrderCommentDTO.getCommentType());
            // 买家类型
            if ("01".equals(dlOrderCommentDTO.getBuyerType())) {
                dlOrderConentExtDTO.setBuyerType("终端店");
            } else {
                dlOrderConentExtDTO.setBuyerType("经销商");
            }
            // 商品包装整洁度
            if (dlOrderCommentDTO.getGoodsSatisfaction() != null) {

                dlOrderConentExtDTO.setGoodsSatisfaction(dlOrderCommentDTO.getGoodsSatisfaction().toString());
            }
            // 卖家服务态度
            if (dlOrderCommentDTO.getServiceSatisfaction() != null) {

                dlOrderConentExtDTO.setServiceSatisfaction(dlOrderCommentDTO.getServiceSatisfaction().toString());
            }
            // 卖家配送速度
            if (dlOrderCommentDTO.getDistributionSatisfaction() != null) {

                dlOrderConentExtDTO.setDistributionSatisfaction(dlOrderCommentDTO.getDistributionSatisfaction()
                        .toString());
            }
            // 获取订单评价标签内容
            dlOrderConentExtDTO.setOrderCommentTagList(orderCommentTagList.get(orderNo));
            // 获取订单评价内容
            dlOrderConentExtDTO.setOrderCommentConentList(orderCommentConentList.get(orderNo));
            // 买家名称
            dlOrderConentExtDTO.setBuyerName(dlOrderCommentDTO.getBuyerName());
            // 卖家名称
            dlOrderConentExtDTO.setSellerName(dlOrderCommentDTO.getSellerName());
            if (dlOrderCommentDTO.getAmount() != null) {
                // 订单金额
                dlOrderConentExtDTO.setAmount(dlOrderCommentDTO.getAmount().toString());
            }
            // 获取订单评价图片
            dlOrderConentExtDTO.setOrderCommentPicDTOList(orderCommentPicList.get(orderNo));
            result.add(dlOrderConentExtDTO);
        }
        jsonPage.setData_list(result);
        // log
        logger.info("[{}][{}][{}]", "用户中心-根据筛选条件获取订单评价详情 List", "方法出");
        return new ResponseEntity<JsonPage<List<DlOrderConentExtDTO>>>(jsonPage, HttpStatus.OK);
    }


    /**
     * 获取订单详情(订单评价页面)
     * 
     * @param orderNo
     *            订单No
     * @return 商品名称List ,sellerName 卖家名称
     */
    @ApiOperation(value = "获取订单详情", notes = "根据订单No获取订单详情")
    @ApiImplicitParams(value = { @ApiImplicitParam(paramType = "header", name = "X-ApiVersion", defaultValue = "1.0", dataType = "string") })
    @ApiResponses(value = {
            @ApiResponse(code = 200, message = "查询成功", response = JsonResult.class),
            @ApiResponse(code = 400, message = "参数错误", response = Void.class),
            @ApiResponse(code = 404, message = "资源不存在", response = Void.class),
            @ApiResponse(code = 415, message = "不支持的媒体类型/Api废弃/主版本号错误", response = Void.class),
            @ApiResponse(code = 500, message = "服务器异常", response = Void.class)
    })
    @RequestMapping(value = "/v1/order_detail_list/{orderNo}", method = RequestMethod.GET)
    public ResponseEntity<JsonResult<DlOrderDetailExtDTO>> getOrderDetailList(
            @ApiParam(value = "订单No") @PathVariable(value = "orderNo") String orderNo) {
        // log
        logger.info("[{}][{}][{}]", "用户中心-根据订单No获取订单详情", "方法入");
        HttpHeaders httpHeaders = new HttpHeaders();
        httpHeaders.add(HttpAspect.X_API_VERSION, "1.0");
        JsonResult<DlOrderDetailExtDTO> jsonResult = new JsonResult<DlOrderDetailExtDTO>();
        ResponseEntity<OrderDetailDTO> responseEntity1 = httpService.getJson4Entity(
                CenterBase.build(CenterBase.ocBase, "/trade/V1/orders/{orderNo}"), httpHeaders,
                new ParameterizedTypeReference<OrderDetailDTO>() {
                }, Maps.newHashMap(ImmutableMap.of("orderNo", (Object) orderNo)));
        if (!responseEntity1.getStatusCode().is2xxSuccessful()) {
            throw new RuntimeException();
        }
        DlOrderDetailExtDTO dlOrderDetailExtDTO = new DlOrderDetailExtDTO();
        if (responseEntity1.getBody() == null) {
            jsonResult.setStatus(1);
            jsonResult.setData(null);
            return new ResponseEntity<JsonResult<DlOrderDetailExtDTO>>(jsonResult, HttpStatus.OK);
        }
        dlOrderDetailExtDTO.setDate(responseEntity1.getBody().getCreateTime());
        dlOrderDetailExtDTO.setSellerName(responseEntity1.getBody().getSellerName());
        dlOrderDetailExtDTO.setOrderNo(orderNo);
        dlOrderDetailExtDTO.setGoodsSnapshotDTO(responseEntity1.getBody().getGoodsSnapshots());
        List<DlCommentTagStorageDTO> commentTagStorageList = dlOrderCommentApi.getCommentTagStorage().getResult();
        dlOrderDetailExtDTO.setCommentTagStorageList(commentTagStorageList);
        jsonResult.setStatus(0);
        jsonResult.setData(dlOrderDetailExtDTO);
        // log
        logger.info("[{}][{}][{}]", "用户中心-根据订单No获取订单详情", "方法出");
        return new ResponseEntity<JsonResult<DlOrderDetailExtDTO>>(jsonResult, HttpStatus.OK);

    }

    /**
     * 审批订单评价图片
     * 
     * @param orderNo
     *            订单No
     * @return boolean
     */
    @ApiOperation(value = "审批订单评价图片", notes = "审批订单评价图片")
    @ApiImplicitParams(value = { @ApiImplicitParam(paramType = "header", name = "X-ApiVersion", defaultValue = "1.0", dataType = "string") })
    @ApiResponses(value = {
            @ApiResponse(code = 200, message = "查询成功", response = JsonResult.class),
            @ApiResponse(code = 400, message = "参数错误", response = Void.class),
            @ApiResponse(code = 404, message = "资源不存在", response = Void.class),
            @ApiResponse(code = 415, message = "不支持的媒体类型/Api废弃/主版本号错误", response = Void.class),
            @ApiResponse(code = 500, message = "服务器异常", response = Void.class)
    })
    @RequestMapping(value = "/v1/examine_order_comment_pic", method = RequestMethod.GET)
    public ResponseEntity<JsonResult<Boolean>> examineOrderCommentPic(
            @ApiParam(value = "订单No") @RequestParam(value = "order_no", required = false) final String orderNo,
            @ApiParam(value = "审批状态") @RequestParam(value = "status", required = false) final String status,
            @ApiParam(value = "更新人") @RequestParam(value = "updated_person", required = false) final String updatedPerson) {
        // log
        logger.info("[{}][{}][{}]", "用户中心-审批订单评价图片", "方法入");
        JsonResult<Boolean> jsonResult = new JsonResult<Boolean>();
        List<String> orderNoList = new ArrayList<String>();
        orderNoList.add(orderNo);
        ServiceResult<Map<String, List<DlOrderCommentPicDTO>>> serviceResult = dlOrderCommentApi.getEvaluatePicList(orderNoList);
        if (serviceResult.getSuccess() && serviceResult.getResult() != null && serviceResult.getResult().size() > 0) {
            String orderStatus = serviceResult.getResult().get(orderNo).get(0).getStatus();
            if ("01".equals(orderStatus) || "02".equals(orderStatus)) {
                jsonResult.setStatus(1);
                jsonResult.setData(false);
            } else {
                Map<String, String> map = new HashMap<String, String>();
                map.put("orderNo", orderNo);
                map.put("status", status);
                map.put("updatedPerson", updatedPerson);
                Boolean result = dlOrderCommentApi.getEvaluatePicStatus(map).getResult();
                jsonResult.setStatus(0);
                jsonResult.setData(result);
            }
        }
        // log
        logger.info("[{}][{}][{}]", "用户中心-审批订单评价图片", "方法出");
        return new ResponseEntity<JsonResult<Boolean>>(jsonResult, HttpStatus.OK);
    }
    
    /**
     * 获取订单评价中经销商名称列表(联想经销商名称)
     * 
     * @param Map<String, Object>
     *       key:sellerName,卖家名称<br/>key:pageSize,页大小<br/>key:currentPage,当前页<br/>key:queryType,查询类型区别经销商统计还是订单评价内容(01,,02)(<br/>     
     * @return ResponseEntity<JsonPage<List<DlOrderCommentDTO>>>
     */
    @ApiOperation(value = "获取订单评价中经销商名称列表", notes = "获取订单评价中经销商名称列表")
    @ApiImplicitParams(value = { @ApiImplicitParam(paramType = "header", name = "X-ApiVersion", defaultValue = "1.0", dataType = "string") })
    @ApiResponses(value = {
            @ApiResponse(code = 200, message = "查询成功", response = JsonResult.class),
            @ApiResponse(code = 400, message = "参数错误", response = Void.class),
            @ApiResponse(code = 415, message = "不支持的媒体类型/Api废弃/主版本号错误", response = Void.class),
            @ApiResponse(code = 500, message = "服务器异常", response = Void.class)
    })
    @RequestMapping(value = "/v1/get_seller_name_list", method = RequestMethod.POST)
    public ResponseEntity<JsonPage<List<DlOrderCommentDTO>>> getSellerNameList(
            @ApiParam(value = "key:sellerName,卖家名称<br/>key:pageSize,页大小<br/>key:currentPage,当前页<br/>key:queryType,查询类型区别经销商统计还是订单评价内容(01,,02)(<br/>") @RequestBody Map<String, Object> requestBodyMap) {
        // log
        logger.info("[{}][{}][{}]", "获取订单评价中经销商名称(联想经销商名称)", "方法入");
        JsonPage<List<DlOrderCommentDTO>> jsonPage = new JsonPage<List<DlOrderCommentDTO>>();
        ServiceResult<List<DlOrderCommentDTO>> serviceResult;
        String queryType = (String) requestBodyMap.get("queryType");
        Assert.hasText(queryType, "查询类型不可为空!");
        //获取经销商统计中的所有卖家名称
        if("01".equals(queryType)){
            serviceResult = dlOrderCommentApi.getBusinessSellerNameList(requestBodyMap);
        }else{
            //获取评价管理中的所有卖家名称
            serviceResult = dlOrderCommentApi.getOrderCommentSellerNameList(requestBodyMap);
        }
        
        if (serviceResult.getPager().getRowsCount() != 0) {
            jsonPage.setTotal((serviceResult.getPager().getRowsCount() % serviceResult.getPager().getPageSize()) == 0 ? serviceResult
                    .getPager().getRowsCount() / serviceResult.getPager().getPageSize()
                    : serviceResult.getPager().getRowsCount() / serviceResult.getPager().getPageSize() + 1); // 获取总页数
            jsonPage.setData_list(serviceResult.getResult());
        } else {
            jsonPage.setTotal(0);
            jsonPage.setData_list(null);
        }
        // log
        logger.info("[{}][{}][{}]", "获取订单评价中经销商名称(联想经销商名称)", "方法出");
        return new ResponseEntity<JsonPage<List<DlOrderCommentDTO>>>(jsonPage, HttpStatus.OK);
    }
}

其中会用到很多对方法的描述的注解

####springfox、swagger.annotations.*注解部分参数介绍 
在上面只展示了如何使用,这里将对上面添加的swagger注解进行说明,笔记使用时参考了swagger annotations Api 手册,接下来进行部分常用注解使用说明介绍。 
- @ApiIgnore 忽略注解标注的类或者方法,不添加到API文档中

 

  • @ApiOperation 展示每个API基本信息
    • value api名称
    • notes 备注说明
  • @ApiImplicitParam 用于规定接收参数类型、名称、是否必须等信息
    • name 对应方法中接收参数名称
    • value 备注说明
    • required 是否必须 boolean
    • paramType 参数类型 body、path、query、header、form中的一种 
  • body 使用@RequestBody接收数据 POST有效
  • path 在url中配置{}的参数
  • query 普通查询参数 例如 ?query=q ,jquery ajax中data设置的值也可以,例如 {query:”q”},springMVC中不需要添加注解接收
  • header 使用@RequestHeader接收数据
  • form 笔者未使用,请查看官方API文档
    • dataType 数据类型,如果类型名称相同,请指定全路径,例如 dataType = “java.util.Date”,springfox会自动根据类型生成模型
  • @ApiImplicitParams 包含多个@ApiImplicitParam
  • @ApiResponse描述该api操作可能出现异常情况
    • code 数字,例如400
    • mesaage 异常信息
    • response 抛出异常类
  • @ApiResponses 包含多个@ApiResponse
    • value 描述该api操作可能出现一种或多种异常情况

@ApiParam 对单独某个参数进行说明,使用在类中或者controller方法中都可以。注解中的属性和上面列出的同名属性作用相同

以上为主要常用的注解介绍,请结合springfox使用查看

5、使用swagger2展示springfox生成的API文档

通过上述配置,我们已经完成了API数据生成,现在我们只需要使用swagger2 UI展示API文档即可

打开浏览器输入"http://uc.xxx.com/swagger-ui.html"

 

© 著作权归作者所有

共有 人打赏支持
粉丝 1
博文 2
码字总数 7948
作品 0
大连
程序员
加载中

评论(1)

Mi啥都不懂
Mi啥都不懂
你好, 按照你的部署步骤 部署了一下,发现最后显示fetching resource list: http://localhost:8080/solar-api/v2/api-docs 不显示API,您有碰到这个情况吗?
Spring Boot中使用Swagger2构建RESTful API文档

随着前后端的分离,借口文档变的尤其重要,今天我们来说一说用SWAGGER2,来风骚的生成api文档。配置很简单,废话少说,直接上代码: build.gradle SwaggerConfig.java DemoApplication.java...

不正经茂 ⋅ 2016/12/02 ⋅ 0

Spring mvc整合swagger2。

看到http://git.oschina.net/didispace/SpringBoot-Learning 的时候突然发现一个好玩的东西swagger2,是spring boot整合的。那么不用spring boot有没有办法呢,突然一下来感觉了就试试了。肯定...

z201 ⋅ 2016/08/04 ⋅ 0

swagger2常用注解说明

说明: 1.这里使用的版本:springfox-swagger2(2.4)springfox-swagger-ui (2.4) 2.这里是说明常用注解的含义和基本用法(也就是说已经对swagger进行集成完成) 没有集成的请参见 Spring...

u014231523 ⋅ 2017/08/01 ⋅ 0

Springfox

官网地址:http://springfox.github.io/springfox/ build.gradle

不正经茂 ⋅ 2016/08/03 ⋅ 0

使用springfox 集成swagger 与spring mvc

创建一个maven 模块 将springfox相关的配置都配置在一个单独的api模块中,可以把这个模块当成web应用跑起来。 在需要引入swagger注解的模块中引入相应的依赖。 在api模块中添加初始化swagger...

java9 ⋅ 2016/07/29 ⋅ 0

Swagger使用指南

1:认识Swagger Swagger 是一个规范和完整的框架,用于生成、描述、调用和可视化 RESTful 风格的 Web 服务。总体目标是使客户端和文件系统作为服务器以同样的速度来更新。文件的方法,参数和...

玄影镜心 ⋅ 2016/12/19 ⋅ 0

SpringMVC集成springfox-swagger2构建restful API

在集成springfox-swagger2之前,我也尝试着集成了swagger-springmvc,方式差不多,但是swagger-springmvc相对麻烦一点,因为要把它的静态文件copy到自己的项目中。所以还是用新版本的。 至于...

u014231523 ⋅ 2017/01/13 ⋅ 0

Spring 4.2.2以上版本和swagger集成方案和踩过的坑

因为公司使用的spring版本太高,在集成swagger的时候会存在一些问题,而网上的很多实例大多都是版本比较低的,为了是朋友们少才坑,我这边将集成的过程记录一下: 1. 引入spring、swagger的相...

原野先 ⋅ 2017/11/09 ⋅ 0

SpringBoot集成SwaggerUI

Swagger是当前最好用的Restful API文档生成的开源项目,通过swagger-spring项目,实现了与SpingMVC框架的无缝集成功能,方便生成spring restful风格的接口文档,同时swagger-ui还可以测试spr...

黄步欢 ⋅ 2017/05/19 ⋅ 0

spring boot 1.5.4 集成Swagger2构建Restful API(十八)

上一篇博客地址:springboot 1.5.4 整合rabbitMQ(十七) 1 Spring Boot集成Swagger2构建RESTful API文档 1.1 Swagger2简介 Swagger2官网:http://swagger.io/ 由于Spring Boot能够快速开发、...

wyait ⋅ 2017/11/03 ⋅ 0

没有更多内容

加载失败,请刷新页面

加载更多

下一页

Netweaver和SAP云平台的quota管理

Netweaver 以需要为一个用户上下文(User Context)能够在SAP extended memory区域中分配内存尺寸创建quota为例。 对于Dialog工作进程,使用事务码修改参数 ztta/roll_extension_dia. 对于非D...

JerryWang_SAP ⋅ 3分钟前 ⋅ 0

IDEA提示编码速度

焦点移动 将焦点冲代码编辑窗口移动到菜单栏:Alt+菜单栏带下划线字母 将焦点从工具窗口移动到代码编辑窗口 Esc或Shift+Esc 将焦点从代码编辑移动到最近使用的工具窗口 F12 模板提示 Ctrl+J...

bithup ⋅ 12分钟前 ⋅ 0

180623-SpringBoot之logback配置文件

SpringBoot配置logback 项目的日志配置属于比较常见的case了,之前接触和使用的都是Spring结合xml的方式,引入几个依赖,然后写个 logback.xml 配置文件即可,那么在SpringBoot中可以怎么做?...

小灰灰Blog ⋅ 36分钟前 ⋅ 0

冒泡排序

原理:比较两个相邻的元素,将值大的元素交换至右端。 思路:依次比较相邻的两个数,将小数放在前面,大数放在后面。即在第一趟:首先比较第1个和第2个数,将小数放前,大数放后。然后比较第...

人觉非常君 ⋅ 42分钟前 ⋅ 0

Vagrant setup

安装软件 brew cask install virtualboxbrew cask install vagrant 创建project mkdir -p mst/vmcd mst/vmvagrant init hashicorp/precise64vagrant up hashicorp/precise64是一个box......

遥借东风 ⋅ 59分钟前 ⋅ 0

python3.6 安装pyhook_3

我的是在win下的,忙了半天老是安装不了, pip install 也不行。 那么可以看出自己的版本是32bit 一脸懵逼 没办法 只好下载32版本的来安装 我一直以为 是 对应32 位的 。 下面是 小例子 http...

之渊 ⋅ 今天 ⋅ 0

004、location正则表达式

1、location的作用 location指令的作用是根据用户请求的URI来执行不同的应用,也就是根据用户请求的网站URL进行匹配,匹配成功即进行相关的操作。 2、location的语法 = 开头表示精确匹配 ^~...

北岩 ⋅ 今天 ⋅ 0

CentOS7 静默安装 Oracle 12c

环境 CentOS7.5 最小安装 数据库软件 linuxx64_12201_database.zip 操作系统配置 关闭 SELinux sed -i '/^SELINUX=/cSELINUX=disabled' /etc/selinux/config 关闭防火墙 systemctl disable ......

Colben ⋅ 今天 ⋅ 0

Yii2中findAll()的正确使用姿势/返回为空的处理办法

从一次错误的操作开始 $buildingObject = Building::findAll("status=1"); 1 这个调用看着没有任何毛病,但是在使用时返回的结果却是一个空数组。再回过头来看看数据表中: 按照套路来讲,查...

dragon_tech ⋅ 今天 ⋅ 0

如何优雅的编程——C语言界面的一点小建议

我们鼓励在编程时应有清晰的哲学思维,而不是给予硬性规则。我并不希望你们能认可所有的东西,因为它们只是观点,观点会随着时间的变化而变化。可是,如果不是直到现在把它们写在纸上,长久以...

柳猫 ⋅ 今天 ⋅ 0

没有更多内容

加载失败,请刷新页面

加载更多

下一页

返回顶部
顶部