java接口供APP端调用

java接口供APP端调用packagecom.idorabox.manage.web.app;importjava.util.HashMap;importjava.util.Map;importjava.io.IOException;importjava.io.PrintWriter;importjavax.annotation.Resource;importjavax.servlet.http.H

package com.idorabox.manage.web.app;

import java.util.HashMap;
import java.util.Map;
import java.io.IOException;
import java.io.PrintWriter;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import com.idorabox.manage.service.book.JdBookTokenService;
import com.idorabox.manage.service.jd.JdTokenService;
import com.idorabox.manage.web.util.HttpUtils;
/** * 3.12 商品可售验证接口 * @author chen * */
@Controller
@RequestMapping("/appMessage")
public class CheckAction {
    @Resource
    JdTokenService jdTokenService;
    @Resource
    JdBookTokenService jdBookTokenService;
    @RequestMapping("/productCheck.html")
    public void check(
            @RequestParam(value = "skuIds", required = false)String skuIds,
            @RequestParam(value = "token", required = false)String token,
            HttpServletResponse response) {
        Map<String, String> params = new HashMap<String, String>();
        //京东查询接口
        String url = "https://bizapi.jd.com/api/product/check";
        params.put("token", token);
        params.put("skuIds", skuIds);
        String jsonResult = HttpUtils.sendPost(url, params);
        //将调用京东查询的接口的数据写出给app端
        PrintWriter writer = null;
            try {
               writer = response.getWriter();
               writer.write(jsonResult);
            } catch (IOException e) {
                e.printStackTrace();
            } finally {
                writer.close();
            }
    }
}

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
如需转载请保留出处:https://bianchenghao.cn/34459.html

(0)
编程小号编程小号

相关推荐

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注