package com.meas.system.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.meas.common.annotation.Log;
import com.meas.common.core.controller.BaseController;
import com.meas.common.core.domain.AjaxResult;
import com.meas.common.enums.BusinessType;
import com.meas.system.domain.MeasAngle;
import com.meas.system.service.IMeasAngleService;
import com.meas.common.utils.poi.ExcelUtil;
import com.meas.common.core.page.TableDataInfo;

/**
 * 角度Controller
 *
 * @author Allen
 * @date 2024-07-24
 */
@RestController
@RequestMapping("/meas/angle")
public class MeasAngleController extends BaseController {
    @Autowired
    private IMeasAngleService measAngleService;

/**
 * 查询角度列表
 */
@PreAuthorize("@ss.hasPermi('system:angle:list')")
@GetMapping("/list")
    public TableDataInfo list(MeasAngle measAngle) {
        startPage();
        List<MeasAngle> list = measAngleService.selectMeasAngleList(measAngle);
        return getDataTable(list);
    }

    /**
     * 导出角度列表
     */
    @PreAuthorize("@ss.hasPermi('system:angle:export')")
    @Log(title = "角度", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MeasAngle measAngle) {
        List<MeasAngle> list = measAngleService.selectMeasAngleList(measAngle);
        ExcelUtil<MeasAngle> util = new ExcelUtil<MeasAngle>(MeasAngle. class);
        util.exportExcel(response, list, "角度数据");
    }

    /**
     * 获取角度详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:angle:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(measAngleService.selectMeasAngleById(id));
    }

    /**
     * 新增角度
     */
    @PreAuthorize("@ss.hasPermi('system:angle:add')")
    @Log(title = "角度", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MeasAngle measAngle) {
        return toAjax(measAngleService.insertMeasAngle(measAngle));
    }

    /**
     * 修改角度
     */
    @PreAuthorize("@ss.hasPermi('system:angle:edit')")
    @Log(title = "角度", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MeasAngle measAngle) {
        return toAjax(measAngleService.updateMeasAngle(measAngle));
    }

    /**
     * 删除角度
     */
    @PreAuthorize("@ss.hasPermi('system:angle:remove')")
    @Log(title = "角度", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(measAngleService.deleteMeasAngleByIds(ids));
    }

    @GetMapping("/getOption")
    public AjaxResult getOption(){
        return success(measAngleService.getOption());
    }
}
