package com.ycwl.basic.profitsharing.mapper;

import com.github.pagehelper.Page;
import com.ycwl.basic.profitsharing.dto.ProfitSharingConfigReqQuery;
import com.ycwl.basic.profitsharing.dto.ProfitSharingConfigVO;
import com.ycwl.basic.profitsharing.entity.ProfitSharingConfig;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface ProfitSharingConfigMapper {
    @Insert("INSERT INTO profit_sharing_config (scenic_id, name, description, create_time, update_time) " +
            "VALUES (#{scenicId}, #{name}, #{description}, #{createTime}, #{updateTime})")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    void insert(ProfitSharingConfig config);

    @Update("UPDATE profit_sharing_config SET scenic_id = #{scenicId}, name = #{name}, description = #{description}, " +
            "create_time = #{createTime}, update_time = #{updateTime} WHERE id = #{id}")
    void update(ProfitSharingConfig config);

    @Delete("DELETE FROM profit_sharing_config WHERE id = #{id}")
    void deleteById(Long id);

    @Select("SELECT * FROM profit_sharing_config WHERE id = #{id}")
    ProfitSharingConfig findById(Long id);

    @Select("SELECT * FROM profit_sharing_config")
    List<ProfitSharingConfig> findAll();

    // 修改: 根据scenicId查询单个记录
    @Select("SELECT * FROM profit_sharing_config WHERE scenic_id = #{scenicId}")
    ProfitSharingConfig findByScenicId(Long scenicId);

    List<ProfitSharingConfigVO> list(ProfitSharingConfigReqQuery req);
}