package com.cyl.manager.ums.controller;

import java.util.List;

import com.cyl.manager.ums.service.MemberDoorLockService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
import com.cyl.manager.ums.domain.MemberDoorLock;

/**
 * 门锁信息Controller
 * 
 * @author daixiande
 * @date 2024-07-07
 */
//@Api("门锁信息")
@RestController
@RequestMapping("/mall/memberDoorLock")
public class MemberDoorLockController extends BaseController {

    @Autowired
    private MemberDoorLockService memberDoorLockService;

    /**
     * 查询门锁信息列表
     */
//    @ApiOperation("查询门锁信息列表")
    @PreAuthorize("@ss.hasPermi('mall:memberDoorLock:list')")
    @GetMapping("/list")
    public TableDataInfo list(MemberDoorLock memberDoorLock) {
        startPage();
        List<MemberDoorLock> list = memberDoorLockService.selectMemberDoorLockList(memberDoorLock);
        return getDataTable(list);
    }

    /**
     * 导出门锁信息列表
     */
//    @ApiOperation("导出门锁信息列表")
    @PreAuthorize("@ss.hasPermi('mall:memberDoorLock:export')")
    @Log(title = "门锁信息", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(MemberDoorLock memberDoorLock) {
        List<MemberDoorLock> list = memberDoorLockService.selectMemberDoorLockList(memberDoorLock);
        ExcelUtil<MemberDoorLock> util = new ExcelUtil<MemberDoorLock>(MemberDoorLock.class);
        return util.exportExcel(list, "门锁信息数据");
    }

    /**
     * 获取门锁信息详细信息
     */
//    @ApiOperation("获取门锁信息详细信息")
    @PreAuthorize("@ss.hasPermi('mall:memberDoorLock:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(memberDoorLockService.selectMemberDoorLockById(id));
    }

    /**
     * 新增门锁信息
     */
//    @ApiOperation("新增门锁信息")
    @PreAuthorize("@ss.hasPermi('mall:memberDoorLock:add')")
    @Log(title = "门锁信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MemberDoorLock memberDoorLock) {
        return toAjax(memberDoorLockService.insertMemberDoorLock(memberDoorLock));
    }

    /**
     * 修改门锁信息
     */
//    @ApiOperation("修改门锁信息")
    @PreAuthorize("@ss.hasPermi('mall:memberDoorLock:edit')")
    @Log(title = "门锁信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MemberDoorLock memberDoorLock) {
        return toAjax(memberDoorLockService.updateMemberDoorLock(memberDoorLock));
    }

    /**
     * 删除门锁信息
     */
//    @ApiOperation("删除门锁信息")
    @PreAuthorize("@ss.hasPermi('mall:memberDoorLock:remove')")
    @Log(title = "门锁信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(memberDoorLockService.deleteMemberDoorLockByIds(ids));
    }
}
