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.Relate;
import com.ruoyi.web.work.domain.vo.RelateCompanyListVo;
import com.ruoyi.web.work.service.IRelateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 关联企业
 *
 * @author lsw
 * @date 2024-04-18
 */
@RestController
@RequestMapping("/app/relate")
public class Api_RelateController extends BaseController {
    @Autowired
    private IRelateService relateService;

    @GetMapping("/list")
    public TableDataInfo list(Relate relate) {
        relate.setUserId(getUser().getId());
        startPage();
        List<RelateCompanyListVo> list = relateService.selectRelateCompanyList(relate);
        return getDataTable(list);
    }

    @PostMapping("/add")
    public AjaxResult add(@Validated @RequestBody Relate relate) {
        return relateService.add(relate);
    }

    @PostMapping("/remove")
    public AjaxResult remove(@RequestBody Relate relate) {
        return relateService.remove(relate);
    }
}
