package com.ylx.web.controller.massage;

import java.util.List;

import com.ylx.common.core.domain.model.LoginUser;
import com.ylx.massage.domain.vo.MaCarouselChartVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
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.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.ylx.common.annotation.Log;
import com.ylx.common.core.controller.BaseController;
import com.ylx.common.core.domain.AjaxResult;
import com.ylx.common.enums.BusinessType;
import com.ylx.massage.domain.MaCarouselChart;
import com.ylx.massage.service.IMaCarouselChartService;
import com.ylx.common.core.page.TableDataInfo;

/**
 * 轮播图管理Controller
 *
 * @author ylx
 * @date 2024-03-21
 */
@Api("轮播图管理")
@RestController
@RequestMapping("/massage/carousel")
public class MaCarouselChartController extends BaseController
{
    @Autowired
    private IMaCarouselChartService maCarouselChartService;

    /**
     * 查询轮播图管理列表
     */
    @PreAuthorize("@ss.hasPermi('massage:carousel:list')")
    @GetMapping("/list")
    @ApiOperation("PC查询轮播图管理列表")
    public TableDataInfo list(MaCarouselChart maCarouselChart)
    {
        startPage();
        List<MaCarouselChartVo> list = maCarouselChartService.selectMaCarouselChartList(maCarouselChart);
        return getDataTable(list);
    }


    /**
     * 获取轮播图管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('massage:carousel:query')")
    @GetMapping(value = "/{id}")
    @ApiOperation("PC获取轮播图管理详细信息")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(maCarouselChartService.selectMaCarouselChartById(id));
    }

    /**
     * 新增轮播图管理
     */
    @PreAuthorize("@ss.hasPermi('massage:carousel:add')")
    @Log(title = "轮播图管理", businessType = BusinessType.INSERT)
    @PostMapping("save")
    @ApiOperation("PC新增/修改轮播图管理")
    public AjaxResult add(@RequestBody MaCarouselChartVo maCarouselChart)
    {
        LoginUser loginUser = getLoginUser();
        return toAjax(maCarouselChartService.insertMaCarouselChart(maCarouselChart,loginUser));
    }



    /**
     * 删除轮播图管理
     */
    @ApiOperation("PC删除轮播图管理")
    @PreAuthorize("@ss.hasPermi('massage:carousel:remove')")
    @Log(title = "轮播图管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(maCarouselChartService.deleteMaCarouselChartByIds(ids));
    }
}
