package com.bonus.sharedstation.app.controller;


import com.bonus.common.core.web.domain.AjaxResult;
import com.bonus.sharedstation.web.dto.FirstAidInfoDTO;
import com.bonus.sharedstation.web.service.IFirstAidService;
import io.swagger.annotations.ApiOperation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
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.RestController;

import javax.annotation.Resource;

/**
 * @author 云归
 */
@Tag(name = "Web - 急救知识")
@RestController
@RequestMapping("/information/firstaidapp")
public class FirstAidAppController {
    private static final Logger log = LoggerFactory.getLogger(FirstAidAppController.class);
    @Resource
    private IFirstAidService formService;

    @ApiOperation("查询订单列表")
    @PostMapping("/getOrderList")
    public AjaxResult getFirstAidInfoList(@RequestBody FirstAidInfoDTO firstAidInfoDTO) {
        try {
            return formService.getFirstAidInfoList(firstAidInfoDTO);
        } catch (Exception e) {
            log.error("查询订单列表", e);
            return AjaxResult.error("查询失败");
        }

    }

    @ApiOperation("查询急救全部数据")
    @PostMapping(value = "selectAll", produces = "application/json; charset=utf-8")
    public AjaxResult selectAll(@RequestBody FirstAidInfoDTO firstAidInfoDTO) {
        return AjaxResult.success(formService.selectAll(firstAidInfoDTO));
    }


    @PostMapping(value = "selectById", produces = "application/json; charset=utf-8")
    @ApiOperation("查询急救详情")
    public AjaxResult selectInfoById(@RequestBody FirstAidInfoDTO firstAidInfoDTO) {
        return AjaxResult.success(formService.selectInfoById(firstAidInfoDTO));
    }

}
