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.*;
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.ScBreastRating;
import com.zhyc.module.produce.bodyManage.service.IScBreastRatingService;
import com.zhyc.common.utils.poi.ExcelUtil;
import com.zhyc.common.core.page.TableDataInfo;

/**
 * 乳房评分Controller
 * 
 * @author ruoyi
 * @date 2025-07-27
 */
@RestController
@RequestMapping("/breast_rating/breast_rating")
public class ScBreastRatingController extends BaseController
{
    @Autowired
    private IScBreastRatingService scBreastRatingService;

    /**
     * 查询乳房评分列表
     */
    @PreAuthorize("@ss.hasPermi('breast_rating:breast_rating:list')")
    @GetMapping("/list")
    public TableDataInfo list(ScBreastRating scBreastRating)
    {
        startPage();
        List<ScBreastRating> list = scBreastRatingService.selectScBreastRatingList(scBreastRating);
        return getDataTable(list);
    }

    /**
     * 导出乳房评分列表
     */
    @PreAuthorize("@ss.hasPermi('breast_rating:breast_rating:export')")
    @Log(title = "乳房评分", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ScBreastRating scBreastRating)
    {
        List<ScBreastRating> list = scBreastRatingService.selectScBreastRatingList(scBreastRating);
        ExcelUtil<ScBreastRating> util = new ExcelUtil<ScBreastRating>(ScBreastRating.class);
        util.exportExcel(response, list, "乳房评分数据");
    }

    /**
     * 获取乳房评分详细信息
     */
    @PreAuthorize("@ss.hasPermi('breast_rating:breast_rating:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(scBreastRatingService.selectScBreastRatingById(id));
    }

    /**
     * 新增乳房评分
     */
    @PreAuthorize("@ss.hasPermi('breast_rating:breast_rating:add')")
    @Log(title = "乳房评分", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ScBreastRating scBreastRating)
    {
        scBreastRating.setUserId(getUserId());
        scBreastRating.setDeptId(getDeptId());
        return toAjax(scBreastRatingService.insertScBreastRating(scBreastRating));
    }

    /**
     * 修改乳房评分
     */
    @PreAuthorize("@ss.hasPermi('breast_rating:breast_rating:edit')")
    @Log(title = "乳房评分", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ScBreastRating scBreastRating)
    {
        return toAjax(scBreastRatingService.updateScBreastRating(scBreastRating));
    }

    /**
     * 删除乳房评分
     */
    @PreAuthorize("@ss.hasPermi('breast_rating:breast_rating:remove')")
    @Log(title = "乳房评分", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(scBreastRatingService.deleteScBreastRatingByIds(ids));
    }

    @GetMapping("/search_ear_numbers")
    public AjaxResult searchEarNumbers(@RequestParam("query") String query){
        return success(scBreastRatingService.searchEarNumbers(query.trim()));
    }
}
