package com.jiayue.ipp.idp.controller;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jiayue.ipp.common.data.entity.NwpHis;
import com.jiayue.ipp.idp.service.NwpHisService;
import com.jiayue.ipp.idp.util.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;


/**
 * idp_nwp_his
 *
 * @author whc
 * @date 2022-03-18 15:49:46
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/nwphis")
@Api(value = "nwphis", tags = "idp_nwp_his管理")
public class NwpHisController {

    private final NwpHisService nwpHisService;

    /**
     * 分页查询
     *
     * @param page   分页对象
     * @param nwpHis idp_nwp_his
     * @return
     */
    @ApiOperation(value = "分页查询", notes = "分页查询")
    @GetMapping("/page")
    //@PreAuthorize("@pms.hasPermission('idp_nwphis_get')")
    public R getNwpHisPage(Page page, NwpHis nwpHis) {
        return R.ok(nwpHisService.page(page, Wrappers.query(nwpHis)));
    }

    /**
     * 通过id查询idp_nwp_his
     *
     * @param id id
     * @return R
     */
    @ApiOperation(value = "通过id查询", notes = "通过id查询")
    @GetMapping("/{id}")
    //@PreAuthorize("@pms.hasPermission('idp_nwphis_get')")
    public R getById(@PathVariable("id") String id) {
        return R.ok(nwpHisService.getById(id));
    }

    /**
     * 新增idp_nwp_his
     *
     * @param nwpHis idp_nwp_his
     * @return R
     */
    @ApiOperation(value = "新增idp_nwp_his", notes = "新增idp_nwp_his")
    //    @SysLog("新增idp_nwp_his")
    @PostMapping
    //@PreAuthorize("@pms.hasPermission('idp_nwphis_add')")
    public R save(@RequestBody NwpHis nwpHis) {
        return R.ok(nwpHisService.save(nwpHis));
    }

    /**
     * 修改idp_nwp_his
     *
     * @param nwpHis idp_nwp_his
     * @return R
     */
    @ApiOperation(value = "修改idp_nwp_his", notes = "修改idp_nwp_his")
    //    @SysLog("修改idp_nwp_his")
    @PutMapping
    //@PreAuthorize("@pms.hasPermission('idp_nwphis_edit')")
    public R updateById(@RequestBody NwpHis nwpHis) {
        return R.ok(nwpHisService.updateById(nwpHis));
    }

    /**
     * 通过id删除idp_nwp_his
     *
     * @param id id
     * @return R
     */
    @ApiOperation(value = "通过id删除idp_nwp_his", notes = "通过id删除idp_nwp_his")
    //    @SysLog("通过id删除idp_nwp_his")
    @DeleteMapping("/{id}")
    //@PreAuthorize("@pms.hasPermission('idp_nwphis_del')")
    public R removeById(@PathVariable String id) {
        return R.ok(nwpHisService.removeById(id));
    }

}
