package com.elephant.framework.galaxy.aroad.module.zhjg.controller;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.elephant.framework.galaxy.aroad.module.zhjg.entity.ZhjgDckhRwCb;
import com.elephant.framework.galaxy.aroad.module.zhjg.service.ZhjgDckhRwCbService;
import com.elephant.framework.galaxy.aroad.response.R;
import com.elephant.framework.galaxy.aroad.module.common.annotation.SysLog;

import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;
import com.elephant.framework.galaxy.aroad.module.common.controller.BaseController;

import java.time.LocalDateTime;


/**
 * 任务催办
 *
 * @author zyw
 * @date 2019-04-15 16:27:04
 */
@RestController
@AllArgsConstructor
@RequestMapping("/zhjg/zhjgdckhrwcb")
public class ZhjgDckhRwCbController extends BaseController  {

  private final ZhjgDckhRwCbService zhjgDckhRwCbService;

  /**
   * 分页查询
   * @param page 分页对象
   * @param zhjgDckhRwCb 任务催办
   * @return
   */
  @GetMapping("/page")
  public R getZhjgDckhRwCbPage(Page page, ZhjgDckhRwCb zhjgDckhRwCb) {
    return  new R<>(zhjgDckhRwCbService.page(page,Wrappers.query(zhjgDckhRwCb)));
  }


  /**
   * 通过id查询任务催办
   * @param id id
   * @return R
   */
  @GetMapping("/{id}")
  public R getById(@PathVariable("id") Integer id){
    return new R<>(zhjgDckhRwCbService.getById(id));
  }

  /**
   * 新增任务催办
   * @param zhjgDckhRwCb 任务催办
   * @return R
   */
  @SysLog("新增任务催办")
  @PostMapping
  public R save(@RequestBody ZhjgDckhRwCb zhjgDckhRwCb){
    zhjgDckhRwCb.setCbsj(LocalDateTime.now());
    return new R<>(zhjgDckhRwCbService.save(zhjgDckhRwCb));
  }

  /**
   * 修改任务催办
   * @param zhjgDckhRwCb 任务催办
   * @return R
   */
  @SysLog("修改任务催办")
  @PutMapping
  public R updateById(@RequestBody ZhjgDckhRwCb zhjgDckhRwCb){
    return new R<>(zhjgDckhRwCbService.updateById(zhjgDckhRwCb));
  }

  /**
   * 通过id删除任务催办
   * @param id id
   * @return R
   */
  @SysLog("删除任务催办")
  @DeleteMapping("/{id}")
  public R removeById(@PathVariable Integer id){
    return new R<>(zhjgDckhRwCbService.removeById(id));
  }

}
