package com.gree.mall.miniapp.controller.apply;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.gree.mall.miniapp.bean.apply.WorkerApplyCount;
import com.gree.mall.miniapp.bean.apply.WorkerInvolveApplyDetail;
import com.gree.mall.miniapp.bean.apply.WorkerInvolveApplyVO;
import com.gree.mall.miniapp.helper.ResponseHelper;
import com.gree.mall.miniapp.logic.apply.WorkerApplyLogic;
import com.gree.mall.miniapp.plus.entity.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

@Slf4j
@RestController
@Api(value = "难度费用申请", tags = {"难度费用申请"})
@RequestMapping(value = "/workerApply", produces = "application/json; charset=utf-8")
public class WorkerApplyController {

    @Autowired
    WorkerApplyLogic workerApplyLogic;

    @PostMapping("/add")
    @ApiOperation(value = "申请难度费")
    public ResponseHelper add(
            @RequestBody WorkerInvolveApply workerInvolveApply,
            HttpServletRequest request
    ) throws Exception {

        workerApplyLogic.add(workerInvolveApply);
        return ResponseHelper.success();
    }


    @PostMapping("/update")
    @ApiOperation(value = "驳回重新申请难度费")
    public ResponseHelper update(
            @RequestBody WorkerInvolveApply workerInvolveApply,
            HttpServletRequest request
    ) throws Exception {

        workerApplyLogic.update(workerInvolveApply);
        return ResponseHelper.success();
    }

    @PostMapping("/detail")
    @ApiOperation(value = "难度费详情")
    public ResponseHelper<WorkerInvolveApplyDetail> detail(
            @ApiParam("id") @RequestParam String orderBaseId,
            HttpServletRequest request
    ) throws Exception {

        WorkerInvolveApplyDetail workerInvolveApplyDetail = workerApplyLogic.detail(orderBaseId);
        return ResponseHelper.success(workerInvolveApplyDetail);
    }


    @ApiOperation("难度费列表")
    @PostMapping("/list")
    public ResponseHelper<IPage<WorkerInvolveApplyVO>> list(
            @ApiParam(required = true, value = "1 待网点审核 2驳回重申 3待中心审核 4驳回禁止申诉 5通过审核 ") @RequestParam(required = true) List<String> status,
            @ApiParam(required = true, value = "查询") @RequestParam(required = true) String value,
            @ApiParam(required = true, value = "页大小") @RequestParam(required = true) Integer pageSize,
            @ApiParam(required = true, value = "页数") @RequestParam(required = true) Integer pageNum,
            HttpServletRequest request
    ){
        IPage<WorkerInvolveApplyVO> list = workerApplyLogic.list(pageNum, pageSize, status,value);
        return ResponseHelper.success(list);
    }


    @ApiOperation("统计数量")
    @PostMapping("/count")
    public ResponseHelper<WorkerApplyCount> count(

    ){
        WorkerApplyCount workerApplyCount = workerApplyLogic.count();
        return ResponseHelper.success(workerApplyCount);
    }



}
