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

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.yuchen.saas.park.api.request.SpaceUseTypeRequest;
import com.yuchen.saas.park.api.response.SpaceUseResponse;
import com.yuchen.saas.park.service.service.SpaceUseTypeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.nest.springwrap.core.mp.support.Query;
import org.nest.springwrap.core.tool.api.R;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @ClassName SpaceUseTypeController
 * @Description 空间用途控制器
 * @Author 肖祥
 * @Date 2022/12/01 18:36
 */
@RestController
@AllArgsConstructor
@RequestMapping("/space/useType/")
@Api(value = "空间用途控制器", tags = "空间用途控制器")
public class SpaceUseTypeController {

    @Resource
    private SpaceUseTypeService spaceUseTypeService;

    /**
     * 新增空间用途
     * @return
     */
    @PostMapping("/save")
    @ApiOperation(value = "新增空间用途", notes = "新增空间用途")
    public R save(@RequestBody SpaceUseTypeRequest useTypeRequest){
        return spaceUseTypeService.save(useTypeRequest);
    }

    /**
     * 更新空间用途
     * @return
     */
    @PostMapping("/update")
    @ApiOperation(value = "更新空间用途", notes = "更新空间用途")
    public R update(@RequestBody SpaceUseTypeRequest useTypeRequest){
        return spaceUseTypeService.update(useTypeRequest);
    }

    /**
     * 删除空间用途
     * @return
     */
    @PostMapping("/delete")
    @ApiOperation(value = "删除空间用途", notes = "删除空间用途")
    public R delete(@RequestBody SpaceUseTypeRequest useTypeRequest){
        return spaceUseTypeService.delete(useTypeRequest);
    }

    /**
     * 空间用途列表
     * @return
     */
    @GetMapping("/list")
    @ApiOperation(value = "空间用途列表", notes = "空间用途列表")
    public R<IPage<SpaceUseResponse>> list(SpaceUseTypeRequest useTypeRequest, Query query){
        return spaceUseTypeService.List(useTypeRequest,query);
    }
}
