package com.zhyc.module.produce.bodyManage.controller;

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.zhyc.common.annotation.Log;
import com.zhyc.common.core.controller.BaseController;
import com.zhyc.common.core.domain.AjaxResult;
import com.zhyc.common.enums.BusinessType;
import com.zhyc.module.produce.bodyManage.domain.ScBodyMeasure;
import com.zhyc.module.produce.bodyManage.service.IScBodyMeasureService;
import com.zhyc.common.utils.poi.ExcelUtil;
import com.zhyc.common.core.page.TableDataInfo;

/**
 * 体尺测量Controller
 * 
 * @author ruoyi
 * @date 2025-07-27
 */
@RestController
@RequestMapping("/body_measure/body_measure")
public class ScBodyMeasureController extends BaseController
{
    @Autowired
    private IScBodyMeasureService scBodyMeasureService;


    /**
     * 查询体尺测量列表
     */
    @PreAuthorize("@ss.hasPermi('body_measure:body_measure:list')")
    @GetMapping("/list")
    public TableDataInfo list(ScBodyMeasure scBodyMeasure)
    {
        startPage();
        List<ScBodyMeasure> list = scBodyMeasureService.selectScBodyMeasureList(scBodyMeasure);
        return getDataTable(list);
    }

    /**
     * 导出体尺测量列表
     */
    @PreAuthorize("@ss.hasPermi('body_measure:body_measure:export')")
    @Log(title = "体尺测量", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ScBodyMeasure scBodyMeasure)
    {
        List<ScBodyMeasure> list = scBodyMeasureService.selectScBodyMeasureList(scBodyMeasure);
        ExcelUtil<ScBodyMeasure> util = new ExcelUtil<ScBodyMeasure>(ScBodyMeasure.class);
        util.exportExcel(response, list, "体尺测量数据");
    }

    /**
     * 获取体尺测量详细信息
     */
    @PreAuthorize("@ss.hasPermi('body_measure:body_measure:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(scBodyMeasureService.selectScBodyMeasureById(id));
    }

    /**
     * 新增体尺测量
     */
    @PreAuthorize("@ss.hasPermi('body_measure:body_measure:add')")
    @Log(title = "体尺测量", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ScBodyMeasure scBodyMeasure)
    {
        return toAjax(scBodyMeasureService.insertScBodyMeasure(scBodyMeasure));
    }

    /**
     * 修改体尺测量
     */
    @PreAuthorize("@ss.hasPermi('body_measure:body_measure:edit')")
    @Log(title = "体尺测量", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ScBodyMeasure scBodyMeasure)
    {
        return toAjax(scBodyMeasureService.updateScBodyMeasure(scBodyMeasure));
    }

    /**
     * 删除体尺测量
     */
    @PreAuthorize("@ss.hasPermi('body_measure:body_measure:remove')")
    @Log(title = "体尺测量", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(scBodyMeasureService.deleteScBodyMeasureByIds(ids));
    }
}
