package com.hxhq.business.controller;


import com.hxhq.business.domain.Zcg;
import com.hxhq.business.form.zcg.ZcgYsffForm;
import com.hxhq.business.form.zcg.ZcgYsghForm;
import com.hxhq.business.form.zcg.ZcgSearchForm;
import com.hxhq.common.security.annotation.RequiresPermissions;
import com.hxhq.common.security.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.hxhq.business.service.IZcgService;
import com.hxhq.common.core.web.controller.BaseController;
import com.hxhq.common.core.web.domain.AjaxResult;
import com.hxhq.common.core.web.page.TableDataInfo;

import java.util.List;


/**
 * 暂存柜Controller
 *
 * @author hxhq
 * @date 2025-12-18
 */
@RestController
@RequestMapping("/business/zcg")
public class ZcgController extends BaseController
{
    @Autowired
    private IZcgService zcgService;

    /**
     * 查询暂存柜列表
     */
    @RequiresPermissions("business:resource:zcg:list")
    @GetMapping("/list")
    public TableDataInfo list(ZcgSearchForm form)
    {
        startPage();
        List<Zcg> list = zcgService.queryList(form);
        return getDataTable(list);
    }

    /**
     * 获取暂存柜详细信息
     */
    @RequiresPermissions("business:resource:zcg:list")
    @GetMapping(value = "/info")
    public AjaxResult getInfo(Long id)
    {
        return AjaxResult.success(zcgService.queryInfo(id));
    }

    /**
     * 钥匙归还
     */
    @PostMapping("/ysgh")
    @RequiresPermissions("business:resource:zcg:ysgh")
    public AjaxResult ysgh(@RequestBody ZcgYsghForm form)
    {
        form.setJsrId(SecurityUtils.getUserId());
        zcgService.ysgh(form);
        return AjaxResult.success("操作成功");
    }


    /**
     * 批量钥匙归还
     */
    @PostMapping("/ysghBatch")
    @RequiresPermissions("business:resource:zcg:ysgh")
    public AjaxResult ysghBatch(@RequestBody ZcgYsghForm form)
    {
        form.setJsrId(SecurityUtils.getUserId());
        zcgService.ysghBatch(form);
        return AjaxResult.success("操作成功");
    }

    /**
     * 钥匙发放
     */
    @PostMapping("/ysff")
    @RequiresPermissions("business:resource:zcg:ysff")
    public AjaxResult ysff(@RequestBody ZcgYsffForm form)
    {
        form.setFfrId(SecurityUtils.getUserId());
        zcgService.ysff(form);
        return AjaxResult.success("操作成功");
    }


}
