package com.fs.qw;

import com.fs.common.annotation.Log;
import com.fs.common.core.controller.BaseController;
import com.fs.common.core.domain.AjaxResult;
import com.fs.common.core.page.TableDataInfo;
import com.fs.common.enums.BusinessType;
import com.fs.common.utils.poi.ExcelUtil;
import com.fs.qw.domain.QwFriendCircle;
import com.fs.qw.service.IQwFriendCircleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 客户朋友圈Controller
 *
 * @author fs
 * @date 2024-09-18
 */
@RestController
@RequestMapping("/qw/friendCircle")
public class QwFriendCircleController extends BaseController
{
    @Autowired
    private IQwFriendCircleService qwFriendCircleService;

    /**
     * 查询客户朋友圈列表
     */
    @PreAuthorize("@ss.hasPermi('qw:friendCircle:list')")
    @GetMapping("/list")
    public TableDataInfo list(QwFriendCircle qwFriendCircle)
    {
        startPage();
        List<QwFriendCircle> list = qwFriendCircleService.selectQwFriendCircleList(qwFriendCircle);
        return getDataTable(list);
    }

    /**
     * 导出客户朋友圈列表
     */
    @PreAuthorize("@ss.hasPermi('qw:friendCircle:export')")
    @Log(title = "客户朋友圈", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(QwFriendCircle qwFriendCircle)
    {
        List<QwFriendCircle> list = qwFriendCircleService.selectQwFriendCircleList(qwFriendCircle);
        ExcelUtil<QwFriendCircle> util = new ExcelUtil<QwFriendCircle>(QwFriendCircle.class);
        return util.exportExcel(list, "客户朋友圈数据");
    }

    /**
     * 获取客户朋友圈详细信息
     */
    @PreAuthorize("@ss.hasPermi('qw:friendCircle:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(qwFriendCircleService.selectQwFriendCircleById(id));
    }

    /**
     * 新增客户朋友圈
     */
    @PreAuthorize("@ss.hasPermi('qw:friendCircle:add')")
    @Log(title = "客户朋友圈", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody QwFriendCircle qwFriendCircle)
    {
        return toAjax(qwFriendCircleService.insertQwFriendCircle(qwFriendCircle));
    }

    /**
     * 修改客户朋友圈
     */
    @PreAuthorize("@ss.hasPermi('qw:friendCircle:edit')")
    @Log(title = "客户朋友圈", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody QwFriendCircle qwFriendCircle)
    {
        return toAjax(qwFriendCircleService.updateQwFriendCircle(qwFriendCircle));
    }

    /**
     * 删除客户朋友圈
     */
    @PreAuthorize("@ss.hasPermi('qw:friendCircle:remove')")
    @Log(title = "客户朋友圈", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(qwFriendCircleService.deleteQwFriendCircleByIds(ids));
    }
}
