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.entity.ZhtjGlqsqkSdqk;
import com.elephant.framework.galaxy.aroad.module.zhtj.service.ZhtjGlqsqkSdqkService;
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-11 20:53:25
 */
@RestController
@AllArgsConstructor
@RequestMapping("/zhtj/zhtjglqsqksdqk")
public class ZhtjGlqsqkSdqkController extends BaseController  {

  private final ZhtjGlqsqkSdqkService zhtjGlqsqkSdqkService;

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


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



  /**
   * 综合展示-综合统计-隧道统计
   * @param zhtjGlqsqkSdqk
   * @return
   */
  @GetMapping("/getSdqk")
  public R getSdqk(ZhtjGlqsqkSdqk zhtjGlqsqkSdqk) {
    if(zhtjGlqsqkSdqk.getYear() == null || "".equals(zhtjGlqsqkSdqk.getYear())){
      // 获取最新的时间
      zhtjGlqsqkSdqk.setYear(zhtjGlqsqkSdqkService.newYear());
    }
    return  new R<>(zhtjGlqsqkSdqkService.getSdqk(zhtjGlqsqkSdqk));
  }
}
