package com.zsElectric.boot.business.controller;

import com.zsElectric.boot.business.service.FirmAccountLogService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.zsElectric.boot.business.model.query.FirmAccountLogQuery;
import com.zsElectric.boot.business.model.vo.FirmAccountLogVO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.zsElectric.boot.core.web.PageResult;
import com.zsElectric.boot.core.web.Result;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

/**
 * 企业资金流水前端控制层
 *
 * @author zsElectric
 * @since 2025-12-26
 */
@Tag(name = "企业资金流水接口")
@RestController
@RequestMapping("/api/v1/firmAccountLog")
@RequiredArgsConstructor
public class FirmAccountLogController {

    private final FirmAccountLogService firmAccountLogService;

    @Operation(summary = "企业资金流水分页列表")
    @GetMapping("/page")
    // @PreAuthorize("@ss.hasPerm('business:firmAccountLog:query')")
    public PageResult<FirmAccountLogVO> getFirmAccountLogPage(FirmAccountLogQuery queryParams) {
        IPage<FirmAccountLogVO> result = firmAccountLogService.getFirmAccountLogPage(queryParams);
        return PageResult.success(result);
    }

    @Operation(summary = "删除企业资金流水")
    @DeleteMapping("/{ids}")
    // @PreAuthorize("@ss.hasPerm('business:firmAccountLog:delete')")
    public Result<Void> deleteFirmAccountLogs(
            @Parameter(description = "企业资金流水ID，多个以英文逗号(,)分割") @PathVariable String ids
    ) {
        boolean result = firmAccountLogService.deleteFirmAccountLogs(ids);
        return Result.judge(result);
    }
}
