package com.ktg.iscs.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ktg.common.annotation.Log;
import com.ktg.common.core.controller.BaseController;
import com.ktg.common.enums.BusinessType;
import com.ktg.common.pojo.CommonResult;
import com.ktg.common.utils.poi.ExcelUtil;
import com.ktg.iscs.domain.IsLockType;
import com.ktg.iscs.domain.vo.lockType.IsLockTypeVO;
import com.ktg.iscs.service.IIsLockTypeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 物资类型Controller
 *
 * @author cgj
 * @date 2024-11-12
 */
@Api(tags = "挂锁类型")
@RestController
@RequestMapping("/iscs/lockType")
public class IsLockTypeController extends BaseController
{
    @Autowired
    private IIsLockTypeService isLockTypeService;

    /**
     * 查询物资类型分页
     */
    @ApiOperation("查询物资类型-分页")
    @Parameters({
            @Parameter(name = "page", description = "Page"),
            @Parameter(name = "isLockType", description = "实体参数")
    })
    // @PreAuthorize("@ss.hasPermi('iscs:type:list')")
    @GetMapping("/getIsLockTypePage")
    public CommonResult<Page<IsLockTypeVO>> getIsLockTypePage(Page<IsLockType> page, IsLockType isLockType)
    {
        return CommonResult.success(isLockTypeService.getIsLockTypePage(page, isLockType));
    }

    /**
     * 导出物资类型列表
     */
    @ApiOperation("导出物资类型列表")
    @Parameter(name = "isLockType", description = "实体参数")
    @PreAuthorize("@ss.hasPermi('iscs:type:export')")
    @Log(title = "物资类型", businessType = BusinessType.EXPORT)
    @PostMapping("/exportIsLockType")
    public void exportIsLockType(HttpServletResponse response, IsLockType isLockType)
    {
        List<IsLockType> list = isLockTypeService.selectIsLockTypeList(isLockType);
        ExcelUtil<IsLockType> util = new ExcelUtil<IsLockType>(IsLockType.class);
        util.exportExcel(response, list, "物资类型数据");
    }

    /**
     * 获取物资类型详细信息
     */
    @ApiOperation("获取物资类型详细信息")
    @Parameter(name = "lockTypeId", description = "lockTypeId")
    // @PreAuthorize("@ss.hasPermi('iscs:type:query')")
    @GetMapping(value = "/selectIsLockTypeById")
    public CommonResult<IsLockType> selectIsLockTypeById(Long lockTypeId)
    {
        return CommonResult.success(isLockTypeService.selectIsLockTypeByLockTypeId(lockTypeId));
    }

    /**
     * 新增物资类型
     */
    @ApiOperation("新增物资类型")
    // @PreAuthorize("@ss.hasPermi('iscs:type:add')")
    @Log(title = "物资类型", businessType = BusinessType.INSERT)
    @PostMapping("/insertIsLockType")
    public CommonResult<Boolean> insertIsLockType(@RequestBody @Parameter(name = "isLockType", description = "新增数据类,放到body") IsLockType isLockType)
    {
        return CommonResult.success(isLockTypeService.insertIsLockType(isLockType) == 1);
    }

    /**
     * 修改物资类型
     */
    @ApiOperation("修改物资类型")
    // @PreAuthorize("@ss.hasPermi('iscs:type:edit')")
    @Log(title = "物资类型", businessType = BusinessType.UPDATE)
    @PostMapping("/updateIsLockType")
    public CommonResult<Boolean> updateIsLockType(@RequestBody @Parameter(name = "isLockType", description = "修改数据类,放到body") IsLockType isLockType)
    {
        return CommonResult.success(isLockTypeService.updateIsLockType(isLockType) == 1);
    }

    /**
     * 删除物资类型
     */
    @ApiOperation("删除物资类型")
    // @PreAuthorize("@ss.hasPermi('iscs:type:remove')")
    @Log(title = "物资类型", businessType = BusinessType.DELETE)
	@PostMapping("/deleteIsLockTypeByLockTypeIds")
    public CommonResult<Boolean> deleteIsLockTypeByLockTypeIds(String lockTypeIds)
    {
        return CommonResult.success(isLockTypeService.deleteIsLockTypeByLockTypeIds(lockTypeIds) != 0);
    }
}
