package com.hxhq.business.controller;

import com.hxhq.business.domain.MjyFfjlJcgj;
import com.hxhq.business.dto.mjy.FfjlListDto;
import com.hxhq.business.form.mjy.*;
import com.hxhq.business.service.IMjyFfjlJcgjService;
import com.hxhq.business.service.IMjyFfjlService;
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 com.hxhq.common.security.annotation.Logical;
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 java.util.List;


/**
 * 麻精药发放记录Controller
 *
 * @author hxhq
 * @date 2025-12-15
 */
@RestController
@RequestMapping("/business/mjyFfjl")
public class MjyFfjlController extends BaseController
{
    @Autowired
    private IMjyFfjlJcgjService mjyFfjlJcgjService;
    @Autowired
    private IMjyFfjlService mjyFfjlService;

    /**
     * 列表
     */
    @GetMapping("/list")
    @RequiresPermissions("business:resource:mjy:ffjllist")
    public TableDataInfo list(FfjlSearchForm form)
    {
        startPage();
        List<FfjlListDto> list = mjyFfjlService.queryList(form);
        return getDataTable(list);
    }

    /**
     * 详细信息
     */
    @RequiresPermissions(value={"business:resource:mjy:ffjlxq","business:archive:mjy:ffjlxq"}, logical= Logical.OR)
    @GetMapping(value = "/info")
    public AjaxResult getInfo(Long id)
    {
        return AjaxResult.success(mjyFfjlService.queryInfo(id));
    }

    /**
     * 稽查轨迹列表
     */
    @RequiresPermissions(value={"business:resource:mjy:ffjlxq","business:archive:mjy:ffjlxq"}, logical= Logical.OR)
    @GetMapping("/jcgjList")
    public TableDataInfo jcgjList(MjyFfjlJcgj form)
    {
        startPage();
        List<MjyFfjlJcgj> list = mjyFfjlJcgjService.queryList(form);
        return getDataTable(list);
    }

    /**
     * 解档
     */
    @PostMapping("/jd")
    @RequiresPermissions("business:resource:mjy:ffjljd")
    public AjaxResult jd(@RequestBody FfjlJdForm form)
    {
        form.setQmrId(SecurityUtils.getUserId());
        mjyFfjlService.jd(form);
        return AjaxResult.success("操作成功");
    }

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

    /**
     * 归档
     */
    @PostMapping("/gd")
    @RequiresPermissions("business:resource:mjy:ffjlgd")
    public AjaxResult gd(@RequestBody FfjlGdForm form)
    {
        form.setQmrId(SecurityUtils.getUserId());
        mjyFfjlService.gd(form);
        return AjaxResult.success("操作成功");
    }


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

    /**
     * 锁定
     */
    @PostMapping("/sd")
    @RequiresPermissions("business:resource:mjy:ffjlsd")
    public AjaxResult sd(@RequestBody FfjlSdForm form)
    {
        form.setQmrId(SecurityUtils.getUserId());
        mjyFfjlService.sd(form);
        return AjaxResult.success("操作成功");
    }

    /**
     * 解锁
     */
    @PostMapping("/js")
    @RequiresPermissions("business:resource:mjy:ffjljs")
    public AjaxResult js(@RequestBody FfjlJsForm form)
    {
        form.setQmrId(SecurityUtils.getUserId());
        mjyFfjlService.js(form);
        return AjaxResult.success("操作成功");
    }

    /**
     * 借阅
     */
    @PostMapping("/jy")
    @RequiresPermissions("business:resource:mjy:ffjljy")
    public AjaxResult jy(@RequestBody FfjlJyForm form)
    {
        form.setQmrId(SecurityUtils.getUserId());
        mjyFfjlService.jy(form);
        return AjaxResult.success("操作成功");
    }

    /**
     * 加签
     */
    @PostMapping("/jq")
    @RequiresPermissions("business:resource:mjy:ffjljq")
    public AjaxResult jq(@RequestBody FfjlJqForm form)
    {
        form.setQmrId(SecurityUtils.getUserId());
        mjyFfjlService.jq(form);
        return AjaxResult.success("操作成功");
    }

}
