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

import com.hotwj.platform.resourceManagement.company.domain.bo.HotCompanyThirdPlatformBo;
import com.hotwj.platform.resourceManagement.company.domain.vo.HotCompanyThirdPlatformVo;
import com.hotwj.platform.resourceManagement.company.service.IHotCompanyThirdPlatformService;
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("/companyThirdPlatform/companyThirdPlatform")
@Tag(name = "公司第三方平台账号", description = "公司第三方平台账号增删改查")
public class HotCompanyThirdPlatformController extends BaseController {

    private final IHotCompanyThirdPlatformService hotCompanyThirdPlatformService;

    /**
     * 查询公司第三方平台账号列表
     */
    //@SaCheckPermission("companyThirdPlatform:companyThirdPlatform:list")
    @GetMapping("/list")
    @Operation(summary = "分页查询公司第三方平台账号列表")
    public TableDataInfo<HotCompanyThirdPlatformVo> list(HotCompanyThirdPlatformBo bo, PageQuery pageQuery) {
        return hotCompanyThirdPlatformService.queryPageList(bo, pageQuery);
    }

    /**
     * 导出公司第三方平台账号列表
     */
    //@SaCheckPermission("companyThirdPlatform:companyThirdPlatform:export")
    @Log(title = "公司第三方平台账号", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @Operation(summary = "导出公司第三方平台账号列表")
    public void export(HotCompanyThirdPlatformBo bo, HttpServletResponse response) {
        List<HotCompanyThirdPlatformVo> list = hotCompanyThirdPlatformService.queryList(bo);
        ExcelUtil.exportExcel(list, "公司第三方平台账号", HotCompanyThirdPlatformVo.class, response);
    }

    /**
     * 获取公司第三方平台账号详细信息
     *
     * @param id 主键
     */
    //@SaCheckPermission("公司第三方平台账号:companyThirdPlatform:query")
    @GetMapping("/{id}")
    @Operation(summary = "查询公司第三方平台账号详情")
    public R<HotCompanyThirdPlatformVo> getInfo(@NotNull(message = "主键不能为空")
                                                @PathVariable Long id) {
        return R.ok(hotCompanyThirdPlatformService.queryById(id));
    }

    /**
     * 新增公司第三方平台账号
     */
    //@SaCheckPermission("companyThirdPlatform:companyThirdPlatform:add")
    @Log(title = "公司第三方平台账号", businessType = BusinessType.INSERT)
    @RepeatSubmit()
    @PostMapping()
    @Operation(summary = "新增公司第三方平台账号")
    public R<Void> add(@Validated(AddGroup.class) @RequestBody HotCompanyThirdPlatformBo bo) {
        return toAjax(hotCompanyThirdPlatformService.insertByBo(bo));
    }

    /**
     * 修改公司第三方平台账号
     */
    //@SaCheckPermission("companyThirdPlatform:companyThirdPlatform:edit")
    @Log(title = "公司第三方平台账号", businessType = BusinessType.UPDATE)
    @RepeatSubmit()
    @PutMapping()
    @Operation(summary = "修改公司第三方平台账号")
    public R<Void> edit(@Validated(EditGroup.class) @RequestBody HotCompanyThirdPlatformBo bo) {
        return toAjax(hotCompanyThirdPlatformService.updateByBo(bo));
    }

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