/**
 * Copyright &copy; 2012-2016 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
 */
package com.lightinit.hsdatagateway.modules.gateway.dao;

import com.lightinit.hsdatagateway.common.persistence.CrudDao;
import com.lightinit.hsdatagateway.common.persistence.annotation.MyBatisDao;
import com.lightinit.hsdatagateway.modules.gateway.entity.Charge;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * 计费DAO接口
 * @Author: yangrui
 * @version 2019-03-05
 */
@MyBatisDao
public interface ChargeDao extends CrudDao<Charge> {

    /**
     * 根据appId,routeId,userId 查询
     * @param charge
     * @return
     */
    Charge getByAppAndRouteAndUserId(Charge charge);

    /**
     * 根据routeId和restValue修改restValue
     * @param charge
     * @return
     */
    int updateByRouteIdAndRestValue(Charge charge);

    /**
     * 根据routeId修改次数，次数必须大于0，否则失败
     * @param routeId
     * @return
     */
    int updateByRouteId(@Param("routeId") String routeId);

    /**
     * api调用查询
     * @param charge
     * @return
     */
    List<Charge> findListByApi(Charge charge);

    /**
     * 根据用户、路由、应用Id修改
     * @param charge
     * @return
     */
    int updateByApi(Charge charge);
}