package easydo.technology.controller;

import easydo.technology.exception.BizException;
import easydo.technology.model.SalePlan;
import easydo.technology.service.SalePlanService;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.sql.DataSource;
import java.sql.Connection;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/salePlan")
public class SalePlanController {
    @Resource
    SalePlanService salePlanService;


    @RequestMapping(value = "/getList")
    public Object getList(@RequestBody Map<String, Object> map) throws Exception {
        List<SalePlan> list = salePlanService.getList(map);
        return new ResponseEntity<>(list, HttpStatus.OK);
    }

    @RequestMapping(value = "/getPage")
    public Object getPage(@RequestBody Map<String, Object> map) throws Exception {
        Map<String, Object> recordsPage = salePlanService.getPage(map);
        return new ResponseEntity<>(recordsPage, HttpStatus.OK);
    }

    @RequestMapping(value = "/save")
    public Object save(@RequestBody SalePlan model) throws Exception {
        return new ResponseEntity<>(salePlanService.save(model), HttpStatus.OK);
    }

    @RequestMapping(value = "/update")
    public Object update(@RequestBody SalePlan model) throws Exception {
        salePlanService.update(model);
        return new ResponseEntity<>(HttpStatus.OK);
    }

    @RequestMapping(value = "/remove")
    public Object deleteProgram(@RequestBody SalePlan model) throws Exception {
        salePlanService.remove(model);
        return new ResponseEntity<>(HttpStatus.OK);
    }
}
