package com.ruoyi.ibs.custmap.controller;

import com.github.pagehelper.Page;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataPageInfo;
import com.ruoyi.ibs.custmap.domain.dto.CustMapFavoriteDTO;
import com.ruoyi.ibs.custmap.domain.vo.CustMapVO;
import com.ruoyi.ibs.custmap.service.CustMapFavoriteService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Author 吴凯程
 * @Date 2025/5/26
 **/
@Api(tags = "地图拓客收藏接口")
@RestController
@RequestMapping("/cust/map/favorite")
public class CustMapFavoriteController extends BaseController {

    @Resource
    private CustMapFavoriteService custMapFavoriteService;

    @ApiOperation("添加或取消收藏")
    @GetMapping("/update")
    public AjaxResult updateFavorite(@RequestParam Long radarId) {
        return success(custMapFavoriteService.updateFavorite(radarId));
    }

    @ApiOperation("获取查收藏地图页面")
    @GetMapping("/map")
    public AjaxResult getFavoriteCount() {
        return success(custMapFavoriteService.getFavoriteCountByUser());
    }

    @ApiOperation("获取收藏列表")
    @GetMapping("/list")
    public TableDataPageInfo<CustMapVO> getFavoriteList(CustMapFavoriteDTO custMapFavoriteDTO) {
        Page<Object> page = startPage();
        List<CustMapVO> custMapVOList = custMapFavoriteService.selectCustListByFavorite(custMapFavoriteDTO);
        return getDataTable(custMapVOList, page);
    }



}
