package com.bonus.bracelet.controller;

import com.bonus.bracelet.service.IEquipmentReqService;
import com.bonus.common.core.web.controller.BaseController;
import com.bonus.common.core.web.domain.AjaxResult;
import com.bonus.common.core.web.page.TableDataInfo;
import com.bonus.common.entity.bracelet.BraceletParamsDto;
import com.bonus.common.entity.bracelet.vo.EquipmentReqDataVo;
import com.bonus.common.entity.bracelet.vo.EquipmentReqVo;
import com.bonus.common.log.annotation.SysLog;
import com.bonus.common.log.enums.OperaType;
import com.bonus.common.security.annotation.RequiresPermissions;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @className:EquipmentReqController
 * @author:cwchen
 * @date:2024-08-05-13:42
 * @version:1.0
 * @description:设备领用-web层
 */
@RestController
@RequestMapping("/equipmentReq/")
@Slf4j
public class EquipmentReqController extends BaseController {

    @Resource(name = "IEquipmentReqService")
    private IEquipmentReqService service;

//    @RequiresPermissions("basic:equipmentReq:list")
    @GetMapping("list")
    @SysLog(title = "施工管控", businessType = OperaType.QUERY,logType = 0,module = "施工管控->设备领用",details ="查询设备领用列表")
    public TableDataInfo list(BraceletParamsDto dto) {
        startPage();
        List<EquipmentReqVo> list = service.getEquipmentReqLists(dto);
        return getDataTable(list);
    }

//    @RequiresPermissions("basic:equipmentReq:addData")
    @PostMapping("addData")
    @SysLog(title = "施工管控", businessType = OperaType.INSERT,logType = 0,module = "施工管控->设备领用",details ="设备领用")
    public AjaxResult addData(@Validated @RequestBody EquipmentReqDataVo vo) {
        return service.addData(vo);
    }

    /**
     * 获取未领用的设备
     * @param dto
     * @return AjaxResult
     * @author cwchen
     * @date 2024/8/5 18:05
     */
    @GetMapping("getUseDevices")
    public AjaxResult getUseDevices(BraceletParamsDto dto) {
        return service.getUseDevices(dto);
    }

    //    @RequiresPermissions("basic:equipmentReq:returnDevice")
    @PostMapping("returnDevice")
    @SysLog(title = "施工管控", businessType = OperaType.INSERT,logType = 0,module = "施工管控->设备领用",details ="归还设备")
    public AjaxResult returnDevice(@RequestBody BraceletParamsDto dto) {
        return service.returnDevice(dto);
    }
}
