package com.cool.store.controller.webb;


import com.cool.store.context.CurrentUserHolder;
import com.cool.store.context.LoginUserInfo;
import com.cool.store.request.AuditCheckRequest;
import com.cool.store.request.AuditDetailRequest;
import com.cool.store.response.AuditDetailResponse;
import com.cool.store.response.CheckListResponse;
import com.cool.store.response.ResponseResult;
import com.cool.store.service.AuditStatusService;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

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

@Api(tags = "稽核相关")
@RestController
@RequestMapping("pc/audit/stage")
public class AuditStatusController {

    @Resource
    AuditStatusService auditStatusService;

    @ApiOperation("稽核")
    @PostMapping("/check")
    public ResponseResult<Boolean> check(@RequestBody AuditCheckRequest request) {
        LoginUserInfo user = CurrentUserHolder.getUser();
        return ResponseResult.success(auditStatusService.audit(request,user));
    }

    @ApiOperation("查看/稽核按钮")
    @PostMapping("/detail")
    public ResponseResult<AuditDetailResponse> detail(@RequestBody AuditDetailRequest request) {
        return ResponseResult.success(auditStatusService.detail(request));
    }


    @ApiOperation("稽核列表")
    @GetMapping("/checkList")
    public ResponseResult<PageInfo<CheckListResponse>> checkList(@RequestParam(value = "partnerNameOrPhone",required = false) String partnerNameOrPhone,
                                                                 @RequestParam(value = "startTime",required = false) String startTime,
                                                                 @RequestParam(value = "endTime",required = false) String endTime,
                                                                 @RequestParam(value = "region",required = false) String region,
                                                                 @RequestParam(value = "checkStatus",required = false) Integer checkStatus,
                                                                 @RequestParam(value = "checkStage",defaultValue = "1") Integer checkStage,
                                                                 @RequestParam(value = "pageNum",defaultValue = "1") Integer pageNum,
                                                                 @RequestParam(value = "pageSize",defaultValue = "10")Integer pageSize) {

        return ResponseResult.success(auditStatusService.checkList(partnerNameOrPhone,startTime,endTime,region,checkStatus,checkStage,pageNum,pageSize));
    }


}
