package com.zsElectric.boot.business.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zsElectric.boot.business.model.form.ThirdPartyInfoForm;
import com.zsElectric.boot.business.model.query.ThirdPartyInfoQuery;
import com.zsElectric.boot.business.model.vo.ThirdPartyInfoVO;
import com.zsElectric.boot.business.service.ThirdPartyInfoService;
import com.zsElectric.boot.common.annotation.Log;
import com.zsElectric.boot.common.enums.LogModuleEnum;
import com.zsElectric.boot.core.web.PageResult;
import com.zsElectric.boot.core.web.Result;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * 第三方对接信息控制器
 *
 * @author system
 * @since 2025-12-15
 */
@Tag(name = "渠道方对接信息管理接口")
@RestController
@RequestMapping("/api/v1/third-party-info")
@RequiredArgsConstructor
public class ThirdPartyInfoController {

    private final ThirdPartyInfoService thirdPartyInfoService;

    @Operation(summary = "渠道方对接信息分页列表")
    @PostMapping("/page")
    @Log(value = "渠道方对接信息分页列表", module = LogModuleEnum.OTHER)
    public PageResult<ThirdPartyInfoVO> getThirdPartyInfoPage(@RequestBody ThirdPartyInfoQuery queryParams) {
        Page<ThirdPartyInfoVO> result = thirdPartyInfoService.getThirdPartyInfoPage(queryParams);
        return PageResult.success(result);
    }

    @Operation(summary = "根据ID获取渠道方对接信息详情")
    @GetMapping("/{id}")
    @Log(value = "获取渠道方对接信息详情", module = LogModuleEnum.OTHER)
    public Result<ThirdPartyInfoVO> getThirdPartyInfoById(
            @Parameter(description = "主键ID") @PathVariable Long id) {
        ThirdPartyInfoVO result = thirdPartyInfoService.getThirdPartyInfoById(id);
        return Result.success(result);
    }

    @Operation(summary = "新增渠道方对接信息")
    @PostMapping
    @Log(value = "新增渠道方对接信息", module = LogModuleEnum.OTHER)
    public Result<Boolean> addThirdPartyInfo(@Validated @RequestBody ThirdPartyInfoForm form) {
        boolean result = thirdPartyInfoService.addThirdPartyInfo(form);
        return Result.success(result);
    }

    @Operation(summary = "修改第三方对接信息")
    @PutMapping
    @Log(value = "修改渠道方对接信息", module = LogModuleEnum.OTHER)
    public Result<Boolean> updateThirdPartyInfo(@Validated @RequestBody ThirdPartyInfoForm form) {
        boolean result = thirdPartyInfoService.updateThirdPartyInfo(form);
        return Result.success(result);
    }

    @Operation(summary = "删除第三方对接信息")
    @DeleteMapping("/{id}")
    @Log(value = "删除渠道方对接信息", module = LogModuleEnum.OTHER)
    public Result<Boolean> deleteThirdPartyInfo(
            @Parameter(description = "主键ID") @PathVariable Long id) {
        boolean result = thirdPartyInfoService.deleteThirdPartyInfo(id);
        return Result.success(result);
    }


}
