package com.zcloud.controller.depository;

import com.zcloud.controller.base.BaseController;
import com.zcloud.entity.Page;
import com.zcloud.entity.PageData;
import com.zcloud.service.bus.CorpInfoService;
import com.zcloud.service.depository.RiskUnitService;
import com.zcloud.util.Jurisdiction;
import com.zcloud.util.Tools;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/riskUnit")
public class RiskUnitController extends BaseController {

    @Resource
    private RiskUnitService riskUnitService;

    @Resource
    private CorpInfoService corpInfoService;

    /**列表
     * @param page
     * @throws Exception
     */
    @RequestMapping(value="/list")
    @ResponseBody
    public Object list(Page page) throws Exception{
        Map<String,Object> map = new HashMap<String,Object>();
        String errInfo = "success";
        PageData pd = new PageData();
        pd = this.getPageData();
        String KEYWORDS = pd.getString("KEYWORDS");						//关键词检索条件
        if(Tools.notEmpty(KEYWORDS))pd.put("KEYWORDS", KEYWORDS.trim());
        page.setPd(pd);
        List<PageData> varList = riskUnitService.getList(page);	//列出RiskUnit列表
        map.put("varList", varList);
        map.put("page", page);
        map.put("result", errInfo);
        return map;
    }

    /**
     * 列表
     */
    @RequestMapping(value="/getAllList")
    @ResponseBody
    public Object getAllList() throws Exception{
        Map<String,Object> map = new HashMap<String,Object>();
        PageData request = this.getPageData();
        map.put("list", riskUnitService.getAllList(request));
        map.put("result", "success");
        return map;
    }

    /**列表
     * @param page
     * @throws Exception
     */
    @RequestMapping(value="/getCorpInfoList")
    @ResponseBody
    public Object getCorpInfoList() throws Exception{
        Map<String,Object> map = new HashMap<String,Object>();
        PageData request = this.getPageData();
        map.put("list", corpInfoService.getAllList(request));
        map.put("result", "success");
        return map;
    }

}
