package com.elephant.framework.galaxy.aroad.module.zhyh.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.zhyh.entity.ZhyhQldtjgLrbsjhql;
import com.elephant.framework.galaxy.aroad.module.zhyh.service.ZhyhQldtjgLrbsjhqlService;
import lombok.AllArgsConstructor;
import org.apache.commons.lang.StringUtils;
import org.springframework.web.bind.annotation.*;
import com.elephant.framework.galaxy.aroad.module.common.controller.BaseController;


/**
 * 列入部、省计划桥梁
 *
 * @author wangjian
 * @date 2019-04-22 15:05:42
 */
@RestController
@AllArgsConstructor
@RequestMapping("/zhyh/qldtjglrbsjhql")
public class ZhyhQldtjgLrbsjhqlController extends BaseController  {

  private final  ZhyhQldtjgLrbsjhqlService zhyhQldtjgLrbsjhqlService;

  /**
   * 分页查询
   * @param page 分页对象
   * @param zhyhQldtjgLrbsjhql 列入部、省计划桥梁
   * @return
   */
  @GetMapping("/page")
  public R getZhyhQldtjgLrbsjhqlPage(Page page, ZhyhQldtjgLrbsjhql zhyhQldtjgLrbsjhql) {
    return  new R<>(zhyhQldtjgLrbsjhqlService.page(page,Wrappers.<ZhyhQldtjgLrbsjhql>lambdaQuery().like(StringUtils.isNotBlank(zhyhQldtjgLrbsjhql.getLxbh()),ZhyhQldtjgLrbsjhql::getLxbh,zhyhQldtjgLrbsjhql.getLxbh()).eq(StringUtils.isNotBlank(zhyhQldtjgLrbsjhql.getJgdw()),ZhyhQldtjgLrbsjhql::getJgdw,zhyhQldtjgLrbsjhql.getJgdw())));
  }


  /**
   * 通过id查询列入部、省计划桥梁
   * @param id id
   * @return R
   */
  @GetMapping("/{id}")
  public R getById(@PathVariable("id") String id){
    return new R<>(zhyhQldtjgLrbsjhqlService.getById(id));
  }

  /**
   * 新增列入部、省计划桥梁
   * @param zhyhQldtjgLrbsjhql 列入部、省计划桥梁
   * @return R
   */
  @SysLog("新增列入部、省计划桥梁")
  @PostMapping
  public R save(@RequestBody ZhyhQldtjgLrbsjhql zhyhQldtjgLrbsjhql){
    return new R<>(zhyhQldtjgLrbsjhqlService.save(zhyhQldtjgLrbsjhql));
  }

  /**
   * 修改列入部、省计划桥梁
   * @param zhyhQldtjgLrbsjhql 列入部、省计划桥梁
   * @return R
   */
  @SysLog("修改列入部、省计划桥梁")
  @PutMapping
  public R updateById(@RequestBody ZhyhQldtjgLrbsjhql zhyhQldtjgLrbsjhql){
    return new R<>(zhyhQldtjgLrbsjhqlService.updateById(zhyhQldtjgLrbsjhql));
  }

  /**
   * 通过id删除列入部、省计划桥梁
   * @param id id
   * @return R
   */
  @SysLog("删除列入部、省计划桥梁")
  @DeleteMapping("/{id}")
  public R removeById(@PathVariable String id){
    return new R<>(zhyhQldtjgLrbsjhqlService.removeById(id));
  }

}
