package com.ruoyi.member.controller;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.member.domain.MemberFootprint;
import com.ruoyi.member.service.IMemberFootprintService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 浏览足迹Controller
 * 
 * @author vinjor-m
 * @date 2025-03-17
 */
@RestController
@RequestMapping("/member/footprint")
public class MemberFootprintController extends BaseController
{
    @Autowired
    private IMemberFootprintService memberFootprintService;

    /**
     * 查询浏览足迹列表
     */
    @PreAuthorize("@ss.hasPermi('member:footprint:list')")
    @GetMapping("/list")
    public AjaxResult list(MemberFootprint memberFootprint)
    {

        List<MemberFootprint> list = memberFootprintService.list();
        return success(list);
    }

    /**
     * 导出浏览足迹列表
     */
    @PreAuthorize("@ss.hasPermi('member:footprint:export')")
    @Log(title = "浏览足迹", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MemberFootprint memberFootprint)
    {
        List<MemberFootprint> list = memberFootprintService.list();
        ExcelUtil<MemberFootprint> util = new ExcelUtil<MemberFootprint>(MemberFootprint.class);
        util.exportExcel(response, list, "浏览足迹数据");
    }

    /**
     * 获取浏览足迹详细信息
     */
    @PreAuthorize("@ss.hasPermi('member:footprint:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(memberFootprintService.getById(id));
    }

    /**
     * 新增浏览足迹
     */
    @PreAuthorize("@ss.hasPermi('member:footprint:add')")
    @Log(title = "浏览足迹", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MemberFootprint memberFootprint)
    {
        return toAjax(memberFootprintService.save(memberFootprint));
    }

    /**
     * 修改浏览足迹
     */
    @PreAuthorize("@ss.hasPermi('member:footprint:edit')")
    @Log(title = "浏览足迹", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MemberFootprint memberFootprint)
    {
        return toAjax(memberFootprintService.updateById(memberFootprint));
    }

    /**
     * 删除浏览足迹
     */
    @PreAuthorize("@ss.hasPermi('member:footprint:remove')")
    @Log(title = "浏览足迹", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        List<String> list = new ArrayList<>(Arrays.asList(ids));
        return toAjax(memberFootprintService.removeByIds(list));
    }
}
