package com.xhpc.card.controller;

import com.xhpc.card.domain.CardClientUser;
import com.xhpc.card.service.IXhpcCardClientUserService;
import com.xhpc.common.api.dto.XhpcChargingStationDto;
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 io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

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

/**
 * @author yuyang
 * @date 2022/3/21 10:32
 */
@RestController
@RequestMapping("/cardClientUser")
@Api(value = "卡管理员信息", tags = "卡管理员信息")
public class XhpcCardClientUserController extends BaseController {

    @Autowired
    private IXhpcCardClientUserService xhpcCardClientUserService;


    @GetMapping("/list")
    public TableDataInfo list(String userName, Integer usersLevel,Long operatorId,String tenantId) {
        List<Map<String, Object>> list = xhpcCardClientUserService.selectXhpcCardClientUserList(userName, usersLevel, operatorId, tenantId);
        return getDataTable(list);
    }


    /**
     * 添加
     * @param cardClientUser
     * @return
     */
    @Log(title = "添加", businessType = BusinessType.INSERT)
    @PostMapping(value = "/addOrUpdateXhpcCardClientUser")
    public AjaxResult addOrUpdateXhpcCardClientUser(@RequestBody CardClientUser cardClientUser) {
        return xhpcCardClientUserService.addOrUpdateXhpcCardClientUser(cardClientUser);
    }

    /**
     * 获取运营商接口
     */
    @GetMapping("/getoperatorList")
    public AjaxResult getoperatorList(String tenantId) {
        return xhpcCardClientUserService.getoperatorList(tenantId);
    }

    /**
     * 获取运营商接口
     */
    @GetMapping("/getXhpcCardClientUserById")
    public AjaxResult getXhpcCardClientUserById(Integer usersID) {
        return AjaxResult.success(xhpcCardClientUserService.getXhpcCardClientUserById(usersID));
    }


    /**
     * 修改状态
     */
    @GetMapping("/getXhpcCardClientUserStatus")
    public AjaxResult getXhpcCardClientUserStatus(@RequestParam("usersID") Integer usersID,@RequestParam("status") Integer status) {
        return xhpcCardClientUserService.getXhpcCardClientUserStatus(usersID,status);
    }

}
