package com.nmgs.controller;

import com.alibaba.fastjson.JSONObject;
import com.nmgs.config.ResultData;
import com.nmgs.service.impl.SelectDataImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.util.List;
import java.util.Map;

/**
 * 下拉框内容查询
 */
@RestController
@RequestMapping("/selectData")
@Api(tags = "下拉值获取")
public class SelectController {
    @Autowired
    public SelectDataImpl selectDataImpl;
    SimpleDateFormat df=new SimpleDateFormat("yyyy-MM-dd");
   //获取查验数据
    @RequestMapping(value="/getListByType",method = {RequestMethod.POST})
    @ApiOperation(httpMethod = "POST",value = "下拉值获取")
    public ResultData<List> submitCheck(HttpServletRequest request, @RequestParam(required = true,value = "req") String req,
            @RequestParam(required = false,value = "serviceAreaName") String serviceAreaName,
    @RequestParam(required = false,value = "serviceAreaPosition") String serviceAreaPosition) throws SQLException {
        JSONObject paramsData=new JSONObject();
        paramsData.put("selectType",req);
        paramsData.put("serviceAreaName",serviceAreaName);
        paramsData.put("servicePosition",serviceAreaPosition);
        List ret=selectDataImpl.getDataByType(paramsData);
        if(ret==null){
            return ResultData.fail(-1,"查询数据失败");
        }
        return ResultData.success("查询成功",ret,ret.size());
    }

}
