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.Favorite;
import com.ruoyi.web.work.service.IFavoriteService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 职位收藏
 *
 * @author lsw
 * @date 2024-06-15
 */
@RestController
@RequestMapping("/app/favorite")
public class Api_FavoriteController extends BaseController {
    @Autowired
    private IFavoriteService favoriteService;

    @GetMapping("/list")
    public TableDataInfo list(Favorite favorite) {
        favorite.setUserId(getUser().getId());
        startPage();
        List<Favorite> list = favoriteService.selectList(favorite);
        return getDataTable(list);
    }

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

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