package com.njzscloud.supervisory.biz.controller;

import com.njzscloud.common.core.utils.R;
import com.njzscloud.common.mp.support.PageParam;
import com.njzscloud.common.mp.support.PageResult;
import com.njzscloud.supervisory.biz.contant.AuditStatus;
import com.njzscloud.supervisory.biz.pojo.entity.BizCompanyEntity;
import com.njzscloud.supervisory.biz.pojo.param.ModifyBizCompanyParam;
import com.njzscloud.supervisory.biz.pojo.param.SearchCompanyParam;
import com.njzscloud.supervisory.biz.pojo.result.SearchCompanyResult;
import com.njzscloud.supervisory.biz.service.BizCompanyService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 企业信息
 */
@Slf4j
@RestController
@RequestMapping("/biz_company")
@RequiredArgsConstructor
public class BizCompanyController {

    private final BizCompanyService bizCompanyService;

    /**
     * 修改
     *
     * @param modifyBizCompanyParam 数据
     */
    @PostMapping("/modify")
    public R<?> modify(@RequestBody ModifyBizCompanyParam modifyBizCompanyParam) {
        bizCompanyService.modify(modifyBizCompanyParam);
        return R.success();
    }

    /**
     * 撤销
     *
     * @param id Id
     */
    @GetMapping("/cancel")
    public R<?> cancel(@RequestParam Long id) {
        bizCompanyService.cancel(id);
        return R.success();
    }

    /**
     * 审核
     *
     * @param id Id
     */
    @GetMapping("/audit")
    public R<?> audit(@RequestParam Long id,
                      @RequestParam AuditStatus auditStatus,
                      @RequestParam(required = false, defaultValue = "") String auditMemo) {
        bizCompanyService.audit(id, auditStatus, auditMemo);
        return R.success();
    }

    /**
     * 详情
     *
     * @param id Id
     * @return BizCompanyEntity 结果
     */
    @GetMapping("/detail")
    public R<SearchCompanyResult> detail(@RequestParam(required = false) Long id) {
        return R.success(bizCompanyService.detail(id));
    }

    /**
     * 分页查询
     *
     * @param searchCompanyParam 筛选条件
     * @param pageParam          分页参数
     * @return PageResult&lt;BizCompanyEntity&gt; 分页结果
     */
    @GetMapping("/paging")
    public R<PageResult<BizCompanyEntity>> paging(PageParam pageParam, SearchCompanyParam searchCompanyParam) {
        return R.success(bizCompanyService.paging(pageParam, searchCompanyParam));
    }

    /**
     * 站点列表
     */
    @GetMapping("/station")
    public R<List<BizCompanyEntity>> station() {
        return R.success(bizCompanyService.station());
    }
}
