package com.jeeplus.modules.app.tjcclz.com.sales.performance.web;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.fasterxml.jackson.databind.util.JSONPObject;
import com.jeeplus.common.json.ResultBean;
import com.jeeplus.common.web.BaseController;
import com.jeeplus.modules.app.tjcclz.com.sales.performance.entity.Performance;
import com.jeeplus.modules.app.tjcclz.com.sales.performance.service.PerformanceService;
/**
* @JSONPObject使用例子
* 注释里的为前台调用例子
* function jsonpCallBack(){
*
* }
*
* $.ajax({
* url:'http://192.168.11.43:8080/BI/a/sales/performance/getDirectConsultNewByWkNo',
* type: "get",
* dataType: "jsonp",
* data:{"wkNo":userid,"callback":"jsonCallBack"},
* success: function(json) {
* console.log(json);
* },
* error: function(){
* console.log('Error');
* }
* });
* @注意 JSONPObject 引用的是com.fasterxml.jackson.databind.util.JSONPObject包
*
* @author liuxudong
* @version 2018-01-15
*/
@Controller
@RequestMapping(value = "${adminPath}/sales/performance")
public class PerformanceController extends BaseController {
@Autowired
private PerformanceService performanceService;
/**
* 当月直接新开
* @param performance
* @return
*/
@ResponseBody
@RequestMapping(value = "getDirectConsultNewByWkNo")
public JSONPObject getDirectConsultNewByWkNo(Performance performance, String callback) {
ResultBean<Performance> entity = null;
try {
entity = new ResultBean<Performance>(performanceService.getDirectConsultNewByWkNo(performance));
} catch (Throwable e) {
entity = new ResultBean<Performance>(e);
}
entity.setInfo("当月自动或手动入BOSS的、创建人和收费人一样的、账务明细当前状态在0到199之间的新开咨询单");//公式解释
return new JSONPObject(callback, entity);
}
}
JSONP与JSONPObject结合解决ajax跨域
最新推荐文章于 2022-07-12 13:18:15 发布