package com.leromro.core.controller;

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

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import com.leromro.common.core.domain.R;
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.leromro.common.annotation.Log;
import com.leromro.common.core.controller.BaseController;
import com.leromro.common.core.domain.AjaxResult;
import com.leromro.common.enums.BusinessType;
import com.leromro.core.domain.VolunteerAccountChange;
import com.leromro.core.service.IVolunteerAccountChangeService;
import com.leromro.common.utils.poi.ExcelUtil;
import com.leromro.common.core.page.TableDataInfo;

/**
 * 志愿者账号变动明细Controller
 * 
 * @author ruoyi
 * @date 2025-04-11
 */
@RestController
@Api(tags = "志愿者账号变动明细")
@RequestMapping("/core/volunteer/account-change")
public class VolunteerAccountChangeController extends BaseController
{
    @Autowired
    private IVolunteerAccountChangeService volunteerAccountChangeService;

    /**
     * 查询志愿者账号变动明细列表
     */
    @ApiOperation("查询志愿者账号变动明细列表")
    @PreAuthorize("@ss.hasPermi('core:volunteer/account-change:list')")
    @GetMapping("/list")
    public TableDataInfo<VolunteerAccountChange> list(VolunteerAccountChange volunteerAccountChange)
    {
        startPage();
        List<VolunteerAccountChange> list = volunteerAccountChangeService.selectVolunteerAccountChangeList(volunteerAccountChange);
        return getDataTable(list);
    }

    /**
     * 导出志愿者账号变动明细列表
     */
    @ApiOperation("导出志愿者账号变动明细列表")
    @PreAuthorize("@ss.hasPermi('core:volunteer/account-change:export')")
    @Log(title = "志愿者账号变动明细", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, VolunteerAccountChange volunteerAccountChange)
    {
        List<VolunteerAccountChange> list = volunteerAccountChangeService.selectVolunteerAccountChangeList(volunteerAccountChange);
        ExcelUtil<VolunteerAccountChange> util = new ExcelUtil<VolunteerAccountChange>(VolunteerAccountChange.class);
        util.exportExcel(response, list, "志愿者账号变动明细数据");
    }

    /**
     * 获取志愿者账号变动明细详细信息
     */
    @ApiOperation("获取志愿者账号变动明细详细信息")
    @PreAuthorize("@ss.hasPermi('core:volunteer/account-change:query')")
    @GetMapping(value = "/{volunteerAccountChangeId}")
    public R<VolunteerAccountChange> getInfo(@PathVariable("volunteerAccountChangeId") Long volunteerAccountChangeId)
    {
        return R.ok(volunteerAccountChangeService.selectVolunteerAccountChangeByVolunteerAccountChangeId(volunteerAccountChangeId));
    }

    /**
     * 新增志愿者账号变动明细
     */
    @ApiOperation("新增志愿者账号变动明细")
    @PreAuthorize("@ss.hasPermi('core:volunteer/account-change:add')")
    @Log(title = "志愿者账号变动明细", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody VolunteerAccountChange volunteerAccountChange)
    {
        return toAjax(volunteerAccountChangeService.insertVolunteerAccountChange(volunteerAccountChange));
    }

    /**
     * 修改志愿者账号变动明细
     */
    @ApiOperation("修改志愿者账号变动明细")
    @PreAuthorize("@ss.hasPermi('core:volunteer/account-change:edit')")
    @Log(title = "志愿者账号变动明细", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody VolunteerAccountChange volunteerAccountChange)
    {
        return toAjax(volunteerAccountChangeService.updateVolunteerAccountChange(volunteerAccountChange));
    }

    /**
     * 删除志愿者账号变动明细
     */
    @ApiOperation("删除志愿者账号变动明细")
    @PreAuthorize("@ss.hasPermi('core:volunteer/account-change:remove')")
    @Log(title = "志愿者账号变动明细", businessType = BusinessType.DELETE)
	@DeleteMapping("/{volunteerAccountChangeIds}")
    public R<Integer> remove(@PathVariable Long[] volunteerAccountChangeIds)
    {
        return R.ok(volunteerAccountChangeService.deleteVolunteerAccountChangeByVolunteerAccountChangeIds(volunteerAccountChangeIds));
    }
}
