package com.hotent.project.controller;


import com.hotent.base.annotation.ApiGroup;
import com.hotent.base.constants.ApiGroupConsts;
import com.hotent.common.CrudService;
import com.hotent.project.model.CostProjectApproval;
import com.hotent.project.req.CostProjectApprovalPageReq;
import com.hotent.project.req.CostProjectBasePageReq;
import com.hotent.project.req.CostProjectDocumentPageReq;
import com.hotent.project.req.CostProjectDocumentReq;
import com.hotent.project.resp.CostProjectDocumentResp;
import com.hotent.req.IdReq;
import com.hotent.req.PageReq;
import com.hotent.resp.PageResp;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.hotent.base.model.CommonResult;
import com.hotent.base.util.StringUtil;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import com.hotent.base.controller.BaseController;
import com.hotent.project.model.CostProjectDocument;
import com.hotent.project.manager.CostProjectDocumentManager;

import java.util.List;

/**
 * 监审项目文书表 前端控制器
 *
 * @company 山西清众科技股份有限公司
 * @author 超级管理员
 * @since 2025-09-26
 */
@RestController
@RequestMapping("/api/costProjectDocument/v1/")
@Api(tags = "监审项目文书")
@ApiGroup(group = {ApiGroupConsts.GROUP_COST})
public class CostProjectDocumentController extends BaseController<CostProjectDocumentManager, CostProjectDocument> {

	// 创建通用服务实例
	private final CrudService crudService = new CrudService();

	@Autowired
	private CostProjectDocumentManager costProjectDocumentManager;
	/**
	 * 根据id获取监审项目文书表数据详情
	 * @param id
	 * @return
	 * @throws Exception 
	 * ModelAndView
	 */
	@GetMapping(value="/getDetail")
	@ApiOperation(value="根据id获取监审项目文书表数据详情",httpMethod = "GET",notes = "根据id获取监审项目文书表数据详情")
	public CommonResult<CostProjectDocument> getDetail(@ApiParam(name="id",value="业务对象主键", required = true)@RequestParam(required=true) String id) throws Exception{
		return CommonResult.<CostProjectDocument>ok().value(baseService.getDetail(id));
	}

	//分页查询
	@PostMapping(value="/pageList")
	@ApiOperation(value="分页查询pageList",httpMethod = "POST",notes = "分页查询pageList")
	public CommonResult<PageResp<CostProjectDocument>> pageList(@RequestBody CostProjectDocumentPageReq req) {
		return CommonResult.<PageResp<CostProjectDocument>>ok().value(crudService.pageQuery(req, baseService::pageList));

	}

	//新增
	@PostMapping(value="/save")
	@ApiOperation(value="新增save",httpMethod = "POST",notes = "新增save")
	public CommonResult<String> save(@RequestBody CostProjectDocumentReq req) {
		costProjectDocumentManager.create(req);
		return CommonResult.<String>ok().message("保存成功");

	}

	//修改
	@PutMapping(value="/update")
	@ApiOperation(value="修改update",httpMethod = "Put",notes = "修改update")
	public CommonResult<String> update(@RequestBody CostProjectDocumentReq req) {
		costProjectDocumentManager.updateProjectDocument(req);
		return CommonResult.<String>ok().message("修改成功");

	}

	@PostMapping(value="/deleteByIds")
	@ApiOperation(value="根据id删除数据",httpMethod = "POST",notes = "根据id删除数据")
	public CommonResult<String> cleanByIds(@ApiParam(name="ids", value="id集合") @RequestBody IdReq req){
		costProjectDocumentManager.deleteByIds(req.getIds());
		return CommonResult.<String>ok().message("删除文书成功");
	}

	@GetMapping(value="/getByProjectId")
	@ApiOperation(value="根据项目id获取项目文书内容",httpMethod = "GET",notes = "根据项目id获取项目文书内容")
	public CommonResult<CostProjectDocumentResp> getByProjectId(@ApiParam(name="projectId", value="项目id") @RequestParam String projectId){
		return CommonResult.<CostProjectDocumentResp>ok().value(costProjectDocumentManager.getByProjectId(projectId));
	}

}
