package com.ruoyi.cms.controller.app;


import com.ruoyi.cms.domain.JobFair;
import com.ruoyi.cms.service.IFairCollectionService;
import com.ruoyi.cms.service.IJobFairService;
import com.ruoyi.common.annotation.BussinessLog;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 招聘会Controller
 * 
 * @author lishundong
 * @date 2024-09-04
 */
@RestController
@RequestMapping("/app/fair")
@Api(tags = "移动端：招聘会")
public class AppFairController extends BaseController
{
    @Autowired
    private IJobFairService jobFairService;
    @Autowired
    private IFairCollectionService fairCollectionService;
    /**
     * 招聘会列表
     */
    @BussinessLog(title = "招聘会列表")
    @GetMapping
    public TableDataInfo list(JobFair jobFair)
    {
        startPage();
        List<JobFair> results = jobFairService.appList(jobFair);
        return getDataTable(results);
    }

    /**
     * 招聘会详情
     */
    @BussinessLog(title = "招聘会详情")
    @GetMapping("/{fairId}")
    public AjaxResult appDetail(@ApiParam("招聘会id") @PathVariable Long fairId)
    {
        return success(jobFairService.appDetail(fairId));
    }

    /**
     * 用户收藏招聘会
     */
    @BussinessLog(title = "用户收藏招聘会")
    @PostMapping("/collection/{fairId}")
    public AjaxResult companyCollection(@ApiParam("招聘会id") @PathVariable Long fairId)
    {
        return toAjax(fairCollectionService.fairCollection(fairId));
    }

    /**
     * 用户取消收藏招聘会
     */
    @BussinessLog(title = "用户取消收藏招聘会")
    @DeleteMapping("/collection/{fairId}")
    public AjaxResult companyCancel(@ApiParam("招聘会id") @PathVariable Long fairId)
    {
        return toAjax(fairCollectionService.cancel(fairId));
    }
}
