package easydo.technology.system.rest;

import easydo.technology.components.JdbcClient;
import easydo.technology.system.model.SysJob;
import easydo.technology.system.model.SysRole;
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 java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/sysJob")
public class SysJobController {
    @Resource
    JdbcClient jdbcClient;

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

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


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


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

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

}
