package thyyxxk.webserver.controller.lc.company;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import thyyxxk.webserver.config.auth.PassToken;
import thyyxxk.webserver.config.exception.ExceptionEnum;
import thyyxxk.webserver.entity.ResultVo;
import thyyxxk.webserver.entity.inpatient.chargelist.PatOverview;
import thyyxxk.webserver.entity.lc.company.LcCompany;
import thyyxxk.webserver.entity.lc.company.LcCompanyParam;
import thyyxxk.webserver.service.lc.company.LcCompanyService;
import thyyxxk.webserver.utils.ListUtil;
import thyyxxk.webserver.utils.ResultVoUtil;
import thyyxxk.webserver.utils.StringUtil;

import java.util.List;


@RestController
@RequestMapping("/LcCompany")
public class LcCompanyController {

    @Autowired
    private LcCompanyService companyService;

    /**
     * 通过id获取企业详情
     * @param id
     * @return
     */
    @GetMapping("/getLcCompanyById")
    public ResultVo<LcCompany> getLcCompanyById(@RequestParam("id") String id) {
        if (StringUtil.isBlank(id)) {
            return ResultVoUtil.fail(ExceptionEnum.INVALID_PARAM, "id不能为空！");
        }
        return ResultVoUtil.success(companyService.getLcCompanyById(id));
    }

    /**
     * 模糊分页查询企业列表
     * @param lcCompanyParam
     * @return
     */
    @PostMapping("/getLcCompanyList")
    public ResultVo<Object> getLcCompanyById(@RequestBody LcCompanyParam lcCompanyParam) {
        return ResultVoUtil.success(companyService.getLcCompanyList(lcCompanyParam));
    }

    /**
     * 新增企业
     * @param lcCompany
     * @return
     */
    @PostMapping("/insertLcCompany")
    public ResultVo<String> insertLcCompany(@RequestBody LcCompany lcCompany) {
        int i = companyService.insertLcCompany(lcCompany);
        if(i > 0) {
            return ResultVoUtil.success();
        } else {
            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "新增失败");
        }
    }
}
