package com.bonus.canteen.core.allocation.canteen.controller;

import com.bonus.common.core.web.domain.AjaxResult;
import com.bonus.canteen.core.allocation.canteen.dto.AllocMobileCanteenQueryDTO;
import com.bonus.canteen.core.allocation.canteen.model.AllocCanteen;
import com.bonus.canteen.core.allocation.canteen.service.AllocCanteenService;
import com.bonus.canteen.core.allocation.canteen.service.AllocStallService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
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;

@RestController
@RequestMapping({"/api/v2/alloc/canteen"})
@Api(
   tags = {"lsh_食堂档口相关控制器"}
)
public class AllocCanteenController {
   private static final Logger log = LoggerFactory.getLogger(AllocCanteenController.class);
   @Resource
   @Lazy
   private AllocCanteenService allocCanteenService;

   @Autowired
   @Lazy
   private AllocStallService allocStallService;

   @ApiOperation("查询食堂所有开启的支付方式")
   @PostMapping({"/list-avail-pay-type"})
   public AjaxResult listAvailPayTypeForApp(@RequestBody AllocCanteen bean) {
      try {
         return AjaxResult.success(this.allocCanteenService.listAvailPayTypeForApp(bean.getCanteenId()));
      } catch (Exception e) {
            log.error(e.toString(), e);
            return AjaxResult.error("查询食堂所有开启的支付方式失败");
      }
   }

   /**
    * @author jsk
    * @param bean
    * @return
    */
   @ApiOperation("移动端-查询预订日期列表")
   @PostMapping({"/list-reserve-date"})
   public AjaxResult listReserveDate(@RequestBody AllocMobileCanteenQueryDTO bean) {
      return AjaxResult.success(this.allocStallService.listReserveDate(bean));
   }
}
