package com.ruoyi.web.work.api;

import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.web.work.api.config.BaseController;
import com.ruoyi.web.work.domain.Enterprise;
import com.ruoyi.web.work.domain.vo.EnterpriseListVo;
import com.ruoyi.web.work.service.IEnterpriseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/app/enterprise")
public class Api_EnterpriseController extends BaseController {

    @Autowired
    private IEnterpriseService enterpriseService;

    @GetMapping("/list")
    public TableDataInfo list(Enterprise enterprise) {
        startPage();
        List<EnterpriseListVo> list = enterpriseService.indexList(enterprise);
        return getDataTable(list);
    }

    @GetMapping("/index")
    public AjaxResult index() {
        return enterpriseService.index();
    }

    @GetMapping("/detail/{id}")
    public AjaxResult detail(@PathVariable("id") Long id) {
        return enterpriseService.detail(id);
    }

    @PostMapping("/edit")
    public AjaxResult edit(@Validated @RequestBody Enterprise enterprise) {
        return enterpriseService.edit(enterprise);
    }
}

