
package org.sky.scientific.controller;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import lombok.AllArgsConstructor;
import org.sky.core.boot.ctrl.KdController;
import org.sky.core.tool.api.R;
import org.sky.core.tool.utils.Func;
import org.sky.scientific.pojo.entity.XmJdxbgEntity;
import org.sky.scientific.pojo.vo.XmJdxbgVO;
import org.sky.scientific.service.IXmJdxbgService;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 科研项目-项目实施-阶段性报告 控制器
 *
 * @author Kd
 * @since 2025-07-01
 */
@RestController
@AllArgsConstructor
@RequestMapping("/xm/jdxbg")
@Tag(name = "科研项目-项目实施-阶段性报告", description = "科研项目-项目实施-阶段性报告接口")
public class XmJdxbgController extends KdController {

	private final IXmJdxbgService service;

	@GetMapping("list/{xmId}")
	@Operation(summary = "列表")
	public R<List<XmJdxbgVO>> listByXmId(@PathVariable("xmId") Long xmId){
		return R.data(service.listByXmId(xmId));
	}


	@GetMapping("/{id}")
	@Operation(summary = "详情", description  = "传入xmJdxbg")
	public R<XmJdxbgVO> detail(@PathVariable Long id) {
		XmJdxbgVO detail = service.selectById(id);
		return R.data(detail);
	}

	@PostMapping("/submit")
	@ApiOperationSupport(order = 5)
	@Operation(summary = "保存/修改", description  = "传入xmJdxbg")
	public R submit(@Valid @RequestBody XmJdxbgEntity xmJdxbg) {
//		"[{\"label\":\"test.doc\",\"value\":\"http://sxdhyig3c.hn-bkt.clouddn.com/upload/20250711/6d4f1dfbfa02e4f8f59a4de2ca8abc6a.doc\"}]"
		return R.status(service.submit(xmJdxbg));
	}

	@DeleteMapping("/remove")
	@Operation(summary = "删除")
	public R remove(@Parameter(description = "主键集合", required = true) @RequestParam String ids) {

		return R.status(service.deleteByIds(Func.toLongList(ids)));
	}

}
