package com.ag.web.agCommon;

import com.ag.secp.platform.spring.BeanMange;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 通用mobile接口
 * @author running
 * @since 2021-01-12
 */
@Controller
@RequestMapping(value = "/mobileapi")
public class MobileApiController {

    /**
     * url地址 http://localhost:8080/mobileapi/common?bean=demoService&method=execute&name=hello
     * @param request
     * @param response
     * @throws Exception
     */
    @RequestMapping(value = "/common")
//    @RequestMapping(value = "/common",method = {RequestMethod.POST})
//    @ResponseBody
    public Object common(HttpServletRequest request, HttpServletResponse response) throws Exception {
        BeanMange beanMange = new BeanMange(request, response, request.getParameter("bean"),
                request.getParameter("method"), null);
        return beanMange.execute();
    }

    @RequestMapping(value = "/upload")
    @ResponseBody
    public Object upload(HttpServletRequest request, HttpServletResponse response) throws Exception {
        BeanMange beanMange = new BeanMange();
        beanMange.bean = request.getParameter("bean");
        beanMange.method = request.getParameter("method");
        beanMange.request = request;
        beanMange.response = response;
        return beanMange.execute();

    }

}
