package com.xhpc.user.controller;

import com.xhpc.common.core.web.controller.BaseController;
import com.xhpc.common.core.web.domain.AjaxResult;
import com.xhpc.common.core.web.page.TableDataInfo;
import com.xhpc.common.log.annotation.Log;
import com.xhpc.common.log.enums.BusinessType;
import com.xhpc.user.domain.XhpcBlacklist;
import com.xhpc.user.domain.XhpcCustomers;
import com.xhpc.user.service.IXhpcBlacklistService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/blacklist")
public class XhpcBlacklistController extends BaseController {

    @Resource
    private IXhpcBlacklistService xhpcBlacklistService;

    @GetMapping("/getList")
    public TableDataInfo getList(String phone, String plateNum, String vin, String startTime, String endTime,Integer distinguish){

        Map<String, Object> params = new HashMap<>();
        params.put("phone", phone);
        params.put("plateNum", plateNum);
        params.put("vin", vin);
        params.put("startTime", startTime);
        params.put("endTime", endTime);
        params.put("distinguish", distinguish);
        List<Map<String, Object>> list = xhpcBlacklistService.getList(params);
        return getDataTable(list);
    }


    @PostMapping(value = "/addBlacklist")
    public AjaxResult addBlacklist(HttpServletRequest request, @RequestBody XhpcBlacklist xhpcBlacklist) {
        return xhpcBlacklistService.addBlacklist(request,xhpcBlacklist);
    }


    @GetMapping(value = "/getBlacklistById")
    public AjaxResult getBlacklistById(Long blacklistId) {
        return AjaxResult.success(xhpcBlacklistService.getBlacklistById(blacklistId));
    }


    @GetMapping(value = "/deleteBlacklistById")
    public AjaxResult deleteBlacklistById(Long blacklistId) {
        xhpcBlacklistService.deleteBlacklistById(blacklistId);
        return AjaxResult.success();
    }




}
