package com.hotent.baseInfo.controller;


import com.hotent.base.annotation.ApiGroup;
import com.hotent.base.constants.ApiGroupConsts;
import io.swagger.annotations.Api;
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.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import com.hotent.base.model.CommonResult;
import com.hotent.base.util.StringUtil;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.RestController;
import com.hotent.base.controller.BaseController;
import com.hotent.baseInfo.model.CostDocumentTemplateFile;
import com.hotent.baseInfo.manager.CostDocumentTemplateFileManager;

import java.util.List;

/**
 * 监审文书文件内容表 前端控制器
 *
 * @company 山西清众科技股份有限公司
 * @author 超级管理员
 * @since 2025-10-14
 */
@RestController
@RequestMapping("/costDocumentTemplateFile/v1/")
@Api(tags = "监审文书文件内容关联")
@ApiGroup(group = {ApiGroupConsts.GROUP_COST})
public class CostDocumentTemplateFileController extends BaseController<CostDocumentTemplateFileManager, CostDocumentTemplateFile> {


	@Autowired
	private CostDocumentTemplateFileManager costDocumentTemplateFileManager;
	/**
	 * 根据id获取监审文书文件内容表数据详情
	 * @param id
	 * @return
	 * @throws Exception 
	 * ModelAndView
	 */
	@GetMapping(value="/getDetail")
	@ApiOperation(value="根据id获取监审文书文件内容表数据详情",httpMethod = "GET",notes = "根据id获取监审文书文件内容表数据详情")
	public CommonResult<CostDocumentTemplateFile> getDetail(@ApiParam(name="id",value="业务对象主键", required = true)@RequestParam(required=true) String id) throws Exception{
		return CommonResult.<CostDocumentTemplateFile>ok().value(baseService.getDetail(id));
	}
    /**
	 * 新增,更新监审文书文件内容表
	 * @param costDocumentTemplateFile
	 * @throws Exception 
	 * @return
	 * @exception 
	 */
	@PostMapping(value="/save")
	@ApiOperation(value = "新增,更新监审文书文件内容表数据", httpMethod = "POST", notes = "新增,更新监审文书文件内容表数据")
	public CommonResult<String> save(@ApiParam(name="CostDocumentTemplateFile",value="监审文书文件内容表对象", required = true)@RequestBody CostDocumentTemplateFile costDocumentTemplateFile) throws Exception{
		String msg = StringUtil.isEmpty(costDocumentTemplateFile.getId()) ? "添加监审文书文件内容表成功" : "更新监审文书文件内容表成功";
		baseService.createOrUpdate(costDocumentTemplateFile);
		return CommonResult.<String>ok().message(msg);
	}

	//根据文书id查询
	@GetMapping(value="/queryByDocumentId")
	@ApiOperation(value = "根据文书id查询", httpMethod = "GET", notes = "根据文书id查询")
	public CommonResult<List<CostDocumentTemplateFile>> queryByDocumentId(@ApiParam(name="documentId",value="文书id", required = true)@RequestParam(required=true) String documentId
	) throws Exception{
		List<CostDocumentTemplateFile> costDocumentTemplateFiles = costDocumentTemplateFileManager.getDocumentFileList(documentId);
		return CommonResult.<List<CostDocumentTemplateFile>>ok().value(costDocumentTemplateFiles);

	}

	//根据文书id查询和wherename拿dataValue
	@GetMapping(value="/queryByDocumentIdandWhereValue")
	@ApiOperation(value = "根据文书id查询和whereValue查询", httpMethod = "GET", notes = "根据文书id查询和whereValue查询")
	public CommonResult<List<CostDocumentTemplateFile>> queryByDocumentIdandWhereValue(
			@ApiParam(name="documentId",value="文书id", required = true)@RequestParam() String documentId,
			@ApiParam(name="whereValue",value="条件值", required = true)@RequestParam() String whereValue,
			@ApiParam(name="unitId",value="监审单位id", required = true)@RequestParam() String unitId
	) throws Exception{
		List<CostDocumentTemplateFile> costDocumentTemplateFiles = costDocumentTemplateFileManager.queryByDocumentId(documentId,whereValue,unitId);
		return CommonResult.<List<CostDocumentTemplateFile>>ok().value(costDocumentTemplateFiles);

	}
}
