package com.hxhq.business.controller;

import java.util.Arrays;
import java.util.List;

import com.hxhq.business.domain.GspFfjlJcgj;
import com.hxhq.business.domain.GspRkjlJcgj;
import com.hxhq.business.form.gsp.*;
import com.hxhq.business.form.mjy.*;
import com.hxhq.business.service.IGspRkjlJcgjService;
import com.hxhq.common.security.annotation.RequiresPermissions;
import com.hxhq.common.security.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import com.hxhq.business.domain.GspRkjl;
import com.hxhq.business.service.IGspRkjlService;
import com.hxhq.common.core.web.controller.BaseController;
import com.hxhq.common.core.web.domain.AjaxResult;
import com.hxhq.common.core.web.page.TableDataInfo;


/**
 * 供试品入库记录Controller
 *
 * @author hxhq
 * @date 2025-12-30
 */
@RestController
@RequestMapping("/business/gspRkjl")
public class GspRkjlController extends BaseController
{
    @Autowired
    private IGspRkjlService gspRkjlService;

    @Autowired
    private IGspRkjlJcgjService gspRkjlJcgjService;

    /**
     * 查询供试品入库记录列表
     */
    @GetMapping("/list")
    @RequiresPermissions("business:resource:gsp:rklist")
    public TableDataInfo list(GspSearchListForm form)
    {
        startPage();
        List<GspRkjl> list = gspRkjlService.queryList(form);
        return getDataTable(list);
    }

    /**
     * 获取供试品入库记录详细信息
     */
    @RequiresPermissions("business:resource:gsp:rkxq")
    @GetMapping(value = "/info")
    public AjaxResult getInfo(Long id)
    {
        return AjaxResult.success(gspRkjlService.getById(id));
    }
    /**
     * 稽查轨迹列表
     */
    @GetMapping("/jcgjList")
    @RequiresPermissions("business:resource:gsp:rklist")
    public TableDataInfo jcgjList(GspRkjlJcgj form)
    {
        startPage();
        List<GspRkjlJcgj> list = gspRkjlJcgjService.queryList(form);
        return getDataTable(list);
    }

    /**
     * 新增供试品入库记录信息
     */
    @PostMapping("/xz")
    @RequiresPermissions("business:resource:gsp:rkxz")
    public AjaxResult save(@RequestBody GspRkjlForm form)
    {
        form.setQmrId(SecurityUtils.getUserId());
        gspRkjlService.add(form);
        return AjaxResult.success("操作成功");
    }
    /**
     * 编辑供试品入库记录信息
     */
    @PostMapping("/bj")
    @RequiresPermissions("business:resource:gsp:rkbj")
    public AjaxResult bj(@RequestBody GspRkjlForm form)
    {
        form.setQmrId(SecurityUtils.getUserId());
        gspRkjlService.update(form);
        return AjaxResult.success("操作成功");
    }

    /**
     * 锁定
     */
    @PostMapping("/sd")
    @RequiresPermissions("business:resource:gsp:rksd")
    public AjaxResult sd(@RequestBody GspSdForm form)
    {
        form.setQmrId(SecurityUtils.getUserId());
        gspRkjlService.sd(form);
        return AjaxResult.success("操作成功");
    }

    /**
     * 批量锁定
     */
    @PostMapping("/plsd")
    @RequiresPermissions("business:resource:gsp:rksd")
    public AjaxResult plsd(@RequestBody GspSdForm form)
    {
        form.setQmrId(SecurityUtils.getUserId());
        gspRkjlService.plsd(form);
        return AjaxResult.success("操作成功");
    }

    /**
     * 解锁
     */
    @PostMapping("/js")
    @RequiresPermissions("business:resource:gsp:rkjs")
    public AjaxResult js(@RequestBody GspJsForm form)
    {
        form.setQmrId(SecurityUtils.getUserId());
        gspRkjlService.js(form);
        return AjaxResult.success("操作成功");
    }


    /**
     * 解档
     */
    @PostMapping("/jd")
    @RequiresPermissions("business:resource:gsp:rkjd")
    public AjaxResult jd(@RequestBody GspJdForm form)
    {
        form.setQmrId(SecurityUtils.getUserId());
        gspRkjlService.jd(form);
        return AjaxResult.success("操作成功");
    }

    /**
     * 批量归档
     */
    @PostMapping("/plgd")
    @RequiresPermissions("business:resource:gsp:rkgd")
    public AjaxResult plgd(@RequestBody GspGdForm form)
    {
        form.setQmrId(SecurityUtils.getUserId());
        gspRkjlService.plgd(form);
        return AjaxResult.success("操作成功");
    }

    /**
     * 归档
     */
    @PostMapping("/gd")
    @RequiresPermissions("business:resource:gsp:rkgd")
    public AjaxResult gd(@RequestBody GspGdForm form)
    {
        form.setQmrId(SecurityUtils.getUserId());
        gspRkjlService.gd(form);
        return AjaxResult.success("操作成功");
    }

    /**
     * 借阅
     */
    @PostMapping("/jy")
    @RequiresPermissions("business:resource:gsp:rkjy")
    public AjaxResult jy(@RequestBody GspJyForm form)
    {
        form.setQmrId(SecurityUtils.getUserId());
        gspRkjlService.jy(form);
        return AjaxResult.success("操作成功");
    }

}
