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

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.elephant.framework.galaxy.aroad.response.R;
import com.elephant.framework.galaxy.aroad.module.common.annotation.SysLog;
import com.elephant.framework.galaxy.aroad.module.zhjc.entity.ZhjcGljcQsgdsxmqk;
import com.elephant.framework.galaxy.aroad.module.zhjc.service.ZhjcGljcQsgdsxmqkService;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;
import com.elephant.framework.galaxy.aroad.module.common.controller.BaseController;


/**
 * 全省各地市项目情况
 *
 * @author wangjian
 * @date 2019-03-29 14:42:12
 */
@RestController
@AllArgsConstructor
@RequestMapping("/zhjc/gljcqsgdsxmqk")
public class ZhjcGljcQsgdsxmqkController extends BaseController  {

  private final  ZhjcGljcQsgdsxmqkService zhjcGljcQsgdsxmqkService;

  /**
   * 分页查询
   * @param page 分页对象
   * @param zhjcGljcQsgdsxmqk 全省各地市项目情况
   * @return
   */
  @GetMapping("/page")
  public R getZhjcGljcQsgdsxmqkPage(Page page, ZhjcGljcQsgdsxmqk zhjcGljcQsgdsxmqk) {
    return  new R<>(zhjcGljcQsgdsxmqkService.page(page,Wrappers.query(zhjcGljcQsgdsxmqk)));
  }


  /**
   * 通过id查询全省各地市项目情况
   * @param id id
   * @return R
   */
  @GetMapping("/{id}")
  public R getById(@PathVariable("id") String id){
    return new R<>(zhjcGljcQsgdsxmqkService.getById(id));
  }

  /**
   * 新增全省各地市项目情况
   * @param zhjcGljcQsgdsxmqk 全省各地市项目情况
   * @return R
   */
  @SysLog("新增全省各地市项目情况")
  @PostMapping
  public R save(@RequestBody ZhjcGljcQsgdsxmqk zhjcGljcQsgdsxmqk){
    return new R<>(zhjcGljcQsgdsxmqkService.save(zhjcGljcQsgdsxmqk));
  }

  /**
   * 修改全省各地市项目情况
   * @param zhjcGljcQsgdsxmqk 全省各地市项目情况
   * @return R
   */
  @SysLog("修改全省各地市项目情况")
  @PutMapping
  public R updateById(@RequestBody ZhjcGljcQsgdsxmqk zhjcGljcQsgdsxmqk){
    return new R<>(zhjcGljcQsgdsxmqkService.updateById(zhjcGljcQsgdsxmqk));
  }

  /**
   * 通过id删除全省各地市项目情况
   * @param id id
   * @return R
   */
  @SysLog("删除全省各地市项目情况")
  @DeleteMapping("/{id}")
  public R removeById(@PathVariable String id){
    return new R<>(zhjcGljcQsgdsxmqkService.removeById(id));
  }

}
