package com.hotwj.platform.resourceManagement.company.controller;

import com.hotwj.platform.resourceManagement.company.domain.bo.HotCompanyBankAccountBo;
import com.hotwj.platform.resourceManagement.company.domain.vo.HotCompanyBankAccountVo;
import com.hotwj.platform.resourceManagement.company.service.IHotCompanyBankAccountService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import lombok.RequiredArgsConstructor;
import org.dromara.common.core.domain.R;
import org.dromara.common.core.validate.AddGroup;
import org.dromara.common.core.validate.EditGroup;
import org.dromara.common.excel.utils.ExcelUtil;
import org.dromara.common.idempotent.annotation.RepeatSubmit;
import org.dromara.common.log.annotation.Log;
import org.dromara.common.log.enums.BusinessType;
import org.dromara.common.mybatis.core.page.PageQuery;
import org.dromara.common.mybatis.core.page.TableDataInfo;
import org.dromara.common.web.core.BaseController;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 公司银行账户
 *
 * @author shihongwei
 * @date 2025-12-08
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/companyBankAccount/companyBankAccount")
@Tag(name = "公司银行账户", description = "公司银行账户增删改查")
public class HotCompanyBankAccountController extends BaseController {

    private final IHotCompanyBankAccountService hotCompanyBankAccountService;

    /**
     * 查询公司银行账户列表
     */
    //@SaCheckPermission("companyBankAccount:companyBankAccount:list")
    @GetMapping("/list")
    @Operation(summary = "分页查询公司银行账户列表")
    public TableDataInfo<HotCompanyBankAccountVo> list(HotCompanyBankAccountBo bo, PageQuery pageQuery) {
        return hotCompanyBankAccountService.queryPageList(bo, pageQuery);
    }

    /**
     * 导出公司银行账户列表
     */
    //@SaCheckPermission("companyBankAccount:companyBankAccount:export")
    @Log(title = "公司银行账户", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @Operation(summary = "导出公司银行账户列表")
    public void export(HotCompanyBankAccountBo bo, HttpServletResponse response) {
        List<HotCompanyBankAccountVo> list = hotCompanyBankAccountService.queryList(bo);
        ExcelUtil.exportExcel(list, "公司银行账户", HotCompanyBankAccountVo.class, response);
    }

    /**
     * 获取公司银行账户详细信息
     *
     * @param id 主键
     */
    //@SaCheckPermission("companyBankAccount:companyBankAccount:query")
    @GetMapping("/{id}")
    @Operation(summary = "查询公司银行账户详情")
    public R<HotCompanyBankAccountVo> getInfo(@NotNull(message = "主键不能为空")
                                              @PathVariable Long id) {
        return R.ok(hotCompanyBankAccountService.queryById(id));
    }

    /**
     * 新增公司银行账户
     */
    //@SaCheckPermission("companyBankAccount:companyBankAccount:add")
    @Log(title = "公司银行账户", businessType = BusinessType.INSERT)
    @RepeatSubmit()
    @PostMapping()
    @Operation(summary = "新增公司银行账户")
    public R<Void> add(@Validated(AddGroup.class) @RequestBody HotCompanyBankAccountBo bo) {
        return toAjax(hotCompanyBankAccountService.insertByBo(bo));
    }

    /**
     * 修改公司银行账户
     */
    //@SaCheckPermission("companyBankAccount:companyBankAccount:edit")
    @Log(title = "公司银行账户", businessType = BusinessType.UPDATE)
    @RepeatSubmit()
    @PutMapping()
    @Operation(summary = "修改公司银行账户")
    public R<Void> edit(@Validated(EditGroup.class) @RequestBody HotCompanyBankAccountBo bo) {
        return toAjax(hotCompanyBankAccountService.updateByBo(bo));
    }

    /**
     * 删除公司银行账户
     *
     * @param ids 主键串
     */
    //@SaCheckPermission("companyBankAccount:companyBankAccount:remove")
    @Log(title = "公司银行账户", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    @Operation(summary = "删除公司银行账户")
    public R<Void> remove(@NotEmpty(message = "主键不能为空")
                          @PathVariable Long[] ids) {
        return toAjax(hotCompanyBankAccountService.deleteWithValidByIds(List.of(ids), true));
    }
}
