package com.zt.plat.module.qms.business.bus.controller.admin;

import java.util.List;

import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.zt.plat.framework.business.interceptor.BusinessControllerMarker;
import com.zt.plat.framework.common.pojo.CommonResult;
import com.zt.plat.framework.common.pojo.PageResult;
import com.zt.plat.framework.datapermission.core.annotation.DeptDataPermissionIgnore;
import com.zt.plat.framework.security.core.LoginUser;
import com.zt.plat.framework.security.core.util.SecurityFrameworkUtils;
import com.zt.plat.module.qms.business.bus.controller.vo.SampleProjectResultDetailReqVO;
import com.zt.plat.module.qms.business.bus.controller.vo.SampleProjectResultDetailRespVO;
import com.zt.plat.module.qms.business.bus.controller.vo.SampleProjectResultPageReqVO;
import com.zt.plat.module.qms.business.bus.controller.vo.SampleProjectResultRespVO;
import com.zt.plat.module.qms.business.bus.service.SampleResultQueryService;

import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;

/**
 * 样品结果查询
 */
@Tag(name = "管理后台 - 样品结果查询")
@RestController
@RequestMapping("/qms/bus/sample/result-query")
@Validated
@DeptDataPermissionIgnore(enable = "true")
public class SampleResultQueryController implements BusinessControllerMarker {
	
	@Resource
	private SampleResultQueryService sampleResultQueryService;

	@GetMapping("/sampleProjectResultQuery")
	public CommonResult<PageResult<SampleProjectResultRespVO>> sampleProjectResultQuery(SampleProjectResultPageReqVO reqVO) {
		if (reqVO.getAssayDepartmentId() == null) {
    		LoginUser loginUser = SecurityFrameworkUtils.getLoginUser();
            reqVO.setAssayDepartmentId(loginUser.getVisitDeptId());
		}
		PageResult<SampleProjectResultRespVO> page = sampleResultQueryService.sampleProjectResultQuery(reqVO);
		return CommonResult.success(page);
	}
	
	@GetMapping("/sampleProjectResultDetailQuery")
	public CommonResult<List<SampleProjectResultDetailRespVO>> sampleProjectResultDetailQuery(SampleProjectResultDetailReqVO reqVO) {
		List<SampleProjectResultDetailRespVO> list = sampleResultQueryService.sampleProjectResultDetailQuery(reqVO);
		return CommonResult.success(list);
	}
}
