package com.ruoyi.web.modules.industryservice.controller;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.web.modules.industryservice.domain.BizDisposableIncome;
import com.ruoyi.web.modules.industryservice.service.IBizDisposableIncomeService;

/**
 * 可支配收入数据填报
 */
@RestController
@RequestMapping("/dataModel/disposableIncome")
public class BizDisposableIncomeController extends BaseController
{
    @Autowired
    private IBizDisposableIncomeService bizDisposableIncomeService;

    @PreAuthorize("@ss.hasPermi('dataModel:disposableIncome:list')")
    @GetMapping("/list")
    public TableDataInfo list(BizDisposableIncome query)
    {
        startPage();
        List<BizDisposableIncome> list = bizDisposableIncomeService.selectBizDisposableIncomeList(query);
        return getDataTable(list);
    }

    @PreAuthorize("@ss.hasPermi('dataModel:disposableIncome:query')")
    @GetMapping("/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(bizDisposableIncomeService.selectBizDisposableIncomeById(id));
    }

    @PreAuthorize("@ss.hasPermi('dataModel:disposableIncome:add')")
    @Log(title = "可支配收入数据填报", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@Validated @RequestBody BizDisposableIncome row)
    {
        row.setCreateBy(getUsername());
        return toAjax(bizDisposableIncomeService.insertBizDisposableIncome(row));
    }

    @PreAuthorize("@ss.hasPermi('dataModel:disposableIncome:edit')")
    @Log(title = "可支配收入数据填报", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@Validated @RequestBody BizDisposableIncome row)
    {
        row.setUpdateBy(getUsername());
        return toAjax(bizDisposableIncomeService.updateBizDisposableIncome(row));
    }

    @PreAuthorize("@ss.hasPermi('dataModel:disposableIncome:remove')")
    @Log(title = "可支配收入数据填报", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(bizDisposableIncomeService.deleteBizDisposableIncomeByIds(ids, getUsername()));
    }

    @PreAuthorize("@ss.hasPermi('dataModel:disposableIncome:list')")
    @GetMapping("/yearOptions")
    public AjaxResult yearOptions()
    {
        return success(bizDisposableIncomeService.listYearOptions());
    }
}
