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

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.elephant.framework.galaxy.aroad.module.zhtj.entity.ZhtjGlqsqkQlqk;
import com.elephant.framework.galaxy.aroad.module.zhtj.service.ZhtjGlqsqkQlqkService;
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;


/**
 * 综合统计_公路桥隧情况_桥梁情况
 *
 * @author xuyanqi
 * @date 2019-03-12 08:57:24
 */
@RestController
@AllArgsConstructor
@RequestMapping("/zhtj/zhtjglqsqkqlqk")
public class ZhtjGlqsqkQlqkController extends BaseController  {

  private final ZhtjGlqsqkQlqkService zhtjGlqsqkQlqkService;

  /**
   * 分页查询
   * @param page 分页对象
   * @param zhtjGlqsqkQlqk 综合统计_公路桥隧情况_桥梁情况
   * @return
   */
  @GetMapping("/page")
  public R getZhtjGlqsqkQlqkPage(Page page, ZhtjGlqsqkQlqk zhtjGlqsqkQlqk) {
    if(zhtjGlqsqkQlqk.getYear() == null || "".equals(zhtjGlqsqkQlqk.getYear())){
      // 获取最新的时间
      zhtjGlqsqkQlqk.setYear(zhtjGlqsqkQlqkService.newYear());
    }
    return  new R<>(zhtjGlqsqkQlqkService.page(page,Wrappers.query(zhtjGlqsqkQlqk)));
  }


  /**
   * 通过id查询综合统计_公路桥隧情况_桥梁情况
   * @param id id
   * @return R
   */
  @GetMapping("/{id}")
  public R getById(@PathVariable("id") Integer id){
    return new R<>(zhtjGlqsqkQlqkService.getById(id));
  }

  /**
   * 综合展示-综合统计-桥梁统计
   * @param zhtjGlqsqkQlqk
   * @return
   */
  @GetMapping("/getQlqk")
  public R getQlqk(ZhtjGlqsqkQlqk zhtjGlqsqkQlqk) {
    if(zhtjGlqsqkQlqk.getYear() == null || "".equals(zhtjGlqsqkQlqk.getYear())){
      // 获取最新的时间
      zhtjGlqsqkQlqk.setYear(zhtjGlqsqkQlqkService.newYear());
    }
    return  new R<>(zhtjGlqsqkQlqkService.getQlqk(zhtjGlqsqkQlqk));
  }
}
