package com.trade.admin.enterprise.controller;


import com.trade.admin.enterprise.dto.EnterpriseAuditDto;
import com.trade.admin.enterprise.dto.EnterpriseDetailDto;
import com.trade.service.enterprise.dto.EnterpriseBaseInfoDto;
import com.trade.service.enterprise.dto.EnterpriseSearchDto;
import com.trade.admin.system.controller.BaseController;
import com.trade.common.core.domain.ResponseResult;
import com.trade.common.core.page.GridPage;
import com.trade.service.enterprise.dto.EnterpriseDto;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import com.trade.admin.enterprise.service.EnterpriseService;


import javax.annotation.Resource;


/**
 * 企业信息接口
 *
 * @author hlb
 * @since 2024-05-29 15:02:09
 */
@RestController
@RequestMapping("/enterprise")
public class EnterpriseController extends BaseController {

    @Resource
    private EnterpriseService enterpriseService;

    /**
     * 分页查询企业信息
     *
     * @param search 查询实体
     * @return 所有数据
     */
    @GetMapping("/pages")
    @PreAuthorize("@ss.hasPermi('enterprise:enterprise:query')")
    public ResponseResult<GridPage<EnterpriseBaseInfoDto>> getPages(@RequestBody EnterpriseSearchDto search) {
        GridPage<EnterpriseBaseInfoDto> pages = enterpriseService.getPages(search);
        return success(pages);
    }

    /**
     * 通过主键查询企业信息
     *
     * @param id 主键
     * @return 企业信息
     */
    @GetMapping("/{id}")
    @PreAuthorize("@ss.hasPermi('enterprise:enterprise:query')")
    public ResponseResult<EnterpriseDetailDto> queryById(@PathVariable Long id) {
        EnterpriseDetailDto enterprise = enterpriseService.queryDetailById(id);
        return success(enterprise);
    }
}

