package com.yiqi.api.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.yiqi.app.domain.AppDeliveryMan;
import com.yiqi.app.service.IAppDeliveryManService;
import com.yiqi.common.constant.UrlConstants;
import com.yiqi.common.core.domain.AuthHolder;
import com.yiqi.common.core.domain.R;
import com.yiqi.common.enums.DeleteStatus;
import com.yiqi.common.enums.StatusType;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author xiaohei
 * @date 2023/11/22
 */
@Api(tags = "配送员")
@RestController
@RequestMapping(value = UrlConstants.wxappApi + "/deliveryMan")
public class WeAppDeliveryManController {

    @Autowired
    private IAppDeliveryManService appDeliveryManService;

    @ApiOperation("判断是否是配送员")
    @GetMapping(value = "isDelievery")
    public R isDelivery() throws Exception{
        if(appDeliveryManService.count(new QueryWrapper<AppDeliveryMan>().lambda()
                .eq(AppDeliveryMan::getAppUserId, AuthHolder.userId())
                .eq(AppDeliveryMan::getDelFlag, DeleteStatus.OK.getCode())
                .eq(AppDeliveryMan::getStatus, StatusType.OK.getCode())) > 0){
            return R.ok(true);
        }
        return R.ok(false);
    }
}
