package com.usky.fire.controller.web;


import com.usky.common.core.bean.ApiResult;
import com.usky.common.core.bean.CommonPage;
import com.usky.common.log.annotation.Log;
import com.usky.common.log.enums.BusinessType;
import com.usky.fire.domain.PatrolInspectionType;
import com.usky.fire.service.PatrolInspectionTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 类型表 前端控制器
 * </p>
 *
 * @author fu
 * @since 2024-02-05
 */
@RestController
@RequestMapping("/patrolInspectionType")
public class PatrolInspectionTypeController {
    @Autowired
    private PatrolInspectionTypeService patrolInspectionTypeService;
    /**
     * 操作类型分页查询
     * @param pageNum
     * @param pageSize
     * @return
     */
    @GetMapping("/pageQuery")
    public ApiResult<CommonPage<PatrolInspectionType>> pageQuery(
            @RequestParam(value = "pageNum", required = false, defaultValue = "1") Integer pageNum,
            @RequestParam(value = "pageSize", required = false, defaultValue = "10") Integer pageSize) {
        return ApiResult.success(patrolInspectionTypeService.pageList( pageNum, pageSize));
    }

    /**
     * 新增
     * @param patrolInspectionType
     * @return
     */
    @Log(title = "操作类型", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public ApiResult<Void> add(@RequestBody PatrolInspectionType patrolInspectionType){
        patrolInspectionTypeService.add(patrolInspectionType);
        return ApiResult.success();
    }

    /**
     * 删除
     * @param deleteType
     * @return
     */
    @Log(title = "操作类型", businessType = BusinessType.DELETE)
    @GetMapping("/delete")
    public ApiResult<Void> delete(@RequestBody PatrolInspectionType deleteType){
        patrolInspectionTypeService.softDelete(deleteType);
        return ApiResult.success();
    }
}

