package com.zcloud.basic.info.app;


import com.alibaba.cola.dto.PageResponse;
import com.alibaba.cola.dto.Response;
import com.alibaba.cola.dto.SingleResponse;
import com.jjb.saas.framework.auth.model.SSOUser;
import com.jjb.saas.framework.auth.utils.AuthContext;
import com.jjb.saas.security.starter.api.co.DecryptCmd;
import com.zcloud.basic.info.api.CorpInfoServiceI;
import com.zcloud.basic.info.dto.*;
import com.zcloud.basic.info.dto.clientobject.CorpDepartmentCO;
import com.zcloud.basic.info.dto.clientobject.CorpInfoCO;
import com.zcloud.basic.info.dto.clientobject.CorpUserMiddleCO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * web-adapter
 *
 * @Author zhaokai
 * @Date 2025-10-29 16:02:16
 */
@Api(tags = "APP企业信息")
@RequestMapping("/${application.gateway}/app/corpInfo")
@RestController
@AllArgsConstructor
public class AppCorpInfoController {
    private final CorpInfoServiceI corpInfoService;



    @ApiOperation("获取企业列表")
    @PostMapping("/list")
    public PageResponse<CorpInfoCO> page(@Validated @RequestBody CorpInfoPageQry qry) {
        return corpInfoService.listPage(qry);
    }

    @ApiOperation("详情")
    @PostMapping("/info/{id}")
    public SingleResponse<CorpInfoCO> getInfoById(@PathVariable("id") Long id) {
        if(id==null){
            SSOUser ssoUser = AuthContext.getCurrentUser();
            id = ssoUser.getTenantId();
        }
        return SingleResponse.of(corpInfoService.info(id));
    }


}

