package com.xinelu.manage.controller.projectresult;

import com.xinelu.common.annotation.Log;
import com.xinelu.common.core.controller.BaseController;
import com.xinelu.common.core.domain.AjaxResult;
import com.xinelu.common.core.domain.R;
import com.xinelu.common.core.page.TableDataInfo;
import com.xinelu.common.enums.BusinessType;
import com.xinelu.common.utils.poi.ExcelUtil;
import com.xinelu.manage.domain.projectresult.ProjectResult;
import com.xinelu.manage.dto.projectresult.ProjectResultStatisticDto;
import com.xinelu.manage.service.projectresult.IProjectResultService;
import com.xinelu.manage.vo.projectresult.ProjectResultStatisticVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import java.util.List;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @description: 检测项目结果控制器
 * @author: haown
 * @create: 2024-03-06 11:20
 **/
@Api(tags = "检测项目结果控制器")
@RestController
@RequestMapping("/manage/projectResult")
public class ProjectResultController extends BaseController {

	@Resource
	private IProjectResultService projectResultService;
	/**
	 * 查询检测项目结果列表
	 */
	@ApiOperation("查询检测项目结果列表")
	@PreAuthorize("@ss.hasPermi('manage:projectresult:list')")
	@GetMapping("/list")
	public TableDataInfo list(ProjectResult projectResult) {
		startPage();
		List<ProjectResult> list = projectResultService.selectProjectResultList(projectResult);
		return getDataTable(list);
	}

	/**
	 * 导出检测项目结果列表
	 */
	@PreAuthorize("@ss.hasPermi('manage:projectresult:export')")
	@Log(title = "检测项目结果", businessType = BusinessType.EXPORT)
	@PostMapping("/export")
	public void export(HttpServletResponse response, ProjectResult projectResult) {
		List<ProjectResult> list = projectResultService.selectProjectResultList(projectResult);
		ExcelUtil<ProjectResult> util = new ExcelUtil<ProjectResult>(ProjectResult. class);
		util.exportExcel(response, list, "检测项目结果数据");
	}

	/**
	 * 获取检测项目结果详细信息
	 */
	@ApiOperation("根据id获取检测项目结果详细信息")
	@PreAuthorize("@ss.hasPermi('manage:projectresult:query')")
	@GetMapping(value = "/{id}")
	public AjaxResult getInfo(@PathVariable("id") Long id) {
		return AjaxResult.success(projectResultService.selectProjectResultById(id));
	}

	/**
	 * 新增检测项目结果
	 */
	@PreAuthorize("@ss.hasPermi('manage:projectresult:add')")
	@Log(title = "检测项目结果", businessType = BusinessType.INSERT)
	@PostMapping
	public AjaxResult add(@RequestBody ProjectResult projectResult) {
		return toAjax(projectResultService.insertProjectResult(projectResult));
	}

	/**
	 * 修改检测项目结果
	 */
	@PreAuthorize("@ss.hasPermi('manage:projectresult:edit')")
	@Log(title = "检测项目结果", businessType = BusinessType.UPDATE)
	@PutMapping
	public AjaxResult edit(@RequestBody ProjectResult projectResult) {
		return toAjax(projectResultService.updateProjectResult(projectResult));
	}

	/**
	 * 删除检测项目结果
	 */
	@PreAuthorize("@ss.hasPermi('manage:projectresult:remove')")
	@Log(title = "检测项目结果", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
	public AjaxResult remove(@PathVariable Long[] ids) {
		return toAjax(projectResultService.deleteProjectResultByIds(ids));
	}
	/**
	 * 查询检测检测项目结果曲线统计
	 */
	@ApiOperation("查询检测项目结果曲线统计")
	@GetMapping("/curveStatistics")
	public R<ProjectResultStatisticVo> curveStatistics(ProjectResultStatisticDto projectResultStatisticDto) {
		return R.ok(projectResultService.curveStatistics(projectResultStatisticDto));
	}

}
