package com.bonus.app.controller;

import com.bonus.app.service.IAppEquipmentReqService;
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.app.AppParamsDto;
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 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:AppEquipmentReqController
 * @author:cwchen
 * @date:2024-08-06-15:49
 * @version:1.0
 * @description:APP-设备领用
 */
@RestController
@RequestMapping("/appEquipmentReq/")
@Slf4j
public class AppEquipmentReqController extends BaseController {

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

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

    //    @RequiresPermissions("app: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(AppParamsDto dto) {
        return service.getUseDevices(dto);
    }

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