package com.ylx.web.controller.massage;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ylx.massage.domain.vo.MaTechnicianAppAddVo;
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.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.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.MaTechnician;
import com.ylx.massage.service.IMaTechnicianService;
import com.ylx.common.utils.poi.ExcelUtil;
import com.ylx.common.core.page.TableDataInfo;

/**
 * 技师Controller
 *
 * @author ylx
 * @date 2024-03-22
 */
@Api("技师管理")
@RestController
@RequestMapping("/technician/technician")
public class MaTechnicianController extends BaseController
{
    @Autowired
    private IMaTechnicianService maTechnicianService;

    /**
     * 查询技师列表
     */
    @PreAuthorize("@ss.hasPermi('technician:technician:list')")
    @GetMapping("/list")
    public TableDataInfo list(MaTechnician maTechnician)
    {
        startPage();
        List<MaTechnician> list = maTechnicianService.selectMaTechnicianList(maTechnician);
        return getDataTable(list);
    }

    /**
     * 导出技师列表
     */
    @PreAuthorize("@ss.hasPermi('technician:technician:export')")
    @Log(title = "技师", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MaTechnician maTechnician)
    {
        List<MaTechnician> list = maTechnicianService.selectMaTechnicianList(maTechnician);
        ExcelUtil<MaTechnician> util = new ExcelUtil<MaTechnician>(MaTechnician.class);
        util.exportExcel(response, list, "技师数据");
    }

    /**
     * 获取技师详细信息
     */
    @PreAuthorize("@ss.hasPermi('technician:technician:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(maTechnicianService.selectMaTechnicianById(id));
    }

    /**
     * 新增技师
     */
    @ApiOperation("技师入驻")
    @PreAuthorize("@ss.hasPermi('technician:technician:add')")
    @Log(title = "技师", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MaTechnicianAppAddVo maTechnicianAppAddVo)
    {
        return toAjax(maTechnicianService.insertMaTechnician(maTechnicianAppAddVo));
    }

    /**
     * 修改技师
     */
    @PreAuthorize("@ss.hasPermi('technician:technician:edit')")
    @Log(title = "技师", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MaTechnicianAppAddVo maTechnicianAppAddVo)
    {
        return toAjax(maTechnicianService.updateMaTechnician(maTechnicianAppAddVo));
    }

    /**
     * 删除技师
     */
    @PreAuthorize("@ss.hasPermi('technician:technician:remove')")
    @Log(title = "技师", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(maTechnicianService.deleteMaTechnicianByIds(ids));
    }
}
