package com.yuchen.saas.park.service.controller.work;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.yuchen.saas.park.api.dto.work.SaasWorkOrderTypeDto;
import com.yuchen.saas.park.api.dto.work.SaasWorkOrderTypeQueryDto;
import com.yuchen.saas.park.api.vo.work.SaasWorkOrderTypeVo;
import com.yuchen.saas.park.service.service.work.ISaasWorkOrderTypeService;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.nest.springwrap.core.mp.support.NestPage;
import org.nest.springwrap.core.tool.api.R;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 工单类型表 前端控制器
 * </p>
 *
 * @author caiwq
 * @since 2024-04-01
 */
@Slf4j
@RestController
@RequiredArgsConstructor
@RequestMapping("/workOrderType")
public class SaasWorkOrderTypeController {

    private final ISaasWorkOrderTypeService baseService;

    /**
     * 添加工单类型
     * @param workOrderTypeDto 工单类型Dto
     * @return TRUE/FALSE
     */
    @PostMapping("/add")
    @ApiOperationSupport(order = 1)
    @ApiOperation(value = "添加工单类型", notes = "添加工单类型")
    public R<Boolean> add(@RequestBody @Validated SaasWorkOrderTypeDto workOrderTypeDto) {
        return R.data(baseService.add(workOrderTypeDto));
    }

    /**
     * 编辑工单类型
     * @param workOrderTypeDto 工单类型Dto
     * @return TRUE/FALSE
     */
    @PostMapping("/edit")
    @ApiOperationSupport(order = 2)
    @ApiOperation(value = "编辑工单类型", notes = "编辑工单类型")
    public R<Boolean> edit(@RequestBody @Validated SaasWorkOrderTypeDto workOrderTypeDto) {
        return R.data(baseService.edit(workOrderTypeDto));
    }

    /**
     * 删除工单类型
     * @param id 工单类型ID
     * @return TRUE/FALSE
     */
    @DeleteMapping("/remove/{id}")
    @ApiOperationSupport(order = 3)
    @ApiOperation(value = "删除工单类型", notes = "删除工单类型")
    public R<Boolean> remove(@ApiParam(name = "id", value = "主键ID", required = true) @PathVariable("id") Long id) {
        return R.data(baseService.remove(id));
    }

    /**
     * 工单类型列表(分页)
     * @param queryDto 工单类型列表查询参数
     * @return 消息列表Vo
     */
    @PostMapping("/list")
    @ApiOperationSupport(order = 4)
    @ApiOperation(value = "工单类型列表(分页)", notes = "工单类型列表(分页)")
    public R<NestPage<SaasWorkOrderTypeVo>> list(@RequestBody SaasWorkOrderTypeQueryDto queryDto) {
        return R.data(baseService.list(queryDto));
    }

    /**
     * 工单类型列表
     * @param queryDto 工单类型列表查询参数
     * @return 消息列表Vo
     */
    @GetMapping("/listAll")
    @ApiOperationSupport(order = 4)
    @ApiOperation(value = "工单类型列表", notes = "工单类型列表")
    public R<List<SaasWorkOrderTypeVo>> listAll(SaasWorkOrderTypeQueryDto queryDto) {
        return R.data(baseService.listAll(queryDto));
    }

}
