package com.jeeplus.psimanage.dishManage.controller;

import com.jeeplus.logging.annotation.ApiLog;
import com.jeeplus.logging.constant.enums.LogTypeEnum;
import com.jeeplus.psimanage.dishManage.domain.PsiDishRoom;
import com.jeeplus.psimanage.dishManage.service.PsiDishRoomService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * 包房管理
 */
@RestController
@Api(tags = "包房管理")
@RequestMapping(value = "/psi/dishRoom")
public class PsiDishRoomController {

    @Resource
    private PsiDishRoomService service;

    @ApiOperation(value = "列表查询")
    @GetMapping("/list")
    public ResponseEntity<List<PsiDishRoom>> list(PsiDishRoom info) {
        return ResponseEntity.ok(service.list(info));
    }

    @ApiOperation(value = "查询详情")
    @GetMapping("/findById")
    public ResponseEntity<PsiDishRoom> findById(@RequestParam String id) {
        return ResponseEntity.ok(service.findById(id));
    }

    @ApiLog(value = "保存包房", type = LogTypeEnum.SAVE)
    @ApiOperation(value = "新增/修改")
    @PostMapping("/save")
    public ResponseEntity<String> save(@RequestBody PsiDishRoom info) {
        return ResponseEntity.ok(service.saveRoom(info));
    }

    @ApiLog(value = "删除包房", type = LogTypeEnum.SAVE)
    @ApiOperation(value = "删除")
    @DeleteMapping("/delete")
    public ResponseEntity<String> delete(@RequestParam String ids) {
        return ResponseEntity.ok(service.deleteByIds(ids));
    }

    @ApiLog(value = "修改包房状态", type = LogTypeEnum.SAVE)
    @ApiOperation(value = "启用/停用")
    @GetMapping("/changeStatus")
    public ResponseEntity<String> changeStatus(@RequestParam String id, @RequestParam String status) {
        return service.changeStatus(id, status);
    }
}
