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

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.tenant.core.aop.TenantIgnore;
import cn.iocoder.yudao.module.system.controller.admin.tenant.vo.enterprise.EnterpriseInfoRespVO;
import cn.iocoder.yudao.module.system.controller.admin.tenant.vo.enterprise.EnterpriseInfoSaveReqVO;
import cn.iocoder.yudao.module.system.service.tenant.EnterpriseInfoService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
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 static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;


@Tag(name = "管理后台 - 企业信息")
@RestController
@RequestMapping("/system/enterpriseInfo")
@Validated
public class TenantEnterpriseInfoController {

    @Resource
    private EnterpriseInfoService enterpriseInfoService;



    @PostMapping("/create")
    @Operation(summary = "创建企业信息")
    @TenantIgnore
    public CommonResult<Long> createEnterpriseInfo(@Valid @RequestBody EnterpriseInfoSaveReqVO createReqVO) {
        return success(enterpriseInfoService.createEnterpriseInfo(createReqVO));
    }

    @PutMapping("/update")
    @Operation(summary = "更新企业信息")
    @TenantIgnore
    public CommonResult<Boolean> updateEnterpriseInfo(@Valid @RequestBody EnterpriseInfoSaveReqVO updateReqVO) {
        enterpriseInfoService.updateEnterpriseInfo(updateReqVO);
        return success(true);
    }




//
//    @DeleteMapping("/delete")
//    @Operation(summary = "删除企业信息")
//    @Parameter(name = "id", description = "编号", required = true)
//    @PreAuthorize("@ss.hasPermission('system:enterprise-info:delete')")
//    public CommonResult<Boolean> deleteEnterpriseInfo(@RequestParam("id") Long id) {
//        enterpriseInfoService.deleteEnterpriseInfo(id);
//        return success(true);
//    }
//
    @GetMapping("/get")
    @Operation(summary = "获得企业信息")
    @Parameter(name = "tenantId", description = "租户ID", required = true, example = "1024")
    @TenantIgnore
    public CommonResult<EnterpriseInfoRespVO> getEnterpriseInfo(@RequestParam("tenantId") Long tenantId) {
        EnterpriseInfoRespVO enterpriseInfo = enterpriseInfoService.getEnterpriseInfo(tenantId);
        return success(enterpriseInfo);
    }
//
//    @GetMapping("/page")
//    @Operation(summary = "获得企业信息分页")
//    @PreAuthorize("@ss.hasPermission('system:enterprise-info:query')")
//    public CommonResult<PageResult<EnterpriseInfoRespVO>> getEnterpriseInfoPage(@Valid EnterpriseInfoPageReqVO pageReqVO) {
//        PageResult<EnterpriseInfoDO> pageResult = enterpriseInfoService.getEnterpriseInfoPage(pageReqVO);
//        return success(BeanUtils.toBean(pageResult, EnterpriseInfoRespVO.class));
//    }
//
//    @GetMapping("/export-excel")
//    @Operation(summary = "导出企业信息 Excel")
//    @PreAuthorize("@ss.hasPermission('system:enterprise-info:export')")
//    @ApiAccessLog(operateType = EXPORT)
//    public void exportEnterpriseInfoExcel(@Valid EnterpriseInfoPageReqVO pageReqVO,
//              HttpServletResponse response) throws IOException {
//        pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
//        List<EnterpriseInfoDO> list = enterpriseInfoService.getEnterpriseInfoPage(pageReqVO).getList();
//        // 导出 Excel
//        ExcelUtils.write(response, "企业信息.xls", "数据", EnterpriseInfoRespVO.class,
//                        BeanUtils.toBean(list, EnterpriseInfoRespVO.class));
//    }

}