/*
*  Copyright 2019-2020 Zheng Jie
*
*  Licensed under the Apache License, Version 2.0 (the "License");
*  you may not use this file except in compliance with the License.
*  You may obtain a copy of the License at
*
*  http://www.apache.org/licenses/LICENSE-2.0
*
*  Unless required by applicable law or agreed to in writing, software
*  distributed under the License is distributed on an "AS IS" BASIS,
*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*  See the License for the specific language governing permissions and
*  limitations under the License.
*/
package cn.ysk.cashier.repository.shop;

import cn.ysk.cashier.pojo.shop.TbShopCashSpread;
import org.apache.ibatis.annotations.Param;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import javax.transaction.Transactional;

/**
* @website https://eladmin.vip
* @author lyf
* @date 2024-01-05
**/
public interface TbShopCashSpreadRepository extends JpaRepository<TbShopCashSpread, String>, JpaSpecificationExecutor<TbShopCashSpread> {
    @Query("select spread from TbShopCashSpread spread where spread.id = :shopId")
    TbShopCashSpread findByShopId(@Param("shopId")Integer shopId);

    @Modifying
    @Transactional
    @Query("update TbShopCashSpread spread set spread.screenConfig = :screenConfig, spread.updatedAt = :updatedTime where spread.id = :shopId")
    Integer updateConfig(@Param("shopId")Integer shopId, @Param("screenConfig")String screenConfig,
                        @Param("updatedTime")Long updatedTime);


}