package com.fastbee.data.controller.userRecharge;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.fastbee.common.annotation.Log;
import com.fastbee.common.core.controller.BaseController;
import com.fastbee.common.core.domain.AjaxResult;
import com.fastbee.common.enums.BusinessType;
import com.fastbee.rechargecard.domain.NgUrbanMuRights;
import com.fastbee.rechargecard.service.INgUrbanMuRightsService;
import com.fastbee.common.utils.poi.ExcelUtil;
import com.fastbee.common.core.page.TableDataInfo;

/**
 * 城镇亩均确权Controller
 *
 * @author kerwincui
 * @date 2024-12-19
 */
@RestController
@RequestMapping("/rechargecard/rights")
@Api(tags = "城镇亩均确权")
public class NgUrbanMuRightsController extends BaseController
{
    @Autowired
    private INgUrbanMuRightsService ngUrbanMuRightsService;

/**
 * 查询城镇亩均确权列表
 */
//@PreAuthorize("@ss.hasPermi('rechargecard:rights:list')")
@GetMapping("/list")
@ApiOperation("查询城镇亩均确权列表")
    public TableDataInfo list(NgUrbanMuRights ngUrbanMuRights)
    {
        startPage();
        List<NgUrbanMuRights> list = ngUrbanMuRightsService.selectNgUrbanMuRightsList(ngUrbanMuRights);
        return getDataTable(list);
    }

    /**
     * 导出城镇亩均确权列表
     */
    @ApiOperation("导出城镇亩均确权列表")
//    @PreAuthorize("@ss.hasPermi('rechargecard:rights:export')")
    @PostMapping("/export")
    public void export(HttpServletResponse response, NgUrbanMuRights ngUrbanMuRights)
    {
        List<NgUrbanMuRights> list = ngUrbanMuRightsService.selectNgUrbanMuRightsList(ngUrbanMuRights);
        ExcelUtil<NgUrbanMuRights> util = new ExcelUtil<NgUrbanMuRights>(NgUrbanMuRights.class);
        util.exportExcel(response, list, "城镇亩均确权数据");
    }

    /**
     * 获取城镇亩均确权详细信息
     */
//    @PreAuthorize("@ss.hasPermi('rechargecard:rights:query')")
    @GetMapping(value = "/{muRightsId}")
    @ApiOperation("获取城镇亩均确权详细信息")
    public AjaxResult getInfo(@PathVariable("muRightsId") Long muRightsId)
    {
        return success(ngUrbanMuRightsService.selectNgUrbanMuRightsByMuRightsId(muRightsId));
    }

    /**
     * 新增城镇亩均确权
     */
//    @PreAuthorize("@ss.hasPermi('rechargecard:rights:add')")
    @PostMapping
    @ApiOperation("新增城镇亩均确权")
    public AjaxResult add(@RequestBody NgUrbanMuRights ngUrbanMuRights)
    {
        return toAjax(ngUrbanMuRightsService.insertNgUrbanMuRights(ngUrbanMuRights));
    }

    /**
     * 修改城镇亩均确权
     */
//    @PreAuthorize("@ss.hasPermi('rechargecard:rights:edit')")
    @PutMapping
    @ApiOperation("修改城镇亩均确权")
    public AjaxResult edit(@RequestBody NgUrbanMuRights ngUrbanMuRights)
    {
        return toAjax(ngUrbanMuRightsService.updateNgUrbanMuRights(ngUrbanMuRights));
    }

    /**
     * 删除城镇亩均确权
     */
//    @PreAuthorize("@ss.hasPermi('rechargecard:rights:remove')")
    @DeleteMapping("/{muRightsIds}")
    @ApiOperation("删除城镇亩均确权")
    public AjaxResult remove(@PathVariable Long[] muRightsIds)
    {
        return toAjax(ngUrbanMuRightsService.deleteNgUrbanMuRightsByMuRightsIds(muRightsIds));
    }
}
