package cn.iocoder.yudao.module.system.controller.admin.sys;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.system.controller.admin.sys.vo.BusinessConfigUpdateReqVO;
import cn.iocoder.yudao.module.system.dal.dataobject.sys.BusinessParamsConfigDO;
import cn.iocoder.yudao.module.system.service.sys.BusinessParamsConfigService;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.validation.Valid;

import org.springframework.validation.annotation.Validated;
import io.swagger.v3.oas.annotations.tags.Tag;

import java.util.List;

import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;


@Tag(name = "管理后台 - 系统业务参数配置")
@RestController
@RequestMapping("/system/businessParamsConfig")
@Validated
public class BusinessParamsConfigController {

    @Resource
    private BusinessParamsConfigService businessParamsConfigService;

    @PostMapping("/getList")
    @Operation(summary = "获取所有系统业务参数配置")
    public CommonResult<List<BusinessParamsConfigDO>> getList() {
        return success(businessParamsConfigService.getList());
    }

    @PutMapping("/update")
    @Operation(summary = "更新系统业务参数配置")
    public CommonResult<Boolean> updateBusinessParamsConfig(@Valid @RequestBody BusinessParamsConfigDO updateReqVO) {
        businessParamsConfigService.updateBusinessParamsConfig(updateReqVO);
        return success(true);
    }

    @PutMapping("/batchUpdate")
    @Operation(summary = "批量更新系统业务参数配置")
    public CommonResult<Boolean> batchUpdate(@Valid @RequestBody BusinessConfigUpdateReqVO updateReqVO) {
        businessParamsConfigService.batchUpdate(updateReqVO);
        return success(true);
    }

//
//    @DeleteMapping("/delete")
//    @Operation(summary = "删除系统业务参数配置")
//    @Parameter(name = "id", description = "编号", required = true)
//    @PreAuthorize("@ss.hasPermission('system:business-params-config:delete')")
//    public CommonResult<Boolean> deleteBusinessParamsConfig(@RequestParam("id") Long id) {
//        businessParamsConfigService.deleteBusinessParamsConfig(id);
//        return success(true);
//    }
//
//    @GetMapping("/get")
//    @Operation(summary = "获得系统业务参数配置")
//    @Parameter(name = "id", description = "编号", required = true, example = "1024")
//    @PreAuthorize("@ss.hasPermission('system:business-params-config:query')")
//    public CommonResult<BusinessParamsConfigRespVO> getBusinessParamsConfig(@RequestParam("id") Long id) {
//        BusinessParamsConfigDO businessParamsConfig = businessParamsConfigService.getBusinessParamsConfig(id);
//        return success(BeanUtils.toBean(businessParamsConfig, BusinessParamsConfigRespVO.class));
//    }
//
//    @GetMapping("/page")
//    @Operation(summary = "获得系统业务参数配置分页")
//    @PreAuthorize("@ss.hasPermission('system:business-params-config:query')")
//    public CommonResult<PageResult<BusinessParamsConfigRespVO>> getBusinessParamsConfigPage(@Valid BusinessParamsConfigPageReqVO pageReqVO) {
//        PageResult<BusinessParamsConfigDO> pageResult = businessParamsConfigService.getBusinessParamsConfigPage(pageReqVO);
//        return success(BeanUtils.toBean(pageResult, BusinessParamsConfigRespVO.class));
//    }
//
//    @GetMapping("/export-excel")
//    @Operation(summary = "导出系统业务参数配置 Excel")
//    @PreAuthorize("@ss.hasPermission('system:business-params-config:export')")
//    @ApiAccessLog(operateType = EXPORT)
//    public void exportBusinessParamsConfigExcel(@Valid BusinessParamsConfigPageReqVO pageReqVO,
//              HttpServletResponse response) throws IOException {
//        pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
//        List<BusinessParamsConfigDO> list = businessParamsConfigService.getBusinessParamsConfigPage(pageReqVO).getList();
//        // 导出 Excel
//        ExcelUtils.write(response, "系统业务参数配置.xls", "数据", BusinessParamsConfigRespVO.class,
//                        BeanUtils.toBean(list, BusinessParamsConfigRespVO.class));
//    }

}