package com.ylx.web.controller.massage;

import java.util.List;

import com.ylx.common.core.domain.model.LoginUser;
import com.ylx.massage.domain.MaProject;
import com.ylx.massage.domain.vo.MaProjectListVo;
import com.ylx.massage.domain.vo.MaProjectSaveVo;
import com.ylx.massage.service.IMaProjectService;
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.common.core.page.TableDataInfo;

/**
 * 服务项目Controller
 *
 * @author ylx
 * @date 2024-03-20
 */
@Api("服务项目管理")
@RestController
@RequestMapping("/massage/project")
public class MaProjectController extends BaseController
{
    @Autowired
    private IMaProjectService maProjectService;

    /**
     * 查询服务项目列表
     */
    @ApiOperation("PC查询服务项目列表")
    @PreAuthorize("@ss.hasPermi('massage:project:list')")
    @GetMapping("/list")
    public TableDataInfo list(MaProject maProject)
    {
        startPage();
        List<MaProjectListVo> list = maProjectService.selectMaProjectList(maProject);
        return getDataTable(list);
    }



    /**
     * 获取服务项目详细信息
     */
    @ApiOperation("PC获取服务项目详细信息")
    @PreAuthorize("@ss.hasPermi('massage:project:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(maProjectService.selectMaProjectById(id));
    }

    /**
     * 新增服务项目
     */
    @ApiOperation("新增/修改服务项目")
    @PreAuthorize("@ss.hasPermi('massage:project:add')")
    @Log(title = "服务项目", businessType = BusinessType.INSERT)
    @PostMapping("save")
    public AjaxResult add(@RequestBody MaProjectSaveVo maProject)
    {
        LoginUser loginUser = getLoginUser();

        return toAjax(maProjectService.insertMaProject(maProject,loginUser));
    }


    /**
     * 删除服务项目
     */
    @ApiOperation("删除服务项目")
    @PreAuthorize("@ss.hasPermi('massage:project:remove')")
    @Log(title = "服务项目", businessType = BusinessType.DELETE)
	@DeleteMapping("/{id}")
    public AjaxResult remove(@PathVariable("id") Long id)
    {
        return toAjax(maProjectService.deleteMaProjectById(id));
    }
}
