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.ZhtjGljszkpd;
import com.elephant.framework.galaxy.aroad.module.zhtj.service.ZhtjGljszkpdService;
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 17:58:58
 */
@RestController
@AllArgsConstructor
@RequestMapping("/zhtj/zhtjgljszkpd")
public class ZhtjGljszkpdController extends BaseController  {
  private final ZhtjGljszkpdService zhtjGljszkpdService;

  /**
   * 分页查询
   * @param page 分页对象
   * @param zhtjGljszkpd 综合统计_公路技术状况评定
   * @return
   */
  @GetMapping("/page")
  public R getZhtjGljszkpdPage(Page page, ZhtjGljszkpd zhtjGljszkpd) {
    if(zhtjGljszkpd.getYear() == null || "".equals(zhtjGljszkpd.getYear())){
      // 获取最新的时间
      zhtjGljszkpd.setYear(zhtjGljszkpdService.newYear(zhtjGljszkpd.getType()));
    }
    return  new R<>(zhtjGljszkpdService.page(page,Wrappers.query(zhtjGljszkpd)));
  }


  /**
   * 按年度和道路类型查询评定数据
   * @param zhtjGljszkpd 综合统计_公路技术状况评定
   * @return R
   */
  @GetMapping("/getList")
  public R getList(ZhtjGljszkpd zhtjGljszkpd) {
    return new R<>(zhtjGljszkpdService.list(Wrappers.query(zhtjGljszkpd)));
  }

}
